[folks] Change LocalIdDetails.local_ids to be of type Set<string>



commit 99af9effc77f18bb83c369d48b16513a92cff920
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Apr 20 01:40:10 2011 +0100

    Change LocalIdDetails.local_ids to be of type Set<string>
    
    Helps: bgo#640092

 NEWS                                        |    1 +
 backends/tracker/lib/trf-persona-store.vala |   12 ++++++------
 backends/tracker/lib/trf-persona.vala       |    6 ++++--
 folks/individual-aggregator.vala            |    2 +-
 folks/individual.vala                       |    7 +++++--
 folks/local-id-details.vala                 |    4 ++--
 tools/inspect/utils.vala                    |    3 ++-
 7 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3387867..88e5917 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ API changes:
   Map<Individual, MatchResult>
 * IndividualAggregator.individuals now has type Map<string, Individual>
 * PersonaStore.personas now has type Map<string, Persona>
+* LocalIdDetails.local_ids now has type Set<string>
 
 Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
 =========================================================
diff --git a/backends/tracker/lib/trf-persona-store.vala b/backends/tracker/lib/trf-persona-store.vala
index d20f445..136250b 100644
--- a/backends/tracker/lib/trf-persona-store.vala
+++ b/backends/tracker/lib/trf-persona-store.vala
@@ -775,9 +775,9 @@ public class Trf.PersonaStore : Folks.PersonaStore
  /**
    * Transform HashSet<string> to "id1,id2,.."
    *
-   * @since 0.5.0
+   * @since UNRELEASED
    */
-  public  static string serialize_local_ids (Gee.HashSet<string> local_ids)
+  public static string serialize_local_ids (Set<string> local_ids)
     {
       var str = "";
 
@@ -796,11 +796,11 @@ public class Trf.PersonaStore : Folks.PersonaStore
   /**
    * Transform from id1,id2,.. to HashSet<string>
    *
-   * @since 0.5.0
+   * @since UNRELEASED
    */
-  public static Gee.HashSet<string> unserialize_local_ids (string local_ids)
+  public static Set<string> unserialize_local_ids (string local_ids)
     {
-      Gee.HashSet<string> ids = new Gee.HashSet<string> ();
+      var ids = new HashSet<string> ();
 
       if (local_ids != "")
         {
@@ -1849,7 +1849,7 @@ public class Trf.PersonaStore : Folks.PersonaStore
     }
 
   internal async void _set_local_ids (Trf.Persona persona,
-      Gee.HashSet<string> local_ids)
+      Set<string> local_ids)
     {
       string ids = Trf.PersonaStore.serialize_local_ids (local_ids);
       yield this._set_tracker_property (persona,
diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala
index 8a818be..0718236 100644
--- a/backends/tracker/lib/trf-persona.vala
+++ b/backends/tracker/lib/trf-persona.vala
@@ -283,10 +283,11 @@ public class Trf.Persona : Folks.Persona,
       }
 
   private HashSet<string> _local_ids = new HashSet<string> ();
+
   /**
    * IDs used to link { link Trf.Persona}s.
    */
-  public HashSet<string> local_ids
+  public Set<string> local_ids
     {
       get
         {
@@ -794,7 +795,8 @@ public class Trf.Persona : Folks.Persona,
 
   internal bool _set_local_ids (string local_ids)
     {
-      this._local_ids = Trf.PersonaStore.unserialize_local_ids (local_ids);
+      this._local_ids =
+          (HashSet<string>) Trf.PersonaStore.unserialize_local_ids (local_ids);
       this.notify_property ("local-ids");
       return true;
     }
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index f0fd7fd..f0e0d54 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -1029,7 +1029,7 @@ public class Folks.IndividualAggregator : Object
 
       if (local_ids.size > 0)
         {
-          var local_ids_value = Value (typeof (Gee.HashSet<string>));
+          var local_ids_value = Value (typeof (Set<string>));
           local_ids_value.set_object (local_ids);
           details.insert (
               Folks.PersonaStore.detail_key (PersonaDetail.LOCAL_IDS),
diff --git a/folks/individual.vala b/folks/individual.vala
index b5fb594..76c7c55 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -311,15 +311,18 @@ public class Folks.Individual : Object,
     }
 
   private HashSet<string> _local_ids;
+
   /**
    * { inheritDoc}
    */
-  public HashSet<string> local_ids
+  public Set<string> local_ids
     {
       get { return this._local_ids; }
       private set
         {
-          this._local_ids = value;
+          this._local_ids = new HashSet<string> ();
+          foreach (var id in value)
+            this._local_ids.add (id);
           this.notify_property ("local-ids");
         }
     }
diff --git a/folks/local-id-details.vala b/folks/local-id-details.vala
index b09d085..9de6b07 100644
--- a/folks/local-id-details.vala
+++ b/folks/local-id-details.vala
@@ -34,7 +34,7 @@ public interface Folks.LocalIdDetails : Object
    * The IDs corresponding to contacts in a
    * backend that we fully trust.
    *
-   * @since 0.5.0
+   * @since UNRELEASED
    */
-  public abstract HashSet<string> local_ids { get; set; }
+  public abstract Set<string> local_ids { get; set; }
 }
diff --git a/tools/inspect/utils.vala b/tools/inspect/utils.vala
index 0b36547..1b3ac9f 100644
--- a/tools/inspect/utils.vala
+++ b/tools/inspect/utils.vala
@@ -233,7 +233,8 @@ private class Folks.Inspect.Utils
               (Map<string, Persona>) prop_value.get_object ();
           return "Set of %u personas".printf (personas.size);
         }
-      else if (prop_name == "groups")
+      else if (prop_name == "groups" ||
+               prop_name == "local-ids")
         {
           Set<string> groups = (Set<string>) prop_value.get_object ();
           output_string = "{ ";



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