summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/nla
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2009-12-10 07:10:53 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-01-04 01:15:57 (GMT)
commit6f0a0af87c2063cd1dac75134f5cd05291a9196d (patch)
treee1cf0a83e4faebb227787a97c097ee5afc70e0b3 /src/plugins/bearer/nla
parentb22d0a9c4d6e3309287aefdc1a300e2fc566c2c7 (diff)
downloadQt-6f0a0af87c2063cd1dac75134f5cd05291a9196d.zip
Qt-6f0a0af87c2063cd1dac75134f5cd05291a9196d.tar.gz
Qt-6f0a0af87c2063cd1dac75134f5cd05291a9196d.tar.bz2
Convert NLA plugin to be incremental.
Diffstat (limited to 'src/plugins/bearer/nla')
-rw-r--r--src/plugins/bearer/nla/qnlaengine.cpp101
-rw-r--r--src/plugins/bearer/nla/qnlaengine.h6
2 files changed, 85 insertions, 22 deletions
diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp
index 47bd8d5..a9fc2ee 100644
--- a/src/plugins/bearer/nla/qnlaengine.cpp
+++ b/src/plugins/bearer/nla/qnlaengine.cpp
@@ -238,21 +238,8 @@ QList<QNetworkConfigurationPrivate *> QNlaThread::getConfigurations()
{
QMutexLocker locker(&mutex);
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- for (int i = 0; i < fetchedConfigurations.count(); ++i) {
- QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate;
- config->name = fetchedConfigurations.at(i)->name;
- config->isValid = fetchedConfigurations.at(i)->isValid;
- config->id = fetchedConfigurations.at(i)->id;
- config->state = fetchedConfigurations.at(i)->state;
- config->type = fetchedConfigurations.at(i)->type;
- config->roamingSupported = fetchedConfigurations.at(i)->roamingSupported;
- config->purpose = fetchedConfigurations.at(i)->purpose;
- config->internet = fetchedConfigurations.at(i)->internet;
-
- foundConfigurations.append(config);
- }
+ QList<QNetworkConfigurationPrivate *> foundConfigurations = fetchedConfigurations;
+ fetchedConfigurations.clear();
return foundConfigurations;
}
@@ -324,7 +311,10 @@ void QNlaThread::run()
#ifndef Q_OS_WINCE
// Not interested in unrelated IO completion events
// although we also don't want to block them
- while (WaitForSingleObjectEx(changeEvent, WSA_INFINITE, true) != WAIT_IO_COMPLETION) {}
+ while (WaitForSingleObjectEx(changeEvent, WSA_INFINITE, true) != WAIT_IO_COMPLETION &&
+ handle)
+ {
+ }
#else
WaitForSingleObject(changeEvent, WSA_INFINITE);
#endif
@@ -515,7 +505,7 @@ QNlaEngine::QNlaEngine(QObject *parent)
{
nlaThread = new QNlaThread(this);
connect(nlaThread, SIGNAL(networksChanged()),
- this, SIGNAL(configurationsChanged()));
+ this, SLOT(networksChanged()));
nlaThread->start();
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
@@ -526,12 +516,57 @@ QNlaEngine::~QNlaEngine()
delete nlaThread;
}
-QList<QNetworkConfigurationPrivate *> QNlaEngine::getConfigurations(bool *ok)
+void QNlaEngine::networksChanged()
{
- if (ok)
- *ok = true;
+ QStringList previous = accessPointConfigurations.keys();
+
+ QList<QNetworkConfigurationPrivate *> foundConfigurations = nlaThread->getConfigurations();
+ while (!foundConfigurations.isEmpty()) {
+ QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst();
+
+ previous.removeAll(cpPriv->id);
+
+ if (accessPointConfigurations.contains(cpPriv->id)) {
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
+
+ bool changed = false;
+
+ if (ptr->isValid != cpPriv->isValid) {
+ ptr->isValid = cpPriv->isValid;
+ changed = true;
+ }
+
+ if (ptr->name != cpPriv->name) {
+ ptr->name = cpPriv->name;
+ changed = true;
+ }
+
+ if (ptr->state != cpPriv->state) {
+ ptr->state = cpPriv->state;
+ changed = true;
+ }
- return nlaThread->getConfigurations();
+ if (changed)
+ emit configurationChanged(ptr);
+
+ delete cpPriv;
+ } else {
+ QNetworkConfigurationPrivatePointer ptr(cpPriv);
+
+ accessPointConfigurations.insert(ptr->id, ptr);
+
+ emit configurationAdded(ptr);
+ }
+ }
+
+ while (!previous.isEmpty()) {
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.take(previous.takeFirst());
+
+ emit configurationRemoved(ptr);
+ }
+
+ emit updateCompleted();
}
QString QNlaEngine::getInterfaceFromId(const QString &id)
@@ -577,6 +612,30 @@ void QNlaEngine::requestUpdate()
nlaThread->forceUpdate();
}
+QNetworkSession::State QNlaEngine::sessionStateForId(const QString &id)
+{
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ if (!ptr)
+ return QNetworkSession::Invalid;
+
+ if (!ptr->isValid) {
+ return QNetworkSession::Invalid;
+ } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ return QNetworkSession::Connected;
+ } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
+ QNetworkConfiguration::Discovered) {
+ return QNetworkSession::Disconnected;
+ } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
+ return QNetworkSession::NotAvailable;
+ } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
+ QNetworkConfiguration::Undefined) {
+ return QNetworkSession::NotAvailable;
+ }
+
+ return QNetworkSession::Invalid;
+}
+
#include "qnlaengine.moc"
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/nla/qnlaengine.h b/src/plugins/bearer/nla/qnlaengine.h
index 464275d..dd038d1 100644
--- a/src/plugins/bearer/nla/qnlaengine.h
+++ b/src/plugins/bearer/nla/qnlaengine.h
@@ -81,7 +81,6 @@ public:
QNlaEngine(QObject *parent = 0);
~QNlaEngine();
- QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0);
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
@@ -92,6 +91,11 @@ public:
void requestUpdate();
+ QNetworkSession::State sessionStateForId(const QString &id);
+
+private Q_SLOTS:
+ void networksChanged();
+
private:
QWindowsSockInit2 winSock;
QNlaThread *nlaThread;