From 56113a03eb61eb40d7dcdb524bb2fbc68b93c20c Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 27 Feb 2014 13:07:16 +0100 Subject: [PATCH 3/6] client-factory: take a vardict for new connection props --- telepathy-glib/client-factory.c | 28 ++++++++++++++++++++-------- telepathy-glib/client-factory.h | 4 ++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c index 81502df..7b5242e 100644 --- a/telepathy-glib/client-factory.c +++ b/telepathy-glib/client-factory.c @@ -211,7 +211,7 @@ dup_account_features_impl (TpClientFactory *self, static TpConnection * create_connection_impl (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties G_GNUC_UNUSED, + GVariant *immutable_properties, GError **error) { return _tp_connection_new_with_factory (self, self->priv->dbus, NULL, @@ -575,8 +575,8 @@ tp_client_factory_add_account_features_varargs ( * tp_client_factory_ensure_connection: * @self: a #TpClientFactory object * @object_path: the object path of a connection - * @immutable_properties: (transfer none) (element-type utf8 GObject.Value): - * the immutable properties of the connection. + * @immutable_properties: (allow-none) a #G_VARIANT_TYPE_VARDICT containing + * the immutable properties of the connection, or %NULL. * @error: Used to raise an error if @object_path is not valid * * Returns a #TpConnection proxy for the connection at @object_path. @@ -591,6 +591,8 @@ tp_client_factory_add_account_features_varargs ( * This function is rather low-level. #TpAccount:connection is more * appropriate for most applications. * + * @immutable_properties is consumed if it is floating. + * * Returns: (transfer full): a reference to a #TpConnection; * see tp_connection_new(). * @@ -599,7 +601,7 @@ tp_client_factory_add_account_features_varargs ( TpConnection * tp_client_factory_ensure_connection (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error) { TpConnection *connection; @@ -609,11 +611,21 @@ tp_client_factory_ensure_connection (TpClientFactory *self, connection = lookup_proxy (self, object_path); if (connection != NULL) - return g_object_ref (connection); + { + g_object_ref (connection); + } + else + { + connection = TP_CLIENT_FACTORY_GET_CLASS (self)->create_connection ( + self, object_path, immutable_properties, error); + insert_proxy (self, connection); + } - connection = TP_CLIENT_FACTORY_GET_CLASS (self)->create_connection ( - self, object_path, immutable_properties, error); - insert_proxy (self, connection); + if (immutable_properties != NULL) + { + g_variant_ref_sink (immutable_properties); + g_variant_unref (immutable_properties); + } return connection; } diff --git a/telepathy-glib/client-factory.h b/telepathy-glib/client-factory.h index bf3e698..4806fce 100644 --- a/telepathy-glib/client-factory.h +++ b/telepathy-glib/client-factory.h @@ -54,7 +54,7 @@ struct _TpClientFactoryClass { /* TpConnection */ TpConnection * (*create_connection) (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error); GArray * (*dup_connection_features) (TpClientFactory *self, TpConnection *connection); @@ -124,7 +124,7 @@ void tp_client_factory_add_account_features_varargs (TpClientFactory *self, /* TpConnection */ TpConnection *tp_client_factory_ensure_connection (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error); GArray *tp_client_factory_dup_connection_features (TpClientFactory *self, TpConnection *connection); -- 1.8.5.3