From: Flavio Tordini Date: Mon, 7 Sep 2009 08:37:33 +0000 (+0200) Subject: System proxy on the Mac X-Git-Tag: 0.6~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b5f4733477a4c20f19bd1db634b06f84b1b94c99;p=minitube System proxy on the Mac --- diff --git a/src/global.h b/src/global.h index c96d3d1..4f64187 100644 --- a/src/global.h +++ b/src/global.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "networkaccess.h" @@ -26,6 +27,31 @@ namespace The { return g_menus; } + void maybeSetSystemProxy() { + + QNetworkProxyQuery proxyQuery(QUrl("http://www")); + proxyQuery.setProtocolTag("http"); + QList proxylist = QNetworkProxyFactory::systemProxyForQuery(proxyQuery); + + for (int i = 0; i < proxylist.count(); i++) { + QNetworkProxy proxy = proxylist.at(i); + + /* + qDebug() << i << " type:"<< proxy.type(); + qDebug() << i << " host:" << proxy.hostName(); + qDebug() << i << " port:" << proxy.port(); + qDebug() << i << " user:" << proxy.user(); + qDebug() << i << " pass:" << proxy.password(); + */ + + if (!proxy.hostName().isEmpty()) { + qDebug() << "Using proxy:" << proxy.hostName() << proxy.port(); + QNetworkProxy::setApplicationProxy(proxy); + return; + } + } + } + void networkHttpProxySetting() { char *http_proxy_env; http_proxy_env = std::getenv("http_proxy"); @@ -98,6 +124,7 @@ namespace The { QNetworkAccessManager* networkAccessManager() { if (!nam) { networkHttpProxySetting(); + maybeSetSystemProxy(); nam = new QNetworkAccessManager(); // A simple disk based cache