From 13ab976001d2e579ad302c95afc6ea65a61cb4ad Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 5 Aug 2013 00:53:18 +0200 Subject: Fix support for http proxy in private mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this patch is a tiny modification of the one provided by Pali Rohàr (thanks!!!). I just misunderstood it before and then forgot in my mail. Sorry for that, Pali. And thank you again :) CCMAIL: pali.rohar@gmail.com --- src/webtab/knetworkaccessmanager.cpp | 42 ++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/webtab/knetworkaccessmanager.cpp b/src/webtab/knetworkaccessmanager.cpp index f02ec2d8..40b53933 100644 --- a/src/webtab/knetworkaccessmanager.cpp +++ b/src/webtab/knetworkaccessmanager.cpp @@ -51,21 +51,45 @@ KNetworkAccessManager::KNetworkAccessManager(QObject *parent) kDebug() << "PROXY TYPE: " << proxyType; if (proxyType == 0) - proxy.setType(QNetworkProxy::NoProxy); - else - proxy.setType(QNetworkProxy::Socks5Proxy); + return; + + QStringList httpProxy = proxyGroup.readEntry( QL1S("httpProxy"), QString("") ).split(QL1C(' ')); + QStringList socksProxy = proxyGroup.readEntry( QL1S("socksProxy"), QString("") ).split(QL1C(' ')); + + QStringList proxyInfoList; - QString proxyHost = proxyGroup.readEntry( QL1S("socksProxy"), QString("") ); - QStringList proxyInfoList = proxyHost.split(QL1C(' ')); - kDebug() << proxyInfoList; + if (!httpProxy.isEmpty()) + { + proxy.setType(QNetworkProxy::HttpProxy); + proxyInfoList = httpProxy; + } + else + { + if (!socksProxy.isEmpty()) + { + proxy.setType(QNetworkProxy::Socks5Proxy); + proxyInfoList = socksProxy; + } + } + if (proxyInfoList.isEmpty()) return; - proxy.setHostName(proxyInfoList.at(0)); + // else + proxyInfoList.first().remove("http://"); + + // set host + QString proxyHost = proxyInfoList.at(0); + kDebug() << "PROXY HOST: " << proxyHost; + proxy.setHostName(proxyHost); + // set port if (proxyInfoList.count() == 2) - proxy.setPort(proxyInfoList.at(1).toInt()); - + { + int proxyPort = proxyInfoList.at(1).toInt(); + kDebug() << "PROXY PORT: " << proxyPort; + proxy.setPort(proxyPort); + } // proxy.setUser("username"); // proxy.setPassword("password"); // -- cgit v1.2.1