I am querying NetworkManager's org.freedesktop.NetworkManager.Settings.Connection
interface, calling "GetSettings" on it. It returns a Dict of {String, Dict of {String, Variant}}
or a{sa{sv}}
in Dbus type terms. I'm using QtCreator with Qt4 to build my application.
I cannot seem to get a piece of useable information out of this dictionary. I cannot provide a MVE as it is heavily dependent if NetworkManager and DBus and Qt4 is installed on someone's system.
Here is the method I am developing to get information out of this Dictionary of Strings and Dictionary of Strings and Variants. I can see all the nice data that I want when piping it into qDebug(): qDebug()<<reply
.
void GetInfo()
{
//sysbus just means the system DBus.
QDBusInterface connSettings("org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager/Settings/1", "org.freedesktop.NetworkManager.Settings.Connection", sysbus);
QDBusMessage reply = connections.call("GetSettings");
if(reply.type() == QDBusMessage::ReplyMessage)
{
//I have tried everything I can imagine here,
//QVariant g = reply.arguments().at(0).value<QVariant>(); did not work
//g.canConvert<QMap>(); returns false, in contrast to what KDE says.
//QDbusArgument g = query.arguments().at(0).value<QDBusArgument>();
//g.beginMap(); and such don't work
}
}
It's very hard finding information on parsing a Dict type. The only source I found that provides some info is KDE. It says "The DBus Dict type should map to QMap, example to follow.." and no other hits on Google or examples exist. Maybe I am missing some fundemantal DBus knowledge, but I'm stumped.
I also checked out this excellent answer: How do I extract the returned data from QDBusMessage in a Qt DBus call? but I could not adapt it to parse a dict.
Would anyone know how to get to the last nested QVariant?