[folks] libsocialweb: factor build_facebook_jid and build_iid
- From: Alban Crequy <albanc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] libsocialweb: factor build_facebook_jid and build_iid
- Date: Tue, 5 Apr 2011 13:29:52 +0000 (UTC)
commit 30b64d46df840e23e9ecf1b486d64104577d7a66
Author: Alban Crequy <alban crequy collabora co uk>
Date: Mon Mar 28 12:00:24 2011 +0100
libsocialweb: factor build_facebook_jid and build_iid
backends/libsocialweb/lib/swf-persona.vala | 56 ++++++++++++++++++++++-----
1 files changed, 45 insertions(+), 11 deletions(-)
---
diff --git a/backends/libsocialweb/lib/swf-persona.vala b/backends/libsocialweb/lib/swf-persona.vala
index 410aa90..0244e46 100644
--- a/backends/libsocialweb/lib/swf-persona.vala
+++ b/backends/libsocialweb/lib/swf-persona.vala
@@ -101,32 +101,65 @@ public class Swf.Persona : Folks.Persona,
}
/**
- * Create a new persona.
+ * Build the Facebook JID.
*
- * Create a new persona for the { link PersonaStore} `store`, representing
- * the libsocialweb contact given by `contact`.
+ * @param store_id the { link PersonaStore.id}
+ * @param lsw_id the lsw id
+ * @return the Facebook JID or null if it is not a Facebook contact
+ *
+ * @since UNRELEASED
*/
- public Persona (PersonaStore store, Contact contact)
+ internal static string? _build_facebook_jid (string store_id, string lsw_id)
{
- var id = get_contact_id (contact);
- var uid = this.build_uid (BACKEND_NAME, store.id, id);
+ string facebook_jid = null;
+ if (store_id == "facebook" && "facebook-" in lsw_id)
+ {
+ /* The lsw_id is in the form "facebook-XXXX", while the JID is
+ * "-XXXX chat facebook com". */
+ facebook_jid = lsw_id.replace("facebook", "") + "@chat.facebook.com";
+ }
+ return facebook_jid;
+ }
+ /**
+ * Build a IID.
+ *
+ * @param store_id the { link PersonaStore.id}
+ * @param lsw_id the lsw id
+ * @return a valid IID
+ *
+ * @since UNRELEASED
+ */
+ internal static string _build_iid (string store_id, string lsw_id)
+ {
/* This is a hack so that Facebook contacts from libsocialweb are
* automatically merged with Facebook contacts from Telepathy
* because they have the same iid. */
string facebook_jid = null;
string iid;
- if (store.id == "facebook" && "facebook-" in id)
+ facebook_jid = _build_facebook_jid (store_id, lsw_id);
+ if (facebook_jid != null)
{
- /* The id is in the form "facebook-XXXX", while the JID is
- * "-XXXX chat facebook com". */
- facebook_jid = id.replace("facebook", "") + "@chat.facebook.com";
iid = "jabber:" + facebook_jid;
}
else
{
- iid = store.id + ":" + id;
+ iid = store_id + ":" + lsw_id;
}
+ return iid;
+ }
+
+ /**
+ * Create a new persona.
+ *
+ * Create a new persona for the { link PersonaStore} `store`, representing
+ * the libsocialweb contact given by `contact`.
+ */
+ public Persona (PersonaStore store, Contact contact)
+ {
+ var id = get_contact_id (contact);
+ var uid = this.build_uid (BACKEND_NAME, store.id, id);
+ var iid = this._build_iid (store.id, id);
Object (display_id: id,
uid: uid,
@@ -137,6 +170,7 @@ public class Swf.Persona : Folks.Persona,
debug ("Creating new Sw.Persona '%s' for %s UID '%s': %p",
uid, store.display_name, id, this);
+ var facebook_jid = this._build_facebook_jid (store.id, id);
if (facebook_jid != null)
{
var im_address_array = new LinkedHashSet<string> ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]