[evolution-data-server] Google: allow writing X-GOOGLE-SYSTEM-GROUP-IDS



commit f7da59992f82768c798acd53ce180da286726a55
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Oct 28 16:24:46 2012 +0100

    Google: allow writing X-GOOGLE-SYSTEM-GROUP-IDS
    
    We expose GData system groups as an extended attribute with that
    name, but if we found it in the EContact we would turn it into
    an extended property. Instead, marshal the system group IDs into
    Evolution categories, and then those into GData groups or system
    groups.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=687051

 addressbook/backends/google/e-book-google-utils.c |   37 +++++++++++++++++++-
 1 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/addressbook/backends/google/e-book-google-utils.c b/addressbook/backends/google/e-book-google-utils.c
index 98f4a02..ab4af4a 100644
--- a/addressbook/backends/google/e-book-google-utils.c
+++ b/addressbook/backends/google/e-book-google-utils.c
@@ -232,8 +232,10 @@ gdata_entry_update_from_e_contact (GDataEntry *entry,
 		    0 == g_ascii_strcasecmp (name, EVC_ROLE) ||
 		    0 == g_ascii_strcasecmp (name, EVC_NOTE) ||
 		    0 == g_ascii_strcasecmp (name, EVC_CATEGORIES) ||
-		    0 == g_ascii_strcasecmp (name, EVC_PHOTO)) {
-			/* Ignore UID, VERSION, X-EVOLUTION-FILE-AS, N, FN, LABEL, TITLE, ROLE, NOTE, CATEGORIES, PHOTO */
+		    0 == g_ascii_strcasecmp (name, EVC_PHOTO) ||
+                    0 == g_ascii_strcasecmp (name, GOOGLE_SYSTEM_GROUP_ATTR)) {
+			/* Ignore UID, VERSION, X-EVOLUTION-FILE-AS, N, FN, LABEL, TITLE, ROLE, NOTE, CATEGORIES, PHOTO,
+                                  X-GOOGLE-SYSTEM-GROUP-IDS */
 		} else if (0 == g_ascii_strcasecmp (name, EVC_EMAIL)) {
 			/* EMAIL */
 			GDataGDEmailAddress *email;
@@ -388,6 +390,37 @@ gdata_entry_update_from_e_contact (GDataEntry *entry,
 		e_contact_date_free (bdate);
 	}
 
+        /* Map X-GOOGLE-SYSTEM-GROUP-IDS from outside to CATEGORIES.
+           They will be mapped again to system group ids below; this is done
+           so e-d-s/evolution (which use CATEGORIES), folks/gnome-contacts (which
+           use X-GOOGLE-SYSTEM-GROUP-IDS) and google contacts (which uses the
+           GData group IDs) all stay in sync */
+        {
+                EVCardAttribute *system_group_attr;
+                EVCardAttribute *categories_attr;
+
+                system_group_attr = e_vcard_get_attribute (E_VCARD (contact), GOOGLE_SYSTEM_GROUP_ATTR);
+                categories_attr = e_vcard_get_attribute (E_VCARD (contact), EVC_CATEGORIES);
+
+                if (system_group_attr) {
+                        GList *system_groups = e_vcard_attribute_get_values (system_group_attr);
+                        GList *sys_group;
+
+                        for (sys_group = system_groups; sys_group; sys_group = sys_group->next) {
+                                const char *category_name;
+
+                                category_name = e_contact_map_google_with_evo_group (sys_group->data, TRUE);
+
+                                if (!categories_attr) {
+                                        categories_attr = e_vcard_attribute_new (NULL, EVC_CATEGORIES);
+                                        e_vcard_append_attribute (E_VCARD (contact), categories_attr);
+                                }
+
+                                e_vcard_attribute_add_value (categories_attr, category_name);
+                        }
+                }
+        }
+
 	/* CATEGORIES */
 	for (category_names = e_contact_get (contact, E_CONTACT_CATEGORY_LIST); category_names != NULL; category_names = category_names->next) {
 		gchar *category_id = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]