diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-08 01:04:00 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-02-08 07:49:34 (GMT) |
commit | 8df1491dfb261ab41f9f360af8e23fd283ad1ca5 (patch) | |
tree | 7ecb3663e5aa53363de79db5c1682c3d5b2cee2f | |
parent | 992af6c30d5e1216bf7a6db2521c16f0b508e396 (diff) | |
download | Qt-8df1491dfb261ab41f9f360af8e23fd283ad1ca5.zip Qt-8df1491dfb261ab41f9f360af8e23fd283ad1ca5.tar.gz Qt-8df1491dfb261ab41f9f360af8e23fd283ad1ca5.tar.bz2 |
Calculate default configuration if one is not provided by engines.
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index a94fd2f..9ebb0b3 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -173,6 +173,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() QFactoryLoader *l = loader(); + QBearerEngine *generic = 0; + foreach (const QString &key, l->keys()) { QBearerEnginePlugin *plugin = qobject_cast<QBearerEnginePlugin *>(l->instance(key)); if (plugin) { @@ -180,7 +182,11 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() if (!engine) continue; - sessionEngines.append(engine); + if (key == QLatin1String("generic")) + generic = engine; + else + sessionEngines.append(engine); + connect(engine, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations())); connect(engine, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), @@ -193,6 +199,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() capFlags |= engine->capabilities(); } } + + sessionEngines.append(generic); } QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender()); @@ -229,6 +237,58 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration( } } + // Engines don't have a default configuration. + + // Return first active snap + QNetworkConfigurationPrivatePointer firstDiscovered; + + foreach (QBearerEngine *engine, sessionEngines) { + foreach (const QString &id, engine->snapConfigurations.keys()) { + QNetworkConfigurationPrivatePointer ptr = engine->snapConfigurations.value(id); + + if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + QNetworkConfiguration config; + config.d = ptr; + return config; + } else if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + firstDiscovered = ptr; + } + } + } + + // No Active SNAPs return first Discovered SNAP. + if (firstDiscovered) { + QNetworkConfiguration config; + config.d = firstDiscovered; + return config; + } + + // No Active or Discovered SNAPs, do same for InternetAccessPoints. + firstDiscovered.reset(); + + foreach (QBearerEngine *engine, sessionEngines) { + foreach (const QString &id, engine->accessPointConfigurations.keys()) { + QNetworkConfigurationPrivatePointer ptr = engine->accessPointConfigurations.value(id); + + if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { + QNetworkConfiguration config; + config.d = ptr; + return config; + } else if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + firstDiscovered = ptr; + } + } + } + + // No Active InternetAccessPoint return first Discovered InternetAccessPoint. + if (firstDiscovered) { + QNetworkConfiguration config; + config.d = firstDiscovered; + return config; + } + return QNetworkConfiguration(); } |