From c011166a0555d8c1d67a8f3eb43303935f0eebb8 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 25 Apr 2012 10:21:14 +0200 Subject: [PATCH] add _tp_boxed_to_variant() https://bugs.freedesktop.org/show_bug.cgi?id=30422 --- telepathy-glib/dbus-internal.h | 4 ++++ telepathy-glib/dbus.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/telepathy-glib/dbus-internal.h b/telepathy-glib/dbus-internal.h index fda71b8..1c34728 100644 --- a/telepathy-glib/dbus-internal.h +++ b/telepathy-glib/dbus-internal.h @@ -38,6 +38,10 @@ gboolean _tp_dbus_daemon_is_the_shared_one (TpDBusDaemon *self); GVariant *_tp_asv_to_vardict (const GHashTable *asv); +GVariant * _tp_boxed_to_variant (GType gtype, + const gchar *variant_type, + gpointer boxed); + G_END_DECLS #endif /* __TP_INTERNAL_DBUS_GLIB_H__ */ diff --git a/telepathy-glib/dbus.c b/telepathy-glib/dbus.c index 8e40db4..8b41484 100644 --- a/telepathy-glib/dbus.c +++ b/telepathy-glib/dbus.c @@ -1974,3 +1974,24 @@ _tp_asv_to_vardict (const GHashTable *asv) return g_variant_ref_sink (ret); } + +GVariant * +_tp_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); +} -- 1.7.7.6