Unwrapping the glib dbus lump: a(iii)

Rob Taylor robtaylor at floopily.org
Wed Sep 20 15:33:03 PDT 2006


Richard Hughes wrote:
> Hey.
> 
> It's been a while since I added the "send" part of the a(iii) dbus
> interface to gnome-power-manager[1] - thanks to the help of Rob Taylor.
> 
> I've spent the last couple of hours knocking my head against a brick
> wall trying to process the return packet with the glib bindings.
> 
> dbus-send --session --print-reply
> --dest=org.gnome.PowerManager /org/gnome/PowerManager/Statistics
> org.gnome.PowerManager.Statistics.GetData
> 
> Produced the correct structure in the console, but I can't find any
> source on google where you this is decoded this like I'm trying to!
> 
> I'm guessing I want something like:
> 
> GValue arrayoptions = {0, };
> g_value_init (&arrayoptions, G_TYPE_BOXED);
> 
> gbus_g_proxy_call (proxy, "GetData", &error,
>                  G_TYPE_INT, time,
>                  G_TYPE_STRING, type,
>                  G_TYPE_INT, options,
>                  G_TYPE_INVALID,
>                  G_TYPE_BOXED, &arrayoptions,
>                  G_TYPE_INVALID;
> 
> But dbus gets upset and spews:
> 
> (./gnome-power-statistics:2857): GLib-GObject-WARNING **: gvalue.c:96:
> cannot initialize GValue with type `GBoxed', this type has no
> GTypeValueTable implementation
> 

Right, the error (as it suggests..) is the G_TYPE_BOXED. This should be:

dbus_g_type_get_collection("GPtrArray",
  dbus_g_type_get_struct("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT))

The array will be returned in a GPtrArray containing GValueArrays with
the ints in.

Thanks,
Rob Taylor



More information about the dbus mailing list