summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-04 07:33:43 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-04 07:37:40 (GMT)
commit445ae84fbd7d5ef04a426f8c32a79a369fed70eb (patch)
tree51d54f1a084f21c7429338a1d723f935f24fdb78
parent1e7b2415bf1bc853655e0a85a8cb21ecd24b149e (diff)
downloadQt-445ae84fbd7d5ef04a426f8c32a79a369fed70eb.zip
Qt-445ae84fbd7d5ef04a426f8c32a79a369fed70eb.tar.gz
Qt-445ae84fbd7d5ef04a426f8c32a79a369fed70eb.tar.bz2
Prefer ethernet over wlan.
Change how the defaultConfiguration is calculated when one is not provided by an engine.
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp69
1 files changed, 51 insertions, 18 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 0eb9c63..b631cf1 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -227,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;
@@ -242,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;
@@ -267,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;
}