[evolution-data-server] Bug 684456 - Google Contacts: Support vCard REV attribute



commit 5dd2bdddb1d4dedd21982851c94c7b0dadcf05bc
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 13 13:00:36 2015 +0200

    Bug 684456 - Google Contacts: Support vCard REV attribute

 .../backends/google/e-book-backend-google.c        |    8 ++++--
 addressbook/backends/google/e-book-google-utils.c  |   22 ++++++++++++++++++++
 2 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/addressbook/backends/google/e-book-backend-google.c 
b/addressbook/backends/google/e-book-backend-google.c
index b3e4022..7e106c5 100644
--- a/addressbook/backends/google/e-book-backend-google.c
+++ b/addressbook/backends/google/e-book-backend-google.c
@@ -199,10 +199,10 @@ migrate_cache (EBookBackendCache *cache)
        g_return_if_fail (cache != NULL);
 
        version = e_file_cache_get_object (E_FILE_CACHE (cache), version_key);
-       if (!version || atoi (version) < 1) {
-               /* not versioned yet, dump the cache and reload it from a server */
+       if (!version || atoi (version) < 2) {
+               /* not versioned yet or too old, dump the cache and reload it from the server */
                e_file_cache_clean (E_FILE_CACHE (cache));
-               e_file_cache_add_object (E_FILE_CACHE (cache), version_key, "1");
+               e_file_cache_add_object (E_FILE_CACHE (cache), version_key, "2");
        }
 }
 
@@ -1516,6 +1516,8 @@ book_backend_google_get_backend_property (EBookBackend *backend,
        } else if (g_str_equal (prop_name, BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS)) {
                return g_strjoin (
                        ",",
+                       e_contact_field_name (E_CONTACT_UID),
+                       e_contact_field_name (E_CONTACT_REV),
                        e_contact_field_name (E_CONTACT_FULL_NAME),
 
                        e_contact_field_name (E_CONTACT_EMAIL_1),
diff --git a/addressbook/backends/google/e-book-google-utils.c 
b/addressbook/backends/google/e-book-google-utils.c
index c8e5b4d..6544b02 100644
--- a/addressbook/backends/google/e-book-google-utils.c
+++ b/addressbook/backends/google/e-book-google-utils.c
@@ -600,6 +600,28 @@ e_contact_new_from_gdata_entry (GDataEntry *entry,
        attr = e_vcard_attribute_new (NULL, EVC_UID);
        e_vcard_add_attribute_with_value (vcard, attr, uid);
 
+       /* REV */
+       attr = e_vcard_attribute_new (NULL, EVC_REV);
+       if (gdata_entry_get_etag (entry)) {
+               e_vcard_add_attribute_with_value (vcard, attr, gdata_entry_get_etag (entry));
+       } else {
+               GDateTime *dt;
+               gchar *rev = NULL;
+
+               dt = g_date_time_new_from_unix_utc (gdata_entry_get_updated (entry));
+               if (dt) {
+                       rev = g_date_time_format (dt, "%Y-%m-%dT%H:%M:%S");
+                       g_date_time_unref (dt);
+               }
+
+               if (!rev)
+                       rev = g_strdup_printf ("%" G_GINT64_FORMAT, gdata_entry_get_updated (entry));
+
+               e_vcard_add_attribute_with_value (vcard, attr, rev);
+
+               g_free (rev);
+       }
+
        /* FN, N */
        name = gdata_contacts_contact_get_name (GDATA_CONTACTS_CONTACT (entry));
        if (name) {


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