From 543fb71cf9a524793664a0081f4812635f4d311a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 6 Mar 2012 11:13:45 +0000 Subject: [PATCH] Remove tp_connection_manager_call_when_ready, is_ready Bug: https://bugs.freedesktop.org/show_bug.cgi?id=45842 Signed-off-by: Simon McVittie --- docs/reference/telepathy-glib-sections.txt | 3 - telepathy-glib/connection-manager.c | 157 ---------------------------- telepathy-glib/connection-manager.h | 13 --- tests/dbus/cm.c | 89 ++--------------- 4 files changed, 7 insertions(+), 255 deletions(-) diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index 98fc0df..89c5979 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -3610,9 +3610,6 @@ TpConnectionManagerClass tp_connection_manager_new tp_connection_manager_get_name TP_CONNECTION_MANAGER_FEATURE_CORE -TpConnectionManagerWhenReadyCb -tp_connection_manager_call_when_ready -tp_connection_manager_is_ready TpCMInfoSource TP_TYPE_CM_INFO_SOURCE tp_connection_manager_get_info_source diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c index 27c89bf..7ba46e3 100644 --- a/telepathy-glib/connection-manager.c +++ b/telepathy-glib/connection-manager.c @@ -91,9 +91,6 @@ * this connection manager has, and adds them to #TpProxy:interfaces (where * they can be queried with tp_proxy_has_interface()). * - * (These are the same guarantees offered by the older - * tp_connection_manager_call_when_ready() mechanism.) - * * One can ask for a feature to be prepared using the * tp_proxy_prepare_async() function, and waiting for it to callback. * @@ -444,38 +441,6 @@ tp_connection_manager_protocol_get_type (void) return type; } - -typedef struct { - TpConnectionManager *cm; - TpConnectionManagerWhenReadyCb callback; - gpointer user_data; - GDestroyNotify destroy; - TpWeakRef *weak_ref; -} WhenReadyContext; - -static void -when_ready_context_free (gpointer d) -{ - WhenReadyContext *c = d; - - if (c->weak_ref != NULL) - { - tp_weak_ref_destroy (c->weak_ref); - c->weak_ref = NULL; - } - - if (c->cm != NULL) - { - g_object_unref (c->cm); - c->cm = NULL; - } - - if (c->destroy != NULL) - c->destroy (c->user_data); - - g_slice_free (WhenReadyContext, c); -} - static void tp_connection_manager_ready_or_failed (TpConnectionManager *self, const GError *error) @@ -501,103 +466,6 @@ tp_connection_manager_ready_or_failed (TpConnectionManager *self, } } -static void -tp_connection_manager_ready_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - WhenReadyContext *c = user_data; - GError *error = NULL; - GObject *weak_object = NULL; - - g_return_if_fail (source_object == (GObject *) c->cm); - - if (c->weak_ref != NULL) - { - weak_object = tp_weak_ref_dup_object (c->weak_ref); - - if (weak_object == NULL) - goto finally; - } - - if (tp_proxy_prepare_finish (source_object, res, &error)) - { - c->callback (c->cm, NULL, c->user_data, weak_object); - } - else - { - g_assert (error != NULL); - c->callback (c->cm, error, c->user_data, weak_object); - g_error_free (error); - } - -finally: - if (weak_object != NULL) - g_object_unref (weak_object); - - when_ready_context_free (c); -} - -/** - * TpConnectionManagerWhenReadyCb: - * @cm: a connection manager - * @error: %NULL on success, or the reason why tp_connection_manager_is_ready() - * would return %FALSE - * @user_data: the @user_data passed to tp_connection_manager_call_when_ready() - * @weak_object: the @weak_object passed to - * tp_connection_manager_call_when_ready() - * - * Called as the result of tp_connection_manager_call_when_ready(). If the - * connection manager's protocol and parameter information could be retrieved, - * @error is %NULL and @cm is considered to be ready. Otherwise, @error is - * non-%NULL and @cm is not ready. - * - * Deprecated: since 0.UNRELEASED, use tp_proxy_prepare_async() instead - */ - -/** - * tp_connection_manager_call_when_ready: (skip) - * @self: a connection manager - * @callback: callback to call when information has been retrieved or on - * error - * @user_data: arbitrary data to pass to the callback - * @destroy: called to destroy @user_data - * @weak_object: object to reference weakly; if it is destroyed, @callback - * will not be called, but @destroy will still be called - * - * Call the @callback from the main loop when information about @cm's - * supported protocols and parameters has been retrieved. - * - * Since: 0.7.26 - * Deprecated: since 0.UNRELEASED, use tp_proxy_prepare_async() instead - */ -void -tp_connection_manager_call_when_ready (TpConnectionManager *self, - TpConnectionManagerWhenReadyCb callback, - gpointer user_data, - GDestroyNotify destroy, - GObject *weak_object) -{ - WhenReadyContext *c; - - g_return_if_fail (TP_IS_CONNECTION_MANAGER (self)); - g_return_if_fail (callback != NULL); - - c = g_slice_new0 (WhenReadyContext); - - c->cm = g_object_ref (self); - c->callback = callback; - c->user_data = user_data; - c->destroy = destroy; - - if (weak_object != NULL) - { - c->weak_ref = tp_weak_ref_new (weak_object, NULL, NULL); - } - - tp_proxy_prepare_async (self, NULL, tp_connection_manager_ready_cb, c); -} - static void tp_connection_manager_continue_introspection (TpConnectionManager *self); @@ -1850,31 +1718,6 @@ tp_connection_manager_get_name (TpConnectionManager *self) } /** - * tp_connection_manager_is_ready: (skip) - * @self: a connection manager - * - * If protocol and parameter information has been obtained from the connection - * manager or the cache in the .manager file, return %TRUE. Otherwise, - * return %FALSE. - * - * This may change from %FALSE to %TRUE at any time that the main loop is - * running; the #GObject::notify signal is emitted for the - * #TpConnectionManager:info-source property. - * - * Returns: %TRUE, unless the #TpConnectionManager:info-source property is - * %TP_CM_INFO_SOURCE_NONE - * Since: 0.7.26 - * Deprecated: since 0.UNRELEASED, use tp_proxy_is_prepared() - * with %TP_CONNECTION_MANAGER_FEATURE_CORE instead - */ -gboolean -tp_connection_manager_is_ready (TpConnectionManager *self) -{ - g_return_val_if_fail (TP_IS_CONNECTION_MANAGER (self), FALSE); - return self->info_source != TP_CM_INFO_SOURCE_NONE; -} - -/** * tp_connection_manager_is_running: * @self: a connection manager * diff --git a/telepathy-glib/connection-manager.h b/telepathy-glib/connection-manager.h index 423b051..1c39da0 100644 --- a/telepathy-glib/connection-manager.h +++ b/telepathy-glib/connection-manager.h @@ -117,19 +117,6 @@ void tp_list_connection_managers (TpDBusDaemon *bus_daemon, gpointer user_data, GDestroyNotify destroy, GObject *weak_object); -#ifndef TP_DISABLE_DEPRECATED -typedef void (*TpConnectionManagerWhenReadyCb) (TpConnectionManager *cm, - const GError *error, gpointer user_data, GObject *weak_object); - -void tp_connection_manager_call_when_ready (TpConnectionManager *self, - TpConnectionManagerWhenReadyCb callback, - gpointer user_data, GDestroyNotify destroy, GObject *weak_object) - _TP_GNUC_DEPRECATED_FOR (tp_proxy_prepare_async); - -gboolean tp_connection_manager_is_ready (TpConnectionManager *self) - _TP_GNUC_DEPRECATED_FOR (tp_proxy_is_prepared); -#endif - const gchar *tp_connection_manager_get_name (TpConnectionManager *self); gboolean tp_connection_manager_is_running (TpConnectionManager *self); TpCMInfoSource tp_connection_manager_get_info_source ( diff --git a/tests/dbus/cm.c b/tests/dbus/cm.c index 37a9e3f..5b6fe52 100644 --- a/tests/dbus/cm.c +++ b/tests/dbus/cm.c @@ -16,8 +16,7 @@ #include "tests/lib/util.h" typedef enum { - ACTIVATE_CM = (1 << 0), - USE_CWR = (1 << 1) + ACTIVATE_CM = (1 << 0) } TestFlags; typedef struct { @@ -663,26 +662,11 @@ test_dbus_got_info (Test *test, } static void -ready_or_not (TpConnectionManager *self, - const GError *error, - gpointer user_data, - GObject *weak_object G_GNUC_UNUSED) -{ - Test *test = user_data; - - if (error != NULL) - test->error = g_error_copy (error); - - g_main_loop_quit (test->mainloop); -} - -static void test_nothing_ready (Test *test, gconstpointer data) { gchar *name; guint info_source; - TestFlags flags = GPOINTER_TO_INT (data); test->error = NULL; test->cm = tp_connection_manager_new (test->dbus, "nonexistent_cm", @@ -693,25 +677,12 @@ test_nothing_ready (Test *test, g_test_bug ("18291"); - if (flags & USE_CWR) - { - tp_connection_manager_call_when_ready (test->cm, ready_or_not, - test, NULL, NULL); - g_main_loop_run (test->mainloop); - g_assert (test->error != NULL); - g_clear_error (&test->error); - } - else - { - tp_tests_proxy_run_until_prepared_or_failed (test->cm, NULL, - &test->error); - - g_assert_error (test->error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN); - } + tp_tests_proxy_run_until_prepared_or_failed (test->cm, NULL, + &test->error); + g_assert_error (test->error, DBUS_GERROR, DBUS_GERROR_SERVICE_UNKNOWN); g_assert_cmpstr (tp_connection_manager_get_name (test->cm), ==, "nonexistent_cm"); - g_assert_cmpuint (tp_connection_manager_is_ready (test->cm), ==, FALSE); g_assert_cmpuint (tp_proxy_is_prepared (test->cm, TP_CONNECTION_MANAGER_FEATURE_CORE), ==, FALSE); g_assert (tp_proxy_get_invalidated (test->cm) == NULL); @@ -734,7 +705,6 @@ test_file_ready (Test *test, { gchar *name; guint info_source; - TestFlags flags = GPOINTER_TO_INT (data); test->error = NULL; test->cm = tp_connection_manager_new (test->dbus, "spurious", @@ -745,21 +715,10 @@ test_file_ready (Test *test, g_test_bug ("18291"); - if (flags & USE_CWR) - { - tp_connection_manager_call_when_ready (test->cm, ready_or_not, - test, NULL, NULL); - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); - } - else - { - tp_tests_proxy_run_until_prepared (test->cm, NULL); - } + tp_tests_proxy_run_until_prepared (test->cm, NULL); g_assert_cmpstr (tp_connection_manager_get_name (test->cm), ==, "spurious"); - g_assert_cmpuint (tp_connection_manager_is_ready (test->cm), ==, TRUE); g_assert_cmpuint (tp_connection_manager_is_running (test->cm), ==, FALSE); g_assert_cmpuint (tp_proxy_is_prepared (test->cm, TP_CONNECTION_MANAGER_FEATURE_CORE), ==, TRUE); @@ -783,7 +742,6 @@ test_complex_file_ready (Test *test, { gchar *name; guint info_source; - TestFlags flags = GPOINTER_TO_INT (data); test->error = NULL; test->cm = tp_connection_manager_new (test->dbus, "test_manager_file", @@ -794,24 +752,13 @@ test_complex_file_ready (Test *test, g_test_bug ("18291"); - if (flags & USE_CWR) - { - tp_connection_manager_call_when_ready (test->cm, ready_or_not, - test, NULL, NULL); - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); - } - else - { - tp_tests_proxy_run_until_prepared (test->cm, NULL); - } + tp_tests_proxy_run_until_prepared (test->cm, NULL); g_assert_cmpstr (tp_connection_manager_get_name (test->cm), ==, "test_manager_file"); g_assert_cmpuint (tp_proxy_is_prepared (test->cm, TP_CONNECTION_MANAGER_FEATURE_CORE), ==, TRUE); g_assert (tp_proxy_get_invalidated (test->cm) == NULL); - g_assert_cmpuint (tp_connection_manager_is_ready (test->cm), ==, TRUE); g_assert_cmpuint (tp_connection_manager_is_running (test->cm), ==, FALSE); g_assert_cmpuint (tp_connection_manager_get_info_source (test->cm), ==, TP_CM_INFO_SOURCE_FILE); @@ -865,24 +812,13 @@ test_dbus_ready (Test *test, g_test_bug ("18291"); } - if (flags & USE_CWR) - { - tp_connection_manager_call_when_ready (test->cm, ready_or_not, - test, NULL, NULL); - g_main_loop_run (test->mainloop); - g_assert_no_error (test->error); - } - else - { - tp_tests_proxy_run_until_prepared (test->cm, NULL); - } + tp_tests_proxy_run_until_prepared (test->cm, NULL); g_assert_cmpstr (tp_connection_manager_get_name (test->cm), ==, "example_echo"); g_assert_cmpuint (tp_proxy_is_prepared (test->cm, TP_CONNECTION_MANAGER_FEATURE_CORE), ==, TRUE); g_assert (tp_proxy_get_invalidated (test->cm) == NULL); - g_assert_cmpuint (tp_connection_manager_is_ready (test->cm), ==, TRUE); g_assert_cmpuint (tp_connection_manager_is_running (test->cm), ==, TRUE); g_assert_cmpuint (tp_connection_manager_get_info_source (test->cm), ==, TP_CM_INFO_SOURCE_LIVE); @@ -931,9 +867,6 @@ on_listed_connection_managers (TpConnectionManager * const * cms, g_assert (tp_proxy_get_invalidated (echo) == NULL); g_assert (tp_proxy_get_invalidated (spurious) == NULL); - g_assert (tp_connection_manager_is_ready (echo)); - g_assert (tp_connection_manager_is_ready (spurious)); - g_assert_cmpuint (tp_connection_manager_get_info_source (echo), ==, TP_CM_INFO_SOURCE_LIVE); g_assert_cmpuint (tp_connection_manager_get_info_source (spurious), @@ -973,20 +906,12 @@ main (int argc, g_test_add ("/cm/nothing", Test, GINT_TO_POINTER (0), setup, test_nothing_ready, teardown); - g_test_add ("/cm/nothing/cwr", Test, GINT_TO_POINTER (USE_CWR), - setup, test_nothing_ready, teardown); g_test_add ("/cm/file", Test, GINT_TO_POINTER (0), setup, test_file_ready, teardown); - g_test_add ("/cm/file/cwr", Test, GINT_TO_POINTER (USE_CWR), - setup, test_file_ready, teardown); g_test_add ("/cm/file/complex", Test, GINT_TO_POINTER (0), setup, test_complex_file_ready, teardown); - g_test_add ("/cm/file/complex/cwr", Test, GINT_TO_POINTER (USE_CWR), setup, - test_complex_file_ready, teardown); g_test_add ("/cm/dbus", Test, GINT_TO_POINTER (0), setup, test_dbus_ready, teardown); - g_test_add ("/cm/dbus/cwr", Test, GINT_TO_POINTER (USE_CWR), setup, - test_dbus_ready, teardown); g_test_add ("/cm/list", Test, NULL, setup, test_list, teardown); -- 1.7.9.1