From 80da6b4bcff9068bed0aa7da2c3eb9cd54b31ba1 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 10 May 2012 13:22:53 +0200 Subject: Deprecate tp_connection_request_handles() Everywhere we need an handle, we can give an ID nowadays. --- telepathy-glib/connection-handles.c | 6 +++++ telepathy-glib/connection.h | 3 ++- telepathy-glib/contact.c | 4 ++++ tests/dbus/message-mixin.c | 13 +++++------ tests/lib/util.c | 44 ------------------------------------- tests/lib/util.h | 4 ---- 6 files changed, 18 insertions(+), 56 deletions(-) diff --git a/telepathy-glib/connection-handles.c b/telepathy-glib/connection-handles.c index d33701a21..f264ef069 100644 --- a/telepathy-glib/connection-handles.c +++ b/telepathy-glib/connection-handles.c @@ -251,6 +251,8 @@ request_handles_context_free (gpointer p) * For convenience, the handle type and IDs requested by the caller are * passed through to this callback, so the caller does not have to include * them in @user_data. + * + * Deprecated: See tp_connection_request_handles(). */ @@ -329,6 +331,10 @@ connection_requested_handles (TpConnection *self, * If they are valid, the callback will later be called with the given * handles; if not all of them are valid, the callback will be called with * an error. + * + * Deprecated: If @handle_type is TP_HANDLE_TYPE_CONTACT, use + * tp_connection_dup_contact_by_id_async() instead. For channel requests, + * use tp_account_channel_request_set_target_id() instead. */ void tp_connection_request_handles (TpConnection *self, diff --git a/telepathy-glib/connection.h b/telepathy-glib/connection.h index c6bc5a646..4f7cea3f3 100644 --- a/telepathy-glib/connection.h +++ b/telepathy-glib/connection.h @@ -240,17 +240,18 @@ void tp_connection_hold_handles (TpConnection *self, gint timeout_ms, TpConnectionHoldHandlesCb callback, gpointer user_data, GDestroyNotify destroy, GObject *weak_object); +#ifndef TP_DISABLE_DEPRECATED typedef void (*TpConnectionRequestHandlesCb) (TpConnection *connection, TpHandleType handle_type, guint n_handles, const TpHandle *handles, const gchar * const *ids, const GError *error, gpointer user_data, GObject *weak_object); +_TP_DEPRECATED_IN_UNRELEASED void tp_connection_request_handles (TpConnection *self, gint timeout_ms, TpHandleType handle_type, const gchar * const *ids, TpConnectionRequestHandlesCb callback, gpointer user_data, GDestroyNotify destroy, GObject *weak_object); -#ifndef TP_DISABLE_DEPRECATED _TP_DEPRECATED_IN_UNRELEASED void tp_connection_unref_handles (TpConnection *self, TpHandleType handle_type, guint n_handles, const TpHandle *handles); diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c index 756c39a33..469543bc4 100644 --- a/telepathy-glib/contact.c +++ b/telepathy-glib/contact.c @@ -4400,11 +4400,13 @@ contacts_request_one_handle (ContactsContext *c) ids[0] = g_ptr_array_index (c->request_ids, c->next_index); g_assert (ids[0] != NULL); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS c->refcount++; tp_connection_request_handles (c->connection, -1, TP_HANDLE_TYPE_CONTACT, ids, contacts_requested_one_handle, c, contacts_context_unref, c->weak_object); + G_GNUC_END_IGNORE_DEPRECATIONS } @@ -4555,12 +4557,14 @@ tp_connection_get_contacts_by_id (TpConnection *self, contacts_context_queue_features (context); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS /* but first, we need to get the handles in the first place */ tp_connection_request_handles (self, -1, TP_HANDLE_TYPE_CONTACT, (const gchar * const *) context->request_ids->pdata, contacts_requested_handles, context, contacts_context_unref, weak_object); + G_GNUC_END_IGNORE_DEPRECATIONS } typedef struct diff --git a/tests/dbus/message-mixin.c b/tests/dbus/message-mixin.c index 22bc33d40..7f526ec19 100644 --- a/tests/dbus/message-mixin.c +++ b/tests/dbus/message-mixin.c @@ -272,32 +272,31 @@ main (int argc, g_hash_table_unref (properties); } - handle = tp_tests_connection_run_request_contact_handle (conn, - "them@example.com"); - { GHashTable *request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_HANDLE, G_TYPE_UINT, handle, + TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, "them@example.com", NULL); tp_cli_connection_interface_requests_run_create_channel (conn, -1, - request, &chan_path, NULL, &error, NULL); + request, &chan_path, ¶meters, &error, NULL); g_assert_no_error (error); g_hash_table_unref (request); } - chan = tp_channel_new (conn, chan_path, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_HANDLE_TYPE_CONTACT, handle, &error); + chan = tp_channel_new_from_properties (conn, chan_path, parameters, &error); g_assert_no_error (error); + g_hash_table_unref (parameters); tp_channel_run_until_ready (chan, &error, NULL); g_assert_no_error (error); + handle = tp_channel_get_handle (chan, NULL); + MYASSERT (tp_cli_channel_type_text_connect_to_received (chan, on_received, NULL, NULL, NULL, NULL) != NULL, ""); MYASSERT (tp_cli_channel_type_text_connect_to_sent (chan, on_sent, diff --git a/tests/lib/util.c b/tests/lib/util.c index 16ece06ef..fea462f0b 100644 --- a/tests/lib/util.c +++ b/tests/lib/util.c @@ -114,50 +114,6 @@ tp_tests_proxy_run_until_dbus_queue_processed (gpointer proxy) g_main_loop_unref (loop); } -typedef struct { - GMainLoop *loop; - TpHandle handle; -} HandleRequestResult; - -static void -handles_requested_cb (TpConnection *connection G_GNUC_UNUSED, - TpHandleType handle_type G_GNUC_UNUSED, - guint n_handles, - const TpHandle *handles, - const gchar * const *ids G_GNUC_UNUSED, - const GError *error, - gpointer user_data, - GObject *weak_object G_GNUC_UNUSED) -{ - HandleRequestResult *result = user_data; - - g_assert_no_error ((GError *) error); - g_assert_cmpuint (n_handles, ==, 1); - result->handle = handles[0]; -} - -static void -handle_request_result_finish (gpointer r) -{ - HandleRequestResult *result = r; - - g_main_loop_quit (result->loop); -} - -TpHandle -tp_tests_connection_run_request_contact_handle (TpConnection *connection, - const gchar *id) -{ - HandleRequestResult result = { g_main_loop_new (NULL, FALSE), 0 }; - const gchar * const ids[] = { id, NULL }; - - tp_connection_request_handles (connection, -1, TP_HANDLE_TYPE_CONTACT, ids, - handles_requested_cb, &result, handle_request_result_finish, NULL); - g_main_loop_run (result.loop); - g_main_loop_unref (result.loop); - return result.handle; -} - void _test_assert_empty_strv (const char *file, int line, diff --git a/tests/lib/util.h b/tests/lib/util.h index 3fccc4c5b..d58138ea9 100644 --- a/tests/lib/util.h +++ b/tests/lib/util.h @@ -18,10 +18,6 @@ TpDBusDaemon *tp_tests_dbus_daemon_dup_or_die (void); void tp_tests_proxy_run_until_dbus_queue_processed (gpointer proxy); -TpHandle tp_tests_connection_run_request_contact_handle ( - TpConnection *connection, - const gchar *id); - void tp_tests_proxy_run_until_prepared (gpointer proxy, const GQuark *features); gboolean tp_tests_proxy_run_until_prepared_or_failed (gpointer proxy, -- cgit v1.2.3