[next] telepathy-glib: TpChannelDispatcher: Always create from a factory

Simon McVittie smcv at kemper.freedesktop.org
Thu Apr 3 07:25:27 PDT 2014


Module: telepathy-glib
Branch: next
Commit: 8b7f8581031ceed7c872767d78ac1798bcf4a0e7
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=8b7f8581031ceed7c872767d78ac1798bcf4a0e7

Author: Xavier Claessens <xavier.claessens at collabora.com>
Date:   Fri Mar 28 23:47:44 2014 -0400

TpChannelDispatcher: Always create from a factory

Conflicts:
	docs/reference/telepathy-glib/telepathy-glib-sections.txt
	telepathy-glib/client-factory.h

---

 .../telepathy-glib/telepathy-glib-sections.txt     |    2 +-
 telepathy-glib/account-channel-request.c           |    6 +++--
 telepathy-glib/base-client.c                       |    2 +-
 telepathy-glib/channel-dispatcher.c                |   23 ++++-------------
 telepathy-glib/channel-dispatcher.h                |    3 ---
 telepathy-glib/client-factory-internal.h           |    2 ++
 telepathy-glib/client-factory.c                    |   27 ++++++++++++++++++++
 telepathy-glib/client-factory.h                    |    3 +++
 telepathy-glib/versions/main-1.0.abi               |    1 -
 tests/dbus/base-client.c                           |    2 +-
 tests/dbus/channel-dispatcher.c                    |    6 ++++-
 11 files changed, 49 insertions(+), 28 deletions(-)

diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index b53bdbd..cd6cd7c 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -4143,7 +4143,6 @@ tp_cli_account_manager_add_signals
 <TITLE>channel-dispatcher</TITLE>
 TpChannelDispatcher
 TpChannelDispatcherClass
-tp_channel_dispatcher_new
 <SUBSECTION>
 tp_cli_channel_dispatcher_interface_messages1_call_send_message
 tp_cli_channel_dispatcher_interface_messages1_callback_for_send_message
@@ -5731,6 +5730,7 @@ tp_client_factory_get_dbus_daemon
 tp_client_factory_get_dbus_connection
 <SUBSECTION>
 tp_client_factory_ensure_account_manager
+tp_client_factory_dup_channel_dispatcher
 <SUBSECTION>
 tp_client_factory_ensure_account
 tp_client_factory_dup_account_features
diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index 66c74a4..e7259fb 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -963,7 +963,8 @@ request_and_handle_channel_async (TpAccountChannelRequest *self,
       return;
     }
 
-  cd = tp_channel_dispatcher_new (self->priv->dbus);
+  cd = tp_client_factory_dup_channel_dispatcher (tp_proxy_get_factory (
+      self->priv->account));
 
   hints = tp_asv_from_vardict (self->priv->hints);
 
@@ -1199,7 +1200,8 @@ request_channel_async (TpAccountChannelRequest *self,
         callback, user_data))
     return;
 
-  cd = tp_channel_dispatcher_new (self->priv->dbus);
+  cd = tp_client_factory_dup_channel_dispatcher (tp_proxy_get_factory (
+      self->priv->account));
 
   hints = tp_asv_from_vardict (self->priv->hints);
 
