From 460e6c2e35357e4df5379f5f76378d6833c7c34b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 8 May 2012 11:14:24 +0200 Subject: [PATCH] Add GVariant converters from tp-glib https://bugzilla.gnome.org/show_bug.cgi?id=676634 --- libempathy/empathy-utils.c | 29 +++++++++++++++++++++++++++++ libempathy/empathy-utils.h | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index 30d40e9a..7d6c8c06 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -1273,3 +1273,32 @@ while_finish: return types; } + +GVariant * +empathy_asv_to_vardict (const GHashTable *asv) +{ + return empathy_boxed_to_variant (TP_HASH_TYPE_STRING_VARIANT_MAP, "a{sv}", + (gpointer) asv); +} + +GVariant * +empathy_boxed_to_variant (GType gtype, + const gchar *variant_type, + gpointer boxed) +{ + GValue v = G_VALUE_INIT; + GVariant *ret; + + g_return_val_if_fail (boxed != NULL, NULL); + + g_value_init (&v, gtype); + g_value_set_boxed (&v, boxed); + + ret = dbus_g_value_build_g_variant (&v); + g_return_val_if_fail (!tp_strdiff (g_variant_get_type_string (ret), + variant_type), NULL); + + g_value_unset (&v); + + return g_variant_ref_sink (ret); +} diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index dae25060..a31ed34f 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -130,6 +130,12 @@ FolksIndividual * empathy_ensure_individual_from_tp_contact ( const gchar * const * empathy_individual_get_client_types ( FolksIndividual *individual); +GVariant * empathy_asv_to_vardict (const GHashTable *asv); + +GVariant * empathy_boxed_to_variant (GType gtype, + const gchar *variant_type, + gpointer boxed); + /* Copied from wocky/wocky-utils.h */ #define empathy_implement_finish_void(source, tag) \ -- 2.39.2