#include #include #include #include #include #include using namespace std; QString getMapArgument(const QDBusMessage &result, const QString &_key) { const QVariant &var = result.arguments()[0].value().variant(); const QDBusArgument &dbArg = var.value(); // Iterate over it int numEntries = 0; dbArg.beginMap(); while ( !dbArg.atEnd() ) { QString key; QVariant value; dbArg.beginMapEntry(); dbArg >> key; dbArg >> value; dbArg.endMapEntry(); numEntries++; if ( _key == key ) { return value.toString(); } } return QString(); } int main( int argc, char **argv ) { QCoreApplication app(argc,argv); QDBusConnection systemBus_ = QDBusConnection::systemBus(); assert( systemBus_.isConnected() ); // Set up Interfaces QDBusInterface testInterface( "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", systemBus_ ); QDBusInterface test2Interface( "org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.DBus.Peer", systemBus_ ); QDBusInterface wpaInterface( "fi.w1.wpa_supplicant1", "/fi/w1/wpa_supplicant1", "fi.w1.wpa_supplicant1", systemBus_ ); QDBusInterface wpaInterface7( "fi.w1.wpa_supplicant1", "/fi/w1/wpa_supplicant1/Interfaces/7", "fi.w1.wpa_supplicant1.Interface", systemBus_ ); QTime timer; timer.start(); int i = 0; while ( true ) { try { int a = timer.elapsed(); //QDBusMessage result = testInterface.call("GetId"); //QString arg = result.arguments().at(0).toString(); // QDBusMessage result = test2Interface.call("GetMachineId"); // QString arg = result.arguments().at(0).toString(); // QDBusMessage result = wpaInterface7.call("SignalPoll"); // QString arg = getMapArgument(result, "rssi"); QDBusMessage result = wpaInterface.call("DebugLevel"); QString arg = result.arguments().at(0).toString(); int b = timer.elapsed(); cout << i++ << " " << b << " " << (b-a) << " " << qPrintable(arg) << endl; } catch ( std::exception &e ) { cout << e.what() << endl; } catch ( char const *e ) { cout << e << endl; } catch ( const std::string &e ) { cout << e << endl; } //usleep(0.001 * 1e6); } }