diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-08 02:51:27 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-08 07:49:45 (GMT) |
commit | 76160422d532b2ccf63a5c477f74a6645428c0f7 (patch) | |
tree | f900472ae29e462312ec7770f93865da8c2cc330 /src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp | |
parent | 8df1491dfb261ab41f9f360af8e23fd283ad1ca5 (diff) | |
download | Qt-76160422d532b2ccf63a5c477f74a6645428c0f7.zip Qt-76160422d532b2ccf63a5c477f74a6645428c0f7.tar.gz Qt-76160422d532b2ccf63a5c477f74a6645428c0f7.tar.bz2 |
Emit signals when access points appear & disappear.
Diffstat (limited to 'src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp')
-rw-r--r-- | src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index 9a9bdad..51afe3e 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -499,19 +499,21 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjec } // Check if configuration exists for connection. - for (int i = 0; i < connections.count(); ++i) { - QNetworkManagerSettingsConnection *connection = connections.at(i); + if (!accessPoint->ssid().isEmpty()) { + for (int i = 0; i < connections.count(); ++i) { + QNetworkManagerSettingsConnection *connection = connections.at(i); - if (accessPoint->ssid() == connection->getSsid()) { - const QString service = connection->connectionInterface()->service(); - const QString settingsPath = connection->connectionInterface()->path(); - const QString connectionId = QString::number(qHash(service + ' ' + settingsPath)); + if (accessPoint->ssid() == connection->getSsid()) { + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + const QString connectionId = QString::number(qHash(service + ' ' + settingsPath)); - QNetworkConfigurationPrivatePointer ptr = - accessPointConfigurations.value(connectionId); - ptr->state = QNetworkConfiguration::Discovered; - emit configurationChanged(ptr); - return; + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.value(connectionId); + ptr->state = QNetworkConfiguration::Discovered; + emit configurationChanged(ptr); + return; + } } } @@ -544,12 +546,32 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path, if (configuredAccessPoints.contains(accessPoint)) { // find connection and change state to Defined configuredAccessPoints.removeOne(accessPoint); - qDebug() << "At least one connection is no longer discovered."; + for (int i = 0; i < connections.count(); ++i) { + QNetworkManagerSettingsConnection *connection = connections.at(i); + + if (accessPoint->ssid() == connection->getSsid()) { + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + const QString connectionId = + QString::number(qHash(service + ' ' + settingsPath)); + + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.value(connectionId); + ptr->state = QNetworkConfiguration::Defined; + emit configurationChanged(ptr); + return; + } + } } else { - // emit configurationRemoved(cpPriv); - qDebug() << "An unconfigured wifi access point was removed."; + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.take(QString::number(qHash(objectPath.path()))); + + if (ptr) + emit configurationRemoved(ptr); } + delete accessPoint; + break; } } @@ -564,7 +586,21 @@ void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map if (!accessPoint) return; - qDebug() << "update access point" << accessPoint; + for (int i = 0; i < connections.count(); ++i) { + QNetworkManagerSettingsConnection *connection = connections.at(i); + + if (accessPoint->ssid() == connection->getSsid()) { + const QString service = connection->connectionInterface()->service(); + const QString settingsPath = connection->connectionInterface()->path(); + const QString connectionId = QString::number(qHash(service + ' ' + settingsPath)); + + QNetworkConfigurationPrivatePointer ptr = + accessPointConfigurations.value(connectionId); + ptr->state = QNetworkConfiguration::Discovered; + emit configurationChanged(ptr); + return; + } + } } QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service, |