Change NoteDetails.notes to be of type Set<Note>
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 20 Apr 2011 00:40:50 +0000 (01:40 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Sat, 23 Apr 2011 21:00:42 +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/note-details.vala
tests/tracker/add-persona.vala
tools/inspect/utils.vala

diff --git a/NEWS b/NEWS
index 88e5917..a7d3c43 100644 (file)
--- 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
 =========================================================
index 136250b..1cc0d44 100644 (file)
@@ -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 " +
index 0718236..e8e7fbd 100644 (file)
@@ -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
index 76c7c55..461d0e9 100644 (file)
@@ -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");
         }
     }
index 4031445..3e194eb 100644 (file)
@@ -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; }
 }
index 567ed8a..ef57262 100644 (file)
@@ -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);
index 1b3ac9f..e12d4bd 100644 (file)
@@ -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 ();