summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-05-17 12:07:42 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-05-18 12:25:24 (GMT)
commit1eff8e70fb9154c3ee96aefd8f6fd44429b117fa (patch)
tree895c42761ea6859466e93292a68d18905fce1da6 /src/network
parent91bf24d44690a643d7cb74ab594da949b9e51e1b (diff)
downloadQt-1eff8e70fb9154c3ee96aefd8f6fd44429b117fa.zip
Qt-1eff8e70fb9154c3ee96aefd8f6fd44429b117fa.tar.gz
Qt-1eff8e70fb9154c3ee96aefd8f6fd44429b117fa.tar.bz2
Symbian socket: Implement systemProxyForQuery for service networks
When the specified (or active/default) network is a service network, try to determine the appropriate IAP network within it. This is the highest priority active network (if any) followed by the highest priority discovered network (if any) or the highest priority network as a last resort. As Symbian doesn't include proxy type in the comms database, proxies are assumed to be http type unless the port is 1080 (iana assigned port for SOCKS) in which case the proxy is set as SOCKS type. Also fixed unitialised member issue with SymbianIapId internal class Task-number: QTBUG-18618 Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qnetworkproxy_symbian.cpp89
1 files changed, 52 insertions, 37 deletions
diff --git a/src/network/kernel/qnetworkproxy_symbian.cpp b/src/network/kernel/qnetworkproxy_symbian.cpp
index 4ba14c0..1fb31b5 100644
--- a/src/network/kernel/qnetworkproxy_symbian.cpp
+++ b/src/network/kernel/qnetworkproxy_symbian.cpp
@@ -68,74 +68,80 @@ QT_BEGIN_NAMESPACE
class SymbianIapId
{
public:
- enum State{
- NotValid,
- Valid
- };
- Q_DECLARE_FLAGS(States, State)
- SymbianIapId() {}
+ SymbianIapId() : valid(false), id(0) {}
~SymbianIapId() {}
- void setIapId(TUint32 iapId) { iapState |= Valid; id = iapId; }
- bool isValid() { return iapState == Valid; }
+ void setIapId(TUint32 iapId) { valid = true; id = iapId; }
+ bool isValid() { return valid; }
TUint32 iapId() { return id; }
private:
- QFlags<States> iapState;
+ bool valid;
TUint32 id;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(SymbianIapId::States)
-
class SymbianProxyQuery
{
public:
static QNetworkConfiguration findCurrentConfiguration(QNetworkConfigurationManager& configurationManager);
+ static QNetworkConfiguration findCurrentConfigurationFromServiceNetwork(const QNetworkConfiguration& serviceNetwork);
static SymbianIapId getIapId(QNetworkConfigurationManager &configurationManager, const QNetworkProxyQuery &query);
static CCDIAPRecord *getIapRecordLC(TUint32 aIAPId, CMDBSession &aDb);
static CMDBRecordSet<CCDProxiesRecord> *prepareQueryLC(TUint32 serviceId, TDesC& serviceType);
static QList<QNetworkProxy> proxyQueryL(TUint32 aIAPId, const QNetworkProxyQuery &query);
};
+QNetworkConfiguration SymbianProxyQuery::findCurrentConfigurationFromServiceNetwork(const QNetworkConfiguration& serviceNetwork)
+{
+ // Note: This code assumes that the only unambigious way to
+ // find current proxy config is if there is only one access point
+ // or if the found access point is immediately usable.
+ QList<QNetworkConfiguration> childConfigurations = serviceNetwork.children();
+ if (childConfigurations.isEmpty()) {
+ qWarning("QNetworkProxyFactory::systemProxyForQuery called with empty service network");
+ return QNetworkConfiguration();
+ } else if (childConfigurations.count() == 1) {
+ //if only one IAP in the service network, it's always going to be used.
+ return childConfigurations.at(0);
+ } else {
+ //use highest priority active config, if available
+ for (int index = 0; index < childConfigurations.count(); index++) {
+ QNetworkConfiguration childConfig = childConfigurations.at(index);
+ if (childConfig.isValid() && childConfig.state() == QNetworkConfiguration::Active)
+ return childConfig;
+ }
+ //otherwise use highest priority discovered config (that's the one which will be activated if start were called now)
+ for (int index = 0; index < childConfigurations.count(); index++) {
+ QNetworkConfiguration childConfig = childConfigurations.at(index);
+ if (childConfig.isValid() && childConfig.state() == QNetworkConfiguration::Discovered)
+ return childConfig;
+ }
+ //otherwise the highest priority defined (most likely to be activated if all were available when start is called)
+ qWarning("QNetworkProxyFactory::systemProxyForQuery called with service network, but none of its IAPs are available");
+ return childConfigurations.at(0);
+ }
+}
+
QNetworkConfiguration SymbianProxyQuery::findCurrentConfiguration(QNetworkConfigurationManager& configurationManager)
{
QList<QNetworkConfiguration> activeConfigurations = configurationManager.allConfigurations(
QNetworkConfiguration::Active);
- QNetworkConfiguration currentConfig;
if (activeConfigurations.count() > 0) {
- currentConfig = activeConfigurations.at(0);
+ return activeConfigurations.at(0);
} else {
// No active configurations, try default one
QNetworkConfiguration defaultConfiguration = configurationManager.defaultConfiguration();
if (defaultConfiguration.isValid()) {
switch (defaultConfiguration.type()) {
case QNetworkConfiguration::InternetAccessPoint:
- currentConfig = defaultConfiguration;
- break;
+ return defaultConfiguration;
case QNetworkConfiguration::ServiceNetwork:
- {
- // Note: This code assumes that the only unambigious way to
- // find current proxy config is if there is only one access point
- // or if the found access point is immediately usable.
- QList<QNetworkConfiguration> childConfigurations = defaultConfiguration.children();
- if (childConfigurations.count() == 1) {
- currentConfig = childConfigurations.at(0);
- } else {
- for (int index = 0; index < childConfigurations.count(); index++) {
- QNetworkConfiguration childConfig = childConfigurations.at(index);
- if (childConfig.isValid() && childConfig.state() == QNetworkConfiguration::Discovered) {
- currentConfig = childConfig;
- break;
- }
- }
- }
- }
- break;
+ return findCurrentConfigurationFromServiceNetwork(defaultConfiguration);
case QNetworkConfiguration::UserChoice:
- // User choice is not a valid configuration for proxy discovery
+ qWarning("QNetworkProxyFactory::systemProxyForQuery called with user choice configuration, which is not valid");
break;
}
}
}
- return currentConfig;
+ return QNetworkConfiguration();
}
SymbianIapId SymbianProxyQuery::getIapId(QNetworkConfigurationManager& configurationManager, const QNetworkProxyQuery &query)
@@ -147,7 +153,11 @@ SymbianIapId SymbianProxyQuery::getIapId(QNetworkConfigurationManager& configura
//If config is not specified, then try to find out an active or default one
currentConfig = findCurrentConfiguration(configurationManager);
}
- if (currentConfig.isValid()) {
+ if (currentConfig.isValid() && currentConfig.type() == QNetworkConfiguration::ServiceNetwork) {
+ //convert service network to the real IAP.
+ currentConfig = findCurrentConfigurationFromServiceNetwork(currentConfig);
+ }
+ if (currentConfig.isValid() && currentConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
// 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
@@ -236,7 +246,12 @@ QList<QNetworkProxy> SymbianProxyQuery::proxyQueryL(TUint32 aIAPId, const QNetwo
CleanupStack::Pop(); // serverName
TUint32 port = proxyRecord->iPortNumber;
- QNetworkProxy proxy(QNetworkProxy::HttpProxy, serverNameQt, port);
+ //Symbian config doesn't include proxy type, assume http unless the port matches assigned port of another type
+ //Mobile operators use a wide variety of port numbers for http proxies.
+ QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy;
+ if (port == 1080) //IANA assigned port for SOCKS
+ proxyType = QNetworkProxy::Socks5Proxy;
+ QNetworkProxy proxy(proxyType, serverNameQt, port);
foundProxies.append(proxy);
}
}