[folks] core: Add PersonaStore:always-writeable-properties



commit 9ce804c7b3f712eb43121c1ef9cf17e0cf75bcc8
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Aug 11 13:55:10 2011 +0200

    core: Add PersonaStore:always-writeable-properties
    
    This complements Persona:writeable-properties, listing the properties which
    are guaranteed to always be writeable on the personas in a given persona
    store. This is in contrast to Persona:writeable-properties, which may list
    extra properties which are only writeable on that particular persona.
    
    This could be the case with, for example, personas representing the user,
    which might have extra writeable properties to allow the user to change their
    alias or avatar.
    
    Helps: bgo#653777

 NEWS                                             |    3 ++
 backends/eds/lib/edsf-persona-store.vala         |   26 ++++++++++++++++++++
 backends/key-file/kf-persona-store.vala          |   17 +++++++++++++
 backends/libsocialweb/lib/swf-persona-store.vala |   17 +++++++++++++
 backends/telepathy/lib/tpf-persona-store.vala    |   15 +++++++++++
 backends/tracker/lib/trf-persona-store.vala      |   28 ++++++++++++++++++++++
 folks/persona-store.vala                         |   19 +++++++++++++++
 7 files changed, 125 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index f8a57fe..47435b2 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Overview of changes from libfolks 0.6.1 to libfolks 0.6.2
 Bugs fixed:
 * Bug 645056 â TpLowlevel library should have only static public functions
 
+API changes:
+* Add PersonaStore:always-writeable-properties property
+
 Overview of changes from libfolks 0.6.0 to libfolks 0.6.1
 =========================================================
 
diff --git a/backends/eds/lib/edsf-persona-store.vala b/backends/eds/lib/edsf-persona-store.vala
index 4fe748a..f6671b2 100644
--- a/backends/eds/lib/edsf-persona-store.vala
+++ b/backends/eds/lib/edsf-persona-store.vala
@@ -44,6 +44,22 @@ public class Edsf.PersonaStore : Folks.PersonaStore
   private string _query_str;
   private bool _groups_supported = false;
 
+  private const string[] _always_writeable_properties =
+    {
+      "web-service-addresses",
+      "local-ids",
+      "postal-addresses",
+      "phone-numbers",
+      "email-addresses",
+      "notes",
+      "avatar",
+      "structured-name",
+      "full-name",
+      "nickname",
+      "im-addresses",
+      "groups"
+    };
+
   /**
    * The type of persona store this is.
    *
@@ -137,6 +153,16 @@ public class Edsf.PersonaStore : Folks.PersonaStore
     }
 
   /**
+   * { inheritDoc}
+   *
+   * @since UNRELEASED
+   */
+  public override string[] always_writeable_properties
+    {
+      get { return this._always_writeable_properties; }
+    }
+
+  /**
    * The { link Persona}s exposed by this PersonaStore.
    *
    * See { link Folks.PersonaStore.personas}.
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala
index 4f2efa9..2c4698e 100644
--- a/backends/key-file/kf-persona-store.vala
+++ b/backends/key-file/kf-persona-store.vala
@@ -39,6 +39,13 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
   private unowned Cancellable _save_key_file_cancellable = null;
   private bool _is_prepared = false;
 
+  private const string[] _always_writeable_properties =
+    {
+      "alias",
+      "im-addresses",
+      "web-service-addresses"
+    };
+
   /**
    * { inheritDoc}
    */
