[folks] tracker: Add enable|disable_persona_store implementation to tracker backend. core: Remove trailing w



commit c893ae90f7d546786975245e09288f5d219c9816
Author: Jeremy Whiting <jpwhiting kde org>
Date:   Mon Oct 22 19:08:28 2012 -0600

    tracker: Add enable|disable_persona_store implementation to tracker backend.
    core: Remove trailing whitespace in folks/backend.vala

 NEWS                             |    1 +
 backends/tracker/tr-backend.vala |   65 ++++++++++++++++++++++++++++++++++++-
 folks/backend.vala               |   12 +++---
 3 files changed, 70 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index 2088f02..2d0ec26 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Bugs fixed:
 â Bug 685084 â Add a folks backend for ofono phonebook
 â Bug 686056 â Add api to create and remove address books
 â Bug 685250 â make <test>.gdb deadlocks
+â Bug 686674 â Tracker backend doesn't implement new Backend functions
 
 API changes:
 â Add Backend.enable_persona_store and disable_persona_store.
diff --git a/backends/tracker/tr-backend.vala b/backends/tracker/tr-backend.vala
index 2a800be..f39ef43 100644
--- a/backends/tracker/tr-backend.vala
+++ b/backends/tracker/tr-backend.vala
@@ -54,6 +54,50 @@ public class Folks.Backends.Tr.Backend : Folks.Backend
   /**
    * { inheritDoc}
    */
+  public override void enable_persona_store (Folks.PersonaStore store)
+    {
+      if (this._persona_stores.has_key (store.id) == false)
+        {
+          this._add_store ((Trf.PersonaStore) store);
+        }
+    }
+
+  /**
+   * { inheritDoc}
+   */
+  public override void disable_persona_store (Folks.PersonaStore store)
+    {
+      if (this._persona_stores.has_key (store.id))
+        {
+          this._store_removed_cb (store);
+        }
+    }
+
+  /**
+   * { inheritDoc}
+   */
+  public override void set_persona_stores (Set<string>? storeids)
+    {
+      if (storeids != null)
+        {
+          if (storeids.size == 0)
+            {
+              this.disable_persona_store (this._persona_stores.get (BACKEND_NAME));
+            }
+          else
+            {
+              this._add_default_persona_store ();
+            }
+        }
+      else
+        {
+          this._add_default_persona_store ();
+        }
+    }
+
+  /**
+   * { inheritDoc}
+   */
   public Backend ()
     {
       Object ();
@@ -159,11 +203,28 @@ public class Folks.Backends.Tr.Backend : Folks.Backend
    */
   private void _add_default_persona_store ()
     {
-      var store = new Trf.PersonaStore ();
+      if (this._persona_stores.has_key (BACKEND_NAME) == false)
+        {
+          var store = new Trf.PersonaStore ();
+          this._add_store (store);
+        }
+    }
+
+  /**
+   * Utility function to add a persona store.
+   *
+   * @param store the store to add.
+   * @param notify whether or not to emit notification signals.
+   */
+  private void _add_store (PersonaStore store, bool notify = true)
+    {
       this._persona_stores.set (store.id, store);
       store.removed.connect (this._store_removed_cb);
-      this.notify_property ("persona-stores");
       this.persona_store_added (store);
+      if (notify)
+        {
+          this.notify_property ("persona-stores");
+        }
     }
 
   private void _store_removed_cb (Folks.PersonaStore store)
diff --git a/folks/backend.vala b/folks/backend.vala
index 5d4ad58..176c9bd 100644
--- a/folks/backend.vala
+++ b/folks/backend.vala
@@ -106,8 +106,8 @@ public abstract class Folks.Backend : Object
    * Enable a { link PersonaStore}.
    *
    * If the given persona store is not already in this backend
-   * { link Backend.persona_stores}, it will be added to the backend and 
-   * { link Backend.persona_stores} property notification will be emitted, 
+   * { link Backend.persona_stores}, it will be added to the backend and
+   * { link Backend.persona_stores} property notification will be emitted,
    * along with { link Backend.persona_store_added}.
    *
    * @param store the { link PersonaStore} to enable.
@@ -120,11 +120,11 @@ public abstract class Folks.Backend : Object
    * Set the { link PersonaStore}s to use in this backend.
    *
    * This will cause { link Backend.persona_store_removed} signals to be emitted
-   * for all removed stores, followed by { link Backend.persona_store_added} 
+   * for all removed stores, followed by { link Backend.persona_store_added}
    * signals for all added stores. As these signals are emitted, the sets of
-   * individuals in any associated { link IndividualAggregator}s will be 
-   * updated, and { link IndividualAggregator.individuals_changed} may be 
-   * emitted multiple times as appropriate. A property change notification for 
+   * individuals in any associated { link IndividualAggregator}s will be
+   * updated, and { link IndividualAggregator.individuals_changed} may be
+   * emitted multiple times as appropriate. A property change notification for
    * { link Backend.persona_stores} will be emitted last.
    * Note: pass null storeids to use all available persona stores.
    *



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