summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2014-05-15 16:48:46 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2014-05-15 16:48:46 +0200
commit994c3d74942e55ca6550f7b3341816642bccbb93 (patch)
tree6f18d658dd4e55729f22f1574f8aa9e7a04936cb
parent1ba6638396a0a2f45a9fe1e6fa5c801b7a248c6e (diff)
add gabble_au_variant_to_garray()
To help us getting rid of tp_handle_set_to_array()
-rw-r--r--src/util.c24
-rw-r--r--src/util.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index dad3859d6..54ec774fa 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 e01ff7e50..f5b3a147c 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: