/srv/mercurial-server/detachablepurple: 87872da89cb2: purple_gva...

Gilles Bedel gillux at cpw.pidgin.im
Fri Jun 15 22:01:49 EDT 2012


Changeset: 87872da89cb25b0871429e6344057db7d23aed83
Author:	 Gilles Bedel <gillux at cpw.pidgin.im>
Date:	 2012-05-25 18:22 +0000
Branch:	 cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/87872da89cb2

Description:

purple_gvariant_to_gvalue_closure_args() now accepts
either an array of GVariant or a tuple.
Will be useful for PurpleDBusCallback?s RunCallback signal.

diffstat:

 libpurple/util.c |  17 +++++++++++++----
 libpurple/util.h |   3 ++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diffs (47 lines):

diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -5271,7 +5271,7 @@
 purple_gvariant_to_gvalue_closure_args(gpointer object, GVariant *params,
                                        GValue **paramv, guint *num_params)
 {
-	GVariant *next;
+	GVariant *next, *boxed;
 	GVariantIter iter;
 	GValue *gval;
 	guint i;
@@ -5285,9 +5285,18 @@
 	/* Then the others, if any. */
 	i = 1;
 	g_variant_iter_init (&iter, params);
-	while ((next = g_variant_iter_next_value(&iter)) != NULL) {
-		g_dbus_gvariant_to_gvalue(next, &gval[i++]);
-		g_variant_unref(next);
+	if (g_variant_is_of_type(params, G_VARIANT_TYPE_ARRAY)) {
+		while ((next = g_variant_iter_next_value(&iter)) != NULL) {
+			boxed = g_variant_get_variant(next);
+			g_dbus_gvariant_to_gvalue(boxed, &gval[i++]);
+			g_variant_unref(boxed);
+			g_variant_unref(next);
+		}
+	} else if (g_variant_is_of_type(params, G_VARIANT_TYPE_TUPLE)) {
+		while ((next = g_variant_iter_next_value(&iter)) != NULL) {
+			g_dbus_gvariant_to_gvalue(next, &gval[i++]);
+			g_variant_unref(next);
+		}
 	}
 }
 
diff --git a/libpurple/util.h b/libpurple/util.h
--- a/libpurple/util.h
+++ b/libpurple/util.h
@@ -1531,7 +1531,8 @@
  * object prepended. Useful to prepare parameters for a g_closure_invoke().
  *
  * @param object The object instance prepended to the parameters.
- * @param params The parameters in a GVariant array.
+ * @param params The parameters in a GVariant. Either a tuple, or an array of
+ *               GVariants.
  * @param paramv A pointer to an array of GValues that will be created. It
  *               must be freed with something like:
  *               for (i = 0; i < num_params; i++)



More information about the Commits mailing list