From 3f172c2a512373ab479602a833400778ade8d4d7 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 11 May 2012 09:57:36 +0200 Subject: contact: use tp_connection_dup_contact_by_id_async() https://bugzilla.gnome.org/show_bug.cgi?id=675808 --- libempathy/empathy-contact.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 97a49d1e7..6b1a7157b 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -690,31 +690,36 @@ contact_is_tpl_entity (gpointer key, } 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; +get_contacts_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + TpWeakRef *wr = user_data; + EmpathyContactPriv *priv; + EmpathyContact *self; - if (n_contacts != 1) - return; + self = tp_weak_ref_dup_object (wr); + if (self == NULL) + goto out; - tp_contact = contacts[0]; + priv = GET_PRIV (self); g_return_if_fail (priv->tp_contact == NULL); - priv->tp_contact = g_object_ref (tp_contact); + + priv->tp_contact = tp_connection_dup_contact_by_id_finish ( + TP_CONNECTION (source), result, NULL); + if (priv->tp_contact == NULL) + goto out; + 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)); + tp_contact_get_capabilities (priv->tp_contact)); + +out: + g_clear_object (&self); + tp_weak_ref_destroy (wr); } EmpathyContact * @@ -770,9 +775,9 @@ empathy_contact_from_tpl_contact (TpAccount *account, TpContactFeature features[] = { TP_CONTACT_FEATURE_CAPABILITIES }; conn = tp_account_get_connection (account); - tp_connection_get_contacts_by_id (conn, 1, &id, + tp_connection_dup_contact_by_id_async (conn, id, G_N_ELEMENTS (features), features, get_contacts_cb, - NULL, NULL, G_OBJECT (retval)); + tp_weak_ref_new (retval, NULL, NULL)); } } -- cgit v1.2.3