diff options
author | Milan Crha <mcrha@redhat.com> | 2010-11-24 20:39:04 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-11-24 20:39:04 +0800 |
commit | 42d44c1059abebe21f70693ca1e078f03fef6e48 (patch) | |
tree | 2d293206511b7c55d0f3bab5594898f47c0c4034 | |
parent | d3d6d96ed54b29787d79863e4808dbaab56a0f02 (diff) | |
download | gsoc2013-evolution-42d44c1059abebe21f70693ca1e078f03fef6e48.tar gsoc2013-evolution-42d44c1059abebe21f70693ca1e078f03fef6e48.tar.gz gsoc2013-evolution-42d44c1059abebe21f70693ca1e078f03fef6e48.tar.bz2 gsoc2013-evolution-42d44c1059abebe21f70693ca1e078f03fef6e48.tar.lz gsoc2013-evolution-42d44c1059abebe21f70693ca1e078f03fef6e48.tar.xz gsoc2013-evolution-42d44c1059abebe21f70693ca1e078f03fef6e48.tar.zst gsoc2013-evolution-42d44c1059abebe21f70693ca1e078f03fef6e48.zip |
Bug #632962 - Duplicate "On this computer" sources after update
-rw-r--r-- | capplet/settings/mail-capplet-shell.c | 24 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-migrate.c | 24 | ||||
-rw-r--r-- | modules/calendar/e-cal-shell-migrate.c | 24 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-migrate.c | 26 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-migrate.c | 26 |
5 files changed, 64 insertions, 60 deletions
diff --git a/capplet/settings/mail-capplet-shell.c b/capplet/settings/mail-capplet-shell.c index a1cdbb8989..46201fb867 100644 --- a/capplet/settings/mail-capplet-shell.c +++ b/capplet/settings/mail-capplet-shell.c @@ -283,21 +283,18 @@ mail_capplet_shell_new (gint socket_id, gboolean just_druid, gboolean main_loop) return GTK_WIDGET (shell); } +#define LOCAL_BASE_URI "local:" #define PERSONAL_RELATIVE_URI "system" static void -setup_abooks() +setup_abooks (void) { - gchar *base_dir, *uri; GSList *groups; ESourceGroup *group; ESourceList *list = NULL; ESourceGroup *on_this_computer = NULL; ESource *personal_source = NULL; - base_dir = g_build_filename (e_get_user_data_dir (), "addressbook", "local", NULL); - uri = g_filename_to_uri (base_dir, NULL, NULL); - if (!e_book_get_addressbooks(&list, NULL)) { g_warning ("Unable to get books\n"); return; @@ -307,16 +304,25 @@ setup_abooks() if (groups) { /* groups are already there, we need to search for things... */ GSList *g; + gchar *base_dir, *base_uri; - for (g = groups; g; g = g->next) { + base_dir = g_build_filename (e_get_user_data_dir (), "addressbook", "local", NULL); + base_uri = g_filename_to_uri (base_dir, NULL, NULL); + for (g = groups; g; g = g->next) { group = E_SOURCE_GROUP (g->data); - if (!on_this_computer && !strcmp (uri, e_source_group_peek_base_uri (group))) { + if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0) + e_source_group_set_base_uri (group, LOCAL_BASE_URI); + + if (!on_this_computer && !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group))) { on_this_computer = g_object_ref (group); break; } } + + g_free (base_dir); + g_free (base_uri); } if (on_this_computer) { @@ -339,7 +345,7 @@ setup_abooks() } else { /* create the local source group */ - group = e_source_group_new (_("On This Computer"), uri); + group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI); e_source_list_add_group (list, group, -1); on_this_computer = group; @@ -362,7 +368,5 @@ setup_abooks() e_source_list_sync (list, NULL); g_object_unref (list); - g_free (uri); - g_free (base_dir); } diff --git a/modules/addressbook/e-book-shell-migrate.c b/modules/addressbook/e-book-shell-migrate.c index 7440564380..7b91a04cff 100644 --- a/modules/addressbook/e-book-shell-migrate.c +++ b/modules/addressbook/e-book-shell-migrate.c @@ -66,6 +66,7 @@ typedef struct { GtkWidget *progress; } MigrationContext; +#define LOCAL_BASE_URI "local:" #define LDAP_BASE_URI "ldap://" #define PERSONAL_RELATIVE_URI "system" @@ -77,27 +78,28 @@ create_groups (MigrationContext *context, { GSList *groups; ESourceGroup *group; - gchar *base_uri, *base_uri_proto; *on_this_computer = NULL; *on_ldap_servers = NULL; *personal_source = NULL; - base_uri = g_build_filename (context->data_dir, "local", NULL); - - base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); - groups = e_source_list_peek_groups (context->source_list); if (groups) { /* groups are already there, we need to search for things... */ GSList *g; + gchar *base_dir, *base_uri; - for (g = groups; g; g = g->next) { + base_dir = g_build_filename (context->data_dir, "local", NULL); + base_uri = g_filename_to_uri (base_dir, NULL, NULL); + for (g = groups; g; g = g->next) { group = E_SOURCE_GROUP (g->data); + if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0) + e_source_group_set_base_uri (group, LOCAL_BASE_URI); + if (!*on_this_computer && - !strcmp (base_uri_proto, + !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_this_computer = g_object_ref (group); else if (!*on_ldap_servers && @@ -105,6 +107,9 @@ create_groups (MigrationContext *context, e_source_group_peek_base_uri (group))) *on_ldap_servers = g_object_ref (group); } + + g_free (base_dir); + g_free (base_uri); } if (*on_this_computer) { @@ -127,7 +132,7 @@ create_groups (MigrationContext *context, } else { /* create the local source group */ - group = e_source_group_new (_("On This Computer"), base_uri_proto); + group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI); e_source_list_add_group (context->source_list, group, -1); *on_this_computer = group; @@ -150,9 +155,6 @@ create_groups (MigrationContext *context, *on_ldap_servers = group; } - - g_free (base_uri_proto); - g_free (base_uri); } static MigrationContext * diff --git a/modules/calendar/e-cal-shell-migrate.c b/modules/calendar/e-cal-shell-migrate.c index c1a7221597..d27b9412c3 100644 --- a/modules/calendar/e-cal-shell-migrate.c +++ b/modules/calendar/e-cal-shell-migrate.c @@ -42,6 +42,7 @@ #include "calendar/gui/e-cal-event.h" #include "shell/e-shell.h" +#define LOCAL_BASE_URI "local:" #define WEBCAL_BASE_URI "webcal://" #define CONTACTS_BASE_URI "contacts://" #define BAD_CONTACTS_BASE_URI "contact://" @@ -79,8 +80,6 @@ create_calendar_sources (EShellBackend *shell_backend, EShellSettings *shell_settings; GSList *groups; ESourceGroup *group; - gchar *base_uri, *base_uri_proto; - const gchar *base_dir; *on_this_computer = NULL; *on_the_web = NULL; @@ -90,15 +89,14 @@ create_calendar_sources (EShellBackend *shell_backend, shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - base_dir = e_shell_backend_get_data_dir (shell_backend); - base_uri = g_build_filename (base_dir, "local", NULL); - - base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); - groups = e_source_list_peek_groups (source_list); if (groups) { /* groups are already there, we need to search for things... */ GSList *g; + gchar *base_dir, *base_uri; + + base_dir = g_build_filename (e_shell_backend_get_data_dir (shell_backend), "local", NULL); + base_uri = g_filename_to_uri (base_dir, NULL, NULL); for (g = groups; g; g = g->next) { @@ -108,9 +106,9 @@ create_calendar_sources (EShellBackend *shell_backend, e_source_group_set_base_uri (group, CONTACTS_BASE_URI); if (!strcmp (base_uri, e_source_group_peek_base_uri (group))) - e_source_group_set_base_uri (group, base_uri_proto); + e_source_group_set_base_uri (group, LOCAL_BASE_URI); - if (!*on_this_computer && !strcmp (base_uri_proto, + if (!*on_this_computer && !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_this_computer = g_object_ref (group); @@ -122,6 +120,9 @@ create_calendar_sources (EShellBackend *shell_backend, e_source_group_peek_base_uri (group))) *contacts = g_object_ref (group); } + + g_free (base_dir); + g_free (base_uri); } if (*on_this_computer) { @@ -143,7 +144,7 @@ create_calendar_sources (EShellBackend *shell_backend, } } else { /* create the local source group */ - group = e_source_group_new (_("On This Computer"), base_uri_proto); + group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI); e_source_list_add_group (source_list, group, -1); *on_this_computer = group; @@ -189,9 +190,6 @@ create_calendar_sources (EShellBackend *shell_backend, *contacts = group; } - - g_free (base_uri_proto); - g_free (base_uri); } gboolean diff --git a/modules/calendar/e-memo-shell-migrate.c b/modules/calendar/e-memo-shell-migrate.c index d85824767f..d2ec8e2048 100644 --- a/modules/calendar/e-memo-shell-migrate.c +++ b/modules/calendar/e-memo-shell-migrate.c @@ -34,6 +34,7 @@ #include "calendar/gui/calendar-config-keys.h" #include "shell/e-shell.h" +#define LOCAL_BASE_URI "local:" #define WEBCAL_BASE_URI "webcal://" #define PERSONAL_RELATIVE_URI "system" #define GROUPWISE_BASE_URI "groupwise://" @@ -49,8 +50,6 @@ create_memo_sources (EShellBackend *shell_backend, EShellSettings *shell_settings; GSList *groups; ESourceGroup *group; - gchar *base_uri, *base_uri_proto; - const gchar *base_dir; *on_this_computer = NULL; *on_the_web = NULL; @@ -59,25 +58,29 @@ create_memo_sources (EShellBackend *shell_backend, shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - base_dir = e_shell_backend_get_data_dir (shell_backend); - base_uri = g_build_filename (base_dir, "local", NULL); - - base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); - groups = e_source_list_peek_groups (source_list); if (groups) { /* groups are already there, we need to search for things... */ GSList *g; + gchar *base_dir, *base_uri; - for (g = groups; g; g = g->next) { + base_dir = g_build_filename (e_shell_backend_get_data_dir (shell_backend), "local", NULL); + base_uri = g_filename_to_uri (base_dir, NULL, NULL); + for (g = groups; g; g = g->next) { group = E_SOURCE_GROUP (g->data); - if (!*on_this_computer && !strcmp (base_uri_proto, e_source_group_peek_base_uri (group))) + if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0) + e_source_group_set_base_uri (group, LOCAL_BASE_URI); + + if (!*on_this_computer && !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_this_computer = g_object_ref (group); else if (!*on_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_the_web = g_object_ref (group); } + + g_free (base_dir); + g_free (base_uri); } if (*on_this_computer) { @@ -99,7 +102,7 @@ create_memo_sources (EShellBackend *shell_backend, } } else { /* create the local source group */ - group = e_source_group_new (_("On This Computer"), base_uri_proto); + group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI); e_source_list_add_group (source_list, group, -1); *on_this_computer = group; @@ -138,9 +141,6 @@ create_memo_sources (EShellBackend *shell_backend, *on_the_web = group; } - - g_free (base_uri_proto); - g_free (base_uri); } static gboolean diff --git a/modules/calendar/e-task-shell-migrate.c b/modules/calendar/e-task-shell-migrate.c index 91da8f45ef..dc240b99a9 100644 --- a/modules/calendar/e-task-shell-migrate.c +++ b/modules/calendar/e-task-shell-migrate.c @@ -42,6 +42,7 @@ #include "calendar/gui/calendar-config-keys.h" #include "shell/e-shell.h" +#define LOCAL_BASE_URI "local:" #define WEBCAL_BASE_URI "webcal://" #define PERSONAL_RELATIVE_URI "system" @@ -56,8 +57,6 @@ create_task_sources (EShellBackend *shell_backend, EShellSettings *shell_settings; GSList *groups; ESourceGroup *group; - gchar *base_uri, *base_uri_proto; - const gchar *base_dir; *on_this_computer = NULL; *on_the_web = NULL; @@ -66,27 +65,31 @@ create_task_sources (EShellBackend *shell_backend, shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); - base_dir = e_shell_backend_get_data_dir (shell_backend); - base_uri = g_build_filename (base_dir, "local", NULL); - - base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); - groups = e_source_list_peek_groups (source_list); if (groups) { /* groups are already there, we need to search for things... */ GSList *g; + gchar *base_dir, *base_uri; - for (g = groups; g; g = g->next) { + base_dir = g_build_filename (e_shell_backend_get_data_dir (shell_backend), "local", NULL); + base_uri = g_filename_to_uri (base_dir, NULL, NULL); + for (g = groups; g; g = g->next) { group = E_SOURCE_GROUP (g->data); - if (!*on_this_computer && !strcmp (base_uri_proto, + if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0) + e_source_group_set_base_uri (group, LOCAL_BASE_URI); + + if (!*on_this_computer && !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_this_computer = g_object_ref (group); else if (!*on_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group))) *on_the_web = g_object_ref (group); } + + g_free (base_dir); + g_free (base_uri); } if (*on_this_computer) { @@ -108,7 +111,7 @@ create_task_sources (EShellBackend *shell_backend, } } else { /* create the local source group */ - group = e_source_group_new (_("On This Computer"), base_uri_proto); + group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI); e_source_list_add_group (source_list, group, -1); *on_this_computer = group; @@ -147,9 +150,6 @@ create_task_sources (EShellBackend *shell_backend, *on_the_web = group; } - - g_free (base_uri_proto); - g_free (base_uri); } gboolean |