Search code examples
c++dbus

Receive multiple arguments after method call in dbus-cxx


I use dbus-cxx to do method calls via dbus. Now there are methods that return more than one argument and I couldn't figure out how to receive any arguments beside the first one.

I initialize the proxy method:

DBus::MethodProxy<int>& info_proxy = *(object->create_method<int>(ServerName, "Info"));

and when I grab the return value, it is only the first value of the three possible outputs in this case.

The XML describing the methods looks like this:

<method name="Info">
    <arg type="i" direction="out" name="rate"/>
    <arg type="i" direction="out" name="freq"/>
    <arg type="i" direction="out" name="nch"/>
</method>

Calling the method from within QDBusViewer delivers the output Arguments: 1813099, 44100, 2 so it provides three outputs but I cannot figure out how to access these.

EDIT: I got it working, by using the tool dbus-cxx-xml2cpp I got a method definition that uses a DBus::CallMessage instead of a DBus::MethodProxy. The resulting reply contained all arguments the method returns.


Solution

  • I got it working, by using the tool dbus-cxx-xml2cpp I got a method definition that uses a DBus::CallMessage instead of a DBus::MethodProxy. The resulting reply contained all arguments the method returns.