ANNOUNCE: D-Bus 0.50 - "You run and you run to catch up with the sun, but � sinking" is released

Colin Walters walters at verbum.org
Wed Sep 7 09:32:46 PDT 2005


On Wed, 2005-09-07 at 10:45 +0100, Jamie McCracken wrote:

> 1) The Glib bindings currently uses GValue for DBUS_TYPE_VARIANT whilst 
> a better mapping might be GValueArray. The Gvalue mapping can be 
> problematic when the variant holds a struct as there is no way to access 
> individual struct members from a GValue 

I know the docs need to be updated...but:

D-BUS structs map to GValueArray (G_TYPE_VALUE_ARRAY).  To access a
structure contained in a variant, it would look something like this:

GValue myvalue = {0,};
GValueArray *values;
guint i;

dbus_g_proxy_call (myproxy, "GetValue", NULL, G_TYPE_INVALID,
                   G_TYPE_VALUE, &myvalue, G_TYPE_INVALID);
if (G_VALUE_TYPE (&myvalue) != G_TYPE_VALUE_ARRAY) {
  g_warning ("communication error");
  return;
}
values = g_value_get_boxed (&myvalue);
for (i = 0; i < values->n_values; i++) {
  g_print ("type: %s\n", g_type_name (G_VALUE_TYPE (g_value_array_get_nth (values, i)));
}

> (this is particularily a problem 
> in cases where the struct could contain anything) and also when passing 
> a G_BOXED_TYPE as an input variant parameter (how can the variant derive 
> the correct signature from a Gvalue holding a struct?).

You can't pass G_TYPE_BOXED to the GLib bindings directly; you need to
pass a derived type.

> 2) I need support for DBUS DICTs of signature a{sv} which need to map to 
> a GHashTable containing (string, GValueArray)

The GLib bindings already support a{sv}; there is some example usage in
the test suite.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/dbus/attachments/20050907/2bbf196d/attachment.pgp


More information about the dbus mailing list