[empathy] add empathy_contact_add_to_contact_list()
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] add empathy_contact_add_to_contact_list()
- Date: Tue, 8 Nov 2011 12:39:41 +0000 (UTC)
commit b018a119c5a7f43eb5a407ed34d90681673c3f78
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Thu Nov 3 14:08:01 2011 +0100
add empathy_contact_add_to_contact_list()
https://bugzilla.gnome.org/show_bug.cgi?id=663327
libempathy/empathy-contact.c | 38 ++++++++++++++++++++++++++++++++++++++
libempathy/empathy-contact.h | 3 +++
2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 935afb5..cf46069 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -2071,3 +2071,41 @@ while_finish:
return best_contact;
}
+
+#define declare_contact_cb(name) \
+static void \
+contact_##name##_cb (GObject *source, \
+ GAsyncResult *result, \
+ gpointer user_data) \
+{ \
+ TpContact *contact = (TpContact *) source; \
+ GError *error = NULL; \
+ \
+ if (!tp_contact_##name##_finish (contact, result, &error)) \
+ { \
+ DEBUG ("Failed to ##name## on %s\n", \
+ tp_contact_get_identifier (contact)); \
+ g_error_free (error); \
+ } \
+}
+
+declare_contact_cb(request_subscription)
+declare_contact_cb(authorize_publication)
+declare_contact_cb(unblock)
+
+void
+empathy_contact_add_to_contact_list (EmpathyContact *self,
+ const gchar *message)
+{
+ EmpathyContactPriv *priv = GET_PRIV (self);
+
+ g_return_if_fail (priv->tp_contact != NULL);
+
+ tp_contact_request_subscription_async (priv->tp_contact, message,
+ contact_request_subscription_cb, NULL);
+
+ tp_contact_authorize_publication_async (priv->tp_contact,
+ contact_authorize_publication_cb, NULL);
+
+ tp_contact_unblock_async (priv->tp_contact, contact_unblock_cb, NULL);
+}
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index cb8f5a6..f15c8ad 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -138,6 +138,9 @@ EmpathyContact * empathy_contact_dup_best_for_action (
FolksIndividual *individual,
EmpathyActionType action_type);
+void empathy_contact_add_to_contact_list (EmpathyContact *self,
+ const gchar *message);
+
G_END_DECLS
#endif /* __EMPATHY_CONTACT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]