From f79c1930c1f75025ddca3cef997a7d0e81a9bf00 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 30 Jun 2011 13:24:36 +0200 Subject: [PATCH] add convenient wrappers for single-contact operations --- docs/reference/telepathy-glib-sections.txt | 15 ++ telepathy-glib/Makefile.am | 2 + telepathy-glib/contact-operations.c | 318 ++++++++++++++++++++++++++++ telepathy-glib/contact-operations.h | 81 +++++++ telepathy-glib/introspection.am | 1 + telepathy-glib/telepathy-glib.h | 1 + 6 files changed, 418 insertions(+), 0 deletions(-) create mode 100644 telepathy-glib/contact-operations.c create mode 100644 telepathy-glib/contact-operations.h diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index 62fe619..bc9fb79 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -4209,6 +4209,21 @@ tp_contact_get_contact_groups tp_contact_set_contact_groups_async tp_contact_set_contact_groups_finish tp_contact_has_feature + +tp_contact_request_subscription_async +tp_contact_request_subscription_finish +tp_contact_authorize_publication_async +tp_contact_authorize_publication_finish +tp_contact_remove_async +tp_contact_remove_finish +tp_contact_unsubscribe_async +tp_contact_unsubscribe_finish +tp_contact_unpublish_async +tp_contact_unpublish_finish +tp_contact_add_to_group_async +tp_contact_add_to_group_finish +tp_contact_remove_from_group_async +tp_contact_remove_from_group_finish tp_contact_feature_get_type tp_contact_get_type diff --git a/telepathy-glib/Makefile.am b/telepathy-glib/Makefile.am index 6034646..38a9387 100644 --- a/telepathy-glib/Makefile.am +++ b/telepathy-glib/Makefile.am @@ -53,6 +53,7 @@ our_headers = \ contact-search-result.h \ capabilities.h \ contact.h \ + contact-operations.h \ base-contact-list.h \ contacts-mixin.h \ dbus.h \ @@ -182,6 +183,7 @@ libtelepathy_glib_internal_la_SOURCES = \ contact.c \ contact-list-channel-internal.h \ contact-list-channel.c \ + contact-operations.c \ contact-search.c \ contact-search-internal.h \ contact-search-result.c \ diff --git a/telepathy-glib/contact-operations.c b/telepathy-glib/contact-operations.c new file mode 100644 index 0000000..8b85f69 --- /dev/null +++ b/telepathy-glib/contact-operations.c @@ -0,0 +1,318 @@ +/* Async operations for TpContact + * + * Copyright (C) 2011 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include + +#define DEBUG_FLAG TP_DEBUG_CONTACTS +#include "telepathy-glib/debug-internal.h" + +/** + * tp_contact_request_subscription_async: + * @self: a #TpContact + * @message: an optional message + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Convenient wrapper for tp_connection_request_subscription_async() on single + * contact. + * + * Since: 0.UNRELEASED + */ +void +tp_contact_request_subscription_async (TpContact *self, + const gchar *message, + GAsyncReadyCallback callback, + gpointer user_data) +{ + tp_connection_request_subscription_async (tp_contact_get_connection (self), + 1, &self, message, callback, user_data); +} + +/** + * tp_contact_request_subscription_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_request_subscription_async() + * + * Returns: %FALSE if the operation failed, %TRUE otherwise. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_request_subscription_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + return tp_connection_request_subscription_finish ( + tp_contact_get_connection (self), result, error); +} + +/** + * tp_contact_authorize_publication_async: + * @self: a #TpContact + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Convenient wrapper for tp_connection_authorize_publication_async() on single + * contact. + * + * Since: 0.UNRELEASED + */ +void +tp_contact_authorize_publication_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + tp_connection_authorize_publication_async (tp_contact_get_connection (self), + 1, &self, callback, user_data); +} + +/** + * tp_contact_authorize_publication_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_authorize_publication_async() + * + * Returns: %FALSE if the operation failed, %TRUE otherwise. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_authorize_publication_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + return tp_connection_authorize_publication_finish ( + tp_contact_get_connection (self), result, error); +} + +/** + * tp_contact_remove_async: + * @self: a #TpContact + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Convenient wrapper for tp_connection_remove_contacts_async() on single + * contact. + * + * Since: 0.UNRELEASED + */ +void +tp_contact_remove_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + tp_connection_remove_contacts_async (tp_contact_get_connection (self), + 1, &self, callback, user_data); +} + +/** + * tp_contact_remove_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_remove_async() + * + * Returns: %FALSE if the operation failed, %TRUE otherwise. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_remove_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + return tp_connection_remove_contacts_finish ( + tp_contact_get_connection (self), result, error); +} + +/** + * tp_contact_unsubscribe_async: + * @self: a #TpContact + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Convenient wrapper for tp_connection_unsubscribe_async() on single + * contact. + * + * Since: 0.UNRELEASED + */ +void +tp_contact_unsubscribe_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + tp_connection_unsubscribe_async (tp_contact_get_connection (self), + 1, &self, callback, user_data); +} + +/** + * tp_contact_unsubscribe_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_unsubscribe_async() + * + * Returns: %FALSE if the operation failed, %TRUE otherwise. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_unsubscribe_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + return tp_connection_unsubscribe_finish ( + tp_contact_get_connection (self), result, error); +} + +/** + * tp_contact_unpublish_async: + * @self: a #TpContact + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Convenient wrapper for tp_connection_unpublish_async() on single + * contact. + * + * Since: 0.UNRELEASED + */ +void +tp_contact_unpublish_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + tp_connection_unpublish_async (tp_contact_get_connection (self), + 1, &self, callback, user_data); +} + +/** + * tp_contact_unpublish_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_unpublish_async() + * + * Returns: %FALSE if the operation failed, %TRUE otherwise. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_unpublish_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + return tp_connection_unpublish_finish ( + tp_contact_get_connection (self), result, error); +} + +/** + * tp_contact_add_to_group_async: + * @self: a #TpContact + * @group: the group to alter. + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Convenient wrapper for tp_connection_add_to_group_async() on single + * contact. + * + * Since: 0.UNRELEASED + */ +void +tp_contact_add_to_group_async (TpContact *self, + const gchar *group, + GAsyncReadyCallback callback, + gpointer user_data) +{ + tp_connection_add_to_group_async (tp_contact_get_connection (self), + group, 1, &self, callback, user_data); +} + +/** + * tp_contact_add_to_group_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_add_to_group_async() + * + * Returns: %FALSE if the operation failed, %TRUE otherwise. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_add_to_group_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + return tp_connection_add_to_group_finish ( + tp_contact_get_connection (self), result, error); +} + +/** + * tp_contact_remove_from_group_async: + * @self: a #TpContact + * @group: the group to alter. + * @callback: a callback to call when the operation finishes + * @user_data: data to pass to @callback + * + * Convenient wrapper for tp_connection_remove_from_group_async() on single + * contact. + * + * Since: 0.UNRELEASED + */ +void +tp_contact_remove_from_group_async (TpContact *self, + const gchar *group, + GAsyncReadyCallback callback, + gpointer user_data) +{ + tp_connection_remove_from_group_async (tp_contact_get_connection (self), + group, 1, &self, callback, user_data); +} + +/** + * tp_contact_remove_from_group_finish: + * @self: a #TpContact + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Finishes tp_contact_remove_from_group_async() + * + * Returns: %FALSE if the operation failed, %TRUE otherwise. + * + * Since: 0.UNRELEASED + */ +gboolean +tp_contact_remove_from_group_finish (TpContact *self, + GAsyncResult *result, + GError **error) +{ + return tp_connection_remove_from_group_finish ( + tp_contact_get_connection (self), result, error); +} diff --git a/telepathy-glib/contact-operations.h b/telepathy-glib/contact-operations.h new file mode 100644 index 0000000..c9fe0e0 --- /dev/null +++ b/telepathy-glib/contact-operations.h @@ -0,0 +1,81 @@ +/* Async operations for TpContact + * + * Copyright (C) 2011 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __TP_CONTACT_OPERATIONS_H__ +#define __TP_CONTACT_OPERATIONS_H__ + +#include + +G_BEGIN_DECLS + +void tp_contact_request_subscription_async (TpContact *self, + const gchar *message, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tp_contact_request_subscription_finish (TpContact *self, + GAsyncResult *result, + GError **error); + +void tp_contact_authorize_publication_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tp_contact_authorize_publication_finish (TpContact *self, + GAsyncResult *result, + GError **error); + +void tp_contact_remove_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tp_contact_remove_finish (TpContact *self, + GAsyncResult *result, + GError **error); + +void tp_contact_unsubscribe_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tp_contact_unsubscribe_finish (TpContact *self, + GAsyncResult *result, + GError **error); + +void tp_contact_unpublish_async (TpContact *self, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tp_contact_unpublish_finish (TpContact *self, + GAsyncResult *result, + GError **error); + +void tp_contact_add_to_group_async (TpContact *self, + const gchar *group, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tp_contact_add_to_group_finish (TpContact *self, + GAsyncResult *result, + GError **error); + +void tp_contact_remove_from_group_async (TpContact *self, + const gchar *group, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean tp_contact_remove_from_group_finish (TpContact *self, + GAsyncResult *result, + GError **error); + +G_END_DECLS + +#endif diff --git a/telepathy-glib/introspection.am b/telepathy-glib/introspection.am index c574481..4dc6d9e 100644 --- a/telepathy-glib/introspection.am +++ b/telepathy-glib/introspection.am @@ -31,6 +31,7 @@ INTROSPECTION_FILES = \ $(srcdir)/dbus.c $(srcdir)/dbus.h \ $(srcdir)/capabilities.c $(srcdir)/capabilities.h \ $(srcdir)/contact.c $(srcdir)/contact.h \ + $(srcdir)/contact-operations.c $(srcdir)/contact-operations.h \ $(srcdir)/contact-search.c $(srcdir)/contact-search.h \ $(srcdir)/contact-search-result.c $(srcdir)/contact-search-result.h \ $(srcdir)/defs.h \ diff --git a/telepathy-glib/telepathy-glib.h b/telepathy-glib/telepathy-glib.h index 46518f5..e93c370 100644 --- a/telepathy-glib/telepathy-glib.h +++ b/telepathy-glib/telepathy-glib.h @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include -- 1.7.4.1