Migrate NoteDetails to AbstractFieldDetails.id
authorTravis Reitter <travis.reitter@collabora.co.uk>
Thu, 20 Oct 2011 17:23:51 +0000 (10:23 -0700)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Mon, 24 Oct 2011 18:39:23 +0000 (11:39 -0700)
Deprecate NoteFieldDetails.uid in favor of AbstractFieldDetails.id

NoteFieldDetails.equal() now ignores NoteFieldDetails.uid

Helps: bgo#662433 - AbstractFieldDetails.equal() is ambiguous about
checking parameters.

NEWS
folks/note-details.vala
tests/tracker/note-details-interface.vala

diff --git a/NEWS b/NEWS
index 24e5d8d..020a38a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,9 +6,11 @@ Bugs fixed:
 API changes:
 * Add AbstractFieldDetails.id to identify instances of details
 * Deprecate PostalAddress.uid in favor of AbstractFieldDetails.id
+* Deprecate NoteFieldDetails.uid in favor of AbstractFieldDetails.id
 
 Behavior changes:
 * PostalAddress.equal() now ignores PostalAddress.uid
+* NoteFieldDetails.equal() now ignores NoteFieldDetails.uid
 
 Overview of changes from libfolks 0.6.4 to libfolks 0.6.4.1
 =============================================================
index 80c27d3..0c42389 100644 (file)
@@ -33,15 +33,24 @@ using GLib;
  */
 public class Folks.NoteFieldDetails : AbstractFieldDetails<string>
 {
-  /* FIXME: deprecate this */
-  private string _uid;
+  private string _id;
+  /**
+   * {@inheritDoc}
+   */
+  public override string id
+    {
+      get { return this._id; }
+      set { this._id = (value != null ? value : ""); }
+    }
+
   /**
    * The UID of the note (if any).
    */
+  [Deprecated (since = "UNRELEASED", replacement = "AbstractFieldDetails.id")]
   public string uid
     {
-      get { return _uid; }
-      set { _uid = (value != null ? value : ""); }
+      get { return this.id; }
+      set { this.id = value; }
     }
 
   /**
@@ -63,7 +72,9 @@ public class Folks.NoteFieldDetails : AbstractFieldDetails<string>
       this.value = value;
       if (parameters != null)
         this.parameters = parameters;
-      this.uid = uid;
+
+      /* These are kept the same value now */
+      this.id = uid;
     }
 
   /**
@@ -80,7 +91,7 @@ public class Folks.NoteFieldDetails : AbstractFieldDetails<string>
       if (that_nfd == null)
         return false;
 
-      return (this.uid == that_nfd.uid && this.value == that_nfd.value);
+      return (this.value == that_nfd.value);
     }
 
   /**
@@ -95,8 +106,8 @@ public class Folks.NoteFieldDetails : AbstractFieldDetails<string>
       if (this.value != null)
         retval += this.value.hash ();
 
-      if (this.uid != null)
-        retval += this.uid.hash ();
+      if (this.id != null)
+        retval += this.id.hash ();
 
       return retval;
     }
index 3702cb4..20d227d 100644 (file)
@@ -111,10 +111,26 @@ public class NoteDetailsInterfaceTests : Folks.TestCase
           if (i.full_name == this._fullname)
             {
               i.notify["notes"].connect (this._notify_note_cb);
-              foreach (var n in i.notes)
+              foreach (var note_fd in i.notes)
                 {
-                  if (n.equal (new NoteFieldDetails (this._note)))
+                  var note_fd_expected = new NoteFieldDetails (this._note, null,
+                      null);
+
+                  /* We copy the tracker_id - we don't know it.
+                   * We could get it from the 1st personas iid but there is no
+                   * real need. */
+                  note_fd_expected.id = note_fd.id;
+
+                  if (note_fd.equal (note_fd_expected))
                     {
+                      /* Ensure that setting the Note uid directly (which is
+                       * deprecated) is equivalent to setting the id on a
+                       * NoteFieldDetails directly */
+                      var note_fd_2 = new NoteFieldDetails (
+                          note_fd_expected.value, null, note_fd.id);
+                      assert (note_fd.equal (note_fd_2));
+                      assert (note_fd.id == note_fd_2.id);
+
                       this._found_note = true;
                       this._main_loop.quit ();
                     }