returning a struct with dbus-glib bindings?
Nick Welch
nick at incise.org
Tue Dec 2 23:49:48 PST 2008
I've run out of places to search for ideas. I found a couple things on google
about returning an array of structs, but nothing about just one struct (seems
odd).
Specifically, I am trying to implement this:
http://wiki.xmms2.xmms.se/wiki/MPRIS#MprisVersion
The xml signature looks like this:
<method name="MprisVersion">
<arg type="(qq)" direction="out"/>
</method>
i.e. a struct of two 16 byte ints. First of all, outside of <typedef short
gshort>, glib seems to completely ignore the existence of 16 byte integers.
There is no G_TYPE_SHORT (or G_TYPE_INT16), for example.
The following is about as close as I think I've gotten to an answer, although
as far as actually working, it's no better than anything else I've tried:
---------------------------------------------------------------------------
#define DBUS_STRUCT_INT_INT (dbus_g_type_get_struct ("GValueArray",
G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID))
gboolean mpris_root_mpris_version(MprisRoot * obj, GValue ** version,
GError ** error)
{
GValue * value = g_new0(GValue, 1);
g_value_init(value, DBUS_STRUCT_INT_INT);
g_value_take_boxed(value,
dbus_g_type_specialized_construct(DBUS_STRUCT_INT_INT));
dbus_g_type_struct_set(value, 0, 1, 1, 0, G_MAXUINT); // {1, 0}
*version = value;
return TRUE;
}
---------------------------------------------------------------------------
More information about the dbus
mailing list