From 42992e45d4441de8378f2c15ae6de157ff9b0ab2 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 20 Apr 2011 11:22:18 +0100 Subject: [PATCH] Change PostalAddress.types to be a Set Helps: bgo#640092 --- NEWS | 1 + backends/tracker/lib/trf-persona-store.vala | 4 ++-- backends/tracker/lib/trf-persona.vala | 4 ++-- folks/postal-address-details.vala | 25 ++++++++++++---------- tests/tracker/add-persona.vala | 4 ++-- .../tracker/postal-address-details-interface.vala | 2 +- tests/tracker/set-postal-addresses.vala | 4 ++-- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index 6ac78c2..6cdcb34 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,7 @@ API changes: * NoteDetails.notes now has type Set * RoleDetails.roles now has type Set * PotentialMatch.known_email_aliases now has type Set +* PostalAddress.types now has type Set 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 86e43b7..0ce7695 100644 --- a/backends/tracker/lib/trf-persona-store.vala +++ b/backends/tracker/lib/trf-persona-store.vala @@ -1700,11 +1700,11 @@ public class Trf.PersonaStore : Folks.PersonaStore var country = cursor.get_string (Trf.AfflInfoFields.AFFL_COUNTRY).dup (); - GLib.List types = new GLib.List (); + var types = new HashSet (); affl_info.postal_address = new Folks.PostalAddress ( po_box, extension, street, locality, region, postal_code, - country, null, (owned) types, affl_info.affl_tracker_id); + country, null, types, affl_info.affl_tracker_id); affl_info.email = cursor.get_string (Trf.AfflInfoFields.AFFL_EMAIL).dup (); diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala index 0251195..da5c01f 100644 --- a/backends/tracker/lib/trf-persona.vala +++ b/backends/tracker/lib/trf-persona.vala @@ -550,7 +550,7 @@ public class Trf.Persona : Folks.Persona, if (address_empty) continue; - GLib.List types = new GLib.List (); + var types = new HashSet (); var pa = new PostalAddress (a_info[Trf.PostalAddressFields.POBOX], a_info[Trf.PostalAddressFields.EXTENDED_ADDRESS], @@ -559,7 +559,7 @@ public class Trf.Persona : Folks.Persona, a_info[Trf.PostalAddressFields.REGION], a_info[Trf.PostalAddressFields.POSTALCODE], a_info[Trf.PostalAddressFields.COUNTRY], - null, (owned) types, + null, types, a_info[Trf.PostalAddressFields.TRACKER_ID]); postal_addresses.add (pa); diff --git a/folks/postal-address-details.vala b/folks/postal-address-details.vala index 86a35d6..8ac7de4 100644 --- a/folks/postal-address-details.vala +++ b/folks/postal-address-details.vala @@ -128,22 +128,22 @@ public class Folks.PostalAddress : Object construct set { _address_format = (value != null ? value : ""); } } - private GLib.List _types; + private HashSet _types; + /** * The types of the address. * * The types of address, for instance an address can be a home or work * address. */ - public GLib.List types + public Set types { get { return this._types; } construct set { - this._types = new GLib.List (); - foreach (unowned string type in value) - this._types.prepend (type); - this._types.reverse (); + this._types = new HashSet (); + foreach (var type in value) + this._types.add (type); } } @@ -169,10 +169,11 @@ public class Folks.PostalAddress : Object * @param region the region (state or province) name * @param postal_code the postal code * @param address_format the address format + * @since UNRELEASED */ public PostalAddress (string? po_box, string? extension, string? street, string? locality, string? region, string? postal_code, string? country, - string? address_format, GLib.List types, string? uid) + string? address_format, Set types, string? uid) { Object (po_box: po_box, extension: extension, @@ -196,14 +197,16 @@ public class Folks.PostalAddress : Object this.postal_code != with.postal_code || this.country != with.country || this.address_format != with.address_format || - this.types.length () != with.types.length () || + this.types.size != with.types.size || this.uid != with.uid) return false; - for (int i=0; i types = new GLib.List (); + var types = new HashSet (); this._address = new PostalAddress (this._po_box, this._extension, this._street, this._locality, this._region, this._postal_code, this._country, null, types, null); @@ -270,7 +270,7 @@ public class AddPersonaTests : Folks.TestCase Value? v13 = Value (typeof (Set)); var postal_addresses = new HashSet (); - GLib.List types = new GLib.List (); + var types = new HashSet (); PostalAddress postal_a = new PostalAddress (this._po_box, this._extension, this._street, this._locality, this._region, this._postal_code, this._country, null, types, null); diff --git a/tests/tracker/postal-address-details-interface.vala b/tests/tracker/postal-address-details-interface.vala index dd021c2..e35138c 100644 --- a/tests/tracker/postal-address-details-interface.vala +++ b/tests/tracker/postal-address-details-interface.vala @@ -67,7 +67,7 @@ public class PostalAddressDetailsInterfaceTests : Folks.TestCase this._fullname = "persona #1"; c1.set (Trf.OntologyDefs.NCO_FULLNAME, this._fullname); - GLib.List types = new GLib.List (); + var types = new HashSet (); this._postal_address = new PostalAddress ( this._pobox, this._extended, diff --git a/tests/tracker/set-postal-addresses.vala b/tests/tracker/set-postal-addresses.vala index ef00a81..7e36e6c 100644 --- a/tests/tracker/set-postal-addresses.vala +++ b/tests/tracker/set-postal-addresses.vala @@ -59,7 +59,7 @@ public class SetPostalAddressesTests : Folks.TestCase c1.set (Trf.OntologyDefs.NCO_FULLNAME, this._persona_fullname); this._tracker_backend.add_contact (c1); - GLib.List types = new GLib.List (); + var types = new HashSet (); this._address = new PostalAddress (null, null, null, null, null, null, null, null, types, null); this._address.po_box = "12345"; @@ -119,7 +119,7 @@ public class SetPostalAddressesTests : Folks.TestCase { i.notify["postal-addresses"].connect (this._notify_postal_cb); - GLib.List types = new GLib.List (); + var types = new HashSet (); var addresses = new HashSet (); var pa = new Folks.PostalAddress (null, null, null, null, null, null, null, null, types, null); -- 2.7.4