cpw.gillux.detachablepurple: 50866305: purple_object_generic_dbus_method_handle...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Sat May 12 16:56:38 EDT 2012


----------------------------------------------------------------------
Revision: 50866305d7e4092ce798271faba01b25f53ea33f
Parent:   0a19561803f0e8e752e0bd2483e6c0bf5fbe8560
Author:   gillux at soc.pidgin.im
Date:     05/12/12 15:14:17
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/50866305d7e4092ce798271faba01b25f53ea33f

Changelog: 

purple_object_generic_dbus_method_handler() now handles return values.
This means that any D-Bus method is now able to return values.
The method handler needs to pack its return value in a GVariant, though.

Changes against parent 0a19561803f0e8e752e0bd2483e6c0bf5fbe8560

  patched  libpurple/pobject.c

-------------- next part --------------
============================================================
--- libpurple/pobject.c	f1a8ae4bbe481db28ab2daaabc1a15ec020fc67b
+++ libpurple/pobject.c	724f1a49adc4c8fc00a1254f493b28488fb4f5b9
@@ -730,6 +730,7 @@ purple_object_generic_dbus_method_handle
                                           gpointer               object)
 {
 	GValue *paramv;
+	GValue ret_val = {0, };
 	GClosure *closure;
 	guint i, num_params;
 
@@ -744,15 +745,27 @@ purple_object_generic_dbus_method_handle
 
 	/* Prepare the closure parameters. */
 	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);
 
 	/* Execute the callback. */
-	g_closure_invoke(closure, NULL, num_params, paramv, NULL);
-	/* TODO: handle output parameters. */
-	g_dbus_method_invocation_return_value(invoc, NULL);
+	g_closure_invoke(closure, &ret_val, num_params, paramv, NULL);
+	g_dbus_method_invocation_return_value(invoc,
+	                                      g_value_get_variant(&ret_val));
+#else
+	g_value_init(&ret_val, G_TYPE_POINTER);
 
+	/* Execute the callback. */
+	g_closure_invoke(closure, &ret_val, num_params, paramv, NULL);
+	g_dbus_method_invocation_return_value(invoc,
+	                                (GVariant*)g_value_get_pointer(&ret_val));
+#endif
+
 	for (i = 0; i < num_params; i++)
 		g_value_unset (&paramv[i]);
 	g_free (paramv);
+	g_value_unset(&ret_val);
 }
 
 GVariant *


More information about the Commits mailing list