[empathy] add empathy_client_factory_dup_contact_by_id_async()
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] add empathy_client_factory_dup_contact_by_id_async()
- Date: Thu, 10 May 2012 09:43:41 +0000 (UTC)
commit 1b678e4f3f233e852dded51c069e8859e16aa3d5
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu May 10 11:31:14 2012 +0200
add empathy_client_factory_dup_contact_by_id_async()
https://bugzilla.gnome.org/show_bug.cgi?id=675597
libempathy/empathy-client-factory.c | 64 +++++++++++++++++++++++++++++++++++
libempathy/empathy-client-factory.h | 15 ++++++++
2 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-client-factory.c b/libempathy/empathy-client-factory.c
index 9135562..d84d445 100644
--- a/libempathy/empathy-client-factory.c
+++ b/libempathy/empathy-client-factory.c
@@ -213,3 +213,67 @@ empathy_client_factory_dup (void)
return singleton;
}
+
+static void
+dup_contact_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *my_result = user_data;
+ GError *error = NULL;
+ TpContact *contact;
+
+ contact = tp_connection_dup_contact_by_id_finish (TP_CONNECTION (source),
+ 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,
+ empathy_contact_dup_from_tp_contact (contact), g_object_unref);
+
+ g_object_unref (contact);
+ }
+
+ g_simple_async_result_complete (my_result);
+ g_object_unref (my_result);
+}
+
+void
+empathy_client_factory_dup_contact_by_id_async (
+ EmpathyClientFactory *self,
+ TpConnection *connection,
+ const gchar *id,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+ GArray *features;
+
+ g_return_if_fail (EMPATHY_IS_CLIENT_FACTORY (self));
+ g_return_if_fail (id != NULL);
+
+ result = g_simple_async_result_new ((GObject *) self, callback, user_data,
+ empathy_client_factory_dup_contact_by_id_async);
+
+ features = empathy_client_factory_dup_contact_features (
+ TP_SIMPLE_CLIENT_FACTORY (self), connection);
+
+ tp_connection_dup_contact_by_id_async (connection, id, features->len,
+ (TpContactFeature * ) features->data, dup_contact_cb, result);
+
+ g_array_unref (features);
+}
+
+EmpathyContact *
+empathy_client_factory_dup_contact_by_id_finish (
+ EmpathyClientFactory *self,
+ GAsyncResult *result,
+ GError **error)
+{
+ empathy_implement_finish_return_copy_pointer (self,
+ empathy_client_factory_dup_contact_by_id_async, g_object_ref);
+}
diff --git a/libempathy/empathy-client-factory.h b/libempathy/empathy-client-factory.h
index c4d88e2..034f6e6 100644
--- a/libempathy/empathy-client-factory.h
+++ b/libempathy/empathy-client-factory.h
@@ -24,6 +24,9 @@
#include <telepathy-glib/telepathy-glib.h>
+
+#include "empathy-contact.h"
+
G_BEGIN_DECLS
#define EMPATHY_TYPE_CLIENT_FACTORY (empathy_client_factory_get_type ())
@@ -52,5 +55,17 @@ GType empathy_client_factory_get_type (void) G_GNUC_CONST;
EmpathyClientFactory * empathy_client_factory_dup (void);
+void empathy_client_factory_dup_contact_by_id_async (
+ EmpathyClientFactory *self,
+ TpConnection *connection,
+ const gchar *id,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+EmpathyContact * empathy_client_factory_dup_contact_by_id_finish (
+ EmpathyClientFactory *self,
+ GAsyncResult *result,
+ GError **error) G_GNUC_WARN_UNUSED_RESULT;
+
G_END_DECLS
#endif /* __EMPATHY_CLIENT_FACTORY_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]