Implement proxy re-configuration

- application level proxy is reconfigured on settings saving
- tested with direct connection (no proxy), local proxy without auth
  (tinyproxy) and SOCKS (ssh -D dynamic port forwarding)
- not sure about QNetworkProxy reuse between invocations
- consider using QNetworkProxyFactory (but since no plain TCP
  connections are used, QNetworkProxy seems to be good choice)

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Sergey Starosek 2014-06-26 20:20:34 +04:00 committed by Dirk Hohndel
parent 9fca5a51d9
commit 5a98a221cc

View file

@ -51,6 +51,7 @@
#ifndef NO_USERMANUAL
#include "usermanual.h"
#endif
#include <QNetworkProxy>
MainWindow *MainWindow::m_Instance = NULL;
@ -828,6 +829,18 @@ void MainWindow::readSettings()
default_dive_computer_product = getSetting(s, "dive_computer_product");
default_dive_computer_device = getSetting(s, "dive_computer_device");
s.endGroup();
QNetworkProxy proxy;
proxy.setType(QNetworkProxy::ProxyType(prefs.proxy_type));
proxy.setHostName(prefs.proxy_host);
proxy.setPort(prefs.proxy_port);
if (prefs.proxy_auth) {
proxy.setUser(prefs.proxy_user);
proxy.setPassword(prefs.proxy_pass);
}
QNetworkProxy::setApplicationProxy(proxy);
loadRecentFiles(&s);
checkSurvey(&s);
}