From 3f1f9fb230e78f98605e25d848a9dee930866fd7 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 27 Feb 2014 13:07:16 +0100 Subject: [PATCH 1/6] client-factory: take a vardict for new account props --- telepathy-glib/client-factory.c | 28 ++++++++++++++++++++-------- telepathy-glib/client-factory.h | 4 ++-- tests/logger/dbus/test-tpl-log-iter-pidgin.c | 2 +- tests/logger/dbus/test-tpl-log-walker.c | 2 +- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/telepathy-glib/client-factory.c b/telepathy-glib/client-factory.c index 0e5f602..81502df 100644 --- a/telepathy-glib/client-factory.c +++ b/telepathy-glib/client-factory.c @@ -193,7 +193,7 @@ _tp_client_factory_insert_proxy (TpClientFactory *self, static TpAccount * create_account_impl (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties G_GNUC_UNUSED, + GVariant *immutable_properties G_GNUC_UNUSED, GError **error) { return _tp_account_new_with_factory (self, self->priv->dbus, object_path, @@ -435,8 +435,8 @@ tp_client_factory_get_dbus_daemon (TpClientFactory *self) * tp_client_factory_ensure_account: * @self: a #TpClientFactory object * @object_path: the object path of an account - * @immutable_properties: (transfer none) (element-type utf8 GObject.Value): - * the immutable properties of the account, or %NULL. + * @immutable_properties: (allow-none) a #G_VARIANT_TYPE_VARDICT containing + * the immutable properties of the account, or %NULL. * @error: Used to raise an error if @object_path is not valid * * Returns a #TpAccount proxy for the account at @object_path. The returned @@ -451,6 +451,8 @@ tp_client_factory_get_dbus_daemon (TpClientFactory *self) * and #TpAccountManager::usability-changed are more appropriate for most * applications. * + * @immutable_properties is consumed if it is floating. + * * Returns: (transfer full): a reference to a #TpAccount; * see tp_account_new(). * @@ -459,7 +461,7 @@ tp_client_factory_get_dbus_daemon (TpClientFactory *self) TpAccount * tp_client_factory_ensure_account (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error) { TpAccount *account; @@ -469,11 +471,21 @@ tp_client_factory_ensure_account (TpClientFactory *self, account = lookup_proxy (self, object_path); if (account != NULL) - return g_object_ref (account); + { + g_object_ref (account); + } + else + { + account = TP_CLIENT_FACTORY_GET_CLASS (self)->create_account (self, + object_path, immutable_properties, error); + insert_proxy (self, account); + } - account = TP_CLIENT_FACTORY_GET_CLASS (self)->create_account (self, - object_path, immutable_properties, error); - insert_proxy (self, account); + if (immutable_properties != NULL) + { + g_variant_ref_sink (immutable_properties); + g_variant_unref (immutable_properties); + } return account; } diff --git a/telepathy-glib/client-factory.h b/telepathy-glib/client-factory.h index ff59c3b..bf3e698 100644 --- a/telepathy-glib/client-factory.h +++ b/telepathy-glib/client-factory.h @@ -46,7 +46,7 @@ struct _TpClientFactoryClass { /* TpAccount */ TpAccount * (*create_account) (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error); GArray * (*dup_account_features) (TpClientFactory *self, TpAccount *account); @@ -111,7 +111,7 @@ TpDBusDaemon *tp_client_factory_get_dbus_daemon (TpClientFactory *self); /* TpAccount */ TpAccount *tp_client_factory_ensure_account (TpClientFactory *self, const gchar *object_path, - const GHashTable *immutable_properties, + GVariant *immutable_properties, GError **error); GArray *tp_client_factory_dup_account_features (TpClientFactory *self, TpAccount *account); diff --git a/tests/logger/dbus/test-tpl-log-iter-pidgin.c b/tests/logger/dbus/test-tpl-log-iter-pidgin.c index 48810e8..63ad87e 100644 --- a/tests/logger/dbus/test-tpl-log-iter-pidgin.c +++ b/tests/logger/dbus/test-tpl-log-iter-pidgin.c @@ -93,7 +93,7 @@ setup (PidginTestCaseFixture* fixture, fixture->account = tp_client_factory_ensure_account (fixture->factory, tp_asv_get_string (params, "account-path"), - params, + tp_asv_to_vardict (params), &error); g_assert_no_error (error); g_assert (fixture->account != NULL); diff --git a/tests/logger/dbus/test-tpl-log-walker.c b/tests/logger/dbus/test-tpl-log-walker.c index 5a8e721..5edb5d1 100644 --- a/tests/logger/dbus/test-tpl-log-walker.c +++ b/tests/logger/dbus/test-tpl-log-walker.c @@ -93,7 +93,7 @@ setup (WalkerTestCaseFixture* fixture, fixture->account = tp_client_factory_ensure_account (fixture->factory, tp_asv_get_string (params, "account-path"), - params, + tp_asv_to_vardict (params), &error); g_assert_no_error (error); g_assert (fixture->account != NULL); -- 1.8.5.3