void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map) { QDBusMessage msg = this->message(); QMapIterator<QString, QVariant> i(map); while (i.hasNext()) { i.next(); if( i.key() == "State") { //state only applies to device interfaces quint32 state = i.value().toUInt(); if( state == NM_DEVICE_STATE_ACTIVATED || state == NM_DEVICE_STATE_DISCONNECTED || state == NM_DEVICE_STATE_UNAVAILABLE || state == NM_DEVICE_STATE_FAILED) { emit pathForPropertiesChanged( msg.path(), map); } } else if( i.key() == "ActiveAccessPoint") { emit pathForPropertiesChanged(msg.path(), map); // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path(); // } else if( i.key() == "Strength") // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt(); // else // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value(); } else if (i.key() == "ActiveConnections") { emit pathForPropertiesChanged(msg.path(), map); } } }
void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map) { QDBusMessage msg = this->message(); QMapIterator<QString, QVariant> i(map); while (i.hasNext()) { i.next(); if( i.key() == "State") { //state only applies to device interfaces quint32 state = i.value().toUInt(); if( state == NM_DEVICE_STATE_ACTIVATED || state == NM_DEVICE_STATE_DISCONNECTED || state == NM_DEVICE_STATE_UNAVAILABLE || state == NM_DEVICE_STATE_FAILED) { emit pathForPropertiesChanged( msg.path(), map); } } } emit pathForPropertiesChanged( msg.path(), map); }
bool QNetworkManagerInterfaceDeviceWireless::setConnections() { if(!isValid() ) return false; QDBusConnection dbusConnection = QDBusConnection::systemBus(); bool allOk = false; delete nmDBusHelper; nmDBusHelper = new QNmDBusHelper(this); connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString,QDBusObjectPath)), this,SIGNAL(accessPointAdded(QString,QDBusObjectPath))); connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString,QDBusObjectPath)), this,SIGNAL(accessPointRemoved(QString,QDBusObjectPath))); if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), d->path, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("AccessPointAdded"), nmDBusHelper, SLOT(slotAccessPointAdded(QDBusObjectPath)))) { allOk = true; } if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), d->path, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("AccessPointRemoved"), nmDBusHelper, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) { allOk = true; } if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE), d->path, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS), QLatin1String("PropertiesChanged"), nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) { allOk = true; } return allOk; }
bool QNetworkManagerConnectionActive::setConnections() { if(!isValid() ) return false; bool allOk = false; delete nmDBusHelper; nmDBusHelper = new QNmDBusHelper(this); connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); if(nmConnection.connect(QLatin1String(NM_DBUS_SERVICE), d->path, QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION), QLatin1String("PropertiesChanged"), nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) { allOk = true; } return allOk; }
QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent) : QObject(parent) { d = new QNetworkManagerInterfacePrivate(); d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE), QLatin1String(NM_DBUS_PATH), QLatin1String(NM_DBUS_INTERFACE), nmConnection); if (!d->connectionInterface->isValid()) { d->valid = false; return; } d->valid = true; nmDBusHelper = new QNmDBusHelper(this); connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)), this, SIGNAL(stateChanged(QString,quint32))); }
bool QNetworkManagerInterfaceDeviceWired::setConnections() { if(!isValid() ) return false; bool allOk = false; delete nmDBusHelper; nmDBusHelper = new QNmDBusHelper(this); connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)), this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>))); if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), d->path, QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED), QLatin1String("PropertiesChanged"), nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) { allOk = true; } return allOk; }