[next] telepathy-gabble: add gabble_au_variant_to_garray()

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Fri May 16 06:05:42 PDT 2014


Module: telepathy-gabble
Branch: next
Commit: 994c3d74942e55ca6550f7b3341816642bccbb93
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=994c3d74942e55ca6550f7b3341816642bccbb93

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Thu May 15 16:48:46 2014 +0200

add gabble_au_variant_to_garray()

To help us getting rid of tp_handle_set_to_array()

---

 src/util.c |   24 ++++++++++++++++++++++++
 src/util.h |    2 ++
 2 files changed, 26 insertions(+)

diff --git a/src/util.c b/src/util.c
index dad3859..54ec774 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1218,3 +1218,27 @@ gabble_simple_async_countdown_dec (GSimpleAsyncResult *simple)
       g_object_unref (simple);
     }
 }
+
+/**
+ * gabble_au_variant_to_garray:
+ * @variant: a #GVariant of type 'au' (array of uint32), consumed if floating
+ *
+ * Returns: (transfer full): a new #GArray containing the same elements as
+ * @variant
+ */
+GArray *
+gabble_au_variant_to_garray (GVariant *variant)
+{
+  const guint32 *tmp;
+  GArray *array;
+  gsize n;
+
+  g_variant_ref_sink (variant);
+
+  tmp = g_variant_get_fixed_array (variant, &n, sizeof (guint32));
+  array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), n);
+  g_array_append_vals (array, tmp, n);
+
+  g_variant_unref (variant);
+  return array;
+}
diff --git a/src/util.h b/src/util.h
index e01ff7e..f5b3a14 100644
--- a/src/util.h
+++ b/src/util.h
@@ -111,6 +111,8 @@ GSimpleAsyncResult *gabble_simple_async_countdown_new (gpointer self,
 void gabble_simple_async_countdown_inc (GSimpleAsyncResult *simple);
 void gabble_simple_async_countdown_dec (GSimpleAsyncResult *simple);
 
+GArray * gabble_au_variant_to_garray (GVariant *variant);
+
 /* Boilerplate for telling servers which implement XEP-0079 not to store these
  * messages for delivery later. Include it in your call to wocky_stanza_build()
  * like so:



More information about the telepathy-commits mailing list