[folks] eds: Add an Edsf.Persona.in_google_personal_group property



commit 85e8d88f2dae0480d9804f6e60f9e6575cb9488a
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Jun 24 11:50:06 2012 +0100

    eds: Add an Edsf.Persona.in_google_personal_group property
    
    This is set whenever the persona is in the âMy Contactsâ group in Google
    Contacts, which is normally exposed by EDS as being in the âPersonalâ
    category. This system group canât be reliably detected normally as âPersonalâ
    is translated by EDS. This caused problems for gnome-contacts, hence the
    new API.
    
    The new API requires EDS 3.5.3 at runtime, and will always be false
    otherwise.
    
    Helps: https://bugzilla.gnome.org/show_bug.cgi?id=676383

 NEWS                               |    3 +-
 backends/eds/lib/edsf-persona.vala |   47 +++++++++++++++++++++++++++++++++++-
 2 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 396cdf6..5573c1f 100644
--- a/NEWS
+++ b/NEWS
@@ -8,9 +8,11 @@ Bugs fixed:
 â Bug 673918 â Port to newer libgee
 â Bug 629537 â Support anti-linking
 â Bug 679618 â Crash when unsetting all groups
+â Bug 678696 â Add API for EDS Google system groups
 
 API changes:
 â Add AntiLinkable interface and implement it on Kf.Persona and Edsf.Persona
+â Add Edsf.Persona.in_google_personal_group
 
 Overview of changes from libfolks 0.7.1 to libfolks 0.7.2
 =========================================================
@@ -29,7 +31,6 @@ Bugs fixed:
 API changes:
 â Add profiling api
 
-
 Overview of changes from libfolks 0.7.0 to libfolks 0.7.1
 =========================================================
 
diff --git a/backends/eds/lib/edsf-persona.vala b/backends/eds/lib/edsf-persona.vala
index 026fd0e..58cd3c9 100644
--- a/backends/eds/lib/edsf-persona.vala
+++ b/backends/eds/lib/edsf-persona.vala
@@ -699,6 +699,20 @@ public class Edsf.Persona : Folks.Persona,
       yield ((Edsf.PersonaStore) this.store)._set_anti_links (this, anti_links);
     }
 
+  private bool _in_google_personal_group;
+
+  /**
+   * Whether this contact is in the âMy Contactsâ section of the userâs address
+   * book, rather than the âOtherâ section.
+   *
+   * @since UNRELEASED
+   */
+  [CCode (notify = false)]
+  public bool in_google_personal_group
+    {
+      get { return this._in_google_personal_group; }
+    }
+
   /**
    * Build a IID.
    *
@@ -1504,8 +1518,34 @@ public class Edsf.Persona : Folks.Persona,
             }
         }
 
-      var old_is_favourite = this._is_favourite;
+      /* Check our new set of system groups if this is a Google address book. */
       var store = (Edsf.PersonaStore) this.store;
+      var in_google_personal_group = false;
+
+      if (store._is_google_contacts_address_book ())
+        {
+          var vcard = (E.VCard) this.contact;
+          unowned E.VCardAttribute? attr =
+             vcard.get_attribute ("X-GOOGLE-SYSTEM-GROUP-IDS");
+          if (attr != null)
+            {
+              unowned GLib.List<string> vals = attr.get_values ();
+
+              /* If we're in the GDATA_CONTACTS_GROUP_CONTACTS group, then
+               * we're in the user's "My Contacts" address book, as opposed
+               * to their "Other" address book. */
+              foreach (var system_group_id in vals)
+                {
+                  if (system_group_id == "Contacts")
+                    {
+                      in_google_personal_group = true;
+                      break;
+                    }
+                }
+            }
+        }
+
+      var old_is_favourite = this._is_favourite;
 
       /* Make the changes to this._groups and emit signals. */
       foreach (var category_name in removed_categories)
@@ -1545,6 +1585,11 @@ public class Edsf.Persona : Folks.Persona,
         {
           this.notify_property ("is-favourite");
         }
+      if (in_google_personal_group != this._in_google_personal_group)
+        {
+          this._in_google_personal_group = in_google_personal_group;
+          this.notify_property ("in-google-personal-group");
+        }
 
       this.thaw_notify ();
    }



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