Commit 87e04d0b authored by Raul Gutierrez Segales's avatar Raul Gutierrez Segales Committed by Travis Reitter
Browse files

Telepathy: implement PhoneDetails for Tpf.Persona

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=657602
parent 47568e34
......@@ -3,6 +3,12 @@ Overview of changes from libfolks 0.6.3.2 to libfolks 0.6.4
Bugs fixed:
* Bug 660217 — folks-0.6.3.2 requires tracker-0.12, but configure.ac calls
VALA_CHECK_PACKAGES([tracker-sparql-0.12])
* Bug 657602 — Telepathy backend fails to set Personas' phone numbers from
ContactInfo
API changes:
* Implement PhoneDetails on Tpf.Persona
* Implement NameDetails on Tpf.Persona
Overview of changes from libfolks 0.6.3.1 to libfolks 0.6.3.2
=============================================================
......
......@@ -58,7 +58,8 @@ public class Tpf.PersonaStore : Folks.PersonaStore
ContactFeature.AVATAR_TOKEN,
ContactFeature.CAPABILITIES,
ContactFeature.CLIENT_TYPES,
ContactFeature.PRESENCE
ContactFeature.PRESENCE,
ContactFeature.CONTACT_INFO
};
private const string[] _always_writeable_properties =
......
......@@ -33,6 +33,7 @@ public class Tpf.Persona : Folks.Persona,
FavouriteDetails,
GroupDetails,
ImDetails,
PhoneDetails,
PresenceDetails
{
private HashSet<string> _groups;
......@@ -286,6 +287,21 @@ public class Tpf.Persona : Folks.Persona,
*/
public Contact? contact { get; construct; }
private HashSet<PhoneFieldDetails> _phone_numbers;
private Set<PhoneFieldDetails> _phone_numbers_ro;
/**
* {@inheritDoc}
*
* @since UNRELEASED
*/
[CCode (notify = false)]
public Set<PhoneFieldDetails> phone_numbers
{
get { return this._phone_numbers_ro; }
set { this.change_phone_numbers.begin (value); }
}
/**
* Create a new persona.
*
......@@ -353,6 +369,11 @@ public class Tpf.Persona : Folks.Persona,
this._groups = new HashSet<string> ();
this._groups_ro = this._groups.read_only_view;
this._phone_numbers = new HashSet<PhoneFieldDetails> (
(GLib.HashFunc) PhoneFieldDetails.hash,
(GLib.EqualFunc) PhoneFieldDetails.equal);
this._phone_numbers_ro = this._phone_numbers.read_only_view;
contact.notify["avatar-file"].connect ((s, p) =>
{
this._contact_notify_avatar ();
......@@ -375,6 +396,12 @@ public class Tpf.Persona : Folks.Persona,
this._contact_notify_presence_type ();
this._contact_notify_presence_status ();
contact.notify["contact-info"].connect ((s, p) =>
{
this._contact_notify_phones ();
});
this._contact_notify_phones ();
((Tpf.PersonaStore) this.store).group_members_changed.connect (
(s, group, added, removed) =>
{
......@@ -401,6 +428,56 @@ public class Tpf.Persona : Folks.Persona,
});
}
private void _contact_notify_phones ()
{
var new_phone_numbers = new HashSet<PhoneFieldDetails> (
(GLib.HashFunc) PhoneFieldDetails.hash,
(GLib.EqualFunc) PhoneFieldDetails.equal);
var contact_info = this.contact.get_contact_info ();
foreach (var info in contact_info)
{
if (info.field_name != "tel")
continue;
foreach (var phone_num in info.field_value)
{
var parameters = this._afd_params_from_strv (info.parameters);
var phone_fd = new PhoneFieldDetails (phone_num, parameters);
new_phone_numbers.add (phone_fd);
}
}
if (!Folks.PersonaStore.equal_sets<PhoneFieldDetails> (new_phone_numbers,
this._phone_numbers))
{
this._phone_numbers = new_phone_numbers;
this._phone_numbers_ro = new_phone_numbers.read_only_view;
this.notify_property ("phone-numbers");
}
}
private MultiMap<string, string> _afd_params_from_strv (string[] parameters)
{
var retval = new HashMultiMap<string, string> ();
foreach (var entry in parameters)
{
var tokens = entry.split ("=", 2);
if (tokens.length == 2)
{
retval.set (tokens[0], tokens[1]);
}
else
{
warning ("Failed to parse vCard parameter from string '%s'",
entry);
}
}
return retval;
}
/**
* Create a new persona for the {@link PersonaStore} `store`, representing
* a cached contact for which we currently have no Telepathy contact.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment