API changes:
* Implement PhoneDetails on Tpf.Persona
* Implement NameDetails on Tpf.Persona
+* Implement EmailDetails on Tpf.Persona
Overview of changes from libfolks 0.6.3.1 to libfolks 0.6.3.2
=============================================================
public class Tpf.Persona : Folks.Persona,
AliasDetails,
AvatarDetails,
+ EmailDetails,
FavouriteDetails,
GroupDetails,
ImDetails,
this.notify_property ("is-favourite");
}
+ private HashSet<EmailFieldDetails> _email_addresses;
+ private Set<EmailFieldDetails> _email_addresses_ro;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @since UNRELEASED
+ */
+ [CCode (notify = false)]
+ public Set<EmailFieldDetails> email_addresses
+ {
+ get { return this._email_addresses_ro; }
+ set { this.change_email_addresses.begin (value); }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @since UNRELEASED
+ */
+ public async void change_email_addresses (
+ Set<EmailFieldDetails> email_addresses) throws PropertyError
+ {
+ yield this._change_details<EmailFieldDetails> (email_addresses,
+ this._email_addresses, "email");
+ }
+
/**
* A mapping of IM protocol to an (unordered) set of IM addresses.
*
this._groups = new HashSet<string> ();
this._groups_ro = this._groups.read_only_view;
+ this._email_addresses = new HashSet<EmailFieldDetails> (
+ (GLib.HashFunc) EmailFieldDetails.hash,
+ (GLib.EqualFunc) EmailFieldDetails.equal);
+ this._email_addresses_ro = this._email_addresses.read_only_view;
this._phone_numbers = new HashSet<PhoneFieldDetails> (
(GLib.HashFunc) PhoneFieldDetails.hash,
(GLib.EqualFunc) PhoneFieldDetails.equal);
var tpf_store = this.store as Tpf.PersonaStore;
this._writeable_properties = this._always_writeable_properties;
+ if ("email" in tpf_store.supported_fields)
+ this._writeable_properties += "email-addresses";
if ("fn" in tpf_store.supported_fields)
this._writeable_properties += "full-name";
if ("tel" in tpf_store.supported_fields)
private void _contact_notify_contact_info ()
{
var new_full_name = "";
+ var new_email_addresses = new HashSet<EmailFieldDetails> (
+ (GLib.HashFunc) EmailFieldDetails.hash,
+ (GLib.EqualFunc) EmailFieldDetails.equal);
var new_phone_numbers = new HashSet<PhoneFieldDetails> (
(GLib.HashFunc) PhoneFieldDetails.hash,
(GLib.EqualFunc) PhoneFieldDetails.equal);
foreach (var info in contact_info)
{
if (info.field_name == "") {}
+ else if (info.field_name == "email")
+ {
+ foreach (var email_addr in info.field_value)
+ {
+ var parameters = this._afd_params_from_strv (info.parameters);
+ var email_fd = new EmailFieldDetails (email_addr, parameters);
+ new_email_addresses.add (email_fd);
+ }
+ }
else if (info.field_name == "fn")
{
new_full_name = info.field_value[0];
}
}
+ if (!Folks.Internal.equal_sets<EmailFieldDetails> (new_email_addresses,
+ this._email_addresses))
+ {
+ this._email_addresses = new_email_addresses;
+ this._email_addresses_ro = new_email_addresses.read_only_view;
+ this.notify_property ("email-addresses");
+ }
+
if (new_full_name != this._full_name)
{
this._full_name = new_full_name;
supported_fields = g_ptr_array_new ();
g_ptr_array_add (supported_fields, tp_value_array_build (4,
+ G_TYPE_STRING, "email",
+ G_TYPE_STRV, NULL,
+ G_TYPE_UINT, 0,
+ G_TYPE_UINT, G_MAXUINT32,
+ G_TYPE_INVALID));
+
+ g_ptr_array_add (supported_fields, tp_value_array_build (4,
G_TYPE_STRING, "fn",
G_TYPE_STRV, NULL,
G_TYPE_UINT, 0,
assert ("groups" in tpf_persona.writeable_properties);
/* These are only writeable for the user contact */
assert (tpf_persona.is_user);
+ assert (
+ "email-addresses" in tpf_persona.writeable_properties);
assert (("full-name" in tpf_persona.writeable_properties));
assert (
("phone-numbers" in tpf_persona.writeable_properties));
assert ("groups" in tpf_persona.writeable_properties);
/* These are only writeable for the user contact */
assert (!tpf_persona.is_user);
+ assert (
+ !("email-addresses" in tpf_persona.writeable_properties));
assert (!("full-name" in tpf_persona.writeable_properties));
assert (
!("phone-numbers" in tpf_persona.writeable_properties));
/* Check ContactInfo-provided properties */
assert (new PhoneFieldDetails ("+15142345678")
in i.phone_numbers);
+ assert (i.full_name == "Olivier Crete");
+ assert (new EmailFieldDetails ("olivier@example.com")
+ in i.email_addresses);
}
}
public void test_individual_properties_change_contact_info ()
{
var main_loop = new GLib.MainLoop (null, false);
+ this._changes_pending.add ("email-addresses");
this._changes_pending.add ("phone-numbers");
this._changes_pending.add ("full-name");
var added = changes.get_values ();
var removed = changes.get_keys ();
+ var new_email_fd = new EmailFieldDetails ("cave@aperturescience.com");
+ new_email_fd.set_parameter (AbstractFieldDetails.PARAM_TYPE,
+ AbstractFieldDetails.PARAM_TYPE_WORK);
var new_phone_fd = new PhoneFieldDetails ("+112233445566");
new_phone_fd.set_parameter (AbstractFieldDetails.PARAM_TYPE,
AbstractFieldDetails.PARAM_TYPE_HOME);
assert (i != null);
/* Check properties */
+ assert (!(new_email_fd in i.email_addresses));
assert (new_full_name != i.full_name);
assert (!(new_phone_fd in i.phone_numbers));
+ i.notify["email-addresses"].connect ((s, p) =>
+ {
+ /* we can't re-use i here due to Vala's implementation */
+ var ind = (Individual) s;
+
+ if (new_email_fd in ind.email_addresses)
+ {
+ this._changes_pending.remove ("email-addresses");
+ }
+ });
+
i.notify["full-name"].connect ((s, p) =>
{
/* we can't re-use i here due to Vala's implementation */
}
assert (persona is Tpf.Persona);
+ var emails = new HashSet<EmailFieldDetails> (
+ (GLib.HashFunc) EmailFieldDetails.hash,
+ (GLib.EqualFunc) EmailFieldDetails.equal);
+ emails.add (new_email_fd);
var phones = new HashSet<PhoneFieldDetails> (
(GLib.HashFunc) PhoneFieldDetails.hash,
(GLib.EqualFunc) PhoneFieldDetails.equal);
uncaught_errors++;
try
{
+ yield ((Tpf.Persona) persona).change_email_addresses (emails);
+ }
+ catch (PropertyError e0)
+ {
+ /* setting the extended info on a non-user is invalid for the
+ * Telepathy backend */
+ if (!i.is_user)
+ uncaught_errors--;
+ }
+
+ if (!i.is_user)
+ uncaught_errors++;
+ try
+ {
yield ((Tpf.Persona) persona).change_full_name (new_full_name);
}
catch (PropertyError e1)