DBus Low level API - Receiving complex structures

Bogdan Lotko boguslaw.lotko at chello.at
Mon Aug 15 13:49:23 PDT 2011


Hello,

Until now I've been sending complex structures over D-Bus  from Low 
Level API application to QT.
Now I have to send a complex structure in the opposite direction, FROM 
Qt to the application written in Low level API.

e.g in QT I've defined  structures, let's say

struct _S1
{
   QString s1;
   QString s2;
   int           i1;
   int           i2;
};

typedef _S1 S1;

typedef QList<S1> S1List;

struct _S2
{
   int         i1;
   int         i2;
   S1List  list;
}

typedef _S2 S2;

According Q_DECLARE_METATYPE, qDBusRegisterMetatype and 
QRegisterMetatype calls are done.

Before sending, I populate the S2 structure s and pack it into QVariant 
variable v

QVariant v;
S2           s;

s.i1 = .....
...
v.setValue( s );

myIf->asyncCall( "myMethod", v );

So far so good.

On the GLib Low Level API side I declare .xml file with following signature:

<method name="myMethod">
<arg type="(iia(ssii))">
</method>

dbus-binding-tool with --mode=glib-server generates according include file.

Now I have to implement

myPrefix_my_method( MyClass *self, <HELP_WHAT_TYPE???> myStruct, GError 
** error );

My question is what is the correct type for my structure parameter 
myStruct? (S2 on Qt side)

For simple signatures e.g. "i" it is just according type e.g. gint.

Here I suppose  it shall be a kind of message I have to iterate into. Is 
it just the DBusMessage or pointer to it?

Please let me know how to unpack the message (if any) and if to clean it 
(how) after usage.

Thanks for your help,

with best regards,

Bogdan























More information about the dbus mailing list