telepathy-glib: add _tp_asv_from_vardict()

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Wed May 9 03:15:58 PDT 2012


Module: telepathy-glib
Branch: master
Commit: 55cb32b5bd54e8f2ca59f62c13b7ab9514ae10bd
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=55cb32b5bd54e8f2ca59f62c13b7ab9514ae10bd

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Thu Apr 19 11:45:43 2012 +0200

add _tp_asv_from_vardict()

---

 telepathy-glib/dbus-internal.h |    2 ++
 telepathy-glib/dbus.c          |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/telepathy-glib/dbus-internal.h b/telepathy-glib/dbus-internal.h
index 50259a5..aade667 100644
--- a/telepathy-glib/dbus-internal.h
+++ b/telepathy-glib/dbus-internal.h
@@ -43,6 +43,8 @@ GVariant * _tp_boxed_to_variant (GType gtype,
     const gchar *variant_type,
     gpointer boxed);
 
+GHashTable * _tp_asv_from_vardict (GVariant *variant);
+
 G_END_DECLS
 
 #endif /* __TP_INTERNAL_DBUS_GLIB_H__ */
diff --git a/telepathy-glib/dbus.c b/telepathy-glib/dbus.c
index 4ef2fcf..aaffce2 100644
--- a/telepathy-glib/dbus.c
+++ b/telepathy-glib/dbus.c
@@ -1984,3 +1984,29 @@ _tp_boxed_to_variant (GType gtype,
 
   return g_variant_ref_sink (ret);
 }
+
+/*
+ * _tp_asv_from_vardict:
+ * @variant: a #GVariant of type %G_VARIANT_TYPE_VARDICT
+ *
+ * Returns: (transfer full): a newly created #GHashTable of
+ * type #TP_HASH_TYPE_STRING_VARIANT_MAP
+ */
+GHashTable *
+_tp_asv_from_vardict (GVariant *variant)
+{
+  GValue v = G_VALUE_INIT;
+  GHashTable *result;
+
+  g_return_val_if_fail (variant != NULL, NULL);
+  g_return_val_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_VARDICT),
+      NULL);
+
+  dbus_g_value_parse_g_variant (variant, &v);
+  g_assert (G_VALUE_HOLDS (&v, TP_HASH_TYPE_STRING_VARIANT_MAP));
+
+  result = g_value_dup_boxed (&v);
+
+  g_value_unset (&v);
+  return result;
+}



More information about the telepathy-commits mailing list