aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-12-05 22:15:54 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-12-06 16:30:33 +0800
commitae0db917820904a353850d532eb3b638f36cb8c6 (patch)
treecf3bf408db648936703d6d2c91c1c2e7ebc37556
parent84fe2ef8b8e152d6a47f42fdd818e84a6e0d48b0 (diff)
downloadgsoc2013-empathy-ae0db917820904a353850d532eb3b638f36cb8c6.tar
gsoc2013-empathy-ae0db917820904a353850d532eb3b638f36cb8c6.tar.gz
gsoc2013-empathy-ae0db917820904a353850d532eb3b638f36cb8c6.tar.bz2
gsoc2013-empathy-ae0db917820904a353850d532eb3b638f36cb8c6.tar.lz
gsoc2013-empathy-ae0db917820904a353850d532eb3b638f36cb8c6.tar.xz
gsoc2013-empathy-ae0db917820904a353850d532eb3b638f36cb8c6.tar.zst
gsoc2013-empathy-ae0db917820904a353850d532eb3b638f36cb8c6.zip
try requesting a TpContact when creating a contact from the logger
This is useful when displaying a contact which is not in our roster in the logger (typically a PSTN number). Having a TpContact allow us to call him if that's supported by the CM. https://bugzilla.gnome.org/show_bug.cgi?id=665592
-rw-r--r--libempathy/empathy-contact.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 15946a16a..216ef6d73 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -694,6 +694,34 @@ contact_is_tpl_entity (gpointer key,
!tp_strdiff (tp_proxy_get_object_path (data->account), path);
}
+static void
+get_contacts_cb (TpConnection *connection,
+ guint n_contacts,
+ TpContact * const *contacts,
+ const gchar * const *requested_ids,
+ GHashTable *failed_id_errors,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ EmpathyContact *self = (EmpathyContact *) weak_object;
+ EmpathyContactPriv *priv = GET_PRIV (self);
+ TpContact *tp_contact;
+
+ if (n_contacts != 1)
+ return;
+
+ tp_contact = contacts[0];
+
+ g_return_if_fail (priv->tp_contact == NULL);
+ priv->tp_contact = g_object_ref (tp_contact);
+ g_object_notify (G_OBJECT (self), "tp-contact");
+
+ /* Update capabilities now that we have a TpContact */
+ set_capabilities_from_tp_caps (self,
+ tp_contact_get_capabilities (tp_contact));
+}
+
EmpathyContact *
empathy_contact_from_tpl_contact (TpAccount *account,
TplEntity *tpl_entity)
@@ -724,14 +752,33 @@ empathy_contact_from_tpl_contact (TpAccount *account,
}
else
{
+ TpConnection *conn;
+ const gchar *id;
+
is_user = (TPL_ENTITY_SELF == tpl_entity_get_entity_type (tpl_entity));
+ id = tpl_entity_get_identifier (tpl_entity);
+
retval = g_object_new (EMPATHY_TYPE_CONTACT,
- "id", tpl_entity_get_identifier (tpl_entity),
+ "id", id,
"alias", tpl_entity_get_alias (tpl_entity),
"account", account,
"is-user", is_user,
NULL);
+
+ /* Try to get a TpContact associated to have at least contact
+ * capabilities if possible. This is useful for CM supporting calling
+ * offline contacts for example. */
+ conn = tp_account_get_connection (account);
+ if (conn != NULL)
+ {
+ TpContactFeature features[] = { TP_CONTACT_FEATURE_CAPABILITIES };
+ conn = tp_account_get_connection (account);
+
+ tp_connection_get_contacts_by_id (conn, 1, &id,
+ G_N_ELEMENTS (features), features, get_contacts_cb,
+ NULL, NULL, G_OBJECT (retval));
+ }
}
if (!EMP_STR_EMPTY (tpl_entity_get_avatar_token (tpl_entity)))