From ad876ac46b398a4120ec316756d76041ab117192 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 8 Mar 2012 12:49:09 +0000 Subject: [PATCH 2/7] Add _tp_asv_to_vardict, a utility function to convert a{sv} representations Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30422 --- telepathy-glib/dbus-internal.h | 2 ++ telepathy-glib/dbus.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/telepathy-glib/dbus-internal.h b/telepathy-glib/dbus-internal.h index da5bbd9..fda71b8 100644 --- a/telepathy-glib/dbus-internal.h +++ b/telepathy-glib/dbus-internal.h @@ -36,6 +36,8 @@ DBusGConnection *_tp_dbus_starter_bus_conn (GError **error) gboolean _tp_dbus_daemon_is_the_shared_one (TpDBusDaemon *self); +GVariant *_tp_asv_to_vardict (const GHashTable *asv); + G_END_DECLS #endif /* __TP_INTERNAL_DBUS_GLIB_H__ */ diff --git a/telepathy-glib/dbus.c b/telepathy-glib/dbus.c index 25246c9..8e40db4 100644 --- a/telepathy-glib/dbus.c +++ b/telepathy-glib/dbus.c @@ -64,6 +64,7 @@ #include #include +#include #include #define DEBUG_FLAG TP_DEBUG_MISC @@ -1951,3 +1952,25 @@ tp_asv_dump (GHashTable *asv) g_debug ("}"); } + +/* + * _tp_asv_to_vardict: + * + * Returns: (transfer full): a #GVariant of type %G_VARIANT_TYPE_VARDICT + */ +GVariant * +_tp_asv_to_vardict (const GHashTable *asv) +{ + GValue v = G_VALUE_INIT; + GVariant *ret; + + g_value_init (&v, TP_HASH_TYPE_STRING_VARIANT_MAP); + g_value_set_boxed (&v, asv); + + ret = dbus_g_value_build_g_variant (&v); + g_assert (!tp_strdiff (g_variant_get_type_string (ret), "a{sv}")); + + g_value_unset (&v); + + return g_variant_ref_sink (ret); +} -- 1.7.9.1