[folks] Rebase PhoneDetails.phone_numbers upon PhoneFieldDetails
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Rebase PhoneDetails.phone_numbers upon PhoneFieldDetails
- Date: Fri, 12 Aug 2011 15:57:56 +0000 (UTC)
commit 85d4de54bd7d7e83da6dfc3444dbddf8afe0a016
Author: Travis Reitter <travis reitter collabora co uk>
Date: Tue Aug 9 15:59:16 2011 +0200
Rebase PhoneDetails.phone_numbers upon PhoneFieldDetails
Closes: bgo#655920 - Rebase PhoneDetails.phone_numbers upon an
AbstractFieldDetails-derived class
NEWS | 4 +
backends/eds/lib/edsf-persona-store.vala | 6 +-
backends/eds/lib/edsf-persona.vala | 16 ++--
backends/tracker/lib/trf-persona-store.vala | 6 +-
backends/tracker/lib/trf-persona.vala | 30 ++++---
folks/individual.vala | 36 ++++----
folks/phone-details.vala | 125 ++++++++++++++++-----------
folks/potential-match.vala | 6 +-
tests/eds/add-persona.vala | 17 ++--
tests/eds/phone-details.vala | 6 +-
tests/eds/set-phones.vala | 10 ++-
tests/tracker/add-persona.vala | 18 ++--
tests/tracker/duplicated-phones.vala | 20 ++--
tests/tracker/match-phone-number.vala | 20 ++--
tests/tracker/phone-details-interface.vala | 4 +-
tests/tracker/set-phones.vala | 15 ++--
16 files changed, 189 insertions(+), 150 deletions(-)
---
diff --git a/NEWS b/NEWS
index 20ec2bb..9383b83 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,8 @@ Bugs fixed:
* Bug 655374 â Un-break avatar tests
* Bug 655919 â Rebase NoteDetails.notes upon an AbstractFieldDetails-derived
class
+* Bug 655920 â Rebase PhoneDetails.numbers upon an AbstractFieldDetails-derived
+ class
API changes:
* Swf.Persona retains and exposes its libsocialweb Contact
@@ -69,6 +71,8 @@ API changes:
* Add and use EmailFieldDetails for EmailFieldDetails.email_addresses
* Add and use NoteFieldDetails for NoteFieldDetails.notes
* Remove Note class (obsoleted by NoteFieldDetails)
+* Add and use PhoneFieldDetails for PhoneFieldDetails.phone_numbers
+* Remove all PhoneDetails functions (obsoleted by PhoneFieldDetails)
Overview of changes from libfolks 0.5.1 to libfolks 0.5.2
=========================================================
diff --git a/backends/eds/lib/edsf-persona-store.vala b/backends/eds/lib/edsf-persona-store.vala
index 8cb0a63..63b3416 100644
--- a/backends/eds/lib/edsf-persona-store.vala
+++ b/backends/eds/lib/edsf-persona-store.vala
@@ -255,8 +255,8 @@ public class Edsf.PersonaStore : Folks.PersonaStore
else if (k == Folks.PersonaStore.detail_key (
PersonaDetail.PHONE_NUMBERS))
{
- Set<FieldDetails> phone_numbers =
- (Set<FieldDetails>) v.get_object ();
+ Set<PhoneFieldDetails> phone_numbers =
+ (Set<PhoneFieldDetails>) v.get_object ();
yield this._set_contact_attributes (contact,
phone_numbers, "TEL",
E.ContactField.TEL);
@@ -798,7 +798,7 @@ public class Edsf.PersonaStore : Folks.PersonaStore
}
internal async void _set_phones (Edsf.Persona persona,
- Set<FieldDetails> phones)
+ Set<PhoneFieldDetails> phones)
{
try
{
diff --git a/backends/eds/lib/edsf-persona.vala b/backends/eds/lib/edsf-persona.vala
index 50072e7..b347388 100644
--- a/backends/eds/lib/edsf-persona.vala
+++ b/backends/eds/lib/edsf-persona.vala
@@ -113,8 +113,8 @@ public class Edsf.Persona : Folks.Persona,
"im-addresses",
"groups"
};
- private HashSet<FieldDetails> _phone_numbers;
- private Set<FieldDetails> _phone_numbers_ro;
+ private HashSet<PhoneFieldDetails> _phone_numbers;
+ private Set<PhoneFieldDetails> _phone_numbers_ro;
private HashSet<EmailFieldDetails> _email_addresses;
private Set<EmailFieldDetails> _email_addresses_ro;
private HashSet<NoteFieldDetails> _notes;
@@ -191,7 +191,7 @@ public class Edsf.Persona : Folks.Persona,
*
* @since 0.5.UNRELEASED
*/
- public Set<FieldDetails> phone_numbers
+ public Set<PhoneFieldDetails> phone_numbers
{
get { return this._phone_numbers_ro; }
set
@@ -484,7 +484,9 @@ public class Edsf.Persona : Folks.Persona,
this._gender = Gender.UNSPECIFIED;
this.contact_id = contact_id;
- this._phone_numbers = new HashSet<FieldDetails> ();
+ this._phone_numbers = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
this._phone_numbers_ro = this._phone_numbers.read_only_view;
this._email_addresses = new HashSet<EmailFieldDetails> (
(GLib.HashFunc) EmailFieldDetails.hash,
@@ -924,16 +926,16 @@ public class Edsf.Persona : Folks.Persona,
var attrs = this.contact.get_attributes (E.ContactField.TEL);
foreach (var attr in attrs)
{
- var fd = new FieldDetails (attr.get_value ());
+ var phone_fd = new PhoneFieldDetails (attr.get_value ());
foreach (var param in attr.get_params ())
{
string param_name = param.get_name ().down ();
foreach (var param_value in param.get_values ())
{
- fd.add_parameter (param_name, param_value);
+ phone_fd.add_parameter (param_name, param_value);
}
}
- this._phone_numbers.add (fd);
+ this._phone_numbers.add (phone_fd);
}
this.notify_property ("phone-numbers");
diff --git a/backends/tracker/lib/trf-persona-store.vala b/backends/tracker/lib/trf-persona-store.vala
index e1b5c06..d1ef72b 100644
--- a/backends/tracker/lib/trf-persona-store.vala
+++ b/backends/tracker/lib/trf-persona-store.vala
@@ -547,8 +547,8 @@ public class Trf.PersonaStore : Folks.PersonaStore
else if (k == Folks.PersonaStore.detail_key (
PersonaDetail.PHONE_NUMBERS))
{
- Set<FieldDetails> phone_numbers =
- (Set<FieldDetails>) v.get_object ();
+ Set<PhoneFieldDetails> phone_numbers =
+ (Set<PhoneFieldDetails>) v.get_object ();
yield this._build_update_query_set (builder, phone_numbers,
"_:p", Trf.Attrib.PHONES);
}
@@ -1950,7 +1950,7 @@ public class Trf.PersonaStore : Folks.PersonaStore
}
internal async void _set_phones (Folks.Persona persona,
- Set<FieldDetails> phone_numbers)
+ Set<PhoneFieldDetails> phone_numbers)
{
yield this._set_unique_attrib_set (persona, phone_numbers,
Trf.Attrib.PHONES);
diff --git a/backends/tracker/lib/trf-persona.vala b/backends/tracker/lib/trf-persona.vala
index a3efb02..9024eb2 100644
--- a/backends/tracker/lib/trf-persona.vala
+++ b/backends/tracker/lib/trf-persona.vala
@@ -49,8 +49,8 @@ public class Trf.Persona : Folks.Persona,
private bool _is_favourite;
private const string[] _linkable_properties =
{"im-addresses", "local-ids", "web-service-addresses"};
- private HashSet<FieldDetails> _phone_numbers;
- private Set<FieldDetails> _phone_numbers_ro;
+ private HashSet<PhoneFieldDetails> _phone_numbers;
+ private Set<PhoneFieldDetails> _phone_numbers_ro;
private HashSet<EmailFieldDetails> _email_addresses;
private Set<EmailFieldDetails> _email_addresses_ro;
private weak Sparql.Cursor _cursor;
@@ -96,7 +96,7 @@ public class Trf.Persona : Folks.Persona,
/**
* { inheritDoc}
*/
- public Set<FieldDetails> phone_numbers
+ public Set<PhoneFieldDetails> phone_numbers
{
get { return this._phone_numbers_ro; }
public set
@@ -406,9 +406,9 @@ public class Trf.Persona : Folks.Persona,
this._full_name = fullname;
this._tracker_id = tracker_id;
this._structured_name = new StructuredName (null, null, null, null, null);
- this._phone_numbers = new HashSet<FieldDetails> (
- (GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
+ this._phone_numbers = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
this._phone_numbers_ro = this._phone_numbers.read_only_view;
this._email_addresses = new HashSet<EmailFieldDetails> (
(GLib.HashFunc) EmailFieldDetails.hash,
@@ -977,8 +977,9 @@ public class Trf.Persona : Folks.Persona,
return;
}
- var phones = new HashSet<FieldDetails> ((GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
+ var phones = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
string[] phones_a = phones_field.split ("\n");
foreach (var p in phones_a)
@@ -986,10 +987,11 @@ public class Trf.Persona : Folks.Persona,
if (p != null && p != "")
{
string[] p_info = p.split ("\t");
- var fd = new FieldDetails (p_info[Trf.PhoneFields.PHONE]);
- fd.set_parameter ("tracker_id",
+ var phone_fd =
+ new PhoneFieldDetails (p_info[Trf.PhoneFields.PHONE]);
+ phone_fd.set_parameter ("tracker_id",
p_info[Trf.PhoneFields.TRACKER_ID]);
- phones.add (fd);
+ phones.add (phone_fd);
}
}
@@ -1012,9 +1014,9 @@ public class Trf.Persona : Folks.Persona,
if (!found)
{
- var fd = new FieldDetails (phone);
- fd.set_parameter ("tracker_id", tracker_id);
- this._phone_numbers.add (fd);
+ var phone_fd = new PhoneFieldDetails (phone);
+ phone_fd.set_parameter ("tracker_id", tracker_id);
+ this._phone_numbers.add (phone_fd);
this.notify_property ("phone-numbers");
}
diff --git a/folks/individual.vala b/folks/individual.vala
index 4453dc2..9ca9ee4 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -334,20 +334,20 @@ public class Folks.Individual : Object,
}
}
- private HashSet<FieldDetails> _phone_numbers;
- private Set<FieldDetails> _phone_numbers_ro;
+ private HashSet<PhoneFieldDetails> _phone_numbers;
+ private Set<PhoneFieldDetails> _phone_numbers_ro;
/**
* { inheritDoc}
*/
- public Set<FieldDetails> phone_numbers
+ public Set<PhoneFieldDetails> phone_numbers
{
get { return this._phone_numbers_ro; }
private set
{
this._phone_numbers.clear ();
- foreach (var fd in value)
- this._phone_numbers.add (fd);
+ foreach (var phone_fd in value)
+ this._phone_numbers.add (phone_fd);
}
}
@@ -698,9 +698,9 @@ public class Folks.Individual : Object,
this._urls = new HashSet<FieldDetails> ((GLib.HashFunc) FieldDetails.hash,
(GLib.EqualFunc) FieldDetails.equal);
this._urls_ro = this._urls.read_only_view;
- this._phone_numbers = new HashSet<FieldDetails> (
- (GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
+ this._phone_numbers = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
this._phone_numbers_ro = this._phone_numbers.read_only_view;
this._email_addresses = new HashSet<EmailFieldDetails> (
(GLib.HashFunc) EmailFieldDetails.hash,
@@ -1343,11 +1343,9 @@ public class Folks.Individual : Object,
{
/* Populate the phone numbers as the union of our Personas' numbers
* If the same number exists multiple times we merge the parameters. */
- /* FIXME: We should handle phone numbers better, just string comparison
- doesn't work. */
var phone_numbers_set =
- new HashMap<unowned string, unowned FieldDetails> (
- null, null, (GLib.EqualFunc) FieldDetails.equal);
+ new HashMap<unowned string, unowned PhoneFieldDetails> (
+ null, null, (GLib.EqualFunc) PhoneFieldDetails.equal);
this._phone_numbers.clear ();
@@ -1356,19 +1354,19 @@ public class Folks.Individual : Object,
var phone_details = persona as PhoneDetails;
if (phone_details != null)
{
- foreach (var fd in phone_details.phone_numbers)
+ foreach (var phone_fd in phone_details.phone_numbers)
{
- if (fd.value == null)
+ if (phone_fd.value == null)
continue;
- var existing = phone_numbers_set.get (fd.value);
+ var existing = phone_numbers_set.get (phone_fd.value);
if (existing != null)
- existing.extend_parameters (fd.parameters);
+ existing.extend_parameters (phone_fd.parameters);
else
{
- var new_fd = new FieldDetails (fd.value);
- new_fd.extend_parameters (fd.parameters);
- phone_numbers_set.set (fd.value, new_fd);
+ var new_fd = new PhoneFieldDetails (phone_fd.value);
+ new_fd.extend_parameters (phone_fd.parameters);
+ phone_numbers_set.set (phone_fd.value, new_fd);
this._phone_numbers.add (new_fd);
}
}
diff --git a/folks/phone-details.vala b/folks/phone-details.vala
index c742675..b449d6b 100644
--- a/folks/phone-details.vala
+++ b/folks/phone-details.vala
@@ -23,12 +23,15 @@ using GLib;
using Gee;
/**
- * Interface for classes that can provide a phone number, such as
- * { link Persona} and { link Individual}.
+ * Object representing a phone number that can have some parameters associated
+ * with it.
*
- * @since 0.3.5
+ * See { link Folks.AbstractFieldDetails} for details on common parameter names
+ * and values.
+ *
+ * @since UNRELEASED
*/
-public interface Folks.PhoneDetails : Object
+public class Folks.PhoneFieldDetails : AbstractFieldDetails<string>
{
private const string[] _extension_chars = { "p", "P", "w", "W", "x", "X" };
private const string[] _common_delimiters = { ",", ".", "(", ")", "-", " ",
@@ -37,29 +40,39 @@ public interface Folks.PhoneDetails : Object
"5", "6", "7", "8", "9" };
/**
- * The phone numbers of the contact.
+ * Create a new PhoneFieldDetails.
*
- * A list of phone numbers associated to the contact.
+ * @param value the value of the field
+ * @param parameters initial parameters. See
+ * { link AbstractFieldDetails.parameters}. A `null` value is equivalent to a
+ * empty map of parameters.
+ *
+ * @return a new PhoneFieldDetails
*
- * @since 0.5.1
+ * @since UNRELEASED
*/
- public abstract Set<FieldDetails> phone_numbers { get; set; }
+ public PhoneFieldDetails (string value,
+ MultiMap<string, string>? parameters = null)
+ {
+ this.value = value;
+ if (parameters != null)
+ this.parameters = parameters;
+ }
/**
- * Normalise and compare two phone numbers.
- *
- * @param number1 a phone number to compare
- * @param number2 another phone number to compare
- * @return `true` if the phone numbers are equal, `false` otherwise
+ * { inheritDoc}
*
- * @since 0.5.0
+ * @since UNRELEASED
*/
- public static bool numbers_equal (string number1, string number2)
+ public override bool equal (AbstractFieldDetails<string> that)
{
- var n1 =
- PhoneDetails.drop_extension (PhoneDetails.normalise_number (number1));
- var n2 =
- PhoneDetails.drop_extension (PhoneDetails.normalise_number (number2));
+ var that_fd = that as PhoneFieldDetails;
+
+ if (that_fd == null)
+ return false;
+
+ var n1 = this._drop_extension (this.get_normalised ());
+ var n2 = this._drop_extension (that_fd.get_normalised ());
/* Based on http://blog.barisione.org/2010-06/handling-phone-numbers/ */
if (n1.length >= 7 && n2.length >= 7)
@@ -73,11 +86,21 @@ public interface Folks.PhoneDetails : Object
return n1_reduced == n2_reduced;
}
- return false;
+ return n1 == n2;
}
/**
- * Normalise a given phone number.
+ * { inheritDoc}
+ *
+ * @since UNRELEASED
+ */
+ public override uint hash ()
+ {
+ return base.hash ();
+ }
+
+ /**
+ * Return this object's normalised phone number.
*
* Typical normalisations:
*
@@ -85,58 +108,42 @@ public interface Folks.PhoneDetails : Object
* - `+1-800-123-4567` â `18001234567`
* - `+1-800-123-4567P123` â `18001234567P123`
*
- * @param number the phone number to normalise
* @return the normalised form of `number`
*
- * @since 0.5.0
+ * @since UNRELEASED
*/
- public static string normalise_number (string number)
+ public string get_normalised ()
{
string normalised_number = "";
- for (int i=0; i<number.length; i++)
+ for (int i = 0; i < this.value.length; i++)
{
- var digit = number.slice (i, i + 1);
+ var digit = this.value.slice (i, i + 1);
if (i == 0 && digit == "+")
{
/* we drop the initial + */
continue;
}
- else if (PhoneDetails.is_extension_digit (digit) ||
- PhoneDetails.is_valid_digit (digit))
+ else if (digit in this._extension_chars ||
+ digit in this._valid_digits)
{
/* lets keep valid digits */
normalised_number += digit;
}
- else if (PhoneDetails.is_common_delimiter (digit))
+ else if (digit in this._common_delimiters)
{
continue;
}
else
{
- debug ("[PhoneDetails.normalise] unknown digit: %s", digit);
+ debug ("[PhoneDetails.get_normalised] unknown digit: %s", digit);
}
}
return normalised_number.up ();
}
- internal static bool is_extension_digit (string digit)
- {
- return digit in PhoneDetails._extension_chars;
- }
-
- internal static bool is_valid_digit (string digit)
- {
- return digit in PhoneDetails._valid_digits;
- }
-
- internal static bool is_common_delimiter (string digit)
- {
- return digit in PhoneDetails._common_delimiters;
- }
-
/**
* Returns the given number without its extension (if any).
*
@@ -144,18 +151,36 @@ public interface Folks.PhoneDetails : Object
* @return the number without its extension; if the number didn't have an
* extension in the first place, the number is returned unmodified
*
- * @since 0.5.0
+ * @since UNRELEASED
*/
- internal static string drop_extension (string number)
+ internal static string _drop_extension (string number)
{
- for (var i=0; i < PhoneDetails._extension_chars.length; i++)
+ for (var i = 0; i < PhoneFieldDetails._extension_chars.length; i++)
{
- if (number.index_of (PhoneDetails._extension_chars[i]) >= 0)
+ if (number.index_of (PhoneFieldDetails._extension_chars[i]) >= 0)
{
- return number.split (PhoneDetails._extension_chars[i])[0];
+ return number.split (PhoneFieldDetails._extension_chars[i])[0];
}
}
return number;
}
}
+
+/**
+ * Interface for classes that can provide a phone number, such as
+ * { link Persona} and { link Individual}.
+ *
+ * @since 0.3.5
+ */
+public interface Folks.PhoneDetails : Object
+{
+ /**
+ * The phone numbers of the contact.
+ *
+ * A list of phone numbers associated to the contact.
+ *
+ * @since UNRELEASED
+ */
+ public abstract Set<PhoneFieldDetails> phone_numbers { get; set; }
+}
diff --git a/folks/potential-match.vala b/folks/potential-match.vala
index 8452ce2..0bac511 100644
--- a/folks/potential-match.vala
+++ b/folks/potential-match.vala
@@ -149,11 +149,11 @@ public class Folks.PotentialMatch : Object
var set_a = this._individual_a.phone_numbers;
var set_b = this._individual_b.phone_numbers;
- foreach (var fd_a in set_a)
+ foreach (var phone_fd_a in set_a)
{
- foreach (var fd_b in set_b)
+ foreach (var phone_fd_b in set_b)
{
- if (PhoneDetails.numbers_equal (fd_a.value, fd_b.value))
+ if (phone_fd_a.equal (phone_fd_b))
{
this._result = MatchResult.HIGH;
return;
diff --git a/tests/eds/add-persona.vala b/tests/eds/add-persona.vala
index 513c178..d635c8b 100644
--- a/tests/eds/add-persona.vala
+++ b/tests/eds/add-persona.vala
@@ -181,12 +181,15 @@ public class AddPersonaTests : Folks.TestCase
details.insert (
Folks.PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES), v4);
- Value? v5 = Value (typeof (Set<FieldDetails>));
- var phones = new HashSet<FieldDetails> ();
- var phone_1 = new FieldDetails (this._phone_1);
+ Value? v5 = Value (typeof (Set<PhoneFieldDetails>));
+ var phones = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+
+ var phone_1 = new PhoneFieldDetails (this._phone_1);
phone_1.set_parameter ("type", Edsf.Persona.phone_fields[0]);
phones.add (phone_1);
- var phone_2 = new FieldDetails (this._phone_2);
+ var phone_2 = new PhoneFieldDetails (this._phone_2);
phone_2.set_parameter ("type", Edsf.Persona.phone_fields[1]);
phones.add (phone_2);
v5.set_object (phones);
@@ -361,13 +364,13 @@ public class AddPersonaTests : Folks.TestCase
}
}
- foreach (var e in i.phone_numbers)
+ foreach (var phone_fd in i.phone_numbers)
{
- if (e.value == this._phone_1)
+ if (phone_fd.equal (new PhoneFieldDetails (this._phone_1)))
{
this._properties_found.replace ("phone-1", true);
}
- else if (e.value == this._phone_2)
+ else if (phone_fd.equal (new PhoneFieldDetails (this._phone_2)))
{
this._properties_found.replace ("phone-2", true);
}
diff --git a/tests/eds/phone-details.vala b/tests/eds/phone-details.vala
index dffcc13..4c871c3 100644
--- a/tests/eds/phone-details.vala
+++ b/tests/eds/phone-details.vala
@@ -160,10 +160,10 @@ public class PhoneDetailsTests : Folks.TestCase
contact.unset ("full_name");
var phone_numbers = (Folks.PhoneDetails) i;
- foreach (var p in phone_numbers.phone_numbers)
+ foreach (var phone_fd in phone_numbers.phone_numbers)
{
this._phones_count++;
- foreach (var t in p.get_parameter_values ("type"))
+ foreach (var t in phone_fd.get_parameter_values ("type"))
{
string? v = null;
@@ -186,7 +186,7 @@ public class PhoneDetailsTests : Folks.TestCase
}
this._phone_types.add (v);
- assert (contact.get (v).get_string () == p.value);
+ assert (contact.get (v).get_string () == phone_fd.value);
contact.unset (v);
}
}
diff --git a/tests/eds/set-phones.vala b/tests/eds/set-phones.vala
index df4aa6f..aaebf84 100644
--- a/tests/eds/set-phones.vala
+++ b/tests/eds/set-phones.vala
@@ -115,8 +115,10 @@ public class SetPhonesTests : Folks.TestCase
foreach (var p in i.personas)
{
- var phones = new HashSet<FieldDetails> ();
- var phone_1 = new FieldDetails ("1234");
+ var phones = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+ var phone_1 = new PhoneFieldDetails ("1234");
phone_1.set_parameter ("type", "HOME");
phones.add (phone_1);
((PhoneDetails) p).phone_numbers = phones;
@@ -130,9 +132,9 @@ public class SetPhonesTests : Folks.TestCase
private void _notify_phones_cb (Object individual_obj, ParamSpec ps)
{
Folks.Individual i = (Folks.Individual) individual_obj;
- foreach (var p in i.phone_numbers)
+ foreach (var phone_fd in i.phone_numbers)
{
- if (p.value == "1234")
+ if (phone_fd.equal (new PhoneFieldDetails ("1234")))
{
this._found_after_update = true;
this._main_loop.quit ();
diff --git a/tests/tracker/add-persona.vala b/tests/tracker/add-persona.vala
index a334066..eedb3d3 100644
--- a/tests/tracker/add-persona.vala
+++ b/tests/tracker/add-persona.vala
@@ -257,12 +257,14 @@ public class AddPersonaTests : Folks.TestCase
details.insert (Folks.PersonaStore.detail_key (PersonaDetail.NOTES),
(owned) v10);
- Value? v11 = Value (typeof (Set<FieldDetails>));
- var phones = new HashSet<FieldDetails> ((GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
- var phone_1 = new FieldDetails (this._phone_1);
+ Value? v11 = Value (typeof (Set<PhoneFieldDetails>));
+ var phones = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+
+ var phone_1 = new PhoneFieldDetails (this._phone_1);
phones.add (phone_1);
- var phone_2 = new FieldDetails (this._phone_2);
+ var phone_2 = new PhoneFieldDetails (this._phone_2);
phones.add (phone_2);
v11.set_object (phones);
details.insert (
@@ -460,13 +462,13 @@ public class AddPersonaTests : Folks.TestCase
}
}
- foreach (var e in i.phone_numbers)
+ foreach (var phone_fd in i.phone_numbers)
{
- if (e.value == this._phone_1)
+ if (phone_fd.equal (new PhoneFieldDetails (this._phone_1)))
{
this._properties_found.replace ("phone-1", true);
}
- else if (e.value == this._phone_2)
+ else if (phone_fd.equal (new PhoneFieldDetails (this._phone_2)))
{
this._properties_found.replace ("phone-2", true);
}
diff --git a/tests/tracker/duplicated-phones.vala b/tests/tracker/duplicated-phones.vala
index aa5d04a..3c96e19 100644
--- a/tests/tracker/duplicated-phones.vala
+++ b/tests/tracker/duplicated-phones.vala
@@ -166,11 +166,11 @@ public class DuplicatedPhonesTests : Folks.TestCase
details1.insert (Folks.PersonaStore.detail_key (PersonaDetail.FULL_NAME),
(owned) val);
- val = Value (typeof (Set<FieldDetails>));
- var phones1 = new HashSet<FieldDetails> (
- (GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
- var phone_1 = new FieldDetails (this._phone_1);
+ val = Value (typeof (Set<PhoneFieldDetails>));
+ var phones1 = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+ var phone_1 = new PhoneFieldDetails (this._phone_1);
phones1.add (phone_1);
val.set_object (phones1);
details1.insert (
@@ -182,11 +182,11 @@ public class DuplicatedPhonesTests : Folks.TestCase
details2.insert (Folks.PersonaStore.detail_key (PersonaDetail.FULL_NAME),
(owned) val);
- val = Value (typeof (Set<FieldDetails>));
- var phones2 = new HashSet<FieldDetails> (
- (GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
- var phone_2 = new FieldDetails (this._phone_1);
+ val = Value (typeof (Set<PhoneFieldDetails>));
+ var phones2 = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+ var phone_2 = new PhoneFieldDetails (this._phone_1);
phones2.add (phone_2);
val.set_object (phones2);
details2.insert (
diff --git a/tests/tracker/match-phone-number.vala b/tests/tracker/match-phone-number.vala
index 268592e..528d6bd 100644
--- a/tests/tracker/match-phone-number.vala
+++ b/tests/tracker/match-phone-number.vala
@@ -173,11 +173,11 @@ public class MatchPhoneNumberTests : Folks.TestCase
details1.insert (Folks.PersonaStore.detail_key (PersonaDetail.FULL_NAME),
(owned) val);
- val = Value (typeof (Set<FieldDetails>));
- var phone_numbers1 = new HashSet<FieldDetails> (
- (GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
- var phone_number_1 = new FieldDetails (this._phone_1);
+ val = Value (typeof (Set<PhoneFieldDetails>));
+ var phone_numbers1 = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+ var phone_number_1 = new PhoneFieldDetails (this._phone_1);
phone_numbers1.add (phone_number_1);
val.set_object (phone_numbers1);
details1.insert (
@@ -189,11 +189,11 @@ public class MatchPhoneNumberTests : Folks.TestCase
details2.insert (Folks.PersonaStore.detail_key (PersonaDetail.FULL_NAME),
(owned) val);
- val = Value (typeof (Set<FieldDetails>));
- var phone_numbers2 = new HashSet<FieldDetails> (
- (GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
- var phone_number_2 = new FieldDetails (this._phone_2);
+ val = Value (typeof (Set<PhoneFieldDetails>));
+ var phone_numbers2 = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+ var phone_number_2 = new PhoneFieldDetails (this._phone_2);
phone_numbers2.add (phone_number_2);
val.set_object (phone_numbers2);
details2.insert (
diff --git a/tests/tracker/phone-details-interface.vala b/tests/tracker/phone-details-interface.vala
index 8f5606d..623e7bd 100644
--- a/tests/tracker/phone-details-interface.vala
+++ b/tests/tracker/phone-details-interface.vala
@@ -113,12 +113,12 @@ public class PhoneDetailsInterfaceTests : Folks.TestCase
{
foreach (var phone in i.phone_numbers)
{
- if (phone.value == "12345")
+ if (phone.equal (new PhoneFieldDetails ("12345")))
{
this._found_phone_1 = true;
this._num_phones++;
}
- else if (phone.value == "54321")
+ else if (phone.equal (new PhoneFieldDetails ("54321")))
{
this._found_phone_2 = true;
this._num_phones++;
diff --git a/tests/tracker/set-phones.vala b/tests/tracker/set-phones.vala
index 58dceb6..1af2d84 100644
--- a/tests/tracker/set-phones.vala
+++ b/tests/tracker/set-phones.vala
@@ -113,12 +113,13 @@ public class SetPhonesTests : Folks.TestCase
{
i.notify["phone-numbers"].connect (this._notify_phones_cb);
- var phones = new HashSet<FieldDetails> (
- (GLib.HashFunc) FieldDetails.hash,
- (GLib.EqualFunc) FieldDetails.equal);
- var p1 = new FieldDetails (this._phone_1);
+ var phones = new HashSet<PhoneFieldDetails> (
+ (GLib.HashFunc) PhoneFieldDetails.hash,
+ (GLib.EqualFunc) PhoneFieldDetails.equal);
+
+ var p1 = new PhoneFieldDetails (this._phone_1);
phones.add (p1);
- var p2 = new FieldDetails (this._phone_2);
+ var p2 = new PhoneFieldDetails (this._phone_2);
phones.add (p2);
foreach (var p in i.personas)
@@ -138,9 +139,9 @@ public class SetPhonesTests : Folks.TestCase
{
foreach (var p in i.phone_numbers)
{
- if (p.value == this._phone_1)
+ if (p.equal (new PhoneFieldDetails (this._phone_1)))
this._phone_1_found = true;
- else if (p.value == this._phone_2)
+ else if (p.equal (new PhoneFieldDetails (this._phone_2)))
this._phone_2_found = true;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]