From b018a119c5a7f43eb5a407ed34d90681673c3f78 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 3 Nov 2011 14:08:01 +0100 Subject: 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(+) (limited to 'libempathy') diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 935afb556..cf46069b7 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 cb8f5a660..f15c8ad5d 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__ */ -- cgit v1.2.3