From 76160422d532b2ccf63a5c477f74a6645428c0f7 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 8 Feb 2010 12:51:27 +1000 Subject: Emit signals when access points appear & disappear. --- .../networkmanager/qnetworkmanagerengine.cpp | 66 +++++++++++++++++----- 1 file 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 &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, -- cgit v0.12