[folks] Migrate PostalAddressDetails to using AbstractFieldDetails.id
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Migrate PostalAddressDetails to using AbstractFieldDetails.id
- Date: Mon, 24 Oct 2011 19:18:42 +0000 (UTC)
commit cb4f43fc84f359589467543136e43302950959d0
Author: Travis Reitter <travis reitter collabora co uk>
Date: Thu Oct 20 10:23:08 2011 -0700
Migrate PostalAddressDetails to using AbstractFieldDetails.id
Deprecate PostalAddress.uid in favor of AbstractFieldDetails.id
PostalAddress.equal() now ignores PostalAddress.uid
Helps: bgo#662433 - AbstractFieldDetails.equal() is ambiguous about
checking parameters.
NEWS | 4 ++
backends/tracker/lib/trf-persona.vala | 5 ++-
folks/postal-address-details.vala | 33 ++++++++++++++++++-
tests/eds/add-persona.vala | 2 +-
tests/eds/postal-address-details.vala | 2 +-
tests/eds/set-postal-addresses.vala | 2 +-
tests/eds/set-properties-race.vala | 2 +-
tests/tracker/add-persona.vala | 4 +-
.../tracker/postal-address-details-interface.vala | 19 +++++++++++-
tests/tracker/set-postal-addresses.vala | 2 +-
10 files changed, 63 insertions(+), 12 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5b95fcc..24e5d8d 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,10 @@ Bugs fixed:
API changes:
* Add AbstractFieldDetails.id to identify instances of details
+* Deprecate PostalAddress.uid in favor of AbstractFieldDetails.id
+
+Behavior changes:
+* PostalAddress.equal() now ignores PostalAddress.uid
Overview of changes from libfolks 0.6.4 to libfolks 0.6.4.1
=============================================================
diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala
index 8639bc7..8867684 100644
--- a/backends/tracker/lib/trf-persona.vala
+++ b/backends/tracker/lib/trf-persona.vala
@@ -806,8 +806,9 @@ public class Trf.Persona : Folks.Persona,
a_info[Trf.PostalAddressFields.POSTALCODE],
a_info[Trf.PostalAddressFields.COUNTRY],
null,
- a_info[Trf.PostalAddressFields.TRACKER_ID]);
+ null);
var pafd = new PostalAddressFieldDetails (pa);
+ pafd.id = a_info[Trf.PostalAddressFields.TRACKER_ID];
postal_addresses.add (pafd);
}
@@ -851,7 +852,7 @@ public class Trf.Persona : Folks.Persona,
{
foreach (var pafd in this._postal_addresses)
{
- if (pafd.value.uid == tracker_id)
+ if (pafd.id == tracker_id)
{
this._postal_addresses.remove (pafd);
this.notify_property ("postal-addresses");
diff --git a/folks/postal-address-details.vala b/folks/postal-address-details.vala
index e77d83f..2781b2b 100644
--- a/folks/postal-address-details.vala
+++ b/folks/postal-address-details.vala
@@ -134,6 +134,7 @@ public class Folks.PostalAddress : Object
/**
* The UID of the Postal Address (if any).
*/
+ [Deprecated (since = "UNRELEASED", replacement = "AbstractFieldDetails.id")]
public string uid
{
get { return _uid; }
@@ -177,6 +178,8 @@ public class Folks.PostalAddress : Object
* components are equal (where `null` compares equal only with `null`) and
* they have the same set of types (or both have no types).
*
+ * This does not factor in the { link PostalAddress.uid}.
+ *
* @param with another postal address to compare with
* @return `true` if the addresses are equal, `false` otherwise
*/
@@ -189,8 +192,7 @@ public class Folks.PostalAddress : Object
this.region != with.region ||
this.postal_code != with.postal_code ||
this.country != with.country ||
- this.address_format != with.address_format ||
- this.uid != with.uid)
+ this.address_format != with.address_format)
return false;
return true;
@@ -224,6 +226,23 @@ public class Folks.PostalAddress : Object
public class Folks.PostalAddressFieldDetails :
AbstractFieldDetails<PostalAddress>
{
+ private string _id;
+ /**
+ * { inheritDoc}
+ */
+ public override string id
+ {
+ get { return this._id; }
+ set
+ {
+ this._id = (value != null ? value : "");
+
+ /* Keep the PostalAddress.uid sync'd from our id */
+ if (this._id != this.value.uid)
+ this.value.uid = this._id;
+ }
+ }
+
/**
* Create a new PostalAddressFieldDetails.
*
@@ -243,6 +262,16 @@ public class Folks.PostalAddressFieldDetails :
this.value = value;
if (parameters != null)
this.parameters = parameters;
+
+ /* We keep these sync'd both directions */
+ this.id = this.value.uid;
+
+ /* Keep the PostalAddress.uid sync'd to our id */
+ this.value.notify["uid"].connect ((s, p) =>
+ {
+ if (this.id != this.value.uid)
+ this.id = this.value.uid;
+ });
}
/**
diff --git a/tests/eds/add-persona.vala b/tests/eds/add-persona.vala
index fa751e7..9b2ed02 100644
--- a/tests/eds/add-persona.vala
+++ b/tests/eds/add-persona.vala
@@ -411,7 +411,7 @@ public class AddPersonaTests : Folks.TestCase
foreach (var pa_fd in i.postal_addresses)
{
- this._address.value.uid = pa_fd.value.uid;
+ this._address.id = pa_fd.id;
if (pa_fd.equal (this._address))
this._properties_found.replace ("postal-address-1", true);
}
diff --git a/tests/eds/postal-address-details.vala b/tests/eds/postal-address-details.vala
index 807fa3f..216b950 100644
--- a/tests/eds/postal-address-details.vala
+++ b/tests/eds/postal-address-details.vala
@@ -153,7 +153,7 @@ public class PostalAddressDetailsTests : Folks.TestCase
* Although we could get it from the 1st
* personas iid; there is no real need.
*/
- this._postal_address.value.uid = pa_fd.value.uid;
+ this._postal_address.id = pa_fd.id;
if (pa_fd.equal (this._postal_address))
{
diff --git a/tests/eds/set-postal-addresses.vala b/tests/eds/set-postal-addresses.vala
index d0ffc8d..ef65ca9 100644
--- a/tests/eds/set-postal-addresses.vala
+++ b/tests/eds/set-postal-addresses.vala
@@ -151,7 +151,7 @@ public class SetPostalAddressesTests : Folks.TestCase
Folks.Individual i = (Folks.Individual) individual_obj;
foreach (var pa_fd in i.postal_addresses)
{
- pa_fd.value.uid = this._pa_fd.value.uid;
+ pa_fd.id = this._pa_fd.id;
if (pa_fd.equal (this._pa_fd))
{
this._found_after_update = true;
diff --git a/tests/eds/set-properties-race.vala b/tests/eds/set-properties-race.vala
index 348af71..8179e5d 100644
--- a/tests/eds/set-properties-race.vala
+++ b/tests/eds/set-properties-race.vala
@@ -159,7 +159,7 @@ public class SetPropertiesRaceTests : Folks.TestCase
assert (pa_fd is PostalAddressFieldDetails);
assert (pa_fd.value is PostalAddress);
- pa_fd.value.uid = this._pa_fd.value.uid;
+ pa_fd.id = this._pa_fd.id;
if (pa_fd.equal (this._pa_fd))
{
this._found_after_update = true;
diff --git a/tests/tracker/add-persona.vala b/tests/tracker/add-persona.vala
index 4d3f928..e1d63b2 100644
--- a/tests/tracker/add-persona.vala
+++ b/tests/tracker/add-persona.vala
@@ -482,8 +482,8 @@ public class AddPersonaTests : Folks.TestCase
foreach (var pafd in i.postal_addresses)
{
- this._postal_address_fd.value.uid = pafd.value.uid;
- if (pafd.value.equal (this._postal_address_fd.value))
+ this._postal_address_fd.id = pafd.id;
+ if (pafd.equal (this._postal_address_fd))
this._properties_found.replace ("postal-address-1", true);
}
diff --git a/tests/tracker/postal-address-details-interface.vala b/tests/tracker/postal-address-details-interface.vala
index 83409ee..2166e53 100644
--- a/tests/tracker/postal-address-details-interface.vala
+++ b/tests/tracker/postal-address-details-interface.vala
@@ -149,10 +149,27 @@ public class PostalAddressDetailsInterfaceTests : Folks.TestCase
* Although we could get it from the 1st
* personas iid; there is no real need.
*/
- this._postal_address_fd.value.uid = pafd.value.uid;
+ this._postal_address_fd.id = pafd.id;
if (pafd.value.equal (this._postal_address_fd.value))
{
+ /* Ensure that setting the postal address uid directly
+ * (which is deprecated) is equivalent to setting the id on
+ * a PostalAddressFieldDetails directly */
+ var pa_2 = new PostalAddress (
+ this._postal_address_fd.value.po_box,
+ this._postal_address_fd.value.extension,
+ this._postal_address_fd.value.street,
+ this._postal_address_fd.value.locality,
+ this._postal_address_fd.value.region,
+ this._postal_address_fd.value.postal_code,
+ this._postal_address_fd.value.country,
+ null,
+ pafd.id);
+ var pa_fd_2 = new PostalAddressFieldDetails (pa_2);
+ assert (pafd.equal (pa_fd_2));
+ assert (pafd.id == pa_fd_2.id);
+
this._found_postal_address = true;
this._main_loop.quit ();
}
diff --git a/tests/tracker/set-postal-addresses.vala b/tests/tracker/set-postal-addresses.vala
index 7183f54..9c80f75 100644
--- a/tests/tracker/set-postal-addresses.vala
+++ b/tests/tracker/set-postal-addresses.vala
@@ -159,7 +159,7 @@ public class SetPostalAddressesTests : Folks.TestCase
foreach (var pafd in i.postal_addresses)
{
/* we don't care if UIDs differ for this test */
- this._postal_address_fd.value.uid = pafd.value.uid;
+ this._postal_address_fd.id = pafd.id;
if (pafd.value.equal (this._postal_address_fd.value))
{
this._postal_address_found = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]