summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2014-05-12 14:15:19 +0200
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-09-17 14:13:31 +0100
commit1ad31f448204fcbaa2dc75ee38391bceefa462d1 (patch)
treedf41597ebb9e2fb306b102e1a277bec5a6d9b6b7
parente06339fe7f6a383f1d5b3871a44b9e4d4f0e0868 (diff)
downloadtelepathy-glib-1ad31f448204fcbaa2dc75ee38391bceefa462d1.tar.gz
_tp_client_factory_ensure_channel_request: take a GVariant
Reduce the number of TpAsv <-> G_VARIANT_TYPE_VARDICT conversions in client code. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77882 Reviewed-by: Simon McVittie
-rw-r--r--telepathy-glib/account-channel-request.c2
-rw-r--r--telepathy-glib/base-client.c10
-rw-r--r--telepathy-glib/client-factory-internal.h2
-rw-r--r--telepathy-glib/client-factory.c17
-rw-r--r--tests/dbus/channel-request.c2
5 files changed, 13 insertions, 20 deletions
diff --git a/telepathy-glib/account-channel-request.c b/telepathy-glib/account-channel-request.c
index c5b564968..90b00277d 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 a2adb8c31..a406aa0db 100644
--- a/telepathy-glib/base-client.c
+++ b/telepathy-glib/base-client.c
@@ -1594,12 +1594,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)
@@ -2307,11 +2305,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);
@@ -2345,14 +2341,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 43d04ddaf..55db35b6d 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 416161e69..d1826244f 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 988e0a677..17be53dc6 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);