Search code examples
glibdbusgobject

Passing array in dbus-glib server


I have some writing a server exporting and interface over dbus, using dbus-glib.

I'm trying write a method that takes an array of bytes as an input, but I'm having difficulty working out what types to use in my method arguments.

For example, if I have a method that looks like this in the XML definition:

<method name="SetData">
  <arg type="ay" name="data" direction="in" />
</method>

I would have expected that I would need a method like this:

gboolean set_data(MyObj *obj, GArray *arr, GError **error);

If I have a look at the generated marshalling code that directly calls the method though, it's expecting a function signature like this:

  typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED_POINTER) (gpointer     data1,
                                                           gpointer     arg_1,
                                                           gpointer     arg_2,
                                                           gpointer     data2)

The data1 and data2 match the *obj and the **error, and so arg_1 and arg_2 presumably between them relate to the array. This is presumably a length and value, but in which case why are they both pointers? Or is it a GArray and some type information or something?

I'm aware I should probably be using GDBus instead, but this is what I'm stuck with at the moment.


Solution

  • It would appear that the marshalling code is a red herring and I was overthinking it.

    Experimentation has shown that a simple GArray* is the expected type for passing an array.