tracker: Add enable|disable_persona_store implementation to tracker backend.
authorJeremy Whiting <jpwhiting@kde.org>
Tue, 23 Oct 2012 01:08:28 +0000 (19:08 -0600)
committerJeremy Whiting <jpwhiting@kde.org>
Fri, 26 Oct 2012 16:56:58 +0000 (10:56 -0600)
core: Remove trailing whitespace in folks/backend.vala

NEWS
backends/tracker/tr-backend.vala
folks/backend.vala

diff --git a/NEWS b/NEWS
index 2088f02..2d0ec26 100644 (file)
--- 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.
index 2a800be..f39ef43 100644 (file)
@@ -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)
index 5d4ad58..176c9bd 100644 (file)
@@ -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.
    *