[folks] Add a PersonaStore.is_writeable property



commit 16f931677aba582bc5d5aa0f7c49974ac23924df
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Aug 9 17:07:28 2010 +0100

    Add a PersonaStore.is_writeable property

 folks/individual-aggregator.vala |   13 ++++++++++++-
 folks/persona-store.vala         |   11 +++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 3af1fc5..bf1fd87 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -160,15 +160,17 @@ public class Folks.IndividualAggregator : Object
       string store_id = this.get_store_full_id (store.type_id, store.id);
 
       /* FIXME: We hardcode the key-file backend's singleton PersonaStore as the
-       * only trusted PersonaStore for now. */
+       * only trusted and writeable PersonaStore for now. */
       if (store.type_id == "key-file")
         {
+          store.is_writeable = true;
           store.trust_level = PersonaStoreTrust.FULL;
           this.writeable_store = store;
         }
 
       this.stores.set (store_id, store);
       store.personas_changed.connect (this.personas_changed_cb);
+      store.notify["is-writeable"].connect (this.is_writeable_changed_cb);
       store.notify["trust-level"].connect (this.trust_level_changed_cb);
 
       store.prepare.begin ((obj, result) =>
@@ -190,6 +192,7 @@ public class Folks.IndividualAggregator : Object
     {
       store.personas_changed.disconnect (this.personas_changed_cb);
       store.notify["trust-level"].disconnect (this.trust_level_changed_cb);
+      store.notify["is-writeable"].disconnect (this.is_writeable_changed_cb);
 
       /* no need to remove this store's personas from all the individuals, since
        * they'll do that themselves (and emit their own 'removed' signal if
@@ -389,6 +392,14 @@ public class Folks.IndividualAggregator : Object
         }
     }
 
+  private void is_writeable_changed_cb (Object object, ParamSpec pspec)
+    {
+      /* Ensure that we only have one writeable PersonaStore */
+      unowned PersonaStore store = (PersonaStore) object;
+      assert ((store.is_writeable == true && store == this.writeable_store) ||
+          (store.is_writeable == false && store != this.writeable_store));
+    }
+
   private void trust_level_changed_cb (Object object, ParamSpec pspec)
     {
       /* FIXME: For the moment, assert that only the key-file backend's
diff --git a/folks/persona-store.vala b/folks/persona-store.vala
index 2a74928..48dbf39 100644
--- a/folks/persona-store.vala
+++ b/folks/persona-store.vala
@@ -153,6 +153,17 @@ public abstract class Folks.PersonaStore : Object
    */
   public abstract HashTable<string, Persona> personas { get; }
 
+   /**
+   * Whether the PersonaStore is writeable.
+   *
+   * Only if a PersonaStore is writeable will changes to its { link Persona}s'
+   * properties be written out to the relevant backing store.
+   *
+   * PersonaStores must not set this property themselves; it will be set as
+   * appropriate by the { link IndividualAggregator}.
+   */
+  public bool is_writeable { get; set; default = false; }
+
   /**
    * The trust level of the PersonaStore for linking.
    *



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