[folks] Change RoleDetails.roles to be of type Set<Role>



commit a1aa6294a48a6cec8b92edd7f7cc73f6047c39cc
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Apr 20 01:41:20 2011 +0100

    Change RoleDetails.roles to be of type Set<Role>
    
    Helps: bgo#640092

 NEWS                                        |    1 +
 backends/tracker/lib/trf-persona-store.vala |    2 +-
 backends/tracker/lib/trf-persona.vala       |    2 +-
 folks/individual.vala                       |    7 +++++--
 folks/role-details.vala                     |    4 ++--
 tests/tracker/add-persona.vala              |    4 ++--
 tools/inspect/utils.vala                    |   20 ++++++++++++++++++++
 7 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index a7d3c43..50c0fbe 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ API changes:
 * PersonaStore.personas now has type Map<string, Persona>
 * LocalIdDetails.local_ids now has type Set<string>
 * NoteDetails.notes now has type Set<Note>
+* RoleDetails.roles now has type Set<Role>
 
 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 1cc0d44..86e43b7 100644
--- a/backends/tracker/lib/trf-persona-store.vala
+++ b/backends/tracker/lib/trf-persona-store.vala
@@ -2013,7 +2013,7 @@ public class Trf.PersonaStore : Folks.PersonaStore
     }
 
   internal async void _set_roles (Folks.Persona persona,
-      owned Gee.HashSet<Role> roles)
+      Set<Role> roles)
     {
       const string del_t = "DELETE { " +
         " ?p " + Trf.OntologyDefs.NCO_HAS_AFFILIATION + " ?a " +
diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala
index e8e7fbd..0251195 100644
--- a/backends/tracker/lib/trf-persona.vala
+++ b/backends/tracker/lib/trf-persona.vala
@@ -189,7 +189,7 @@ public class Trf.Persona : Folks.Persona,
   /**
    * { inheritDoc}
    */
-  public HashSet<Role> roles
+  public Set<Role> roles
     {
       get { return this._roles; }
       public set
diff --git a/folks/individual.vala b/folks/individual.vala
index 461d0e9..b4309f8 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -297,15 +297,18 @@ public class Folks.Individual : Object,
     }
 
   private HashSet<Role> _roles;
+
   /**
    * { inheritDoc}
    */
-  public HashSet<Role> roles
+  public Set<Role> roles
     {
       get { return this._roles; }
       private set
         {
-          this._roles = value;
+          this._roles = new HashSet<Role> ();
+          foreach (var role in value)
+            this._roles.add (role);
           this.notify_property ("roles");
         }
     }
diff --git a/folks/role-details.vala b/folks/role-details.vala
index 0fe48b8..c039fc0 100644
--- a/folks/role-details.vala
+++ b/folks/role-details.vala
@@ -117,7 +117,7 @@ public interface Folks.RoleDetails : Object
   /**
    * The roles of the contact.
    *
-   * @since 0.4.0
+   * @since UNRELEASED
    */
-  public abstract HashSet<Role> roles { get; set; }
+  public abstract Set<Role> roles { get; set; }
 }
diff --git a/tests/tracker/add-persona.vala b/tests/tracker/add-persona.vala
index ef57262..cc6bc39 100644
--- a/tests/tracker/add-persona.vala
+++ b/tests/tracker/add-persona.vala
@@ -259,8 +259,8 @@ public class AddPersonaTests : Folks.TestCase
           Folks.PersonaStore.detail_key (PersonaDetail.PHONE_NUMBERS),
           (owned) v11);
 
-      Value? v12 = Value (typeof (Gee.HashSet<Role>));
-      Gee.HashSet<Role> roles = new Gee.HashSet<Role> ();
+      Value? v12 = Value (typeof (Set<Role>));
+      var roles = new HashSet<Role> ();
       Role r1 = new Role (this._title_1, this._organisation_1);
       roles.add (r1);
       v12.set_object (roles);
diff --git a/tools/inspect/utils.vala b/tools/inspect/utils.vala
index e12d4bd..11767e6 100644
--- a/tools/inspect/utils.vala
+++ b/tools/inspect/utils.vala
@@ -390,6 +390,26 @@ private class Folks.Inspect.Utils
 
             return output_string;
         }
+      else if (prop_name == "roles")
+        {
+          Set<Role> roles = (Set<Role>) prop_value.get_object ();
+
+          output_string = "{ ";
+          bool first = true;
+
+          foreach (var role in roles)
+            {
+              if (!first)
+                {
+                  output_string += ", ";
+                }
+              output_string += role.to_string ();
+              first = false;
+            }
+            output_string += " }";
+
+            return output_string;
+        }
       else if (prop_name == "structured-name")
         {
           unowned StructuredName sn = (StructuredName) prop_value.get_object ();



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