summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorJyri Tahtela <jyri.tahtela@nokia.com>2011-05-19 13:56:55 (GMT)
committerJyri Tahtela <jyri.tahtela@nokia.com>2011-05-19 13:56:55 (GMT)
commit94051a438e64eaede021b4e926ef58f793a09a70 (patch)
tree9860dc49d8e6453df356f51da9126b583ac35206 /src/network
parent06557b8d7c472c6298f7d8b310feda225864265f (diff)
parent35b5f15c3fe5c2f1f0d046d09b9d95dee3bb91b5 (diff)
downloadQt-94051a438e64eaede021b4e926ef58f793a09a70.zip
Qt-94051a438e64eaede021b4e926ef58f793a09a70.tar.gz
Qt-94051a438e64eaede021b4e926ef58f793a09a70.tar.bz2
Merge remote-tracking branch 'qt/4.8'
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qhostaddress.cpp31
-rw-r--r--src/network/kernel/qnetworkproxy_symbian.cpp89
2 files changed, 80 insertions, 40 deletions
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index f55f383..7eeb4e5 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -720,7 +720,8 @@ Q_IPV6ADDR QHostAddress::toIPv6Address() const
Returns the address as a string.
For example, if the address is the IPv4 address 127.0.0.1, the
- returned string is "127.0.0.1".
+ returned string is "127.0.0.1". For IPv6 the string format will
+ follow the RFC5952 recommendation.
\sa toIPv4Address()
*/
@@ -741,8 +742,32 @@ QString QHostAddress::toString() const
ugle[i] = (quint16(d->a6[2*i]) << 8) | quint16(d->a6[2*i+1]);
}
QString s;
- s.sprintf("%X:%X:%X:%X:%X:%X:%X:%X",
- ugle[0], ugle[1], ugle[2], ugle[3], ugle[4], ugle[5], ugle[6], ugle[7]);
+ QString temp;
+ bool zeroDetected = false;
+ bool zeroShortened = false;
+ for (int i = 0; i < 8; i++) {
+ if ((ugle[i] != 0) || zeroShortened) {
+ temp.sprintf("%X", ugle[i]);
+ s.append(temp);
+ if (zeroDetected)
+ zeroShortened = true;
+ } else {
+ if (!zeroDetected) {
+ if (i<7 && (ugle[i+1] == 0)) {
+ s.append(QLatin1Char(':'));
+ zeroDetected = true;
+ } else {
+ temp.sprintf("%X", ugle[i]);
+ s.append(temp);
+ if (i<7)
+ s.append(QLatin1Char(':'));
+ }
+ }
+ }
+ if (i<7 && ((ugle[i] != 0) || zeroShortened || (i==0 && zeroDetected)))
+ s.append(QLatin1Char(':'));
+ }
+
if (!d->scopeId.isEmpty())
s.append(QLatin1Char('%') + d->scopeId);
return s;
diff --git a/src/network/kernel/qnetworkproxy_symbian.cpp b/src/network/kernel/qnetworkproxy_symbian.cpp
index 1be8de3..73068d6 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);
}
}