aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'modules/calendar')
-rw-r--r--modules/calendar/e-cal-shell-backend.c122
-rw-r--r--modules/calendar/e-memo-shell-backend.c67
-rw-r--r--modules/calendar/e-task-shell-backend.c71
3 files changed, 55 insertions, 205 deletions
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index dede49c5b8..cab1f2fa3d 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -55,11 +55,6 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_CAL_SHELL_BACKEND, ECalShellBackendPrivate))
-#define CONTACTS_BASE_URI "contacts://"
-#define WEATHER_BASE_URI "weather://"
-#define WEB_BASE_URI "webcal://"
-#define PERSONAL_RELATIVE_URI "system"
-
struct _ECalShellBackendPrivate {
ESourceList *source_list;
};
@@ -85,9 +80,8 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend)
ESource *personal;
EShell *shell;
EShellSettings *shell_settings;
- const gchar *data_dir, *name;
- gchar *base_uri, base_uri_seventh;
- gchar *filename;
+ GSList *sources, *iter;
+ const gchar *name;
gchar *property;
gboolean save_list = FALSE;
@@ -104,78 +98,30 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend)
return;
}
- data_dir = e_shell_backend_get_data_dir (shell_backend);
- filename = g_build_filename (data_dir, "local", NULL);
- base_uri = g_filename_to_uri (filename, NULL, NULL);
- g_free (filename);
-
- if (strlen (base_uri) > 7) {
- /* Compare only file:// part. If user home dir name
- * changes we do not want to create one more group. */
- base_uri_seventh = base_uri[7];
- base_uri[7] = 0;
- } else {
- base_uri_seventh = -1;
- }
-
on_this_computer = e_source_list_ensure_group (
- priv->source_list, _("On This Computer"), base_uri, TRUE);
+ priv->source_list, _("On This Computer"), "local:", TRUE);
contacts = e_source_list_ensure_group (
- priv->source_list, _("Contacts"), CONTACTS_BASE_URI, TRUE);
+ priv->source_list, _("Contacts"), "contacts://", TRUE);
e_source_list_ensure_group (
- priv->source_list, _("On The Web"), WEB_BASE_URI, FALSE);
+ priv->source_list, _("On The Web"), "webcal://", FALSE);
e_source_list_ensure_group (
- priv->source_list, _("Weather"), WEATHER_BASE_URI, FALSE);
-
- if (base_uri_seventh != -1) {
- base_uri[7] = base_uri_seventh;
- }
-
- name = _("On This Computer");
-
- if (on_this_computer != NULL) {
- GSList *sources, *iter;
- const gchar *group_base_uri;
-
- sources = e_source_group_peek_sources (on_this_computer);
- group_base_uri = e_source_group_peek_base_uri (on_this_computer);
+ priv->source_list, _("Weather"), "weather://", FALSE);
- /* Make sure this group includes a "Personal" source. */
- for (iter = sources; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
- const gchar *relative_uri;
+ g_return_if_fail (on_this_computer != NULL);
+ g_return_if_fail (contacts != NULL);
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
+ sources = e_source_group_peek_sources (on_this_computer);
- if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0)
- continue;
+ /* Make sure this group includes a "Personal" source. */
+ for (iter = sources; iter != NULL; iter = iter->next) {
+ ESource *source = iter->data;
+ const gchar *relative_uri;
+ relative_uri = e_source_peek_relative_uri (source);
+ if (g_strcmp0 (relative_uri, "system") == 0) {
personal = source;
break;
}
-
- /* Make sure we have the correct base URI. This can
- * change when the user's home directory changes. */
- if (strcmp (base_uri, group_base_uri) != 0) {
- e_source_group_set_base_uri (
- on_this_computer, base_uri);
-
- /* XXX We shouldn't need this sync call here as
- * set_base_uri() results in synching to GConf,
- * but that happens in an idle loop and too late
- * to prevent the user from seeing a "Cannot
- * Open ... because of invalid URI" error. */
- save_list = TRUE;
- }
- } else {
- ESourceGroup *source_group;
-
- source_group = e_source_group_new (name, base_uri);
- e_source_list_add_group (priv->source_list, source_group, -1);
- on_this_computer = source_group;
- g_object_unref (source_group);
}
name = _("Personal");
@@ -185,7 +131,7 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend)
GSList *selected;
gchar *primary;
- source = e_source_new (name, PERSONAL_RELATIVE_URI);
+ source = e_source_new (name, "system");
e_source_set_color_spec (source, "#BECEDD");
e_source_group_add_source (on_this_computer, source, -1);
g_object_unref (source);
@@ -215,29 +161,24 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend)
e_source_set_name (personal, name);
}
- if (contacts != NULL) {
- GSList *sources;
+ sources = e_source_group_peek_sources (contacts);
- sources = e_source_group_peek_sources (contacts);
+ if (sources != NULL) {
+ GSList *trash;
- if (sources != NULL) {
- GSList *trash;
-
- /* There is only one source under Contacts. */
- birthdays = E_SOURCE (sources->data);
- sources = g_slist_next (sources);
-
- /* Delete any other sources in this group.
- * Earlier versions allowed you to create
- * additional sources under Contacts. */
- trash = g_slist_copy (sources);
- while (trash != NULL) {
- ESource *source = trash->data;
- e_source_group_remove_source (contacts, source);
- trash = g_slist_delete_link (trash, trash);
- save_list = TRUE;
- }
+ /* There is only one source under Contacts. */
+ birthdays = E_SOURCE (sources->data);
+ sources = g_slist_next (sources);
+ /* Delete any other sources in this group.
+ * Earlier versions allowed you to create
+ * additional sources under Contacts. */
+ trash = g_slist_copy (sources);
+ while (trash != NULL) {
+ ESource *source = trash->data;
+ e_source_group_remove_source (contacts, source);
+ trash = g_slist_delete_link (trash, trash);
+ save_list = TRUE;
}
}
@@ -274,7 +215,6 @@ cal_shell_backend_ensure_sources (EShellBackend *shell_backend)
g_object_unref (on_this_computer);
g_object_unref (contacts);
- g_free (base_uri);
if (save_list)
e_source_list_sync (priv->source_list, NULL);
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index 3996fa699f..8f5bf40825 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -72,10 +72,8 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
ESource *personal;
EShell *shell;
EShellSettings *shell_settings;
- const gchar *data_dir;
+ GSList *sources, *iter;
const gchar *name;
- gchar *base_uri, base_uri_seventh;
- gchar *filename;
gboolean save_list = FALSE;
personal = NULL;
@@ -90,65 +88,25 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
return;
}
- data_dir = e_shell_backend_get_data_dir (shell_backend);
- filename = g_build_filename (data_dir, "local", NULL);
- base_uri = g_filename_to_uri (filename, NULL, NULL);
- g_free (filename);
-
- if (strlen (base_uri) > 7) {
- /* Compare only file:// part. If user home dir name
- * changes we do not want to create one more group. */
- base_uri_seventh = base_uri[7];
- base_uri[7] = 0;
- } else {
- base_uri_seventh = -1;
- }
-
on_this_computer = e_source_list_ensure_group (
- priv->source_list, _("On This Computer"), base_uri, TRUE);
+ priv->source_list, _("On This Computer"), "local:", TRUE);
e_source_list_ensure_group (
- priv->source_list, _("On The Web"), WEB_BASE_URI, FALSE);
-
- if (base_uri_seventh != -1) {
- base_uri[7] = base_uri_seventh;
- }
-
- if (on_this_computer != NULL) {
- GSList *sources, *iter;
- const gchar *group_base_uri;
-
- sources = e_source_group_peek_sources (on_this_computer);
- group_base_uri = e_source_group_peek_base_uri (on_this_computer);
+ priv->source_list, _("On The Web"), "webcal://", FALSE);
- /* Make sure this group includes a "Personal" source. */
- for (iter = sources; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
- const gchar *relative_uri;
+ g_return_if_fail (on_this_computer);
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
+ sources = e_source_group_peek_sources (on_this_computer);
- if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0)
- continue;
+ /* Make sure this group includes a "Personal" source. */
+ for (iter = sources; iter != NULL; iter = iter->next) {
+ ESource *source = iter->data;
+ const gchar *relative_uri;
+ relative_uri = e_source_peek_relative_uri (source);
+ if (g_strcmp0 (relative_uri, "system") == 0) {
personal = source;
break;
}
-
- /* Make sure we have the correct base URI. This can
- * change when the user's home directory changes. */
- if (strcmp (base_uri, group_base_uri) != 0) {
- e_source_group_set_base_uri (
- on_this_computer, base_uri);
-
- /* XXX We shouldn't need this sync call here as
- * set_base_uri() results in synching to GConf,
- * but that happens in an idle loop and too late
- * to prevent the user from seeing a "Cannot
- * Open ... because of invalid URI" error. */
- save_list = TRUE;
- }
}
name = _("Personal");
@@ -158,7 +116,7 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
GSList *selected;
gchar *primary;
- source = e_source_new (name, PERSONAL_RELATIVE_URI);
+ source = e_source_new (name, "system");
e_source_set_color_spec (source, "#BECEDD");
e_source_group_add_source (on_this_computer, source, -1);
g_object_unref (source);
@@ -189,7 +147,6 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
}
g_object_unref (on_this_computer);
- g_free (base_uri);
if (save_list)
e_source_list_sync (priv->source_list, NULL);
diff --git a/modules/calendar/e-task-shell-backend.c b/modules/calendar/e-task-shell-backend.c
index ca2b68228c..cdd4dcc608 100644
--- a/modules/calendar/e-task-shell-backend.c
+++ b/modules/calendar/e-task-shell-backend.c
@@ -48,9 +48,6 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_TASK_SHELL_BACKEND, ETaskShellBackendPrivate))
-#define WEB_BASE_URI "webcal://"
-#define PERSONAL_RELATIVE_URI "system"
-
struct _ETaskShellBackendPrivate {
ESourceList *source_list;
};
@@ -74,10 +71,8 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend)
ESource *personal;
EShell *shell;
EShellSettings *shell_settings;
- const gchar *data_dir;
+ GSList *sources, *iter;
const gchar *name;
- gchar *base_uri, base_uri_seventh;
- gchar *filename;
gboolean save_list = FALSE;
on_this_computer = NULL;
@@ -93,66 +88,25 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend)
return;
}
- data_dir = e_shell_backend_get_data_dir (shell_backend);
- filename = g_build_filename (data_dir, "local", NULL);
- base_uri = g_filename_to_uri (filename, NULL, NULL);
- g_free (filename);
-
- if (strlen (base_uri) > 7) {
- /* Compare only file:// part. If user home dir name
- * changes we do not want to create one more group. */
- base_uri_seventh = base_uri[7];
- base_uri[7] = 0;
- } else {
- base_uri_seventh = -1;
- }
-
on_this_computer = e_source_list_ensure_group (
- priv->source_list, _("On This Computer"), base_uri, TRUE);
+ priv->source_list, _("On This Computer"), "local:", TRUE);
e_source_list_ensure_group (
- priv->source_list, _("On The Web"), WEB_BASE_URI, FALSE);
-
- if (base_uri_seventh != -1) {
- base_uri[7] = base_uri_seventh;
- }
-
- if (on_this_computer != NULL) {
- GSList *sources, *iter;
- const gchar *group_base_uri;
-
- sources = e_source_group_peek_sources (on_this_computer);
- group_base_uri = e_source_group_peek_base_uri (on_this_computer);
+ priv->source_list, _("On The Web"), "webcal://", FALSE);
- /* Make sure this group includes a "Personal" source. */
- for (iter = sources; iter != NULL; iter = iter->next) {
- ESource *source = iter->data;
- const gchar *relative_uri;
+ g_return_if_fail (on_this_computer);
- relative_uri = e_source_peek_relative_uri (source);
- if (relative_uri == NULL)
- continue;
+ sources = e_source_group_peek_sources (on_this_computer);
- if (strcmp (PERSONAL_RELATIVE_URI, relative_uri) != 0)
- continue;
+ /* Make sure this group includes a "Personal" source. */
+ for (iter = sources; iter != NULL; iter = iter->next) {
+ ESource *source = iter->data;
+ const gchar *relative_uri;
+ relative_uri = e_source_peek_relative_uri (source);
+ if (g_strcmp0 (relative_uri, "system") == 0) {
personal = source;
break;
}
-
- /* Make sure we have the correct base URI. This can
- * change when the user's home directory changes. */
- if (strcmp (base_uri, group_base_uri) != 0) {
- e_source_group_set_base_uri (
- on_this_computer, base_uri);
-
- /* XXX We shouldn't need this sync call here as
- * set_base_uri() results in synching to GConf,
- * but that happens in an idle loop and too late
- * to prevent the user from seeing a "Cannot
- * Open ... because of invalid URI" error. */
- save_list = TRUE;
- }
-
}
name = _("Personal");
@@ -162,7 +116,7 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend)
GSList *selected;
gchar *primary;
- source = e_source_new (name, PERSONAL_RELATIVE_URI);
+ source = e_source_new (name, "system");
e_source_set_color_spec (source, "#BECEDD");
e_source_group_add_source (on_this_computer, source, -1);
g_object_unref (source);
@@ -193,7 +147,6 @@ task_shell_backend_ensure_sources (EShellBackend *shell_backend)
}
g_object_unref (on_this_computer);
- g_free (base_uri);
if (save_list)
e_source_list_sync (priv->source_list, NULL);