@@ -106,6 +113,16 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
 
   /**
    * { inheritDoc}
+   *
+   * @since UNRELEASED
+   */
+  public override string[] always_writeable_properties
+    {
+      get { return this._always_writeable_properties; }
+    }
+
+  /**
+   * { inheritDoc}
    */
   public override Map<string, Persona> personas
     {
diff --git a/backends/libsocialweb/lib/swf-persona-store.vala b/backends/libsocialweb/lib/swf-persona-store.vala
index 9215e75..631b783 100644
--- a/backends/libsocialweb/lib/swf-persona-store.vala
+++ b/backends/libsocialweb/lib/swf-persona-store.vala
@@ -40,6 +40,14 @@ public class Swf.PersonaStore : Folks.PersonaStore
   private ClientService _service;
   private ClientContactView _contact_view;
 
+  /* No writeable properties
+   *
+   * FIXME: we can't mark this as const because Vala gets confused
+   *        and generates the wrong C output (char *arr[0] = {}
+   *        instead of char **arr = NULL)
+   */
+  private static string[] _always_writeable_properties = {};
+
   /**
    * The type of persona store this is.
    *
@@ -108,6 +116,15 @@ public class Swf.PersonaStore : Folks.PersonaStore
     }
 
   /**
+   * { inheritDoc}
+   *
+   * @since UNRELEASED
+   */
+  public override string[] always_writeable_properties
+    {
+      get { return this._always_writeable_properties; }
+    }
+  /**
    * The { link Persona}s exposed by this PersonaStore.
    *
    * See { link Folks.PersonaStore.personas}.
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 630c610..3346f9e 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -61,6 +61,11 @@ public class Tpf.PersonaStore : Folks.PersonaStore
         ContactFeature.PRESENCE
       };
 
+  private const string[] _always_writeable_properties =
+    {
+      "is-favourite"
+    };
+
   private HashMap<string, Persona> _personas;
   private Map<string, Persona> _personas_ro;
   private HashSet<Persona> _persona_set;
@@ -171,6 +176,16 @@ public class Tpf.PersonaStore : Folks.PersonaStore
     }
 
   /**
+   * { inheritDoc}
+   *
+   * @since UNRELEASED
+   */
+  public override string[] always_writeable_properties
+    {
+      get { return this._always_writeable_properties; }
+    }
+
+  /**
    * The { link Persona}s exposed by this PersonaStore.
    *
    * See { link Folks.PersonaStore.personas}.
diff --git a/backends/tracker/lib/trf-persona-store.vala b/backends/tracker/lib/trf-persona-store.vala
index e2f00ac..9c3a7de 100644
--- a/backends/tracker/lib/trf-persona-store.vala
+++ b/backends/tracker/lib/trf-persona-store.vala
@@ -287,6 +287,24 @@ public class Trf.PersonaStore : Folks.PersonaStore
     "{ ?_contact a nco:PersonContact . %s } " +
     "ORDER BY tracker:id(?_contact) ";
 
+  private const string[] _always_writeable_properties =
+    {
+      "alias",
+      "phone-numbers",
+      "email-addresses",
+      "avatar",
+      "structured-name",
+      "full-name",
+      "gender",
+      "birthday",
+      "roles",
+      "notes",
+      "urls",
+      "im-addresses",
+      "is-favourite",
+      "local-ids",
+      "web-service-addresses"
+    };
 
   /**
    * The type of persona store this is.
@@ -356,6 +374,16 @@ public class Trf.PersonaStore : Folks.PersonaStore
     }
 
   /**
+   * { inheritDoc}
+   *
+   * @since UNRELEASED
+   */
+  public override string[] always_writeable_properties
+    {
+      get { return this._always_writeable_properties; }
+    }
+
+  /**
    * The { link Persona}s exposed by this PersonaStore.
    *
    * See { link Folks.PersonaStore.personas}.
diff --git a/folks/persona-store.vala b/folks/persona-store.vala
index a8c2f38..4f70778 100644
--- a/folks/persona-store.vala
+++ b/folks/persona-store.vala
@@ -498,6 +498,25 @@ public abstract class Folks.PersonaStore : Object
     }
 
   /**
+   * The names of the properties of the { link Persona}s in this store which are
+   * always writeable.
+   *
+   * If a property name is in this list, setting the property on a persona
+   * should result in the updated value being stored in the backend's permanent
+   * storage (unless it gets rejected due to being invalid, or a different error
+   * occurs).
+   *
+   * This property value is guaranteed to be constant for a given persona store,
+   * but may vary between persona stores in the same backend. It's guaranteed
+   * that this will always be a subset of the value of
+   * { link Persona.writeable_properties} for the personas in this persona
+   * store.
+   *
+   * @since UNRELEASED
+   */
+  public abstract string[] always_writeable_properties { get; }
+
+  /**
    * Prepare the PersonaStore for use.
    *
    * This connects the PersonaStore to whichever backend-specific services it



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