From d3b580fe8b2b0c185f0eadbf794156058496eff3 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 25 Jan 2010 09:53:12 +1000 Subject: Return default configuration from engines. --- src/network/bearer/qnetworkconfigmanager_p.cpp | 34 ++++++-------------------- src/network/bearer/qnetworksessionengine_p.h | 2 ++ src/plugins/bearer/generic/qgenericengine.cpp | 5 ++++ src/plugins/bearer/generic/qgenericengine.h | 2 ++ 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index c00d6d3..bc3cfbd 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -212,42 +212,24 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() } /*! - Returns the first active configuration found, if one exists; otherwise returns the first - discovered configuration found, if one exists; otherwise returns an empty configuration. + Returns the default configuration of the first plugin, if one exists; otherwise returns an + invalid configuration. \internal */ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() { - QNetworkConfigurationPrivatePointer firstActive; - QNetworkConfigurationPrivatePointer firstDiscovered; - foreach (QNetworkSessionEngine *engine, sessionEngines) { - QHash::const_iterator i = - engine->accessPointConfigurations.constBegin(); - - while (i != engine->accessPointConfigurations.constEnd()) { - QNetworkConfigurationPrivatePointer priv = i.value(); - - if (!firstActive && priv->isValid && - (priv->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) - firstActive = priv; - if (!firstDiscovered && priv->isValid && - (priv->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) - firstDiscovered = priv; + QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration(); - ++i; + if (ptr) { + QNetworkConfiguration config; + config.d = ptr; + return config; } } - QNetworkConfiguration item; - - if (firstActive) - item.d = firstActive; - else if (firstDiscovered) - item.d = firstDiscovered; - - return item; + return QNetworkConfiguration(); } void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() diff --git a/src/network/bearer/qnetworksessionengine_p.h b/src/network/bearer/qnetworksessionengine_p.h index 02772cb..029c2c5 100644 --- a/src/network/bearer/qnetworksessionengine_p.h +++ b/src/network/bearer/qnetworksessionengine_p.h @@ -99,6 +99,8 @@ public: virtual QNetworkSessionPrivate *createSessionBackend() = 0; + virtual QNetworkConfigurationPrivatePointer defaultConfiguration() = 0; + public: //this table contains an up to date list of all configs at any time. //it must be updated if configurations change, are added/removed or diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index e9770e1..55d1ae4 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -325,5 +325,10 @@ QNetworkSessionPrivate *QGenericEngine::createSessionBackend() return new QNetworkSessionPrivateImpl; } +QNetworkConfigurationPrivatePointer QGenericEngine::defaultConfiguration() +{ + return QNetworkConfigurationPrivatePointer(); +} + QT_END_NAMESPACE diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h index 04b845e..b44685b 100644 --- a/src/plugins/bearer/generic/qgenericengine.h +++ b/src/plugins/bearer/generic/qgenericengine.h @@ -76,6 +76,8 @@ public: QNetworkSessionPrivate *createSessionBackend(); + QNetworkConfigurationPrivatePointer defaultConfiguration(); + private Q_SLOTS: void doRequestUpdate(); -- cgit v0.12