[Pkg-telepathy-commits] [telepathy-glib-1] 70/212: TpDebusClient: Always create from a factory

Simon McVittie smcv at debian.org
Wed May 14 12:08:52 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-glib-1.

commit 1202709d97c6f5ed11c6259f13c01870fcfb663e
Author: Xavier Claessens <xavier.claessens at collabora.com>
Date:   Sat Mar 29 13:55:59 2014 -0400

    TpDebusClient: Always create from a factory
---
 .../telepathy-glib/telepathy-glib-sections.txt     |  3 +-
 telepathy-glib/client-factory-internal.h           |  4 +++
 telepathy-glib/client-factory.c                    | 32 ++++++++++++++++++++++
 telepathy-glib/client-factory.h                    |  6 ++++
 telepathy-glib/debug-client.c                      | 20 +++-----------
 telepathy-glib/debug-client.h                      |  6 ----
 telepathy-glib/versions/main-1.0.abi               |  1 -
 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 c8de563..b7eb72d 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 1bc709c..dd97147 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 3487ab9..3949ada 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 d593245..41bc78f 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 651031b..666f22f 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 40df631..2d5550a 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 5cdf77e..e667bfc 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 30205ed..6a36c75 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib-1.git



More information about the Pkg-telepathy-commits mailing list