diff --git a/src/lib/network/networkproxyfactory.cpp b/src/lib/network/networkproxyfactory.cpp index e02cb38f8..da2c2c4b0 100644 --- a/src/lib/network/networkproxyfactory.cpp +++ b/src/lib/network/networkproxyfactory.cpp @@ -31,10 +31,18 @@ void NetworkProxyFactory::loadSettings() settings.beginGroup("Web-Proxy"); m_proxyPreference = ProxyPreference(settings.value("UseProxy", SystemProxy).toInt()); m_proxyType = QNetworkProxy::ProxyType(settings.value("ProxyType", QNetworkProxy::HttpProxy).toInt()); + m_useDifferentProxyForHttps = settings.value("UseDifferentProxyForHttps", false).toBool(); + m_hostName = settings.value("HostName", "").toString(); m_port = settings.value("Port", 8080).toInt(); m_username = settings.value("Username", "").toString(); m_password = settings.value("Password", "").toString(); + + m_httpsHostName = settings.value("HttpsHostName", "").toString(); + m_httpsPort = settings.value("HttpsPort", 8080).toInt(); + m_httpsUsername = settings.value("HttpsUsername", "").toString(); + m_httpsPassword = settings.value("HttpsPassword", "").toString(); + m_proxyExceptions = settings.value("ProxyExceptions", QStringList() << "localhost" << "127.0.0.1").toStringList(); settings.endGroup(); } @@ -44,13 +52,12 @@ QList NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q QNetworkProxy proxy; if (m_proxyExceptions.contains(query.url().host(), Qt::CaseInsensitive)) { - proxy.setType(QNetworkProxy::NoProxy); + return QList() << QNetworkProxy::NoProxy; } switch (m_proxyPreference) { case SystemProxy: return systemProxyForQuery(query); - break; case NoProxy: proxy.setType(QNetworkProxy::NoProxy); @@ -58,10 +65,28 @@ QList NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q case DefinedProxy: proxy.setType(m_proxyType); - proxy.setHostName(m_hostName); - proxy.setPort(m_port); - proxy.setUser(m_username); - proxy.setPassword(m_password); + + if (m_useDifferentProxyForHttps && query.url().scheme() == "https") { + proxy.setHostName(m_httpsHostName); + proxy.setPort(m_httpsPort); + proxy.setUser(m_httpsUsername); + proxy.setPassword(m_httpsPassword); + } + else { + proxy.setHostName(m_hostName); + proxy.setPort(m_port); + proxy.setUser(m_username); + proxy.setPassword(m_password); + } + + if (proxy.hostName().isEmpty()) { + proxy = QNetworkProxy::NoProxy; + } + + break; + + default: + qWarning("NetworkProxyFactory::queryProxy Unknown proxy type!"); break; } diff --git a/src/lib/network/networkproxyfactory.h b/src/lib/network/networkproxyfactory.h index 47efe7839..26377607f 100644 --- a/src/lib/network/networkproxyfactory.h +++ b/src/lib/network/networkproxyfactory.h @@ -36,11 +36,19 @@ public: private: ProxyPreference m_proxyPreference; QNetworkProxy::ProxyType m_proxyType; + QString m_hostName; quint16 m_port; QString m_username; QString m_password; + + QString m_httpsHostName; + quint16 m_httpsPort; + QString m_httpsUsername; + QString m_httpsPassword; + QStringList m_proxyExceptions; + bool m_useDifferentProxyForHttps; }; #endif // NETWORKPROXYFACTORY_H diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 586d9ed95..75ee952c7 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -373,16 +373,14 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->languages->addItem(language + ", " + country + " (" + loc + ")", name); } - //Proxy Config + // Proxy Configuration settings.beginGroup("Web-Proxy"); NetworkProxyFactory::ProxyPreference proxyPreference = NetworkProxyFactory::ProxyPreference(settings.value("UseProxy", NetworkProxyFactory::SystemProxy).toInt()); QNetworkProxy::ProxyType proxyType = QNetworkProxy::ProxyType(settings.value("ProxyType", QNetworkProxy::HttpProxy).toInt()); - connect(ui->manualProxy, SIGNAL(toggled(bool)), this, SLOT(setManualProxyConfigurationEnabled(bool))); ui->systemProxy->setChecked(proxyPreference == NetworkProxyFactory::SystemProxy); ui->noProxy->setChecked(proxyPreference == NetworkProxyFactory::NoProxy); ui->manualProxy->setChecked(proxyPreference == NetworkProxyFactory::DefinedProxy); - setManualProxyConfigurationEnabled(proxyPreference == NetworkProxyFactory::DefinedProxy); if (proxyType == QNetworkProxy::HttpProxy) { ui->proxyType->setCurrentIndex(0); } @@ -394,9 +392,22 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) ui->proxyPort->setText(settings.value("Port", 8080).toString()); ui->proxyUsername->setText(settings.value("Username", "").toString()); ui->proxyPassword->setText(settings.value("Password", "").toString()); + + ui->useHttpsProxy->setChecked(settings.value("UseDifferentProxyForHttps", false).toBool()); + ui->httpsProxyServer->setText(settings.value("HttpsHostName", "").toString()); + ui->httpsProxyPort->setText(settings.value("HttpsPort", 8080).toString()); + ui->httpsProxyUsername->setText(settings.value("HttpsUsername", "").toString()); + ui->httpsProxyPassword->setText(settings.value("HttpsPassword", "").toString()); + ui->proxyExceptions->setText(settings.value("ProxyExceptions", QStringList() << "localhost" << "127.0.0.1").toStringList().join(",")); settings.endGroup(); + useDifferentProxyForHttpsChanged(ui->useHttpsProxy->isChecked()); + setManualProxyConfigurationEnabled(proxyPreference == NetworkProxyFactory::DefinedProxy); + + connect(ui->manualProxy, SIGNAL(toggled(bool)), this, SLOT(setManualProxyConfigurationEnabled(bool))); + connect(ui->useHttpsProxy, SIGNAL(toggled(bool)), this, SLOT(useDifferentProxyForHttpsChanged(bool))); + //CONNECTS connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*))); connect(ui->cookieManagerBut, SIGNAL(clicked()), this, SLOT(showCookieManager())); @@ -533,7 +544,10 @@ void Preferences::setManualProxyConfigurationEnabled(bool state) ui->proxyPort->setEnabled(state); ui->proxyUsername->setEnabled(state); ui->proxyPassword->setEnabled(state); - ui->proxyExceptions->setEnabled(state); + + useDifferentProxyForHttpsChanged(state ? ui->useHttpsProxy->isChecked() : false); + + ui->useHttpsProxy->setEnabled(state); } void Preferences::allowJavaScriptChanged(bool state) @@ -609,6 +623,14 @@ void Preferences::changeUserAgentChanged(bool state) ui->userAgentCombo->setEnabled(state); } +void Preferences::useDifferentProxyForHttpsChanged(bool state) +{ + ui->httpsProxyServer->setEnabled(state); + ui->httpsProxyPort->setEnabled(state); + ui->httpsProxyUsername->setEnabled(state); + ui->httpsProxyPassword->setEnabled(state); +} + void Preferences::showPassManager(bool state) { m_autoFillManager->setVisible(state); @@ -870,6 +892,13 @@ void Preferences::saveSettings() settings.setValue("Port", ui->proxyPort->text().toInt()); settings.setValue("Username", ui->proxyUsername->text()); settings.setValue("Password", ui->proxyPassword->text()); + + settings.setValue("UseDifferentProxyForHttps", ui->useHttpsProxy->isChecked()); + settings.setValue("HttpsHostName", ui->httpsProxyServer->text()); + settings.setValue("HttpsPort", ui->httpsProxyPort->text()); + settings.setValue("HttpsUsername", ui->httpsProxyUsername->text()); + settings.setValue("HttpsPassword", ui->httpsProxyPassword->text()); + settings.setValue("ProxyExceptions", ui->proxyExceptions->text().split(",")); settings.endGroup(); diff --git a/src/lib/preferences/preferences.h b/src/lib/preferences/preferences.h index 546f56b44..28a528c95 100644 --- a/src/lib/preferences/preferences.h +++ b/src/lib/preferences/preferences.h @@ -71,6 +71,7 @@ private slots: void setManualProxyConfigurationEnabled(bool state); void useExternalDownManagerChanged(bool state); void changeUserAgentChanged(bool state); + void useDifferentProxyForHttpsChanged(bool state); void cacheValueChanged(int value); void pageCacheValueChanged(int value); diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index b1a0a073e..365d0b9db 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -1178,7 +1178,7 @@ - + @@ -1194,7 +1194,7 @@ - + Don't use on: @@ -1238,6 +1238,71 @@ + + + + <b>Exceptions</b> + + + + + + + Server: + + + + + + + Username: + + + + + + + Password: + + + + + + + + + + + + + + + + + + Port: + + + + + + + + 50 + 16777215 + + + + + + + + + + Use different proxy for https connection + + + diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 8bb864e81..5d49f925f 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -510,6 +510,9 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte case QNetworkReply::ContentNotFoundError: errorString = tr("Content not found"); break; + case QNetworkReply::UnknownNetworkError: + errorString = exOption->errorString.isEmpty() ? tr("Unknown network error") : exOption->errorString; + break; case QNetworkReply::ContentAccessDenied: if (exOption->errorString.startsWith("AdBlockRule")) { if (exOption->frame != erPage->mainFrame()) { //Content in