Hello everyone,

I am planning to develop an application that will make use of DBus and connman, a wireless manager. From my understanding DBus exposes the methods used by a program, and allows developers to also make use of these methods in their own program.

I know Qt has the QtDbus module, and if my understanding is correct, the GetServices method under the net.connman.Manager interface shows the wireless networks available. Inspecting the output of the GetServices from the qdbusviewer program, I can see that each wireless network has its own unique object path, an example would be **/net/connman/service/wifi_00120ec15ba0_4c616964614d616774616c6173_manag ed_psk**.

To use the Connect and Disconnect method under the net.connman.Services interface, I need the object path so that I can create a new interface that would allow me to call Connect/Disconnect. I am currently trying the methods outlined here https://stackoverflow.com/questions/...a-qt-dbus-call, but I only get a blank when I try to return the object path:

Here is my code to obtain the object path:

Qt Code:
  1. QDBusConnection bus = QDBusConnection::systemBus();
  2. QDBusInterface *interface = new QDBusInterface("net.connman",
  3. "/",
  4. "net.connman.Manager",
  5. bus,
  6. this);
  7.  
  8. QDBusMessage test = interface->call("GetServices");
  9. QList<QVariant> outArgs = test.arguments();
  10.  
  11. QVariant first = outArgs.at(0);
  12. qDebug() << first;
  13.  
  14. QDBusVariant dbvFirst = first.value<QDBusVariant>();
  15.  
  16. QVariant vFirst = dbvFirst.variant();
  17. qDebug() << vFirst;
  18.  
  19. QDBusArgument dbusArgs = vFirst.value<QDBusArgument>();
  20. qDebug() << "QDBusArgument current type is" << dbusArgs.currentType();
  21.  
  22. dbusArgs.beginArray();
  23. while (!dbusArgs.atEnd())
  24. {
  25. dbusArgs >> path;
  26. // append path to a vector here if you want to keep it
  27. }
  28.  
  29. dbusArgs.endArray();
  30. qDebug() << path.path();
To copy to clipboard, switch view to plain text mode 


How do I extract the arguments and the object path returned by the GetService method? Has anyone done this correctly?

Thanks