[evolution-data-server/evolution-data-server-3-12] Bug #660535 - Google contact groups/categories not showing in category list



commit bc34be1a286a21fc15a66c15aaca468848c25c00
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Mar 24 16:15:12 2014 +0100

    Bug #660535 - Google contact groups/categories not showing in category list
    
    This means they should automatically appear in Evolution’s category
    selector and editor. Previously, only new groups added manually by
    editing a Google contact in Evolution using the category editor were
    shown in the list.

 .../backends/google/e-book-backend-google.c        |   14 ++++++++++++++
 addressbook/backends/google/e-book-google-utils.c  |    9 ++++++++-
 2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/backends/google/e-book-backend-google.c 
b/addressbook/backends/google/e-book-backend-google.c
index 149f391..0976aaf 100644
--- a/addressbook/backends/google/e-book-backend-google.c
+++ b/addressbook/backends/google/e-book-backend-google.c
@@ -437,8 +437,19 @@ cache_update_group (EBookBackend *backend,
 
                if (!e_file_cache_replace_object (file_cache, key, group_name))
                        e_file_cache_add_object (file_cache, key, group_name);
+
+               /* Add the category to Evolution’s category list. */
+               e_categories_add (group_name, NULL, NULL, TRUE);
        } else {
+               const gchar *old_value;
+
+               old_value = e_file_cache_get_object (file_cache, key);
                changed = e_file_cache_remove_object (file_cache, key);
+
+               /* Remove the category from Evolution’s category list. */
+               if (old_value != NULL) {
+                       e_categories_remove (old_value);
+               }
        }
 
        g_mutex_unlock (&priv->cache_lock);
@@ -1074,6 +1085,9 @@ create_group (EBookBackend *backend,
        g_hash_table_replace (priv->groups_by_name, g_strdup (category_name), 
e_contact_sanitise_google_group_id (uid));
        g_object_unref (new_group);
 
+       /* Update the cache. */
+       cache_update_group (backend, uid, category_name);
+
        g_debug ("...got UID %s", uid);
 
        return uid;
diff --git a/addressbook/backends/google/e-book-google-utils.c 
b/addressbook/backends/google/e-book-google-utils.c
index f4f09c8..cc7639e 100644
--- a/addressbook/backends/google/e-book-google-utils.c
+++ b/addressbook/backends/google/e-book-google-utils.c
@@ -459,6 +459,9 @@ gdata_entry_update_from_e_contact (GDataEntry *entry,
                        }
                }
 
+               /* Add the category to Evolution’s category list. */
+               e_categories_add (category_name, NULL, NULL, TRUE);
+
                gdata_contacts_contact_add_group (GDATA_CONTACTS_CONTACT (entry), category_id);
                if (g_strcmp0 (system_group_id, GDATA_CONTACTS_GROUP_CONTACTS) == 0)
                        ensure_personal_group = FALSE;
@@ -718,8 +721,12 @@ e_contact_new_from_gdata_entry (GDataEntry *entry,
                category_name = g_hash_table_lookup (groups_by_id, category_id);
 
                if (category_name != NULL) {
-                       if (g_list_find_custom (category_names, category_name, (GCompareFunc) g_strcmp0) == 
NULL)
+                       if (g_list_find_custom (category_names, category_name, (GCompareFunc) g_strcmp0) == 
NULL) {
                                category_names = g_list_prepend (category_names, category_name);
+
+                               /* Add the category to Evolution’s category list. */
+                               e_categories_add (category_name, NULL, NULL, TRUE);
+                       }
                } else
                        g_warning ("Couldn't find name for category with ID '%s'.", category_id);
 


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