[next] telepathy-glib: Port to new ChannelDispatcher spec
Xavier Claessens
xclaesse at kemper.freedesktop.org
Thu Sep 13 02:01:52 PDT 2012
Module: telepathy-glib
Branch: next
Commit: 4dccc62af820809fe0dd6cd7770fb3459e086cb7
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=4dccc62af820809fe0dd6cd7770fb3459e086cb7
Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date: Fri Sep 7 20:22:16 2012 +0200
Port to new ChannelDispatcher spec
We now always get ChannelRequest immutable properties.
---
telepathy-glib/account-channel-request.c | 5 +++--
telepathy-glib/base-client.c | 20 ++++++--------------
telepathy-glib/channel-request.c | 11 -----------
telepathy-glib/client-factory-internal.h | 2 --
telepathy-glib/client-factory.c | 12 ++----------
tests/dbus/base-client.c | 9 ++++++++-
tests/lib/simple-channel-dispatcher.c | 20 ++++++++++++++------
7 files changed, 33 insertions(+), 46 deletions(-)
diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index b73ecc0..233bbf5 100644
--- a/telepathy-glib/account-channel-request.c
+++ b/telepathy-glib/account-channel-request.c
@@ -788,6 +788,7 @@ acr_operation_cancelled_cb (GCancellable *cancellable,
static void
acr_request_cb (TpChannelDispatcher *cd,
const gchar *channel_request_path,
+ GHashTable *properties,
const GError *error,
gpointer user_data,
GObject *weak_object)
@@ -808,8 +809,8 @@ acr_request_cb (TpChannelDispatcher *cd,
DEBUG ("Got ChannelRequest: %s", channel_request_path);
self->priv->chan_request = _tp_client_factory_ensure_channel_request (
- tp_proxy_get_factory (self->priv->account), channel_request_path, NULL,
- &err);
+ tp_proxy_get_factory (self->priv->account), channel_request_path,
+ properties, &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 abe9aa1..1fa5ee2 100644
--- a/telepathy-glib/base-client.c
+++ b/telepathy-glib/base-client.c
@@ -2216,21 +2216,13 @@ _tp_base_client_handle_channels (TpSvcClientHandler *iface,
if (request_props != NULL)
props = g_hash_table_lookup (request_props, req_path);
- request = find_request_by_path (self, req_path);
- if (request != NULL)
- {
- g_object_ref (request);
- _tp_channel_request_ensure_immutable_properties (request, props);
- }
- else
+ request = _tp_client_factory_ensure_channel_request (
+ self->priv->factory, req_path, props, &error);
+
+ if (request == NULL)
{
- request = _tp_client_factory_ensure_channel_request (
- self->priv->factory, req_path, props, &error);
- if (request == NULL)
- {
- DEBUG ("Failed to create TpChannelRequest: %s", error->message);
- goto out;
- }
+ DEBUG ("Failed to create TpChannelRequest: %s", error->message);
+ goto out;
}
g_ptr_array_add (requests, request);
diff --git a/telepathy-glib/channel-request.c b/telepathy-glib/channel-request.c
index f8eda8b..b9e8c0a 100644
--- a/telepathy-glib/channel-request.c
+++ b/telepathy-glib/channel-request.c
@@ -540,17 +540,6 @@ tp_channel_request_get_immutable_properties (TpChannelRequest *self)
return self->priv->immutable_properties;
}
-void
-_tp_channel_request_ensure_immutable_properties (TpChannelRequest *self,
- GHashTable *immutable_properties)
-{
- if (self->priv->immutable_properties == NULL && immutable_properties != NULL)
- {
- self->priv->immutable_properties = g_hash_table_ref (immutable_properties);
- g_object_notify ((GObject *) self, "immutable-properties");
- }
-}
-
/**
* tp_channel_request_get_account:
* @self: a #tpchannelrequest
diff --git a/telepathy-glib/client-factory-internal.h b/telepathy-glib/client-factory-internal.h
index c2ac274..11fba48 100644
--- a/telepathy-glib/client-factory-internal.h
+++ b/telepathy-glib/client-factory-internal.h
@@ -64,8 +64,6 @@ TpChannelRequest *_tp_channel_request_new_with_factory (
const gchar *object_path,
GHashTable *immutable_properties,
GError **error);
-void _tp_channel_request_ensure_immutable_properties (TpChannelRequest *self,
- GHashTable *immutable_properties);
TpChannelDispatchOperation *_tp_channel_dispatch_operation_new_with_factory (
TpClientFactory *factory,
diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c
index 95bd575..1a22935 100644
--- a/telepathy-glib/client-factory.c
+++ b/telepathy-glib/client-factory.c
@@ -1136,19 +1136,11 @@ _tp_client_factory_ensure_channel_request (TpClientFactory *self,
g_return_val_if_fail (TP_IS_CLIENT_FACTORY (self), NULL);
g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
+ g_return_val_if_fail (immutable_properties != NULL, NULL);
request = lookup_proxy (self, object_path);
if (request != NULL)
- {
- /* A common usage is request_and_handle, in that case EnsureChannel
- * returns only the object-path of the ChannelRequest but not properties.
- * The TpChannelRequest will be created with no properties, then when
- * handling we get the properties and we reuse the same TpChannelRequest
- * object, and we can give it the immutable-properties. */
- _tp_channel_request_ensure_immutable_properties (request,
- immutable_properties);
- return g_object_ref (request);
- }
+ return g_object_ref (request);
request = _tp_channel_request_new_with_factory (self, self->priv->dbus,
object_path, immutable_properties, error);
diff --git a/tests/dbus/base-client.c b/tests/dbus/base-client.c
index 4b76501..674b365 100644
--- a/tests/dbus/base-client.c
+++ b/tests/dbus/base-client.c
@@ -1026,6 +1026,7 @@ test_handler_requests (Test *test,
GHashTable *info;
TpChannelRequest *request;
GList *requests;
+ GHashTable *request_props;
tp_base_client_take_handler_filter (test->base_client, tp_asv_new (
TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
@@ -1090,7 +1091,12 @@ test_handler_requests (Test *test,
requests_satisified = g_ptr_array_sized_new (1);
g_ptr_array_add (requests_satisified, "/Request");
- info = g_hash_table_new (NULL, NULL);
+ request_props = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (request_props, "/Request", properties);
+ info = tp_asv_new (
+ "request-properties", TP_HASH_TYPE_OBJECT_IMMUTABLE_PROPERTIES_MAP,
+ request_props,
+ NULL);
tp_proxy_add_interface_by_id (TP_PROXY (test->client),
TP_IFACE_QUARK_CLIENT_HANDLER);
@@ -1133,6 +1139,7 @@ test_handler_requests (Test *test,
g_ptr_array_unref (channels);
g_ptr_array_unref (requests_satisified);
g_hash_table_unref (info);
+ g_hash_table_unref (request_props);
}
static void
diff --git a/tests/lib/simple-channel-dispatcher.c b/tests/lib/simple-channel-dispatcher.c
index 1eaf13e..e225976 100644
--- a/tests/lib/simple-channel-dispatcher.c
+++ b/tests/lib/simple-channel-dispatcher.c
@@ -74,7 +74,8 @@ create_channel_request (TpTestsSimpleChannelDispatcher *self,
GHashTable *request,
gint64 user_action_time,
const gchar *preferred_handler,
- GHashTable *hints_)
+ GHashTable *hints_,
+ GHashTable **out_immutable_properties)
{
TpTestsSimpleChannelRequest *chan_request;
GPtrArray *requests;
@@ -112,6 +113,9 @@ create_channel_request (TpTestsSimpleChannelDispatcher *self,
g_signal_emit (self, signals[CHANNEL_REQUEST_CREATED], 0, chan_request);
+ *out_immutable_properties =
+ tp_tests_simple_channel_request_dup_immutable_props (chan_request);
+
return path;
}
@@ -127,6 +131,7 @@ tp_tests_simple_channel_dispatcher_create_channel (
{
TpTestsSimpleChannelDispatcher *self = SIMPLE_CHANNEL_DISPATCHER (dispatcher);
gchar *path;
+ GHashTable *immutable_properties;
tp_clear_pointer (&self->last_request, g_hash_table_unref);
self->last_request = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP, request);
@@ -149,15 +154,16 @@ tp_tests_simple_channel_dispatcher_create_channel (
}
path = create_channel_request (self, account, request, user_action_time,
- preferred_handler, hints);
+ preferred_handler, hints, &immutable_properties);
if (path == NULL)
return;
tp_svc_channel_dispatcher_return_from_create_channel (context,
- path);
+ path, immutable_properties);
g_free (path);
+ g_hash_table_unref (immutable_properties);
}
static void
@@ -172,6 +178,7 @@ tp_tests_simple_channel_dispatcher_ensure_channel (
{
TpTestsSimpleChannelDispatcher *self = SIMPLE_CHANNEL_DISPATCHER (dispatcher);
gchar *path;
+ GHashTable *immutable_properties;
tp_clear_pointer (&self->last_request, g_hash_table_unref);
self->last_request = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP, request);
@@ -187,20 +194,21 @@ tp_tests_simple_channel_dispatcher_ensure_channel (
{
/* Pretend that the channel already exists */
path = create_channel_request (self, account, request, user_action_time,
- self->priv->old_handler, hints);
+ self->priv->old_handler, hints, &immutable_properties);
}
else
{
self->priv->old_handler = g_strdup (preferred_handler);
path = create_channel_request (self, account, request, user_action_time,
- preferred_handler, hints);
+ preferred_handler, hints, &immutable_properties);
}
tp_svc_channel_dispatcher_return_from_ensure_channel (context,
- path);
+ path, immutable_properties);
g_free (path);
+ g_hash_table_unref (immutable_properties);
}
static void
More information about the telepathy-commits
mailing list