diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-05-11 15:57:36 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-05-11 16:26:59 +0800 |
commit | 3f172c2a512373ab479602a833400778ade8d4d7 (patch) | |
tree | 65054fd75890a3c6bd4a5ff49f22d8d62478c25e /libempathy/empathy-contact.c | |
parent | 439ca2f1853454d22ac54eac4c56ac3ee1740f79 (diff) | |
download | gsoc2013-empathy-3f172c2a512373ab479602a833400778ade8d4d7.tar gsoc2013-empathy-3f172c2a512373ab479602a833400778ade8d4d7.tar.gz gsoc2013-empathy-3f172c2a512373ab479602a833400778ade8d4d7.tar.bz2 gsoc2013-empathy-3f172c2a512373ab479602a833400778ade8d4d7.tar.lz gsoc2013-empathy-3f172c2a512373ab479602a833400778ade8d4d7.tar.xz gsoc2013-empathy-3f172c2a512373ab479602a833400778ade8d4d7.tar.zst gsoc2013-empathy-3f172c2a512373ab479602a833400778ade8d4d7.zip |
contact: use tp_connection_dup_contact_by_id_async()
https://bugzilla.gnome.org/show_bug.cgi?id=675808
Diffstat (limited to 'libempathy/empathy-contact.c')
-rw-r--r-- | libempathy/empathy-contact.c | 43 |
1 files changed, 24 insertions, 19 deletions
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)); } } |