[folks] core: Add GROUPS and INVALID to PersonaDetail



commit 3f71f115ee6afc747a47a4576e921e35713180ba
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Sep 4 12:56:36 2011 +0100

    core: Add GROUPS and INVALID to PersonaDetail
    
    One is obviously necessary. The other is necessary for use as an error return
    from a function in the fix for bgo#657789.
    
    This also adds some bounds checking to PersonaStore.detail_key(), which can
    now return null if the PersonaDetail wasn't recognised.
    
    Helps: bgo#657789

 NEWS                     |    1 +
 folks/persona-store.vala |   30 ++++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 885f0c8..4f6a778 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ API changes:
 * Add *Details.change_*() virtual methods
 * Add IndividualAggregator:is-quiescent, Backend:is-quiescent and
   PersonaStore:is-quiescent
+* Add PersonaDetail.GROUPS and PersonaDetail.INVALID
 
 Overview of changes from libfolks 0.6.0 to libfolks 0.6.1
 =========================================================
diff --git a/folks/persona-store.vala b/folks/persona-store.vala
index b330536..e5349c4 100644
--- a/folks/persona-store.vala
+++ b/folks/persona-store.vala
@@ -128,11 +128,18 @@ public errordomain Folks.PersonaStoreError
 public enum Folks.PersonaDetail
 {
   /**
+   * Invalid field for use in error returns.
+   *
+   * @since UNRELEASED
+   */
+  INVALID = -1,
+
+  /**
    * Field for { link AliasDetails.alias}.
    *
    * @since 0.5.0
    */
-  ALIAS,
+  ALIAS = 0,
 
   /**
    * Field for { link AvatarDetails.avatar}.
@@ -244,7 +251,14 @@ public enum Folks.PersonaDetail
    *
    * @since 0.5.0
    */
-  WEB_SERVICE_ADDRESSES
+  WEB_SERVICE_ADDRESSES,
+
+  /**
+   * Field for { link GroupDetails.groups}.
+   *
+   * @since UNRELEASED
+   */
+  GROUPS
 }
 
 /**
@@ -288,7 +302,8 @@ public abstract class Folks.PersonaStore : Object
     "roles",
     "structured-name",
     "urls",
-    "web-service-addresses"
+    "web-service-addresses",
+    "groups"
   };
 
   /**
@@ -296,11 +311,18 @@ public abstract class Folks.PersonaStore : Object
    * the details param of { link PersonaStore.add_persona_from_details}.
    *
    * @param detail the { link PersonaDetail} to lookup
+   * @return the corresponding property name, or `null` if `detail` is invalid
    *
    * @since 0.5.0
    */
-  public static unowned string detail_key (Folks.PersonaDetail detail)
+  public static unowned string? detail_key (Folks.PersonaDetail detail)
     {
+      if (detail == PersonaDetail.INVALID ||
+          detail >= PersonaStore._PERSONA_DETAIL.length)
+        {
+          return null;
+        }
+
       return PersonaStore._PERSONA_DETAIL[detail];
     }
 



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