[folks] core: Add disable_persona_store and enable_persona_store API to backend eds: Implement new API in ed



commit 81a1d481f1df91afab9a012396960fc6afb1b75d
Author: Jeremy Whiting <jpwhiting kde org>
Date:   Thu Sep 20 13:59:54 2012 -0600

    core: Add disable_persona_store and enable_persona_store API to backend
    eds: Implement new API in eds backend

 backends/eds/eds-backend.vala |   34 ++++++++++++++++++++++++++++------
 folks/backend.vala            |   26 ++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 6 deletions(-)
---
diff --git a/backends/eds/eds-backend.vala b/backends/eds/eds-backend.vala
index b03f278..24b2020 100644
--- a/backends/eds/eds-backend.vala
+++ b/backends/eds/eds-backend.vala
@@ -64,6 +64,33 @@ public class Folks.Backends.Eds.Backend : Folks.Backend
   /**
    * { inheritDoc}
    */
+  public override void disable_persona_store (PersonaStore store)
+    {
+      if (this._persona_stores.has_key (store.id))
+        {
+          this._remove_address_book (store);
+        }
+    }
+  
+  /**
+   * { inheritDoc}
+   */
+  public override void enable_persona_store (PersonaStore store)
+    {
+      if (!this._persona_stores.has_key (store.id))
+        {
+          store.removed.connect (this._store_removed_cb);
+          
+          this._persona_stores.set (store.id, store);
+          this.notify_property ("persona-stores");
+          
+          this.persona_store_added (store);
+        }
+    }
+    
+  /**
+   * { inheritDoc}
+   */
   public Backend ()
     {
       Object ();
@@ -238,12 +265,7 @@ public class Folks.Backends.Eds.Backend : Folks.Backend
       var store =
           new Edsf.PersonaStore.with_source_registry (this._ab_sources, s);
 
-      store.removed.connect (this._store_removed_cb);
-
-      this._persona_stores.set (store.id, store);
-      this.notify_property ("persona-stores");
-
-      this.persona_store_added (store);
+      this.enable_persona_store (store);
     }
 
   private void _remove_address_book (Folks.PersonaStore store)
diff --git a/folks/backend.vala b/folks/backend.vala
index ec6613d..2c8861f 100644
--- a/folks/backend.vala
+++ b/folks/backend.vala
@@ -91,6 +91,32 @@ public abstract class Folks.Backend : Object
   public abstract Map<string, PersonaStore> persona_stores { get; }
 
   /**
+   * Disable a { link PersonaStore}.
+   *
+   * If the given persona store is in this backend { link Backend.persona_stores},
+   * it will be removed, and we will disconnect from its signals.
+   *
+   * @param store the { link PersonaStore} to disable.
+   *
+   * @since UNRELEASED
+   */
+  public abstract void disable_persona_store (PersonaStore store);
+
+  /**
+   * 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, 
+   * along with { link Backend.persona_store_added}.
+   *
+   * @param store the { link PersonaStore} to enable.
+   *
+   * @since UNRELEASED
+   */
+  public abstract void enable_persona_store (PersonaStore store);
+
+  /**
    * Emitted when a { link PersonaStore} is added to the backend.
    *
    * This will not be emitted until after { link Backend.prepare} has been



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