[next] telepathy-glib: TpConnection: use tp_connection_upgrade_contacts_async()

Xavier Claessens xclaesse at kemper.freedesktop.org
Wed May 9 13:10:52 PDT 2012


Module: telepathy-glib
Branch: next
Commit: e60b0466429cb381d0cd3e52921c4d0956d36a97
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=e60b0466429cb381d0cd3e52921c4d0956d36a97

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Tue May  8 18:04:04 2012 +0200

TpConnection: use tp_connection_upgrade_contacts_async()

ContactList API was already depending on newer spec, so it's fine.

---

 telepathy-glib/connection-contact-list.c |   43 ++++++++++++++++--------------
 1 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/telepathy-glib/connection-contact-list.c b/telepathy-glib/connection-contact-list.c
index 2848607..9b06784 100644
--- a/telepathy-glib/connection-contact-list.c
+++ b/telepathy-glib/connection-contact-list.c
@@ -134,16 +134,17 @@ contacts_changed_head_ready (TpConnection *self)
 }
 
 static void
-new_contacts_upgraded_cb (TpConnection *self,
-    guint n_contacts,
-    TpContact * const *contacts,
-    const GError *error,
-    gpointer user_data,
-    GObject *weak_object)
+new_contacts_upgraded_cb (GObject *object,
+    GAsyncResult *result,
+    gpointer user_data)
 {
-  if (error != NULL)
+  TpConnection *self = (TpConnection *) object;
+  GError *error = NULL;
+
+  if (!tp_connection_upgrade_contacts_finish (self, result, NULL, &error))
     {
       DEBUG ("Error upgrading new roster contacts: %s", error->message);
+      g_clear_error (&error);
     }
 
   contacts_changed_head_ready (self);
@@ -189,10 +190,10 @@ process_queued_contacts_changed (TpConnection *self)
   features = tp_simple_client_factory_dup_contact_features (
       tp_proxy_get_factory (self), self);
 
-  tp_connection_upgrade_contacts (self,
+  tp_connection_upgrade_contacts_async (self,
       item->new_contacts->len, (TpContact **) item->new_contacts->pdata,
       features->len, (TpContactFeature *) features->data,
-      new_contacts_upgraded_cb, NULL, NULL, NULL);
+      new_contacts_upgraded_cb, NULL);
 
   g_array_unref (features);
 }
@@ -1655,31 +1656,32 @@ blocked_changed_head_ready (TpConnection *self)
 }
 
 static void
-blocked_contacts_upgraded_cb (TpConnection *self,
-    guint n_contacts,
-    TpContact * const *contacts,
-    const GError *error,
-    gpointer user_data,
-    GObject *weak_object)
+blocked_contacts_upgraded_cb (GObject *object,
+    GAsyncResult *result,
+    gpointer user_data)
 {
+  TpConnection *self = (TpConnection *) object;
   BlockedChangedItem *item;
   guint i;
   GPtrArray *added, *removed;
+  GPtrArray *contacts;
+  GError *error = NULL;
 
   item = g_queue_peek_head (self->priv->blocked_changed_queue);
 
-  if (error != NULL)
+  if (!tp_connection_upgrade_contacts_finish (self, result, &contacts, &error))
     {
       DEBUG ("Error upgrading blocked contacts: %s", error->message);
+      g_clear_error (&error);
       goto out;
     }
 
   added = g_ptr_array_new ();
   removed = g_ptr_array_new_with_free_func (g_object_unref);
 
-  for (i = 0; i < n_contacts; i++)
+  for (i = 0; i < contacts->len; i++)
     {
-      TpContact *contact = contacts[i];
+      TpContact *contact = g_ptr_array_index (contacts, i);
       TpHandle handle;
 
       handle = tp_contact_get_handle (contact);
@@ -1718,6 +1720,7 @@ blocked_contacts_upgraded_cb (TpConnection *self,
 
   g_ptr_array_unref (added);
   g_ptr_array_unref (removed);
+  g_ptr_array_unref (contacts);
 
 out:
   blocked_changed_head_ready (self);
@@ -1782,10 +1785,10 @@ process_queued_blocked_changed (TpConnection *self)
   features = tp_simple_client_factory_dup_contact_features (
       tp_proxy_get_factory (self), self);
 
-  tp_connection_upgrade_contacts (self,
+  tp_connection_upgrade_contacts_async (self,
       contacts->len, (TpContact **) contacts->pdata,
       features->len, (TpContactFeature *) features->data,
-      blocked_contacts_upgraded_cb, NULL, NULL, NULL);
+      blocked_contacts_upgraded_cb, NULL);
 
   g_array_unref (features);
   g_ptr_array_unref (contacts);



More information about the telepathy-commits mailing list