Add ProxyType setting in preparation of SOCKS5 proxy support.
authorgregor herrmann <gregor@toastfreeware.priv.at>
Thu, 5 Oct 2017 11:27:04 +0000 (13:27 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Thu, 5 Oct 2017 15:59:45 +0000 (17:59 +0200)
src/app/appsettings.cpp
src/app/appsettings.h
src/gui/mainwindow.cpp
src/gui/settingsdialog.cpp

index b98060d..477c1b0 100644 (file)
@@ -21,7 +21,8 @@
 
 const QString PROXY_ADDRESS_SETTING ("proxyAddress"); 
 const QString PROXY_PORT_SETTING ("proxyPort"); 
-const QString PROXY_ISDIRECT_SETTING ("proxyIsDirectConnection"); 
+const QString PROXY_TYPE_SETTING ("proxyType");
+const QString PROXY_ISDIRECT_SETTING ("proxyIsDirectConnection");
 
 QSettings AppSettings::mSettings("Toastfreeware", "ConfClerk");
 
@@ -35,6 +36,12 @@ quint16 AppSettings::proxyPort()
     return mSettings.value(PROXY_PORT_SETTING).toUInt();
 }
 
+//QNetworkProxy::ProxyType
+int AppSettings::proxyType()
+{
+    return mSettings.value(PROXY_TYPE_SETTING).toInt();
+}
+
 bool AppSettings::isDirectConnection()
 {
     return mSettings.value(PROXY_ISDIRECT_SETTING).toBool();
@@ -50,6 +57,12 @@ void AppSettings::setProxyPort(const quint16 aPort)
     mSettings.setValue(PROXY_PORT_SETTING, aPort);
 }
 
+// QNetworkProxy::ProxyType
+void AppSettings::setProxyType(const int aType)
+{
+    mSettings.setValue(PROXY_TYPE_SETTING, aType);
+}
+
 void AppSettings::setDirectConnection(bool aDirectConnection)
 {
     mSettings.setValue(PROXY_ISDIRECT_SETTING, aDirectConnection);
index 8e5822e..7f26441 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <QString>
 #include <QSettings>
+#include <QNetworkProxy>
 
 class AppSettings
 {
@@ -35,10 +36,12 @@ class AppSettings
 
         static QString proxyAddress();
         static quint16 proxyPort();
+        static int proxyType(); // QNetworkProxy::ProxyType
         static bool isDirectConnection();
 
         static void setProxyAddress(const QString &aAddress);
         static void setProxyPort(const quint16 aPort);
+        static void setProxyType(const int aProxyType); // QNetworkProxy::ProxyType
         static void setDirectConnection(bool aDirectConnection);
         static int preEventAlarmSec() {return 60*15;} ///< seconds that alarm should ring before an event starts
 };
index 3b2582a..dbbcb2f 100644 (file)
@@ -82,7 +82,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) {
         AppSettings::setDirectConnection(true);
 
     QNetworkProxy proxy(
-            AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy,
+            AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : (QNetworkProxy::ProxyType)AppSettings::proxyType(),
             AppSettings::proxyAddress(),
             AppSettings::proxyPort(),
             PROXY_USERNAME,
@@ -363,7 +363,7 @@ void MainWindow::on_settingsAction_triggered()
     if (dialog.exec() == QDialog::Accepted) {
         dialog.saveDialogData();
         QNetworkProxy proxy(
-                AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy,
+                AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : (QNetworkProxy::ProxyType)AppSettings::proxyType(),
                 AppSettings::proxyAddress(),
                 AppSettings::proxyPort(),
                 PROXY_USERNAME,
index 13e4e1d..dfaff36 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "appsettings.h"
 #include <QDebug>
+#include <QNetworkProxy>
 
 SettingsDialog::SettingsDialog(QWidget *aParent)
     : QDialog(aParent)
@@ -45,6 +46,7 @@ void SettingsDialog::saveDialogData()
     // serialize dialog data
     AppSettings::setProxyAddress(address->text());
     AppSettings::setProxyPort(port->value());
+    AppSettings::setProxyType(QNetworkProxy::HttpProxy); // TODO!!
     AppSettings::setDirectConnection(directConnection->isChecked());
 }