Commit efb58d59 authored by Jonathan Marten's avatar Jonathan Marten Committed by Stefano Crocco
Browse files

Fix proxy configuration where WebEngine is not the default

Commit 2b45b2af introduced checking and synchronisation of the KIO proxy
configuration with WebEngine (which can only use a limited set of the
available options).  However, if WebEngine is not the default part
(webengineIsDefault in KonqMainWindow::updateProxyForWebEngine()), the
Qt application proxy is unconditionally set to NoProxy.  This may not be
correct if the user has set proxy environment variables suitable for
WebEngine but it is not the default.

In order to cover the case where WebEngine is not the default but the user
may wish to switch to it later, if it is not the default then assume that
the existing proxy settings are as intended and do not change them.
parent 257014a8
...@@ -5534,32 +5534,31 @@ void KonqMainWindow::updateProxyForWebEngine(bool updateProtocolManager) ...@@ -5534,32 +5534,31 @@ void KonqMainWindow::updateProxyForWebEngine(bool updateProtocolManager)
KService::Ptr service = KMimeTypeTrader::self()->preferredService("text/html", "KParts/ReadOnlyPart"); KService::Ptr service = KMimeTypeTrader::self()->preferredService("text/html", "KParts/ReadOnlyPart");
Q_ASSERT(service); Q_ASSERT(service);
bool webengineIsDefault = service->desktopEntryName() == "webenginepart"; const bool webengineIsDefault = service->desktopEntryName() == "webenginepart";
if (!webengineIsDefault) {
return;
}
KProtocolManager::ProxyType proxyType = KProtocolManager::proxyType(); KProtocolManager::ProxyType proxyType = KProtocolManager::proxyType();
if (proxyType == KProtocolManager::WPADProxy || proxyType == KProtocolManager::PACProxy) { if (proxyType == KProtocolManager::WPADProxy || proxyType == KProtocolManager::PACProxy) {
if (webengineIsDefault) { QString msg = i18n("Your proxy configuration can't be used with the QtWebEngine HTML engine. "
QString msg = i18n("Your proxy configuration can't be used with the QtWebEngine HTML engine. " "No proxy will be used\n\n QtWebEngine only support a fixed proxy, so proxy auto-configuration (PAC) "
"No proxy will be used\n\n QtWebEngine only support a fixed proxy, so proxy auto-configuration (PAC) " "and Web Proxy Auto-Discovery protocol can't be used with QtWebEngine. If you need a proxy, please select "
"and Web Proxy Auto-Discovery protocol can't be used with QtWebEngine. If you need a proxy, please select " "the system proxy configuration or specify a proxy URL manually in the settings dialog. Do you want to "
"the system proxy configuration or specify a proxy URL manually in the settings dialog. Do you want to " "change proxy settings now?");
"change proxy settings now?"); KMessageBox::ButtonCode ans = KMessageBox::warningYesNo(this, msg, i18n("Unsupported proxy configuration"), KGuiItem(i18n("Don't use a proxy")),
KMessageBox::ButtonCode ans = KMessageBox::warningYesNo(this, msg, i18n("Unsupported proxy configuration"), KGuiItem(i18n("Don't use a proxy")), KGuiItem(i18n("Show proxy configuration dialog")), "WebEngineUnsupportedProxyType");
KGuiItem(i18n("Show proxy configuration dialog")), "WebEngineUnsupportedProxyType"); QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy)); if (ans == KMessageBox::No) {
if (ans == KMessageBox::No) { slotConfigure("proxy");
slotConfigure("proxy"); return;
}
} else {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
} }
return;
} }
QString httpProxy = KProtocolManager::proxyForUrl(QUrl("http://fakeurl.test.com")); QString httpProxy = KProtocolManager::proxyForUrl(QUrl("http://fakeurl.test.com"));
QString httpsProxy = KProtocolManager::proxyForUrl(QUrl("https://fakeurl.test.com")); QString httpsProxy = KProtocolManager::proxyForUrl(QUrl("https://fakeurl.test.com"));
if (httpProxy == "DIRECT" && httpsProxy == "DIRECT") { if (httpProxy == "DIRECT" && httpsProxy == "DIRECT") {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy)); QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
} else if (webengineIsDefault) { } else {
QUrl url(httpsProxy); QUrl url(httpsProxy);
if (httpProxy != httpsProxy) { if (httpProxy != httpsProxy) {
QString msg = i18n("Your proxy configuration can't be used with the QtWebEngine HTML engine because it doesn't support having different proxies for the HTTP and HTTPS protocols. Your current settings are:" QString msg = i18n("Your proxy configuration can't be used with the QtWebEngine HTML engine because it doesn't support having different proxies for the HTTP and HTTPS protocols. Your current settings are:"
...@@ -5575,7 +5574,5 @@ void KonqMainWindow::updateProxyForWebEngine(bool updateProtocolManager) ...@@ -5575,7 +5574,5 @@ void KonqMainWindow::updateProxyForWebEngine(bool updateProtocolManager)
} }
} }
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, url.host(), url.port(), url.userName(), url.password())); QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, url.host(), url.port(), url.userName(), url.password()));
} else {
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment