From f9b3e78ab42909596263d3fb097985dd386230cd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 8 Mar 2012 12:51:41 +0000 Subject: [PATCH 4/7] tp_account_dup_storage_specific_information_vardict_async: add This is just like tp_account_get_storage_specific_information_async, but with more GVariant. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30422 --- docs/reference/telepathy-glib-sections.txt | 2 + telepathy-glib/account.c | 54 ++++++++++++++++++++++++++++ telepathy-glib/account.h | 8 ++++ tests/dbus/account.c | 29 +++++++++++++++ 4 files changed, 93 insertions(+), 0 deletions(-) diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index ced5da7..bf3b392 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -5118,6 +5118,8 @@ tp_account_dup_storage_identifier_variant tp_account_get_storage_restrictions tp_account_get_storage_specific_information_async tp_account_get_storage_specific_information_finish +tp_account_dup_storage_specific_information_vardict_async +tp_account_dup_storage_specific_information_vardict_finish tp_account_get_feature_quark_core tp_account_get_feature_quark_connection diff --git a/telepathy-glib/account.c b/telepathy-glib/account.c index 7b0b01b..7b3ce36 100644 --- a/telepathy-glib/account.c +++ b/telepathy-glib/account.c @@ -36,6 +36,7 @@ #define DEBUG_FLAG TP_DEBUG_ACCOUNTS #include "telepathy-glib/connection-internal.h" +#include "telepathy-glib/dbus-internal.h" #include "telepathy-glib/debug-internal.h" #include "telepathy-glib/proxy-internal.h" #include "telepathy-glib/simple-client-factory-internal.h" @@ -3786,6 +3787,7 @@ _tp_account_get_storage_specific_information_cb (TpProxy *self, g_object_unref (result); } +/* FIXME: in Telepathy 1.0, remove this */ /** * tp_account_get_storage_specific_information_async: * @self: a #TpAccount @@ -3818,6 +3820,33 @@ tp_account_get_storage_specific_information_async (TpAccount *self, _tp_account_get_storage_specific_information_cb, result, NULL, NULL); } +/* FIXME: in Telepathy 1.0, rename to ...get_storage_specific_information... */ +/** + * tp_account_dup_storage_specific_information_vardict_async: + * @self: a #TpAccount + * @callback: a callback to call when the request is satisfied + * @user_data: data to pass to @callback + * + * Makes an asynchronous request of @self's StorageSpecificInformation + * property (part of the Account.Interface.Storage interface). + * + * When the operation is finished, @callback will be called. You must then + * call tp_account_dup_storage_specific_information_vardict_finish() to get the + * result of the request. + * + * Since: 0.UNRELEASED + */ +void +tp_account_dup_storage_specific_information_vardict_async (TpAccount *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + /* we share an implementation */ + tp_account_get_storage_specific_information_async (self, callback, + user_data); +} + +/* FIXME: in Telepathy 1.0, remove this */ /** * tp_account_get_storage_specific_information_finish: * @self: a #TpAccount @@ -3844,6 +3873,31 @@ tp_account_get_storage_specific_information_finish (TpAccount *self, tp_account_get_storage_specific_information_async, /* do not copy */); } +/* FIXME: in Telepathy 1.0, rename to ...get_storage_specific_information... */ +/** + * tp_account_dup_storage_specific_information_vardict_finish: + * @self: a #TpAccount + * @result: a #GAsyncResult + * @error: a #GError to fill + * + * Retrieve the value of the request begun with + * tp_account_dup_storage_specific_information_vardict_async(). + * + * Returns: (transfer full): a map from strings to variants, + * of type %G_VARIANT_TYPE_VARDICT + * + * Since: 0.13.2 + */ +GVariant * +tp_account_dup_storage_specific_information_vardict_finish (TpAccount *self, + GAsyncResult *result, + GError **error) +{ + /* we share the source tag with the non-vardict version */ + _tp_implement_finish_return_copy_pointer (self, + tp_account_get_storage_specific_information_async, _tp_asv_to_vardict); +} + static void _tp_account_got_all_addressing_cb (TpProxy *proxy, GHashTable *properties, diff --git a/telepathy-glib/account.h b/telepathy-glib/account.h index d5a57e2..71445ae 100644 --- a/telepathy-glib/account.h +++ b/telepathy-glib/account.h @@ -248,6 +248,14 @@ void tp_account_get_storage_specific_information_async (TpAccount *self, GAsyncReadyCallback callback, gpointer user_data); GHashTable *tp_account_get_storage_specific_information_finish (TpAccount *self, GAsyncResult *result, GError **error); +void tp_account_dup_storage_specific_information_vardict_async ( + TpAccount *self, + GAsyncReadyCallback callback, + gpointer user_data); +GVariant *tp_account_dup_storage_specific_information_vardict_finish ( + TpAccount *self, + GAsyncResult *result, + GError **error); const gchar * const * /* ugh, gtk-doc */ diff --git a/tests/dbus/account.c b/tests/dbus/account.c index 7c268f3..ca9240a 100644 --- a/tests/dbus/account.c +++ b/tests/dbus/account.c @@ -478,6 +478,10 @@ test_storage (Test *test, GVariant *gvariant; GHashTable *info; GError *error = NULL; + gboolean found; + gint32 i; + guint32 u; + const gchar *s; test->account = tp_account_new (test->dbus, ACCOUNT_PATH, NULL); g_assert (test->account != NULL); @@ -562,6 +566,31 @@ test_storage (Test *test, g_assert_cmpstr (tp_asv_get_string (info, "marco"), ==, "polo"); tp_clear_object (&test->result); + + /* the same, but with 100% more GVariant */ + tp_account_dup_storage_specific_information_vardict_async (test->account, + tp_tests_result_ready_cb, &test->result); + tp_tests_run_until_result (&test->result); + + gvariant = tp_account_dup_storage_specific_information_vardict_finish ( + test->account, test->result, &error); + g_assert_no_error (error); + + g_assert_cmpstr (g_variant_get_type_string (gvariant), ==, "a{sv}"); + found = g_variant_lookup (gvariant, "one", "i", &i); + g_assert (found); + g_assert_cmpint (i, ==, 1); + found = g_variant_lookup (gvariant, "two", "u", &u); + g_assert (found); + g_assert_cmpint (u, ==, 2); + found = g_variant_lookup (gvariant, "marco", "&s", &s); + g_assert (found); + g_assert_cmpstr (s, ==, "polo"); + found = g_variant_lookup (gvariant, "barisione", "&s", &s); + g_assert (!found); + + g_variant_unref (gvariant); + tp_clear_object (&test->result); } static void -- 1.7.9.1