[folks] Change NoteDetails.notes to be of type Set<Note>



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

    Change NoteDetails.notes to be of type Set<Note>
    
    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/note-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 88e5917..a7d3c43 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,7 @@ API changes:
 * IndividualAggregator.individuals now has type Map<string, Individual>
 * PersonaStore.personas now has type Map<string, Persona>
 * LocalIdDetails.local_ids now has type Set<string>
+* NoteDetails.notes now has type Set<Note>
 
 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 136250b..1cc0d44 100644
--- a/backends/tracker/lib/trf-persona-store.vala
+++ b/backends/tracker/lib/trf-persona-store.vala
@@ -2062,7 +2062,7 @@ public class Trf.PersonaStore : Folks.PersonaStore
    }
 
   internal async void _set_notes (Folks.Persona persona,
-      owned Gee.HashSet<Note> notes)
+      Set<Note> notes)
     {
       const string del_t = "DELETE { " +
         "?p " + Trf.OntologyDefs.NCO_NOTE  + " ?n " +
diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala
index 0718236..e8e7fbd 100644
--- a/backends/tracker/lib/trf-persona.vala
+++ b/backends/tracker/lib/trf-persona.vala
@@ -205,7 +205,7 @@ public class Trf.Persona : Folks.Persona,
   /**
    * { inheritDoc}
    */
-  public HashSet<Note> notes
+  public Set<Note> notes
     {
       get { return this._notes; }
       private set
diff --git a/folks/individual.vala b/folks/individual.vala
index 76c7c55..461d0e9 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -332,15 +332,18 @@ public class Folks.Individual : Object,
   public string calendar_event_id { get; set; }
 
   private HashSet<Note> _notes;
+
   /**
    * { inheritDoc}
    */
-  public HashSet<Note> notes
+  public Set<Note> notes
     {
       get { return this._notes; }
       private set
         {
-          this._notes = value;
+          this._notes = new HashSet<Note> ();
+          foreach (var note in value)
+            this._notes.add (note);
           this.notify_property ("notes");
         }
     }
diff --git a/folks/note-details.vala b/folks/note-details.vala
index 4031445..3e194eb 100644
--- a/folks/note-details.vala
+++ b/folks/note-details.vala
@@ -86,7 +86,7 @@ public interface Folks.NoteDetails : Object
   /**
    * The notes about the contact.
    *
-   * @since 0.4.0
+   * @since UNRELEASED
    */
-  public abstract HashSet<Note> notes { get; set; }
+  public abstract Set<Note> notes { get; set; }
 }
diff --git a/tests/tracker/add-persona.vala b/tests/tracker/add-persona.vala
index 567ed8a..ef57262 100644
--- a/tests/tracker/add-persona.vala
+++ b/tests/tracker/add-persona.vala
@@ -240,8 +240,8 @@ public class AddPersonaTests : Folks.TestCase
       details.insert (
           Folks.PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES), v9);
 
-      Value? v10 = Value (typeof (Gee.HashSet<Note>));
-      Gee.HashSet<Note> notes = new Gee.HashSet<Note> ();
+      Value? v10 = Value (typeof (Set<Note>));
+      var notes = new HashSet<Note> ();
       Note n1 = new Note (this._note_1);
       notes.add (n1);
       v10.set_object (notes);
diff --git a/tools/inspect/utils.vala b/tools/inspect/utils.vala
index 1b3ac9f..e12d4bd 100644
--- a/tools/inspect/utils.vala
+++ b/tools/inspect/utils.vala
@@ -370,6 +370,26 @@ private class Folks.Inspect.Utils
 
             return output_string;
         }
+      else if (prop_name == "notes")
+        {
+          Set<Note> notes = (Set<Note>) prop_value.get_object ();
+
+          output_string = "{ ";
+          bool first = true;
+
+          foreach (var note in notes)
+            {
+              if (!first)
+                {
+                  output_string += ", ";
+                }
+              output_string += note.uid;
+              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]