diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2014-03-29 13:55:59 -0400 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-01 14:29:19 +0100 |
commit | 1202709d97c6f5ed11c6259f13c01870fcfb663e (patch) | |
tree | d854d31d5ebe6d727608c8625eecc96b11bae93f | |
parent | 091a2b2a84b6779ed609644abbeb84165b21bac3 (diff) | |
download | telepathy-glib-1202709d97c6f5ed11c6259f13c01870fcfb663e.tar.gz |
TpDebusClient: Always create from a factory
-rw-r--r-- | docs/reference/telepathy-glib/telepathy-glib-sections.txt | 3 | ||||
-rw-r--r-- | telepathy-glib/client-factory-internal.h | 4 | ||||
-rw-r--r-- | telepathy-glib/client-factory.c | 32 | ||||
-rw-r--r-- | telepathy-glib/client-factory.h | 6 | ||||
-rw-r--r-- | telepathy-glib/debug-client.c | 20 | ||||
-rw-r--r-- | telepathy-glib/debug-client.h | 6 | ||||
-rw-r--r-- | telepathy-glib/versions/main-1.0.abi | 1 | ||||
-rw-r--r-- | tests/dbus/debug-client.c | 6 |
8 files changed, 53 insertions, 25 deletions
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt index c8de563ce..b7eb72d52 100644 --- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt @@ -5765,6 +5765,8 @@ tp_client_factory_ensure_tls_certificate tp_client_factory_add_tls_certificate_features tp_client_factory_add_tls_certificate_features_varargs tp_client_factory_dup_tls_certificate_features +<SUBSECTION> +tp_client_factory_ensure_debug_client <SUBSECTION Standard> TP_IS_CLIENT_FACTORY TP_IS_CLIENT_FACTORY_CLASS @@ -6049,7 +6051,6 @@ TpBaseMediaCallChannelPrivate <SUBSECTION> TpDebugClient TpDebugClientClass -tp_debug_client_new tp_debug_client_set_enabled_async tp_debug_client_set_enabled_finish tp_debug_client_is_enabled diff --git a/telepathy-glib/client-factory-internal.h b/telepathy-glib/client-factory-internal.h index 1bc709cf0..dd97147fd 100644 --- a/telepathy-glib/client-factory-internal.h +++ b/telepathy-glib/client-factory-internal.h @@ -80,6 +80,10 @@ TpAccountManager *_tp_account_manager_new (TpClientFactory *factory); TpChannelDispatcher *_tp_channel_dispatcher_new (TpClientFactory *factory); +TpDebugClient *_tp_debug_client_new (TpClientFactory *factory, + const gchar *unique_name, + GError **error); + G_END_DECLS #endif diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c index 3487ab9b1..3949ada23 100644 --- a/telepathy-glib/client-factory.c +++ b/telepathy-glib/client-factory.c @@ -1776,3 +1776,35 @@ tp_client_factory_add_tls_certificate_features_varargs ( feature, var_args); va_end (var_args); } + +/** + * tp_client_factory_ensure_debug_client: + * @self: a #TpClientFactory + * @unique_name: the unique name of the process to be debugged; may not be + * %NULL or a well-known name + * @error: Used to raise an error + * + * The returned #TpDebugClient is cached; the same #TpDebugClient object + * will be returned by this function repeatedly, as long as at least one + * reference exists. + * + * Note that the returned #TpDebugClient is not guaranteed to be ready; the + * caller is responsible for calling tp_proxy_prepare_async() with the desired + * features. + * + * Returns: (transfer full): a reference to a #TpDebugClient, + * or %NULL on invalid arguments. + * + * Since: 0.UNRELEASED + */ +TpDebugClient * +tp_client_factory_ensure_debug_client (TpClientFactory *self, + const gchar *unique_name, + GError **error) +{ + g_return_val_if_fail (TP_IS_CLIENT_FACTORY (self), NULL); + + /* FIXME: make it unique per @unique_name, can't use self->priv->proxy_cache + * in this case. */ + return _tp_debug_client_new (self, unique_name, error); +} diff --git a/telepathy-glib/client-factory.h b/telepathy-glib/client-factory.h index d5932458d..41bc78f55 100644 --- a/telepathy-glib/client-factory.h +++ b/telepathy-glib/client-factory.h @@ -34,6 +34,7 @@ #include <telepathy-glib/connection.h> #include <telepathy-glib/contact.h> #include <telepathy-glib/dbus-daemon.h> +#include <telepathy-glib/debug-client.h> #include <telepathy-glib/protocol.h> #include <telepathy-glib/tls-certificate.h> @@ -250,6 +251,11 @@ void tp_client_factory_add_tls_certificate_features_varargs ( GQuark feature, ...); +/* TpDebugClient */ +TpDebugClient *tp_client_factory_ensure_debug_client (TpClientFactory *self, + const gchar *unique_name, + GError **error); + G_END_DECLS #endif diff --git a/telepathy-glib/debug-client.c b/telepathy-glib/debug-client.c index 651031be8..666f22fdb 100644 --- a/telepathy-glib/debug-client.c +++ b/telepathy-glib/debug-client.c @@ -31,6 +31,7 @@ #include <telepathy-glib/util.h> #define DEBUG_FLAG TP_DEBUG_DEBUGGER +#include "telepathy-glib/client-factory-internal.h" #include "telepathy-glib/debug-internal.h" #include "telepathy-glib/proxy-internal.h" #include "telepathy-glib/util-internal.h" @@ -315,22 +316,8 @@ tp_debug_client_list_features (TpProxyClass *klass) return features; } -/** - * tp_debug_client_new: - * @dbus: a D-Bus daemon; may not be %NULL - * @unique_name: the unique name of the process to be debugged; may not be - * %NULL or a well-known name - * @error: used to raise an error if @unique_name is not valid - * - * <!-- --> - * - * Returns: a new debug client proxy, or %NULL on invalid arguments - * - * Since: 0.19.0 - */ TpDebugClient * -tp_debug_client_new ( - TpDBusDaemon *dbus, +_tp_debug_client_new (TpClientFactory *factory, const gchar *unique_name, GError **error) { @@ -339,9 +326,10 @@ tp_debug_client_new ( return NULL; return TP_DEBUG_CLIENT (g_object_new (TP_TYPE_DEBUG_CLIENT, - "dbus-daemon", dbus, + "dbus-daemon", tp_client_factory_get_dbus_daemon (factory), "bus-name", unique_name, "object-path", TP_DEBUG_OBJECT_PATH, + "factory", factory, NULL)); } diff --git a/telepathy-glib/debug-client.h b/telepathy-glib/debug-client.h index 40df631f0..2d5550a74 100644 --- a/telepathy-glib/debug-client.h +++ b/telepathy-glib/debug-client.h @@ -35,12 +35,6 @@ typedef struct _TpDebugClient TpDebugClient; typedef struct _TpDebugClientPrivate TpDebugClientPrivate; typedef struct _TpDebugClientClass TpDebugClientClass; -_TP_AVAILABLE_IN_0_20 -TpDebugClient *tp_debug_client_new ( - TpDBusDaemon *dbus, - const gchar *unique_name, - GError **error); - #define TP_DEBUG_CLIENT_FEATURE_CORE \ (tp_debug_client_get_feature_quark_core ()) _TP_AVAILABLE_IN_0_20 diff --git a/telepathy-glib/versions/main-1.0.abi b/telepathy-glib/versions/main-1.0.abi index 5cdf77ef6..e667bfc70 100644 --- a/telepathy-glib/versions/main-1.0.abi +++ b/telepathy-glib/versions/main-1.0.abi @@ -826,7 +826,6 @@ tp_debug_client_get_messages_async tp_debug_client_get_messages_finish tp_debug_client_get_type tp_debug_client_is_enabled -tp_debug_client_new tp_debug_client_set_enabled_async tp_debug_client_set_enabled_finish tp_debug_divert_messages diff --git a/tests/dbus/debug-client.c b/tests/dbus/debug-client.c index 30205ede6..6a36c7552 100644 --- a/tests/dbus/debug-client.c +++ b/tests/dbus/debug-client.c @@ -36,6 +36,8 @@ static void setup (Test *test, gconstpointer data) { + TpClientFactory *factory; + test->mainloop = g_main_loop_new (NULL, FALSE); test->dbus = tp_tests_dbus_daemon_dup_or_die (); @@ -44,9 +46,11 @@ setup (Test *test, test->sender = tp_debug_sender_dup (); g_assert (test->sender != NULL); - test->client = tp_debug_client_new (test->dbus, + factory = tp_client_factory_new (test->dbus); + test->client = tp_client_factory_ensure_debug_client (factory, tp_dbus_daemon_get_unique_name (test->dbus), &test->error); g_assert_no_error (test->error); + g_object_unref (factory); } static void |