cpw.gillux.detachablepurple: aeb59e75: The GVariant to GValue conversion functi...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Mon May 14 23:27:11 EDT 2012


----------------------------------------------------------------------
Revision: aeb59e75314b7110227e6e500da9c4b76f0a691c
Parent:   f3531495f214a2ae83f9dfc05d2898f16662923e
Author:   gillux at soc.pidgin.im
Date:     05/14/12 20:57:48
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/aeb59e75314b7110227e6e500da9c4b76f0a691c

Changelog: 

The GVariant to GValue conversion function now handles conversion to types
derived from type G_TYPE_FLAGS and G_TYPE_ENUM, giving uint32 GVariant.
This means we can now export enum and flags properties on D-Bus.

Changes against parent f3531495f214a2ae83f9dfc05d2898f16662923e

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

-------------- next part --------------
============================================================
--- libpurple/pobject.c	bb04c1f7351ce1b648a9aeea7292dfe3d6e601b3
+++ libpurple/pobject.c	527cb7d4d2f8133da5b15f0ab3b79302118bd900
@@ -408,9 +408,12 @@ purple_dbus_gvariant_to_gvalue(GVariant 
 	GValue tmp = {0, };
 
 	g_dbus_gvariant_to_gvalue(gvariant, gvalue);
-	/* Convert path names into gobjects. */
-	if (G_TYPE_IS_OBJECT(expected_type)
-	    && G_VALUE_HOLDS_STRING(gvalue))
+	if (/* Convert path names into gobjects. */
+	    (G_TYPE_IS_OBJECT(expected_type)
+	     && G_VALUE_HOLDS_STRING(gvalue)) ||
+	    /* Convert flags/enum into unsigned integers. */
+	    ((G_TYPE_IS_FLAGS(expected_type) || G_TYPE_IS_ENUM(expected_type))
+	     && G_VALUE_HOLDS_UINT(gvalue)))
 	{
 		g_value_init(&tmp, expected_type);
 		g_value_transform(gvalue, &tmp);
@@ -448,7 +451,11 @@ purple_object_get_dbus_property(PurpleOb
 	if (G_VALUE_HOLDS_OBJECT(&gval)) {
 		/* Convert gobjects into dbus path names. */
 		g_value_init(&gval2, G_TYPE_STRING);
-		g_value_transform(&gval, &gval);
+		g_value_transform(&gval, &gval2);
+	} else if (G_VALUE_HOLDS_FLAGS(&gval) || G_VALUE_HOLDS_ENUM(&gval)) {
+		/* Convert flags/enum into unsigned integers. */
+		g_value_init(&gval2, G_TYPE_UINT);
+		g_value_transform(&gval, &gval2);
 	} else {
 		/* Regular value. */
 		g_value_init(&gval2, G_VALUE_TYPE(&gval));
============================================================
--- libpurple/pobject.h	62de0fd0cb0699904559dcd306bf880b90ed369f
+++ libpurple/pobject.h	2c00a2fb407cd68b4cc90ce22cff33d2af4fd0a2
@@ -262,8 +262,8 @@ GClosure *purple_object_get_dbus_closure
 
 /**
  * Transforms a D-Bus GVariant into a GObject GValue, doing a conversion
- * from a D-Bus type (e.g. object path string) to an expected
- * GType (e.g. respectively object reference), if necessary.
+ * from a D-Bus type (e.g. object path string, integer) to an expected
+ * GType (e.g. respectively object reference, flag), if necessary.
  *
  * @param gvariant A GVariant.
  * @param gvalue Return location pointing to a zero-filled


More information about the Commits mailing list