cpw.gillux.detachablepurple: 139bdde6: Moved the purple_gvariant_to_gvalue_clos...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Fri May 25 15:46:46 EDT 2012


----------------------------------------------------------------------
Revision: 139bdde60c2b48c4fcd34fbb292af055037c7d31
Parent:   fad7a50592f4e344ee6ce2e893437a3ca336f75e
Author:   gillux at soc.pidgin.im
Date:     05/25/12 13:59:44
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/139bdde60c2b48c4fcd34fbb292af055037c7d31

Changelog: 

Moved the purple_gvariant_to_gvalue_closure_args() function to util.c,
so that it will be available for the D-Bus user-provided callbacks part.

Changes against parent fad7a50592f4e344ee6ce2e893437a3ca336f75e

  patched  libpurple/pobject.c
  patched  libpurple/util.c
  patched  libpurple/util.h

-------------- next part --------------
============================================================
--- libpurple/util.c	251cf6ffea4244225c552414b576e631f0a75fd8
+++ libpurple/util.c	c9c7350b30a026305b8dca1a284bc9009cce679b
@@ -36,6 +36,8 @@
 #include "prefs.h"
 #include "util.h"
 
+#include "glib-2.30.h"
+
 struct _PurpleUtilFetchUrlData
 {
 	PurpleUtilFetchUrlCallback callback;
@@ -5264,3 +5266,28 @@ purple_uuid_random(void)
 			b,
 			(tmp >> 16) & 0xFFFF, g_random_int());
 }
+
+void
+purple_gvariant_to_gvalue_closure_args(gpointer object, GVariant *params,
+                                       GValue **paramv, guint *num_params)
+{
+	GVariant *next;
+	GVariantIter iter;
+	GValue *gval;
+	guint i;
+
+	*num_params = g_variant_n_children(params) + 1;
+	*paramv = gval = g_new0(GValue, *num_params);
+
+	/* Put the right parameters in paramv. First, the object. */
+	g_value_init (&gval[0], G_TYPE_FROM_INSTANCE(object));
+	g_value_set_object (&gval[0], object);
+	/* 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);
+	}
+}
+
============================================================
--- libpurple/util.h	9a9824b25fe3a2ffab1251bc4cc8c12af0ca01d2
+++ libpurple/util.h	256dca350296c9bc185478bfc6e5194c1b3e092f
@@ -1526,6 +1526,24 @@ gchar *purple_http_digest_calculate_resp
 		const gchar *nonce_count, const gchar *client_nonce,
 		const gchar *session_key);
 
+/*
+ * Converts a set of GVariant parameters into a GValue array with the
+ * 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 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++)
+ *                 g_value_unset (&paramv[i]);
+ *               g_free (paramv);
+ * @param num_params A pointer to a value filled with the size of the
+ *                   newly-created paramv array.
+ *
+ */
+void
+purple_gvariant_to_gvalue_closure_args(gpointer object, GVariant *params,
+                                       GValue **paramv, guint *num_params);
 
 /** @name Slice-allocated GValue helpers */
 /** @{ */
============================================================
--- libpurple/pobject.c	a0b11ecbff30c88c389fbfd8856493e4576d6259
+++ libpurple/pobject.c	7da1132f15d4ccee75c7b011d38898859b54205a
@@ -751,34 +751,6 @@ purple_object_get_dbus_closure(PurpleObj
 	return ret;
 }
 
-/*
- * Converts a GVariant tuple params into a GValue array with object prepended.
- * Returns a newly allocated array in paramv, and its size in num_params.
- */
-static void
-gvariant_to_gvalue_closure_args(gpointer object, GVariant *params,
-                                GValue **paramv, guint *num_params)
-{
-	GVariant *next;
-	GVariantIter iter;
-	GValue *gval;
-	guint i;
-
-	*num_params = g_variant_n_children(params) + 1;
-	*paramv = gval = g_new0(GValue, *num_params);
-
-	/* Put the right parameters in paramv. First, the object. */
-	g_value_init (&gval[0], G_TYPE_FROM_INSTANCE(object));
-	g_value_set_object (&gval[0], object);
-	/* 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);
-	}
-}
-
 void
 purple_object_generic_dbus_method_handler(GDBusConnection       *connection,
                                           const gchar           *sender,
@@ -804,7 +776,9 @@ purple_object_generic_dbus_method_handle
 		         method_name, interface_name);
 
 	/* Prepare the closure parameters. */
-	gvariant_to_gvalue_closure_args(object, params, &paramv, &num_params);
+	purple_gvariant_to_gvalue_closure_args(object, params,
+	                                       &paramv, &num_params);
+
 /* We don't want to force such a recent version, so keep a shitty workaround. */
 #if GLIB_CHECK_VERSION(2, 32, 1)
 	g_value_init(&ret_val, G_TYPE_VARIANT);
@@ -931,7 +905,7 @@ purple_object_generic_dbus_sighandler(GD
 	}
 
 	/* Prepare the closure parameters. */
-	gvariant_to_gvalue_closure_args(object, params, &paramv, &num_params);
+	purple_gvariant_to_gvalue_closure_args(object, params, &paramv, &num_params);
 
 	/* Execute the sighandler. */
 	g_closure_invoke(closure, NULL, num_params, paramv, NULL);


More information about the Commits mailing list