aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/tasks-component.c
diff options
context:
space:
mode:
authorSivaiah Nallagatla <snallagatla@novell.com>2005-02-22 09:04:51 +0800
committerSivaiah Nallagatla <siva@src.gnome.org>2005-02-22 09:04:51 +0800
commitbdd063525416b7c48b7ff6a589636ec00d5ce2e5 (patch)
tree9b64959e080df796a4cecb20e95fb21c8cbdb073 /calendar/gui/tasks-component.c
parent956ec9c13e4da1954d6506fde84806954792f1c1 (diff)
downloadgsoc2013-evolution-bdd063525416b7c48b7ff6a589636ec00d5ce2e5.tar
gsoc2013-evolution-bdd063525416b7c48b7ff6a589636ec00d5ce2e5.tar.gz
gsoc2013-evolution-bdd063525416b7c48b7ff6a589636ec00d5ce2e5.tar.bz2
gsoc2013-evolution-bdd063525416b7c48b7ff6a589636ec00d5ce2e5.tar.lz
gsoc2013-evolution-bdd063525416b7c48b7ff6a589636ec00d5ce2e5.tar.xz
gsoc2013-evolution-bdd063525416b7c48b7ff6a589636ec00d5ce2e5.tar.zst
gsoc2013-evolution-bdd063525416b7c48b7ff6a589636ec00d5ce2e5.zip
Make sure all the default source groups and sources are present by adding
2005-02-19 Sivaiah Nallagatla <snallagatla@novell.com> * gui/calendar-component.c (ensure_sources) : Make sure all the default source groups and sources are present by adding missing ones. Also update the base uri of "On This Computer" group to take care of change in user home dir. (calendar_component_init) : call ensure_sources * gui/tasks-component.c (ensure_sources) (tasks_component_init) : ditto Takes care of #67411 & #67724 for calendar and tasks components. svn path=/trunk/; revision=28840
Diffstat (limited to 'calendar/gui/tasks-component.c')
-rw-r--r--calendar/gui/tasks-component.c106
1 files changed, 102 insertions, 4 deletions
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index 60ac1cd868..1cb4dabef6 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -60,6 +60,9 @@ enum DndTargetType {
};
#define CALENDAR_TYPE "text/calendar"
#define XCALENDAR_TYPE "text/x-calendar"
+#define WEB_BASE_URI "webcal://"
+#define PERSONAL_RELATIVE_URI "system"
+
static GtkTargetEntry drag_types[] = {
{ CALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST },
{ XCALENDAR_TYPE, 0, DND_TARGET_TYPE_CALENDAR_LIST }
@@ -112,6 +115,103 @@ struct _TasksComponentPrivate {
GList *notifications;
};
+static void
+ensure_sources (TasksComponent *component)
+{
+ GSList *groups;
+ ESourceList *source_list;
+ ESourceGroup *group;
+ ESourceGroup *on_this_computer;
+ ESourceGroup *on_the_web;
+ ESource *personal_source;
+ char *base_uri, *base_uri_proto;
+
+ on_this_computer = NULL;
+ on_the_web = NULL;
+ personal_source = NULL;
+
+ if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_TODO, NULL)) {
+ g_warning ("Could not get addressbook source list from GConf!");
+ return;
+ }
+
+ base_uri = g_build_filename (tasks_component_peek_base_directory (component),
+ "tasks", "local",
+ NULL);
+
+ base_uri_proto = g_strconcat ("file://", base_uri, NULL);
+
+ groups = e_source_list_peek_groups (source_list);
+ if (groups) {
+ /* groups are already there, we need to search for things... */
+ GSList *g;
+
+ for (g = groups; g; g = g->next) {
+
+ group = E_SOURCE_GROUP (g->data);
+
+ /* compare only file:// part. If user home dir name changes we do not want to create
+ one more group */
+
+ if (!on_this_computer && !strncmp (base_uri_proto, e_source_group_peek_base_uri (group), 7))
+ on_this_computer = group;
+ else if (!on_the_web && !strcmp (WEB_BASE_URI, e_source_group_peek_base_uri (group)))
+ on_the_web = group;
+ }
+ }
+
+ if (on_this_computer) {
+ /* make sure "Personal" shows up as a source under
+ this group */
+ GSList *sources = e_source_group_peek_sources (on_this_computer);
+ GSList *s;
+ for (s = sources; s; s = s->next) {
+ ESource *source = E_SOURCE (s->data);
+ if (!strcmp (PERSONAL_RELATIVE_URI, e_source_peek_relative_uri (source))) {
+ personal_source = source;
+ break;
+ }
+ }
+ /* Make sure we have the correct base uri. This can change when user's
+ homedir name changes */
+ if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) {
+ e_source_group_set_base_uri (on_this_computer, base_uri_proto);
+
+ /* *sigh* . We shouldn't need this sync call here as set_base_uri
+ call results in synching to gconf, but that happens in idle loop
+ and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/
+ e_source_list_sync (source_list,NULL);
+ }
+ }
+ else {
+ /* create the local source group */
+ group = e_source_group_new (_("On This Computer"), base_uri_proto);
+ e_source_list_add_group (source_list, group, -1);
+
+ on_this_computer = group;
+ }
+
+ if (!personal_source) {
+ /* Create the default Person addressbook */
+ ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
+ e_source_group_add_source (on_this_computer, source, -1);
+
+ personal_source = source;
+ }
+
+ if (!on_the_web) {
+ /* Create the LDAP source group */
+ group = e_source_group_new (_("On The Web"), WEB_BASE_URI);
+ e_source_list_add_group (source_list, group, -1);
+
+ on_the_web = group;
+ }
+
+ component->priv->source_list = source_list;
+ g_free (base_uri_proto);
+ g_free (base_uri);
+}
+
/* Utility functions. */
/* FIXME Some of these are duplicated from calendar-component.c */
static gboolean
@@ -1173,11 +1273,9 @@ tasks_component_init (TasksComponent *component, TasksComponentClass *klass)
priv->config_directory = g_build_filename (g_get_home_dir (),
".evolution", "tasks", "config",
NULL);
-
- if (!e_cal_get_sources (&priv->source_list, E_CAL_SOURCE_TYPE_TODO, NULL))
- ;
-
+
component->priv = priv;
+ ensure_sources (component);
}
/* Public API */