diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-05-06 12:30:21 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-05-07 08:58:44 (GMT) |
commit | 03b29811a3a6eb34421c476d829075505aa42ada (patch) | |
tree | 211628a14c39cc91405bc02ea7c5f57857ba3288 /src/network/kernel/qnetworkproxy.cpp | |
parent | 2fddd3c9b7e45b58b56fec9b89c78af0a8f75731 (diff) | |
download | Qt-03b29811a3a6eb34421c476d829075505aa42ada.zip Qt-03b29811a3a6eb34421c476d829075505aa42ada.tar.gz Qt-03b29811a3a6eb34421c476d829075505aa42ada.tar.bz2 |
Make QNetworkProxy calculate the capabilities for a new proxy type
If you write:
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::HttpProxy);
Then now QNetworkProxy will set the capabilities to the default value
for the new proxy type. Previously, it wouldn't do that: default
values were set only for the type passed in the constructor.
Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/kernel/qnetworkproxy.cpp')
-rw-r--r-- | src/network/kernel/qnetworkproxy.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 5a00840..62bdfc7 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -366,7 +366,8 @@ static QNetworkProxy::Capabilities defaultCapabilitiesForType(QNetworkProxy::Pro int(QNetworkProxy::HostNameLookupCapability)), }; - Q_ASSERT(int(type) >= 0 && int(type) <= int(QNetworkProxy::FtpCachingProxy)); + if (int(type) < 0 && int(type) > int(QNetworkProxy::FtpCachingProxy)) + type = QNetworkProxy::DefaultProxy; return QNetworkProxy::Capabilities(defaults[int(type)]); } @@ -379,6 +380,7 @@ public: QNetworkProxy::Capabilities capabilities; quint16 port; QNetworkProxy::ProxyType type; + bool capabilitiesSet; inline QNetworkProxyPrivate(QNetworkProxy::ProxyType t = QNetworkProxy::DefaultProxy, const QString &h = QString(), quint16 p = 0, @@ -388,7 +390,8 @@ public: password(pw), capabilities(defaultCapabilitiesForType(t)), port(p), - type(t) + type(t), + capabilitiesSet(false) { } inline bool operator==(const QNetworkProxyPrivate &other) const @@ -491,13 +494,16 @@ QNetworkProxy &QNetworkProxy::operator=(const QNetworkProxy &other) Sets the proxy type for this instance to be \a type. Note that changing the type of a proxy does not change - the set of capabilities this QNetworkProxy object holds. + the set of capabilities this QNetworkProxy object holds if any + capabilities have been set with setCapabilities(). \sa type(), setCapabilities() */ void QNetworkProxy::setType(QNetworkProxy::ProxyType type) { d->type = type; + if (!d->capabilitiesSet) + d->capabilities = defaultCapabilitiesForType(type); } /*! @@ -520,6 +526,7 @@ QNetworkProxy::ProxyType QNetworkProxy::type() const void QNetworkProxy::setCapabilities(Capabilities capabilities) { d->capabilities = capabilities; + d->capabilitiesSet = true; } /*! |