aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/google-account-setup/google-contacts-source.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-01-29 19:16:06 +0800
committerMilan Crha <mcrha@src.gnome.org>2009-01-29 19:16:06 +0800
commit7261b445bc5995ebf04c64f35011b091b6e94638 (patch)
treee75d7bb0c69c58f11787df4f14001f6eb909bd82 /plugins/google-account-setup/google-contacts-source.c
parentced75797e19bf3331a6d5f68db462c91022586d0 (diff)
downloadgsoc2013-evolution-7261b445bc5995ebf04c64f35011b091b6e94638.tar
gsoc2013-evolution-7261b445bc5995ebf04c64f35011b091b6e94638.tar.gz
gsoc2013-evolution-7261b445bc5995ebf04c64f35011b091b6e94638.tar.bz2
gsoc2013-evolution-7261b445bc5995ebf04c64f35011b091b6e94638.tar.lz
gsoc2013-evolution-7261b445bc5995ebf04c64f35011b091b6e94638.tar.xz
gsoc2013-evolution-7261b445bc5995ebf04c64f35011b091b6e94638.tar.zst
gsoc2013-evolution-7261b445bc5995ebf04c64f35011b091b6e94638.zip
** Fix for bug #539467
2009-01-29 Milan Crha <mcrha@redhat.com> ** Fix for bug #539467 * plugins/webdav-account-setup/webdav-contacts-source.c: (find_webdav_group), (ensure_webdav_contacts_source_group), (remove_webdav_contacts_source_group): * plugins/google-account-setup/google-contacts-source.h: (manage_google_group): * plugins/google-account-setup/google-contacts-source.c: (manage_google_group), (ensure_google_contacts_source_group), (remove_google_contacts_source_group): * plugins/google-account-setup/google-source.c: (ensure_google_source_group): Find group by its base uri, not by a localized name. svn path=/trunk/; revision=37165
Diffstat (limited to 'plugins/google-account-setup/google-contacts-source.c')
-rw-r--r--plugins/google-account-setup/google-contacts-source.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/plugins/google-account-setup/google-contacts-source.c b/plugins/google-account-setup/google-contacts-source.c
index b33ac86856..f76b7e56ee 100644
--- a/plugins/google-account-setup/google-contacts-source.c
+++ b/plugins/google-account-setup/google-contacts-source.c
@@ -37,36 +37,64 @@
#include "google-contacts-source.h"
-
-void
-ensure_google_contacts_source_group (void)
+/**
+ * manage_google_group:
+ * Searches for a 'Google' source group and ensures it has the correct
+ * name. If only_return is set to true, then only returns found group.
+ * Otherwise returns NULL.
+ **/
+ESourceGroup *
+manage_google_group (ESourceList *slist, gboolean only_return)
{
- ESourceList *source_list;
- ESourceGroup *group;
+ GSList *groups, *g;
+ ESourceGroup *group = NULL;
- source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources");
+ g_return_val_if_fail (slist != NULL, NULL);
- if (source_list == NULL) {
- return;
- }
+ groups = e_source_list_peek_groups (slist);
+ for (g = groups; g; g = g->next) {
+ group = E_SOURCE_GROUP (g->data);
- group = e_source_list_peek_group_by_name (source_list, _("Google"));
+ if (group && e_source_group_peek_base_uri (group) &&
+ g_ascii_strncasecmp ("google://", e_source_group_peek_base_uri (group), 9) == 0)
+ break;
- if (group == NULL) {
- gboolean res;
+ group = NULL;
+ }
- group = e_source_group_new (_("Google"), "google://");
- res = e_source_list_add_group (source_list, group, -1);
+ if (only_return)
+ return group;
- if (res == FALSE) {
- g_warning ("Could not add Google source group!");
- } else {
- e_source_list_sync (source_list, NULL);
- }
+ if (group) {
+ e_source_group_set_name (group, _("Google"));
+ } else {
+ group = e_source_group_new (_("Google"), "google://");
- g_object_unref (group);
- }
- g_object_unref (source_list);
+ if (!e_source_list_add_group (slist, group, -1)) {
+ g_warning ("Could not add Google source group!");
+ } else {
+ e_source_list_sync (slist, NULL);
+ }
+
+ g_object_unref (group);
+ }
+
+ return NULL;
+}
+
+void
+ensure_google_contacts_source_group (void)
+{
+ ESourceList *source_list;
+
+ source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources");
+
+ if (source_list == NULL) {
+ return;
+ }
+
+ manage_google_group (source_list, FALSE);
+ g_object_unref (source_list);
}
void
@@ -81,7 +109,7 @@ remove_google_contacts_source_group (void)
return;
}
- group = e_source_list_peek_group_by_name (source_list, _("Google"));
+ group = manage_google_group (source_list, TRUE);
if (group) {
GSList *sources;