aboutsummaryrefslogtreecommitdiffstats
path: root/capplet/settings/mail-account-view.c
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gustavo.noronha@collabora.com>2011-06-25 02:16:33 +0800
committerGustavo Noronha Silva <gustavo.noronha@collabora.com>2011-06-28 03:53:38 +0800
commit644214f51a06ea4166d1c3c8d8d92f8020f33c3d (patch)
treef4a16d8e31a086a74d027c1b5dedbda1615f4567 /capplet/settings/mail-account-view.c
parent1fe3a4c564c9d28a9291c2cbc0dbbb97f2140a01 (diff)
downloadgsoc2013-evolution-644214f51a06ea4166d1c3c8d8d92f8020f33c3d.tar.gz
gsoc2013-evolution-644214f51a06ea4166d1c3c8d8d92f8020f33c3d.tar.zst
gsoc2013-evolution-644214f51a06ea4166d1c3c8d8d92f8020f33c3d.zip
Bug #653358 Do not duplicate google address book
When a GMail account check that the address book does not already exist before creating an ESource for it, and adding it to the list. https://bugzilla.gnome.org/show_bug.cgi?id=653358
Diffstat (limited to 'capplet/settings/mail-account-view.c')
-rw-r--r--capplet/settings/mail-account-view.c62
1 files changed, 41 insertions, 21 deletions
diff --git a/capplet/settings/mail-account-view.c b/capplet/settings/mail-account-view.c
index eac32cc4b8..6328dbcd02 100644
--- a/capplet/settings/mail-account-view.c
+++ b/capplet/settings/mail-account-view.c
@@ -405,37 +405,57 @@ setup_google_accounts (MailAccountView *mav)
if (mav->priv->do_gcontacts) {
ESourceList *slist;
ESourceGroup *sgrp;
- ESource *abook;
- gchar *rel_uri;;
+ GSList *sources;
+ gboolean source_already_exists = FALSE;
slist = e_source_list_new_for_gconf (gconf, "/apps/evolution/addressbook/sources" );
sgrp = e_source_list_ensure_group (slist, _("Google"), "google://", TRUE);
- /* FIXME: Not sure if we should localize 'Contacts' */
- abook = e_source_new ("Contacts", "");
- e_source_set_property (abook, "default", "true");
- e_source_set_property (abook, "offline_sync", "1");
- e_source_set_property (abook, "auth", "plain/password");
- e_source_set_property (abook, "use-ssl", "true");
- e_source_set_property (abook, "remember_password", "true");
- e_source_set_property (abook, "refresh-interval", "86400");
- e_source_set_property (abook, "completion", "true");
- e_source_set_property (abook, "username", mav->priv->username);
-
- e_source_group_add_source (sgrp, abook, -1);
+ sources = e_source_group_peek_sources (sgrp);
+ for (; sources; sources = sources->next)
+ {
+ ESource *existing = (ESource*) sources->data;
- e_source_set_relative_uri (abook, mav->priv->username);
+ if (!g_strcmp0 (e_source_peek_relative_uri (existing),
+ mav->priv->username))
+ {
+ source_already_exists = TRUE;
+ break;
+ }
+ }
- rel_uri = g_strdup_printf("google://%s/", mav->priv->username);
- e_passwords_add_password (rel_uri, gtk_entry_get_text ((GtkEntry *) mav->password));
- e_passwords_remember_password ("Addressbook", rel_uri);
- e_source_list_sync (slist, NULL);
+ if (!source_already_exists)
+ {
+ ESource *abook;
+ gchar *rel_uri;
+
+ /* FIXME: Not sure if we should localize 'Contacts' */
+ abook = e_source_new ("Contacts", "");
+ e_source_set_property (abook, "default", "true");
+ e_source_set_property (abook, "offline_sync", "1");
+ e_source_set_property (abook, "auth", "plain/password");
+ e_source_set_property (abook, "use-ssl", "true");
+ e_source_set_property (abook, "remember_password", "true");
+ e_source_set_property (abook, "refresh-interval", "86400");
+ e_source_set_property (abook, "completion", "true");
+ e_source_set_property (abook, "username", mav->priv->username);
+
+ e_source_group_add_source (sgrp, abook, -1);
+
+ e_source_set_relative_uri (abook, mav->priv->username);
+
+ rel_uri = g_strdup_printf ("google://%s/", mav->priv->username);
+ e_passwords_add_password (rel_uri, gtk_entry_get_text ((GtkEntry *) mav->password));
+ e_passwords_remember_password ("Addressbook", rel_uri);
+ e_source_list_sync (slist, NULL);
+
+ g_free (rel_uri);
+ g_object_unref (abook);
+ }
- g_free (rel_uri);
g_object_unref (slist);
g_object_unref (sgrp);
- g_object_unref (abook);
}
g_object_unref (gconf);