diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-10-19 17:14:27 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-11-01 13:04:51 +0100 |
commit | c712fb46c5ed09a461a86d52a712a03d33beae2d (patch) | |
tree | 1bc55806133e22717a7805b6c3ea7fa8517ef6a7 /telepathy-glib/contact-operations.c | |
parent | 1b48e12c7ce5104d4266c6917f32add72aba427b (diff) | |
download | telepathy-glib-c712fb46c5ed09a461a86d52a712a03d33beae2d.tar.gz |
add contact operations for blocking API
https://bugs.freedesktop.org/show_bug.cgi?id=41801
Diffstat (limited to 'telepathy-glib/contact-operations.c')
-rw-r--r-- | telepathy-glib/contact-operations.c | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/telepathy-glib/contact-operations.c b/telepathy-glib/contact-operations.c index 1852f3343..fcc10ce6d 100644 --- a/telepathy-glib/contact-operations.c +++ b/telepathy-glib/contact-operations.c @@ -371,3 +371,122 @@ tp_contact_remove_from_group_finish (TpContact *self, { generic_finish (remove_from_group); } + +/* ContactBlocking */ + +/** + * tp_contact_block_async: + * @self: a #TpContact + * @report_abusive: if %TRUE, in addition to blocking, report these contacts as + * abusive to the server administrators, if supported, see + * #TpConnection:can-report-abusive + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Block communications with a contact, optionally reporting the contact as + * abusive to the server administrators. To block more than one contact at once, + * see tp_connection_block_contacts_async(). + * + * Since: 0.UNRELEASED + */ +void +tp_contact_block_async (TpContact *self, + gboolean report_abusive, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + TpHandle handle; + GArray *handles; + + g_return_if_fail (TP_IS_CONTACT (self)); + + handle = tp_contact_get_handle (self); + handles = g_array_new (FALSE, FALSE, sizeof (TpHandle)); + g_array_append_val (handles, handle); + + result = g_simple_async_result_new ((GObject *) self, callback, user_data, + tp_contact_block_async); + + tp_cli_connection_interface_contact_blocking_call_block_contacts ( + tp_contact_get_connection (self), -1, + handles, report_abusive, generic_callback, result, g_object_unref, NULL); + + g_array_unref (handles); +} + +/** + * tp_contact_block_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_block_async() + * + * Returns: %TRUE if the operation was successful, otherwise %FALSE. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_block_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + generic_finish (block); +} + +/** + * tp_contact_unblock_async: + * @self: a #TpContact + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Unblock communications with a contact. To unblock more than one contact + * at once, see tp_connection_unblock_contacts_async(). + * + * Since: 0.UNRELEASED + */ +void +tp_contact_unblock_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + TpHandle handle; + GArray *handles; + + g_return_if_fail (TP_IS_CONTACT (self)); + + handle = tp_contact_get_handle (self); + handles = g_array_new (FALSE, FALSE, sizeof (TpHandle)); + g_array_append_val (handles, handle); + + result = g_simple_async_result_new ((GObject *) self, callback, user_data, + tp_contact_unblock_async); + + tp_cli_connection_interface_contact_blocking_call_unblock_contacts ( + tp_contact_get_connection (self), -1, + handles, generic_callback, result, g_object_unref, NULL); + + g_array_unref (handles); +} + +/** + * tp_contact_unblock_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_unblock_async() + * + * Returns: %TRUE if the operation was successful, otherwise %FALSE. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_unblock_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + generic_finish (unblock); +} |