Qt World Summit: Register Today!

Extract arguments and object path dynamically from net.connman.Manager's GetService method

  • 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_managed_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/20206376/how-do-i-extract-the-returned-data-from-qdbusmessage-in-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:

    QDBusConnection bus = QDBusConnection::systemBus();
    QDBusInterface *interface = new QDBusInterface("net.connman",
    QDBusMessage test = interface->call("GetServices");
    QList<QVariant> outArgs = test.arguments();
    QVariant first = outArgs.at(0);
    qDebug() << first;
    QDBusVariant dbvFirst = first.value<QDBusVariant>();
    QVariant vFirst = dbvFirst.variant();
    qDebug() << vFirst;
    QDBusArgument dbusArgs = vFirst.value<QDBusArgument>();
    qDebug() << "QDBusArgument current type is" << dbusArgs.currentType();
    QDBusObjectPath path;
    while (!dbusArgs.atEnd())
         dbusArgs >> path;
         // append path to a vector here if you want to keep it
    qDebug() << path.path();

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


Log in to reply