diff --git a/telepathy-glib/base-client.c b/telepathy-glib/base-client.c
index 26c6a14..bfb39cc 100644
--- a/telepathy-glib/base-client.c
+++ b/telepathy-glib/base-client.c
@@ -2832,7 +2832,7 @@ tp_base_client_delegate_channels_async (TpBaseClient *self,
   g_return_if_fail (TP_IS_BASE_CLIENT (self));
   g_return_if_fail (self->priv->flags & CLIENT_IS_HANDLER);
 
-  cd = tp_channel_dispatcher_new (self->priv->dbus);
+  cd = tp_client_factory_dup_channel_dispatcher (self->priv->factory);
 
   chans = g_ptr_array_new_full (g_list_length (channels), g_free);
 
diff --git a/telepathy-glib/channel-dispatcher.c b/telepathy-glib/channel-dispatcher.c
index be71f82..772f96f 100644
--- a/telepathy-glib/channel-dispatcher.c
+++ b/telepathy-glib/channel-dispatcher.c
@@ -33,6 +33,7 @@
 
 #define DEBUG_FLAG TP_DEBUG_DISPATCHER
 #include "telepathy-glib/debug-internal.h"
+#include "telepathy-glib/client-factory-internal.h"
 
 /**
  * SECTION:channel-dispatcher
@@ -111,29 +112,15 @@ tp_channel_dispatcher_class_init (TpChannelDispatcherClass *klass)
   proxy_class->interface = TP_IFACE_QUARK_CHANNEL_DISPATCHER;
 }
 
-/**
- * tp_channel_dispatcher_new:
- * @bus_daemon: Proxy for the D-Bus daemon
- *
- * Convenience function to create a new channel dispatcher proxy.
- *
- * Returns: a new reference to a channel dispatcher proxy
- */
 TpChannelDispatcher *
-tp_channel_dispatcher_new (TpDBusDaemon *bus_daemon)
+_tp_channel_dispatcher_new (TpClientFactory *factory)
 {
-  TpChannelDispatcher *self;
-
-  g_return_val_if_fail (bus_daemon != NULL, NULL);
-
-  self = TP_CHANNEL_DISPATCHER (g_object_new (TP_TYPE_CHANNEL_DISPATCHER,
-        "dbus-daemon", bus_daemon,
-        "dbus-connection", tp_proxy_get_dbus_connection (bus_daemon),
+  return TP_CHANNEL_DISPATCHER (g_object_new (TP_TYPE_CHANNEL_DISPATCHER,
+        "dbus-daemon", tp_client_factory_get_dbus_daemon (factory),
         "bus-name", TP_CHANNEL_DISPATCHER_BUS_NAME,
         "object-path", TP_CHANNEL_DISPATCHER_OBJECT_PATH,
+        "factory", factory,
         NULL));
-
-  return self;
 }
 
 static void
diff --git a/telepathy-glib/channel-dispatcher.h b/telepathy-glib/channel-dispatcher.h
index 1946647..fde07c3 100644
--- a/telepathy-glib/channel-dispatcher.h
+++ b/telepathy-glib/channel-dispatcher.h
@@ -70,9 +70,6 @@ GType tp_channel_dispatcher_get_type (void);
   (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_CHANNEL_DISPATCHER, \
                               TpChannelDispatcherClass))
 
-TpChannelDispatcher *tp_channel_dispatcher_new (TpDBusDaemon *bus_daemon)
-    G_GNUC_WARN_UNUSED_RESULT;
-
 _TP_AVAILABLE_IN_0_16
 void tp_channel_dispatcher_present_channel_async (TpChannelDispatcher *self,
     TpChannel *channel,
diff --git a/telepathy-glib/client-factory-internal.h b/telepathy-glib/client-factory-internal.h
index 15a0a67..1bc709c 100644
--- a/telepathy-glib/client-factory-internal.h
+++ b/telepathy-glib/client-factory-internal.h
@@ -78,6 +78,8 @@ TpTLSCertificate *_tp_tls_certificate_new (TpProxy *conn_or_chan,
 
 TpAccountManager *_tp_account_manager_new (TpClientFactory *factory);
 
+TpChannelDispatcher *_tp_channel_dispatcher_new (TpClientFactory *factory);
+
 G_END_DECLS
 
 #endif
diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c
index 6da6225..9830b83 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -652,6 +652,33 @@ tp_client_factory_ensure_account_manager (TpClientFactory *self)
 }
 
 /**
+ * tp_client_factory_dup_channel_dispatcher:
+ * @self: a #TpClientFactory object
+ *
+ * <!-- -->
+ *
+ * Returns: (transfer full): a reference to a #TpChannelDispatcher singleton.
+ *
+ * Since: 0.UNRELEASED
+ */
+TpChannelDispatcher *
+tp_client_factory_dup_channel_dispatcher (TpClientFactory *self)
+{
+  TpChannelDispatcher *channel_dispatcher;
+
+  g_return_val_if_fail (TP_IS_CLIENT_FACTORY (self), NULL);
+
+  channel_dispatcher = lookup_proxy (self, TP_CHANNEL_DISPATCHER_OBJECT_PATH);
+  if (channel_dispatcher != NULL)
+    return g_object_ref (channel_dispatcher);
+
+  channel_dispatcher = _tp_channel_dispatcher_new (self);
+  insert_proxy (self, channel_dispatcher);
+
+  return channel_dispatcher;
+}
+
+/**
  * tp_client_factory_ensure_account:
  * @self: a #TpClientFactory object
  * @object_path: the object path of an account
diff --git a/telepathy-glib/client-factory.h b/telepathy-glib/client-factory.h
index 1f18913..f9eb0a5 100644
--- a/telepathy-glib/client-factory.h
+++ b/telepathy-glib/client-factory.h
@@ -28,6 +28,7 @@
 #include <telepathy-glib/account.h>
 #include <telepathy-glib/account-manager.h>
 #include <telepathy-glib/channel.h>
+#include <telepathy-glib/channel-dispatcher.h>
 #include <telepathy-glib/channel-dispatch-operation.h>
 #include <telepathy-glib/channel-request.h>
 #include <telepathy-glib/connection.h>
@@ -134,6 +135,8 @@ GDBusConnection *tp_client_factory_get_dbus_connection (TpClientFactory *self);
 
 TpAccountManager *tp_client_factory_ensure_account_manager (
     TpClientFactory *self);
+TpChannelDispatcher *tp_client_factory_dup_channel_dispatcher (
+    TpClientFactory *self);
 
 /* TpAccount */
 TpAccount *tp_client_factory_ensure_account (TpClientFactory *self,
diff --git a/telepathy-glib/versions/main-1.0.abi b/telepathy-glib/versions/main-1.0.abi
index a706223..5cdf77e 100644
--- a/telepathy-glib/versions/main-1.0.abi
+++ b/telepathy-glib/versions/main-1.0.abi
@@ -491,7 +491,6 @@ tp_channel_dispatch_operation_handle_with_finish
 tp_channel_dispatch_operation_leave_channel_async
 tp_channel_dispatch_operation_leave_channel_finish
 tp_channel_dispatcher_get_type
-tp_channel_dispatcher_new
 tp_channel_dispatcher_present_channel_async
 tp_channel_dispatcher_present_channel_finish
 tp_channel_dup_immutable_properties
diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c
index f13da5a..c051476 100644
--- a/tests/dbus/base-client.c
+++ b/tests/dbus/base-client.c
@@ -1268,7 +1268,7 @@ test_present_channel (Test *test,
 {
   TpChannelDispatcher *cd;
 
-  cd = tp_channel_dispatcher_new (test->dbus);
+  cd = tp_client_factory_dup_channel_dispatcher (test->factory);
 
   tp_channel_dispatcher_present_channel_async (cd, test->text_chan,
       TP_USER_ACTION_TIME_CURRENT_TIME, present_channel_cb, test);
diff --git a/tests/dbus/channel-dispatcher.c b/tests/dbus/channel-dispatcher.c
index d3b466e..be8375a 100644
--- a/tests/dbus/channel-dispatcher.c
+++ b/tests/dbus/channel-dispatcher.c
@@ -58,8 +58,12 @@ static void
 test_new (Test *test,
           gconstpointer data G_GNUC_UNUSED)
 {
-  test->cd = tp_channel_dispatcher_new (test->dbus);
+  TpClientFactory *factory;
+
+  factory = tp_client_factory_new (test->dbus);
+  test->cd = tp_client_factory_dup_channel_dispatcher (factory);
   g_assert (test->cd != NULL);
+  g_object_unref (factory);
 }
 
 int



More information about the telepathy-commits mailing list