diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-11-24 11:40:52 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-11-30 15:24:09 (GMT) |
commit | 916076bfec520210966f67ae211af65b21a29dac (patch) | |
tree | fc1dd2ae8bd1ce6226caeebb54a0827e266417e2 /src/network/kernel | |
parent | be34b17416535a3bd257398e089ad285ee3a2d77 (diff) | |
download | Qt-916076bfec520210966f67ae211af65b21a29dac.zip Qt-916076bfec520210966f67ae211af65b21a29dac.tar.gz Qt-916076bfec520210966f67ae211af65b21a29dac.tar.bz2 |
Symbian - prefer sessions started by this process to choose proxy
When WLAN and 3G connections are both active, the proxy for the wrong
connection may have been chosen in the case of plain sockets or
QNetworkAccessManager with an invalid configuration.
When enumarating active connections to choose a proxy, prefer a connection
that was opened by this process.
Task-number: QTBUG-22615
Task-number: ou1cimx1#930701
Reviewed-by: mread
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qnetworkproxy_symbian.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/network/kernel/qnetworkproxy_symbian.cpp b/src/network/kernel/qnetworkproxy_symbian.cpp index 73068d6..e96c372 100644 --- a/src/network/kernel/qnetworkproxy_symbian.cpp +++ b/src/network/kernel/qnetworkproxy_symbian.cpp @@ -60,6 +60,7 @@ #include <QtNetwork/QNetworkConfigurationManager> #include <QtNetwork/QNetworkConfiguration> #include <QFlags> +#include <QtCore/private/qcore_symbian_p.h> using namespace CommsDat; @@ -73,6 +74,25 @@ public: void setIapId(TUint32 iapId) { valid = true; id = iapId; } bool isValid() { return valid; } TUint32 iapId() { return id; } + static SymbianIapId fromConfiguration(const QNetworkConfiguration& config) + { + SymbianIapId iapId; + // Note: the following code assumes that the identifier is in format + // I_xxxx where xxxx is the identifier of IAP. This is meant as a + // temporary solution until there is a support for returning + // implementation specific identifier. + const int generalPartLength = 2; + QString idString(config.identifier().mid(generalPartLength)); + bool success; + uint id = idString.toUInt(&success); + if (success) + iapId.setIapId(id); + else + qWarning() << "Failed to convert identifier to access point identifier: " + << config.identifier(); + return iapId; + } + private: bool valid; TUint32 id; @@ -122,9 +142,16 @@ QNetworkConfiguration SymbianProxyQuery::findCurrentConfigurationFromServiceNetw QNetworkConfiguration SymbianProxyQuery::findCurrentConfiguration(QNetworkConfigurationManager& configurationManager) { + QList<TUint32> openConfigurations = QSymbianSocketManager::instance().activeConnections(); QList<QNetworkConfiguration> activeConfigurations = configurationManager.allConfigurations( QNetworkConfiguration::Active); + for (int i = 0; i < activeConfigurations.count(); i++) { + // get first configuration which was opened by this process + if (openConfigurations.contains(SymbianIapId::fromConfiguration(activeConfigurations.at(i)).iapId())) + return activeConfigurations.at(i); + } if (activeConfigurations.count() > 0) { + // get first active configuration opened by any process return activeConfigurations.at(0); } else { // No active configurations, try default one |