Add NOTE support to the Google Contacts backend
authorPhilip Withnall <philip@tecnocode.co.uk>
Wed, 21 Apr 2010 15:34:54 +0000 (16:34 +0100)
committerPhilip Withnall <philip@tecnocode.co.uk>
Wed, 19 May 2010 21:21:06 +0000 (22:21 +0100)
Closes: bgo#602244

addressbook/backends/google/e-book-backend-google.c
addressbook/backends/google/util.c

index fbbe86c..0eb853c 100644 (file)
@@ -1175,7 +1175,8 @@ e_book_backend_google_get_supported_fields (EBookBackendSync *backend, EDataBook
                E_CONTACT_ORG,
                E_CONTACT_ORG_UNIT,
                E_CONTACT_TITLE,
-               E_CONTACT_ROLE
+               E_CONTACT_ROLE,
+               E_CONTACT_NOTE
        };
 
        __debug__ (G_STRFUNC);
index 33e6ea3..1a685cf 100644 (file)
@@ -68,7 +68,7 @@ _gdata_entry_update_from_e_contact (GDataEntry *entry, EContact *contact)
        gboolean have_phone_primary = FALSE;
        gboolean have_postal_primary = FALSE;
        gboolean have_org_primary = FALSE;
-       const gchar *title, *role;
+       const gchar *title, *role, *note;
 
        attributes = e_vcard_get_attributes (E_VCARD (contact));
 
@@ -96,6 +96,13 @@ _gdata_entry_update_from_e_contact (GDataEntry *entry, EContact *contact)
                g_object_unref (name);
        }
 
+       /* NOTE */
+       note = e_contact_get (contact, E_CONTACT_NOTE);
+       if (note)
+               gdata_entry_set_content (entry, note);
+       else
+               gdata_entry_set_content (entry, NULL);
+
        /* Clear out all the old attributes */
        gdata_contacts_contact_remove_all_email_addresses (GDATA_CONTACTS_CONTACT (entry));
        gdata_contacts_contact_remove_all_phone_numbers (GDATA_CONTACTS_CONTACT (entry));
@@ -120,8 +127,9 @@ _gdata_entry_update_from_e_contact (GDataEntry *entry, EContact *contact)
                    0 == g_ascii_strcasecmp (name, EVC_VERSION) ||
                    0 == g_ascii_strcasecmp (name, EVC_X_FILE_AS) ||
                    0 == g_ascii_strcasecmp (name, EVC_TITLE) ||
-                   0 == g_ascii_strcasecmp (name, EVC_ROLE)) {
-                       /* Ignore UID, VERSION, X-EVOLUTION-FILE-AS, N, FN, LABEL, TITLE, ROLE */
+                   0 == g_ascii_strcasecmp (name, EVC_ROLE) ||
+                   0 == g_ascii_strcasecmp (name, EVC_NOTE)) {
+                       /* Ignore UID, VERSION, X-EVOLUTION-FILE-AS, N, FN, LABEL, TITLE, ROLE, NOTE */
                } else if (0 == g_ascii_strcasecmp (name, EVC_EMAIL)) {
                        /* EMAIL */
                        GDataGDEmailAddress *email;
@@ -224,7 +232,7 @@ _e_contact_new_from_gdata_entry (GDataEntry *entry)
        EVCard *vcard;
        EVCardAttribute *attr;
        GList *email_addresses, *im_addresses, *phone_numbers, *postal_addresses, *orgs;
-       const gchar *uid;
+       const gchar *uid, *note;
        GList *itr;
        GDataGDName *name;
        GDataGDEmailAddress *email;
@@ -263,6 +271,11 @@ _e_contact_new_from_gdata_entry (GDataEntry *entry)
                e_contact_set (E_CONTACT (vcard), E_CONTACT_NAME, &name_struct);
        }
 
+       /* NOTE */
+       note = gdata_entry_get_content (entry);
+       if (note)
+               e_contact_set (E_CONTACT (vcard), E_CONTACT_NOTE, note);
+
        /* EMAIL - primary first */
        email = gdata_contacts_contact_get_primary_email_address (GDATA_CONTACTS_CONTACT (entry));
        add_attribute_from_gdata_gd_email_address (vcard, email);