From 5fb93c5290afbc3946308910eec826dc8b3f009c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 9 Aug 2010 12:44:03 +0100 Subject: [PATCH] Implement the IMable interface on TpfPersona Use it to expose the Persona's IM address. Do not allow setting the IM address. --- backends/telepathy/tpf-persona.vala | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/backends/telepathy/tpf-persona.vala b/backends/telepathy/tpf-persona.vala index 5acb443..f7f0c9d 100644 --- a/backends/telepathy/tpf-persona.vala +++ b/backends/telepathy/tpf-persona.vala @@ -37,11 +37,13 @@ public class Tpf.Persona : Folks.Persona, Avatar, Favourite, Groups, + IMable, Presence { private HashTable _groups; private bool _is_favourite; private string _alias; + private HashTable> _im_addresses; /* Whether we've finished being constructed; this is used to prevent * unnecessary trips to the Telepathy service to tell it about properties @@ -103,6 +105,15 @@ public class Tpf.Persona : Folks.Persona, /** * {@inheritDoc} */ + public HashTable> im_addresses + { + get { return this._im_addresses; } + private set {} + } + + /** + * {@inheritDoc} + */ public HashTable groups { get { return this._groups; } @@ -170,6 +181,8 @@ public class Tpf.Persona : Folks.Persona, */ public Persona (Contact contact, PersonaStore store) throws Tpf.PersonaError { + string[] linkable_properties = { "im-addresses" }; + /* FIXME: There is the possibility of a crash in the error condition below * due to bgo#604299, where the C self variable isn't initialised until we * chain up to the Object constructor, below. */ @@ -194,12 +207,22 @@ public class Tpf.Persona : Folks.Persona, * bgo#624842 being fixed. */ iid: account.get_protocol () + ":" + id, uid: uid, - store: store); + store: store, + linkable_properties: linkable_properties); debug ("Creating new Tpf.Persona '%s' for service-specific UID '%s': %p", uid, id, this); this.is_constructed = true; + /* Set our single IM address */ + GenericArray im_address_array = new GenericArray (); + im_address_array.add (id); + + this._im_addresses = + new HashTable> (str_hash, str_equal); + this._im_addresses.insert (account.get_protocol (), im_address_array); + + /* Groups */ this._groups = new HashTable (str_hash, str_equal); contact.notify["avatar-file"].connect ((s, p) => -- 2.7.4