From d113ed3da8d3d48ec346a571dec14b5b15f16aaa Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 8 Mar 2012 13:31:27 +0000 Subject: [PATCH 5/7] tp_account_dup_parameters_vardict: add Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30422 --- docs/reference/telepathy-glib-sections.txt | 1 + telepathy-glib/account.c | 30 ++++++++++++++++++++++++++++ telepathy-glib/account.h | 1 + tests/dbus/account.c | 5 ++++ 4 files changed, 37 insertions(+), 0 deletions(-) diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index bf3b392..0fb0a5e 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -5088,6 +5088,7 @@ tp_account_get_current_presence tp_account_get_requested_presence tp_account_get_automatic_presence tp_account_get_parameters +tp_account_dup_parameters_vardict tp_account_get_nickname tp_account_set_nickname_async tp_account_set_nickname_finish diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c index 7b3ce36..2ff7f85 100644 --- a/telepathy-glib/account.c +++ b/telepathy-glib/account.c @@ -2353,6 +2353,36 @@ tp_account_get_parameters (TpAccount *account) } /** + * tp_account_dup_parameters_vardict: + * @account: a #TpAccount + * + * Returns the parameters of the account, in a variant of type + * %G_VARIANT_TYPE_VARDICT where the keys + * are parameter names (account, password, require-encryption etc.). + * Use g_variant_lookup() or g_variant_lookup_value() for convenient + * access to the values. + * + * The allowed parameters depend on the connection manager, and can be found + * via tp_connection_manager_get_protocol() and + * tp_connection_manager_protocol_get_param(). Well-known parameters are + * listed + * in + * the Telepathy D-Bus Interface Specification. + * + * Returns: (transfer full): the dictionary of + * parameters on @account, of type %G_VARIANT_TYPE_VARDICT + * + * Since: 0.UNRELEASED + */ +GVariant * +tp_account_dup_parameters_vardict (TpAccount *account) +{ + g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); + + return _tp_asv_to_vardict (account->priv->parameters); +} + +/** * tp_account_is_enabled: * @account: a #TpAccount * diff --git a/telepathy-glib/account.h b/telepathy-glib/account.h index 71445ae..4b38fbc 100644 --- a/telepathy-glib/account.h +++ b/telepathy-glib/account.h @@ -197,6 +197,7 @@ TpConnectionPresenceType tp_account_get_automatic_presence ( TpAccount *self, gchar **status, gchar **status_message); const GHashTable *tp_account_get_parameters (TpAccount *account); +GVariant *tp_account_dup_parameters_vardict (TpAccount *account); const gchar *tp_account_get_nickname (TpAccount *account); diff --git a/tests/dbus/account.c b/tests/dbus/account.c index ca9240a..a272da0 100644 --- a/tests/dbus/account.c +++ b/tests/dbus/account.c @@ -346,6 +346,7 @@ test_prepare_success (Test *test, const GHashTable *details = GUINT_TO_POINTER (666); GStrv strv; const gchar * const *cstrv; + GVariant *variant; test->account = tp_account_new (test->dbus, ACCOUNT_PATH, NULL); g_assert (test->account != NULL); @@ -367,6 +368,10 @@ test_prepare_success (Test *test, assert_strprop (test->account, "nickname", "badger"); g_assert_cmpuint (tp_asv_size (tp_account_get_parameters (test->account)), ==, 0); + variant = tp_account_dup_parameters_vardict (test->account); + g_assert_cmpstr (g_variant_get_type_string (variant), ==, "a{sv}"); + g_assert_cmpuint (g_variant_n_children (variant), ==, 0); + g_variant_unref (variant); g_assert (!tp_account_get_connect_automatically (test->account)); assert_boolprop (test->account, "connect-automatically", FALSE); g_assert (tp_account_get_has_been_online (test->account)); -- 1.7.9.1