Add debug stream operator for QNetworkProxy

Change-Id: Ib8e7ba041ede33dc9c751432e39be2d6a9f4662d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Shane Kearns 2012-02-28 11:57:12 +00:00 committed by Qt by Nokia
parent 3c47b52bd3
commit 3650ce5a85
2 changed files with 51 additions and 0 deletions

View File

@ -224,8 +224,10 @@
#include "private/qsocks5socketengine_p.h"
#include "private/qhttpsocketengine_p.h"
#include "qauthenticator.h"
#include "qdebug.h"
#include "qhash.h"
#include "qmutex.h"
#include "qstringlist.h"
#include "qurl.h"
#ifndef QT_NO_BEARERMANAGEMENT
@ -1508,6 +1510,51 @@ QList<QNetworkProxy> QNetworkProxyFactory::proxyForQuery(const QNetworkProxyQuer
return globalNetworkProxy()->proxyForQuery(query);
}
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QNetworkProxy &proxy)
{
QNetworkProxy::ProxyType type = proxy.type();
switch (type) {
case QNetworkProxy::NoProxy:
debug << "NoProxy ";
break;
case QNetworkProxy::DefaultProxy:
debug << "DefaultProxy ";
break;
case QNetworkProxy::Socks5Proxy:
debug << "Socks5Proxy ";
break;
case QNetworkProxy::HttpProxy:
debug << "HttpProxy ";
break;
case QNetworkProxy::HttpCachingProxy:
debug << "HttpCachingProxy ";
break;
case QNetworkProxy::FtpCachingProxy:
debug << "FtpCachingProxy ";
break;
default:
debug << "Unknown proxy " << int(type);
break;
}
debug << "\"" << proxy.hostName() << ":" << proxy.port() << "\" ";
QNetworkProxy::Capabilities caps = proxy.capabilities();
QStringList scaps;
if (caps & QNetworkProxy::TunnelingCapability)
scaps << QStringLiteral("Tunnel");
if (caps & QNetworkProxy::ListeningCapability)
scaps << QStringLiteral("Listen");
if (caps & QNetworkProxy::UdpTunnelingCapability)
scaps << QStringLiteral("UDP");
if (caps & QNetworkProxy::CachingCapability)
scaps << QStringLiteral("Caching");
if (caps & QNetworkProxy::HostNameLookupCapability)
scaps << QStringLiteral("NameLookup");
debug << "[" << scaps.join(QStringLiteral(" ")) << "]";
return debug;
}
#endif
QT_END_NAMESPACE
#endif // QT_NO_NETWORKPROXY

View File

@ -203,6 +203,10 @@ public:
static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery());
};
#ifndef QT_NO_DEBUG_STREAM
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkProxy &proxy);
#endif
QT_END_NAMESPACE
QT_END_HEADER