Change RoleDetails.roles to be of type Set<Role>
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 20 Apr 2011 00:41:20 +0000 (01:41 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Sat, 23 Apr 2011 21:00:44 +0000 (22:00 +0100)
Helps: bgo#640092

NEWS
backends/tracker/lib/trf-persona-store.vala
backends/tracker/lib/trf-persona.vala
folks/individual.vala
folks/role-details.vala
tests/tracker/add-persona.vala
tools/inspect/utils.vala

diff --git a/NEWS b/NEWS
index a7d3c43..50c0fbe 100644 (file)
--- 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
 =========================================================
index 1cc0d44..86e43b7 100644 (file)
@@ -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 " +
index e8e7fbd..0251195 100644 (file)
@@ -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
index 461d0e9..b4309f8 100644 (file)
@@ -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");
         }
     }
index 0fe48b8..c039fc0 100644 (file)
@@ -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; }
 }
index ef57262..cc6bc39 100644 (file)
@@ -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);
index e12d4bd..11767e6 100644 (file)
@@ -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 ();