summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2014-03-28 23:47:44 -0400
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-01 14:27:46 +0100
commit8b7f8581031ceed7c872767d78ac1798bcf4a0e7 (patch)
tree5dca01da3973deb709afa5facbe89f4999cbe197
parentd1a3f5bf60c774510e83d68d87b369d1e948f2da (diff)
downloadtelepathy-glib-8b7f8581031ceed7c872767d78ac1798bcf4a0e7.tar.gz
TpChannelDispatcher: Always create from a factory
Conflicts: docs/reference/telepathy-glib/telepathy-glib-sections.txt telepathy-glib/client-factory.h
-rw-r--r--docs/reference/telepathy-glib/telepathy-glib-sections.txt2
-rw-r--r--telepathy-glib/account-channel-request.c6
-rw-r--r--telepathy-glib/base-client.c2
-rw-r--r--telepathy-glib/channel-dispatcher.c23
-rw-r--r--telepathy-glib/channel-dispatcher.h3
-rw-r--r--telepathy-glib/client-factory-internal.h2
-rw-r--r--telepathy-glib/client-factory.c27
-rw-r--r--telepathy-glib/client-factory.h3
-rw-r--r--telepathy-glib/versions/main-1.0.abi1
-rw-r--r--tests/dbus/base-client.c2
-rw-r--r--tests/dbus/channel-dispatcher.c6
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 b53bdbd40..cd6cd7c19 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 66c74a4f5..e7259fbec 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 26c6a1428..bfb39cc60 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 be71f8296..772f96fff 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 1946647f2..fde07c33b 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 15a0a6702..1bc709cf0 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 6da622510..9830b83fc 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 1f18913e8..f9eb0a501 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 a70622331..5cdf77ef6 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 f13da5a87..c0514761d 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 d3b466e03..be8375ad4 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