diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 17:47:56 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-09 17:47:56 (GMT) |
commit | 9227f8606c85ad9a472628a8a06c312452d69f14 (patch) | |
tree | 004e193bd008fb5bf3c33d128223f425a0e8d614 /src/network/bearer/qnetworkconfigmanager.cpp | |
parent | e06d011cc08de370ece3b0c324b0a735a2625820 (diff) | |
parent | 0edda17e2edb4da968b026ac6658f740323d6dd5 (diff) | |
download | Qt-9227f8606c85ad9a472628a8a06c312452d69f14.zip Qt-9227f8606c85ad9a472628a8a06c312452d69f14.tar.gz Qt-9227f8606c85ad9a472628a8a06c312452d69f14.tar.bz2 |
Merge branch '4.7-cutoff' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7-cutoff' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (82 commits)
Revert 12b6987031be9faee3886d7623888feb4e1762af
Changed TEST_COMPILER from CC to CXX in configure script.
doc: Fixed several qdoc errors.
Carbon: Native filedialog does not apply filters on app-bundles
Cocoa: Native filedialog does not apply filters on app-bundles
Improve performance of QTimer::singleShot
Add a benchmark comparing single shot timer with invokeMethod
use Qt's private mac functions, reduce code redundancy
Assistant: Fix compile warning for empty header.
Doc: mark QEasingCurve support functions as new in 4.7.
Modify the XML test suite not to use non-characters.
Autotest: Fix failing QTextCodec tests
Doc: mark methods as internal (as they were in previous releases)
Doc: add image for Qt Quick to "What's New" page.
qdoc: Clear a static multimap after each qdocconf file.
qdoc: Added some debug output to track down a crash
Fixed mouse wheel handling in scrollareas.
Added two missing keys for X11
Carbon: usage of menu bars can cause exceptions to be thrown
Mac: compile fix
...
Diffstat (limited to 'src/network/bearer/qnetworkconfigmanager.cpp')
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager.cpp | 77 |
1 files changed, 58 insertions, 19 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 9ff197b..b631cf1 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -174,7 +174,8 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate() QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) : QObject(parent) { - QNetworkConfigurationManagerPrivate* priv = connManager(); + QNetworkConfigurationManagerPrivate *priv = connManager(); + connect(priv, SIGNAL(configurationAdded(QNetworkConfiguration)), this, SIGNAL(configurationAdded(QNetworkConfiguration))); connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)), @@ -185,6 +186,8 @@ QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) this, SIGNAL(onlineStateChanged(bool))); connect(priv, SIGNAL(configurationChanged(QNetworkConfiguration)), this, SIGNAL(configurationChanged(QNetworkConfiguration))); + + priv->enablePolling(); } /*! @@ -192,6 +195,9 @@ QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) */ QNetworkConfigurationManager::~QNetworkConfigurationManager() { + QNetworkConfigurationManagerPrivate *priv = connManager(); + + priv->disablePolling(); } @@ -221,7 +227,7 @@ QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const // Engines don't have a default configuration. // Return first active snap - QNetworkConfigurationPrivatePointer firstDiscovered; + QNetworkConfigurationPrivatePointer defaultConfiguration; foreach (QBearerEngine *engine, conPriv->engines()) { QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it; @@ -236,22 +242,35 @@ QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const QNetworkConfiguration config; config.d = it.value(); return config; - } else if ((it.value()->state & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { - firstDiscovered = it.value(); + } else if (!defaultConfiguration) { + if ((it.value()->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + defaultConfiguration = it.value(); + } } } } // No Active SNAPs return first Discovered SNAP. - if (firstDiscovered) { + if (defaultConfiguration) { QNetworkConfiguration config; - config.d = firstDiscovered; + config.d = defaultConfiguration; return config; } - // No Active or Discovered SNAPs, do same for InternetAccessPoints. - firstDiscovered.reset(); + /* + No Active or Discovered SNAPs, find the perferred access point. + The following priority order is used: + + 1. Active Ethernet + 2. Active WLAN + 3. Active Other + 4. Discovered Ethernet + 5. Discovered WLAN + 6. Discovered Other + */ + + defaultConfiguration.reset(); foreach (QBearerEngine *engine, conPriv->engines()) { QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it; @@ -261,22 +280,42 @@ QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const for (it = engine->accessPointConfigurations.begin(), end = engine->accessPointConfigurations.end(); it != end; ++it) { - if ((it.value()->state & QNetworkConfiguration::Active) == - QNetworkConfiguration::Active) { - QNetworkConfiguration config; - config.d = it.value(); - return config; - } else if ((it.value()->state & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { - firstDiscovered = it.value(); + + if ((it.value()->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + if (!defaultConfiguration) { + defaultConfiguration = it.value(); + } else { + if (defaultConfiguration->state == it.value()->state) { + if (defaultConfiguration->bearerName() == QLatin1String("Ethernet")) { + // do nothing + } else if (defaultConfiguration->bearerName() == QLatin1String("WLAN")) { + // ethernet beats wlan + if (it.value()->bearerName() == QLatin1String("Ethernet")) + defaultConfiguration = it.value(); + } else { + // ethernet and wlan beats other + if (it.value()->bearerName() == QLatin1String("Ethernet") || + it.value()->bearerName() == QLatin1String("WLAN")) { + defaultConfiguration = it.value(); + } + } + } else { + // active beats discovered + if ((defaultConfiguration->state & QNetworkConfiguration::Active) != + QNetworkConfiguration::Active) { + defaultConfiguration = it.value(); + } + } + } } } } // No Active InternetAccessPoint return first Discovered InternetAccessPoint. - if (firstDiscovered) { + if (defaultConfiguration) { QNetworkConfiguration config; - config.d = firstDiscovered; + config.d = defaultConfiguration; return config; } |