From 442e4eca2e47a3a93348bc90a262e9e574cea193 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 12 May 2014 14:15:19 +0200 Subject: [PATCH 09/11] _tp_client_factory_ensure_channel_request: take a GVariant Reduce the number of TpAsv <-> G_VARIANT_TYPE_VARDICT conversions in client code. --- telepathy-glib/account-channel-request.c | 2 +- telepathy-glib/base-client.c | 10 ++-------- telepathy-glib/client-factory-internal.h | 2 +- telepathy-glib/client-factory.c | 17 ++++++++--------- tests/dbus/channel-request.c | 2 +- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c index c5b5649..90b0027 100644 --- a/telepathy-glib/account-channel-request.c +++ b/telepathy-glib/account-channel-request.c @@ -825,7 +825,7 @@ acr_request_cb (TpChannelDispatcher *cd, self->priv->chan_request = _tp_client_factory_ensure_channel_request ( tp_proxy_get_factory (self->priv->account), channel_request_path, - properties, &err); + tp_asv_to_vardict (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 e48cce0..4266fbe 100644 --- a/telepathy-glib/base-client.c +++ b/telepathy-glib/base-client.c @@ -1588,12 +1588,10 @@ create_channel_request_array (TpBaseClient *self, while (g_variant_iter_next (&iter, "{o@a{sv}}", &key, &value)) { const gchar *req_path = key; - GHashTable *props = tp_asv_from_vardict (value); TpChannelRequest *request; request = _tp_client_factory_ensure_channel_request ( - self->priv->factory, req_path, props, error); - g_hash_table_unref (props); + self->priv->factory, req_path, value, error); g_variant_unref (value); if (request == NULL) @@ -2301,11 +2299,9 @@ _tp_base_client_add_request (TpSvcClientInterfaceRequests *iface, GError *error = NULL; channel_request_prepare_account_ctx *ctx; GArray *account_features; - GHashTable *asv; - asv = tp_asv_from_vardict (properties); request = _tp_client_factory_ensure_channel_request ( - self->priv->factory, path, asv, &error); + self->priv->factory, path, properties, &error); if (request == NULL) { DEBUG ("Failed to create TpChannelRequest: %s", error->message); @@ -2339,14 +2335,12 @@ _tp_base_client_add_request (TpSvcClientInterfaceRequests *iface, channel_request_account_prepare_cb, ctx); g_array_unref (account_features); - g_hash_table_unref (asv); tp_svc_client_interface_requests_return_from_add_request (context); return TRUE; err: g_clear_object (&account); - g_hash_table_unref (asv); g_dbus_method_invocation_take_error (context, error); return TRUE; diff --git a/telepathy-glib/client-factory-internal.h b/telepathy-glib/client-factory-internal.h index 43d04dd..55db35b 100644 --- a/telepathy-glib/client-factory-internal.h +++ b/telepathy-glib/client-factory-internal.h @@ -32,7 +32,7 @@ void _tp_client_factory_insert_proxy (TpClientFactory *self, TpChannelRequest *_tp_client_factory_ensure_channel_request ( TpClientFactory *self, const gchar *object_path, - GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error); TpChannelDispatchOperation * diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c index 416161e..d182624 100644 --- a/telepathy-glib/client-factory.c +++ b/telepathy-glib/client-factory.c @@ -1410,8 +1410,9 @@ tp_client_factory_add_contact_features_varargs ( * _tp_client_factory_ensure_channel_request: * @self: a #TpClientFactory object * @object_path: the object path of a channel request - * @immutable_properties: (transfer none) (element-type utf8 GObject.Value): - * the immutable properties of the channel request + * @immutable_properties: (allow-none): the immutable properties of the channel + * request as %G_VARIANT_TYPE_VARDICT; ownership is taken + * if floating * @error: Used to raise an error if @object_path is not valid * * Returns a #TpChannelRequest for @object_path. The returned @@ -1430,11 +1431,10 @@ tp_client_factory_add_contact_features_varargs ( TpChannelRequest * _tp_client_factory_ensure_channel_request (TpClientFactory *self, const gchar *object_path, - GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error) { TpChannelRequest *request; - GVariant *props; g_return_val_if_fail (TP_IS_CLIENT_FACTORY (self), NULL); g_return_val_if_fail (g_variant_is_object_path (object_path), NULL); @@ -1444,11 +1444,10 @@ _tp_client_factory_ensure_channel_request (TpClientFactory *self, if (request != NULL) return g_object_ref (request); - props = tp_asv_to_vardict (immutable_properties); - - g_variant_ref_sink (props); - request = _tp_channel_request_new (self, object_path, props, error); - g_variant_unref (props); + g_variant_ref_sink (immutable_properties); + request = _tp_channel_request_new (self, object_path, immutable_properties, + error); + g_variant_unref (immutable_properties); insert_proxy (self, request); return request; diff --git a/tests/dbus/channel-request.c b/tests/dbus/channel-request.c index 988e0a6..17be53d 100644 --- a/tests/dbus/channel-request.c +++ b/tests/dbus/channel-request.c @@ -153,7 +153,7 @@ channel_request_new (GDBusConnection *bus_connection, factory = tp_client_factory_new (bus_connection); self = _tp_client_factory_ensure_channel_request (factory, object_path, - immutable_properties, error); + tp_asv_to_vardict (immutable_properties), error); g_object_unref (factory); g_hash_table_unref (immutable_properties); -- 1.9.0