diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-08 11:24:47 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-08 11:24:47 (GMT) |
commit | 9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6 (patch) | |
tree | 36687843f30efa62a4ac37e863da6d3984626be3 /src/network/bearer/qnetworkconfigmanager_p.cpp | |
parent | 0f3fd01523081656c27ebb7b495c4f1a1c927117 (diff) | |
parent | 29ec793147054ea4beb1ad4adeebbbe1fe07b260 (diff) | |
download | Qt-9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6.zip Qt-9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6.tar.gz Qt-9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (64 commits)
Carbon: usage of menu bars can cause exceptions to be thrown
Mac: compile fix
Fix build
JPEG plugin: Use switch() instead of if()
don't try to build corewlan plugin when corewlan was not found at configure
Avoid conversion to/from QChar in the cn codec to unicode
Avoid memory allocations in conversion from Gb2312/Gb18030 to unicode
fix corewlan detection error when building for 10.5 when 10.6 is also
fixed treatment of zlib on Mac when crossbuilding
Partial overloading support for qdbus cli tool.
Allow empty authority in QUrl::setAuthority as per docs.
Added test for QTBUG-6962: Empty authority ignored by QUrl::setAuthority.
fixed case of GL include directory
check in MAC_APPLICATION_MENU translations
Re-generate the Unicode tables after updates to the program that generates them
Fix the code after merge: DerivedNormalizationProps has two or more columns
add some usefull definitions to qunicodetables_p.h
qchar.cpp: fix identation
finish last commit
prefer DerivedNormalizationProps.txt over CompositionExclusions.txt
...
Diffstat (limited to 'src/network/bearer/qnetworkconfigmanager_p.cpp')
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 90 |
1 files changed, 85 insertions, 5 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 1ac10c5..9740424 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -55,7 +55,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QBearerEngineFactoryInterface_iid, QLatin1String("/bearer"))) QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() -: capFlags(0), mutex(QMutex::Recursive), firstUpdate(true) +: capFlags(0), mutex(QMutex::Recursive), pollTimer(0), forcedPolling(0), firstUpdate(true) { updateConfigurations(); @@ -82,7 +82,7 @@ void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurati } if (ptr->state == QNetworkConfiguration::Active) { - onlineConfigurations.insert(ptr); + onlineConfigurations.insert(ptr->id); if (!firstUpdate && onlineConfigurations.count() == 1) emit onlineStateChanged(true); } @@ -100,7 +100,7 @@ void QNetworkConfigurationManagerPrivate::configurationRemoved(QNetworkConfigura emit configurationRemoved(item); } - onlineConfigurations.remove(ptr); + onlineConfigurations.remove(ptr->id); if (!firstUpdate && onlineConfigurations.isEmpty()) emit onlineStateChanged(false); } @@ -118,9 +118,9 @@ void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigura bool previous = !onlineConfigurations.isEmpty(); if (ptr->state == QNetworkConfiguration::Active) - onlineConfigurations.insert(ptr); + onlineConfigurations.insert(ptr->id); else - onlineConfigurations.remove(ptr); + onlineConfigurations.remove(ptr->id); bool online = !onlineConfigurations.isEmpty(); @@ -133,6 +133,9 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() QMutexLocker locker(&mutex); if (firstUpdate) { + if (sender()) + return; + updating = false; QFactoryLoader *l = loader(); @@ -161,6 +164,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); capFlags |= engine->capabilities(); + + engine->requestUpdate(); } } @@ -180,6 +185,15 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() emit configurationUpdateComplete(); } + if (engine && !pollingEngines.isEmpty()) { + int index = sessionEngines.indexOf(engine); + if (index >= 0) + pollingEngines.remove(index); + + if (pollingEngines.isEmpty()) + startPolling(); + } + if (firstUpdate) firstUpdate = false; } @@ -208,4 +222,70 @@ QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines() return sessionEngines; } +void QNetworkConfigurationManagerPrivate::startPolling() +{ + QMutexLocker locker(&mutex); + + bool pollingRequired = false; + + if (forcedPolling > 0) { + foreach (QBearerEngine *engine, sessionEngines) { + if (engine->requiresPolling()) { + pollingRequired = true; + break; + } + } + } + + if (!pollingRequired) { + foreach (QBearerEngine *engine, sessionEngines) { + if (engine->configurationsInUse()) { + pollingRequired = true; + break; + } + } + } + + if (pollingRequired) { + if (!pollTimer) { + pollTimer = new QTimer(this); + pollTimer->setInterval(10000); + pollTimer->setSingleShot(true); + connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines())); + } + + pollTimer->start(); + } +} + +void QNetworkConfigurationManagerPrivate::pollEngines() +{ + QMutexLocker locker(&mutex); + + for (int i = 0; i < sessionEngines.count(); ++i) { + if ((forcedPolling && sessionEngines.at(i)->requiresPolling()) || + sessionEngines.at(i)->configurationsInUse()) { + pollingEngines.insert(i); + sessionEngines.at(i)->requestUpdate(); + } + } +} + +void QNetworkConfigurationManagerPrivate::enablePolling() +{ + QMutexLocker locker(&mutex); + + ++forcedPolling; + + if (forcedPolling == 1) + startPolling(); +} + +void QNetworkConfigurationManagerPrivate::disablePolling() +{ + QMutexLocker locker(&mutex); + + --forcedPolling; +} + QT_END_NAMESPACE |