From fbeb1a86454e15236b42d01946a6c866ed841e8f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 14 Jul 2011 13:28:45 +0200 Subject: [PATCH] Ensure TpChannelRequest always has a factory Use it to share its TpAccount and TpConnection --- telepathy-glib/account-channel-request.c | 7 ++++--- telepathy-glib/base-client.c | 11 ++++++++--- telepathy-glib/channel-request.c | 9 +++++++-- telepathy-glib/handle-channels-context.c | 2 +- telepathy-glib/observe-channels-context.c | 2 +- telepathy-glib/util-internal.h | 2 +- telepathy-glib/util.c | 6 ++++-- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c index efa6b53..1846513 100644 --- a/telepathy-glib/account-channel-request.c +++ b/telepathy-glib/account-channel-request.c @@ -77,6 +77,7 @@ #include #include #include +#include #include #include #include @@ -794,9 +795,9 @@ acr_request_cb (TpChannelDispatcher *cd, DEBUG ("Got ChannelRequest: %s", channel_request_path); - self->priv->chan_request = tp_channel_request_new ( - self->priv->dbus, channel_request_path, NULL, &err); - + self->priv->chan_request = tp_simple_client_factory_dup_channel_request ( + tp_proxy_get_factory (self->priv->account), channel_request_path, NULL, + &err); if (self->priv->chan_request == NULL) { DEBUG ("Failed to create ChannelRequest: %s", err->message); diff --git a/telepathy-glib/base-client.c b/telepathy-glib/base-client.c index d6c96b8..6765291 100644 --- a/telepathy-glib/base-client.c +++ b/telepathy-glib/base-client.c @@ -189,6 +189,7 @@ #include #include #include +#include #include #include #include @@ -1685,7 +1686,8 @@ _tp_base_client_observe_channels (TpSvcClientObserver *iface, const gchar *req_path = g_ptr_array_index (requests_arr, i); TpChannelRequest *request; - request = tp_channel_request_new (self->priv->dbus, req_path, NULL, + request = tp_simple_client_factory_dup_channel_request ( + tp_proxy_get_factory (self->priv->account_mgr), req_path, NULL, &error); if (request == NULL) { @@ -2242,7 +2244,8 @@ _tp_base_client_handle_channels (TpSvcClientHandler *iface, } else { - request = tp_channel_request_new (self->priv->dbus, req_path, NULL, + request = tp_simple_client_factory_dup_channel_request ( + tp_proxy_get_factory (self->priv->account_mgr), req_path, NULL, &error); if (request == NULL) { @@ -2352,7 +2355,9 @@ _tp_base_client_add_request (TpSvcClientInterfaceRequests *iface, GError *error = NULL; channel_request_prepare_account_ctx *ctx; - request = tp_channel_request_new (self->priv->dbus, path, properties, &error); + request = tp_simple_client_factory_dup_channel_request ( + tp_proxy_get_factory (self->priv->account_mgr), path, properties, + &error); if (request == NULL) { DEBUG ("Failed to create TpChannelRequest: %s", error->message); diff --git a/telepathy-glib/channel-request.c b/telepathy-glib/channel-request.c index 7559da0..e8f3e7d 100644 --- a/telepathy-glib/channel-request.c +++ b/telepathy-glib/channel-request.c @@ -35,6 +35,7 @@ #define DEBUG_FLAG TP_DEBUG_DISPATCHER #include "telepathy-glib/dbus-internal.h" #include "telepathy-glib/debug-internal.h" +#include "telepathy-glib/proxy-internal.h" #include "telepathy-glib/simple-client-factory-internal.h" #include "telepathy-glib/_gen/tp-cli-channel-request-body.h" @@ -250,7 +251,8 @@ tp_channel_request_succeeded_with_channel_cb (TpChannelRequest *self, dbus = tp_proxy_get_dbus_daemon (self); - connection = tp_connection_new (dbus, NULL, conn_path, &error); + connection = tp_simple_client_factory_dup_connection ( + tp_proxy_get_factory (self), conn_path, &error); if (connection == NULL) { DEBUG ("Failed to create TpConnection: %s", error->message); @@ -291,6 +293,8 @@ tp_channel_request_constructed (GObject *object) g_return_if_fail (tp_proxy_get_dbus_daemon (self) != NULL); + _tp_proxy_ensure_factory (self, NULL); + if (self->priv->channel_factory == NULL) { self->priv->channel_factory = TP_CLIENT_CHANNEL_FACTORY ( @@ -686,7 +690,8 @@ tp_channel_request_get_account (TpChannelRequest *self) if (path == NULL) return NULL; - mgr = tp_account_manager_dup (); + mgr = tp_simple_client_factory_dup_account_manager ( + tp_proxy_get_factory (self)); account = tp_account_manager_ensure_account (mgr, path); diff --git a/telepathy-glib/handle-channels-context.c b/telepathy-glib/handle-channels-context.c index 715ecf5..fdfde94 100644 --- a/telepathy-glib/handle-channels-context.c +++ b/telepathy-glib/handle-channels-context.c @@ -751,5 +751,5 @@ tp_handle_channels_context_get_requests ( return NULL; return _tp_create_channel_request_list ( - tp_proxy_get_dbus_daemon (self->account), request_props); + tp_proxy_get_factory (self->account), request_props); } diff --git a/telepathy-glib/observe-channels-context.c b/telepathy-glib/observe-channels-context.c index 3e80f32..91be62d 100644 --- a/telepathy-glib/observe-channels-context.c +++ b/telepathy-glib/observe-channels-context.c @@ -694,5 +694,5 @@ tp_observe_channels_context_get_requests (TpObserveChannelsContext *self) return NULL; return _tp_create_channel_request_list ( - tp_proxy_get_dbus_daemon (self->account), request_props); + tp_proxy_get_factory (self->account), request_props); } diff --git a/telepathy-glib/util-internal.h b/telepathy-glib/util-internal.h index 3ab4b63..4420715 100644 --- a/telepathy-glib/util-internal.h +++ b/telepathy-glib/util-internal.h @@ -36,7 +36,7 @@ GSocketAddress * _tp_create_temp_unix_socket (GSocketService *service, GError **error); #endif /* HAVE_GIO_UNIX */ -GList * _tp_create_channel_request_list (TpDBusDaemon *dbus, +GList * _tp_create_channel_request_list (TpSimpleClientFactory *factory, GHashTable *request_props); /* Copied from wocky/wocky-utils.h */ diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c index ed48f65..e4e85b6 100644 --- a/telepathy-glib/util.c +++ b/telepathy-glib/util.c @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -1570,7 +1571,7 @@ _tp_create_temp_unix_socket (GSocketService *service, #endif /* HAVE_GIO_UNIX */ GList * -_tp_create_channel_request_list (TpDBusDaemon *dbus, +_tp_create_channel_request_list (TpSimpleClientFactory *factory, GHashTable *request_props) { GHashTableIter iter; @@ -1585,7 +1586,8 @@ _tp_create_channel_request_list (TpDBusDaemon *dbus, GHashTable *props = value; GError *error = NULL; - req = tp_channel_request_new (dbus, path, props, &error); + req = tp_simple_client_factory_dup_channel_request (factory, path, props, + &error); if (req == NULL) { DEBUG ("Failed to create TpChannelRequest: %s", error->message); -- 1.7.4.1