[next] telepathy-glib: Add tp_simple_client_factory_ensure_contact_by_id_async/finish

Xavier Claessens xclaesse at kemper.freedesktop.org
Fri May 18 08:09:38 PDT 2012


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

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Tue May 15 15:48:13 2012 +0200

Add tp_simple_client_factory_ensure_contact_by_id_async/finish

---

 docs/reference/telepathy-glib-sections.txt |    2 +
 telepathy-glib/simple-client-factory.c     |   82 ++++++++++++++++++++++++++++
 telepathy-glib/simple-client-factory.h     |   12 ++++
 3 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 5edf14c..9c5ef18 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -6991,6 +6991,8 @@ tp_simple_client_factory_add_channel_features
 tp_simple_client_factory_add_channel_features_varargs
 <SUBSECTION>
 tp_simple_client_factory_ensure_contact
+tp_simple_client_factory_ensure_contact_by_id_async
+tp_simple_client_factory_ensure_contact_by_id_finish
 tp_simple_client_factory_dup_contact_features
 tp_simple_client_factory_add_contact_features
 tp_simple_client_factory_add_contact_features_varargs
diff --git a/telepathy-glib/simple-client-factory.c b/telepathy-glib/simple-client-factory.c
index fa8fd04..8865293 100644
--- a/telepathy-glib/simple-client-factory.c
+++ b/telepathy-glib/simple-client-factory.c
@@ -861,6 +861,88 @@ tp_simple_client_factory_ensure_contact (TpSimpleClientFactory *self,
   return contact;
 }
 
+static void
+dup_contact_by_id_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  TpConnection *connection = (TpConnection *) source;
+  GSimpleAsyncResult *my_result = user_data;
+  TpContact *contact;
+  GError *error = NULL;
+
+  contact = tp_connection_dup_contact_by_id_finish (connection, result, &error);
+  if (contact == NULL)
+    {
+      g_simple_async_result_take_error (my_result, error);
+    }
+  else
+    {
+      g_simple_async_result_set_op_res_gpointer (my_result, contact,
+          g_object_unref);
+    }
+
+  g_simple_async_result_complete (my_result);
+  g_object_unref (my_result);
+}
+
+
+/**
+ * tp_simple_client_factory_ensure_contact_by_id_async:
+ * @self: a #TpSimpleClientFactory object
+ * @connection: a #TpConnection
+ * @identifier: a string representing the contact's identifier
+ * @callback: a callback to call when the operation finishes
+ * @user_data: data to pass to @callback
+ *
+ * Same as tp_connection_dup_contact_by_id_async(), but prepare the
+ * contact with all features previously passed to
+ * tp_simple_client_factory_add_contact_features().
+ *
+ * Since: 0.UNRELEASED
+ */
+void
+tp_simple_client_factory_ensure_contact_by_id_async (
+    TpSimpleClientFactory *self,
+    TpConnection *connection,
+    const gchar *identifier,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  GSimpleAsyncResult *result;
+  GArray *features;
+
+  result = g_simple_async_result_new ((GObject *) self, callback, user_data,
+      tp_simple_client_factory_ensure_contact_by_id_async);
+
+  features = tp_simple_client_factory_dup_contact_features (self, connection);
+  tp_connection_dup_contact_by_id_async (connection, identifier,
+      features->len, (TpContactFeature *) features->data,
+      dup_contact_by_id_cb, result);
+  g_array_unref (features);
+}
+
+/**
+ * tp_simple_client_factory_ensure_contact_by_id_finish:
+ * @self: a #TpSimpleClientFactory
+ * @result: a #GAsyncResult
+ * @error: a #GError to fill
+ *
+ * Finishes tp_simple_client_factory_ensure_contact_by_id_async()
+ *
+ * Returns: (transfer full): a #TpContact or %NULL on error.
+ * Since: 0.UNRELEASED
+ */
+TpContact *
+tp_simple_client_factory_ensure_contact_by_id_finish (
+    TpSimpleClientFactory *self,
+    GAsyncResult *result,
+    GError **error)
+{
+  _tp_implement_finish_return_copy_pointer (self,
+      tp_simple_client_factory_ensure_contact_by_id_async, g_object_ref);
+}
+
 /**
  * tp_simple_client_factory_dup_contact_features:
  * @self: a #TpSimpleClientFactory object
diff --git a/telepathy-glib/simple-client-factory.h b/telepathy-glib/simple-client-factory.h
index 006daaa..fe5cfce 100644
--- a/telepathy-glib/simple-client-factory.h
+++ b/telepathy-glib/simple-client-factory.h
@@ -175,6 +175,18 @@ TpContact *tp_simple_client_factory_ensure_contact (TpSimpleClientFactory *self,
     TpConnection *connection,
     TpHandle handle,
     const gchar *identifier);
+_TP_AVAILABLE_IN_UNRELEASED
+void tp_simple_client_factory_ensure_contact_by_id_async (
+    TpSimpleClientFactory *self,
+    TpConnection *connection,
+    const gchar *identifier,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+_TP_AVAILABLE_IN_UNRELEASED
+TpContact *tp_simple_client_factory_ensure_contact_by_id_finish (
+    TpSimpleClientFactory *self,
+    GAsyncResult *result,
+    GError **error);
 _TP_AVAILABLE_IN_0_16
 GArray *tp_simple_client_factory_dup_contact_features (
     TpSimpleClientFactory *self,



More information about the telepathy-commits mailing list