Added configurable path to extra configuration file.
authorDavid <david@flypig.co.uk>
Tue, 18 Mar 2014 01:08:55 +0000 (01:08 +0000)
committerDavid <david@flypig.co.uk>
Tue, 18 Mar 2014 01:08:55 +0000 (01:08 +0000)
OpenVPNUI.pro.user
qml/pages/ConfigurePage.qml
qml/pages/ConnectPage.qml
rpm/OpenVPNUI.spec
rpm/OpenVPNUI.yaml
src/vpncontrol.cpp
src/vpncontrol.h

index b84568c..3f36955 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 2.8.1, 2014-03-09T01:58:15. -->
+<!-- Written by QtCreator 2.8.1, 2014-03-17T10:17:25. -->
 <qtcreator>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
index d00f37f..7d21761 100644 (file)
@@ -64,6 +64,9 @@ Dialog {
                 case 4:
                     tlsKeyFilename.value = engine.selectedFilename
                     break;
+                case 5:
+                    configFilename.value = engine.selectedFilename
+                    break;
             }
             _fileDialogue = 0;
         }
@@ -151,8 +154,9 @@ Dialog {
 
             ValueButtonAlignRight {
                 id: clientCertFilename
-                value: ((VpnControl.clientCertFile === "") ? "Select" : VpnControl.clientCertFile)
                 label: "Client cert"
+                value: VpnControl.clientCertFile
+                placeholderText: "Select"
                 width: parent.width
                 onClicked: {
                     _fileDialogue = 2;
@@ -162,8 +166,9 @@ Dialog {
 
             ValueButtonAlignRight {
                 id: clientKeyFilename
-                value: ((VpnControl.clientKeyFile === "") ? "Select" : VpnControl.clientKeyFile)
                 label: "Client key"
+                value: VpnControl.clientKeyFile
+                placeholderText: "Select"
                 width: parent.width
                 onClicked: {
                     _fileDialogue = 3;
@@ -173,8 +178,9 @@ Dialog {
 
             ValueButtonAlignRight {
                 id: tlsKeyFilename
-                value: ((VpnControl.tlsKeyFile === "") ? "Select" : VpnControl.tlsKeyFile)
                 label: "TLS key"
+                value: VpnControl.tlsKeyFile
+                placeholderText: "Select"
                 width: parent.width
                 enabled: configureTLS.checked
                 onClicked: {
@@ -182,6 +188,18 @@ Dialog {
                     Functions.goToInitial(Functions.folderFromFile(value), "key")
                 }
             }
+
+            ValueButtonAlignRight {
+                id: configFilename
+                label: "Extra options"
+                value: VpnControl.configFile
+                placeholderText: "Select"
+                width: parent.width
+                onClicked: {
+                    _fileDialogue = 5;
+                    Functions.goToInitial(Functions.folderFromFile(value), "ovpn")
+                }
+            }
         }
     }
 
@@ -196,5 +214,6 @@ Dialog {
         VpnControl.setClientCertFile(clientCertFilename.value)
         VpnControl.setClientKeyFile(clientKeyFilename.value)
         VpnControl.setTlsKeyFile(tlsKeyFilename.value)
+        VpnControl.setConfigFile(configFilename.value)
     }
 }
index 3d6c296..665226e 100644 (file)
@@ -165,6 +165,7 @@ Page {
                     id: logOutput
                     textFormat: Text.PlainText
                     width: parent.width - 2 * Theme.paddingSmall
+                    height: parent.height - 2 * Theme.paddingSmall
                     wrapMode: Text.WrapAnywhere
                     font.pixelSize: Theme.fontSizeTiny * 0.6
                     font.family: "Monospace"
index 93b06cf..5ee1235 100644 (file)
@@ -21,10 +21,10 @@ URL:        http://example.org/
 Source0:    %{name}-%{version}.tar.bz2
 Source100:  OpenVPNUI.yaml
 Requires:   sailfishsilica-qt5 >= 0.10.9
-BuildRequires:  pkgconfig(sailfishapp) >= 0.0.10
-BuildRequires:  pkgconfig(Qt5Core)
-BuildRequires:  pkgconfig(Qt5Qml)
 BuildRequires:  pkgconfig(Qt5Quick)
+BuildRequires:  pkgconfig(Qt5Qml)
+BuildRequires:  pkgconfig(Qt5Core)
+BuildRequires:  pkgconfig(sailfishapp) >= 0.0.10
 BuildRequires:  desktop-file-utils
 
 %description
@@ -63,13 +63,13 @@ desktop-file-install --delete-original       \
 
 %files
 %defattr(-,root,root,-)
-/usr/share/icons/hicolor/86x86/apps
-/usr/share/applications
-/usr/share/OpenVPNUI
-/usr/bin
-%{_datadir}/icons/hicolor/86x86/apps/%{name}.png
-%{_datadir}/applications/%{name}.desktop
-%{_datadir}/%{name}/qml
 %{_bindir}
+%{_datadir}/%{name}/qml
+%{_datadir}/applications/%{name}.desktop
+%{_datadir}/icons/hicolor/86x86/apps/%{name}.png
+/usr/bin
+/usr/share/OpenVPNUI
+/usr/share/applications
+/usr/share/icons/hicolor/86x86/apps
 # >> files
 # << files
index 6c5cd7b..daa3264 100644 (file)
@@ -12,19 +12,19 @@ Description: |
 Configure: none
 Builder: qtc5
 PkgConfigBR:
-- sailfishapp >= 0.0.10
-- Qt5Core
-- Qt5Qml
 - Qt5Quick
+- Qt5Qml
+- Qt5Core
+- sailfishapp >= 0.0.10
 Requires:
 - sailfishsilica-qt5 >= 0.10.9
 Files:
-- /usr/share/icons/hicolor/86x86/apps
-- /usr/share/applications
-- /usr/share/OpenVPNUI
-- /usr/bin
-- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
-- '%{_datadir}/applications/%{name}.desktop'
-- '%{_datadir}/%{name}/qml'
 - '%{_bindir}'
+- '%{_datadir}/%{name}/qml'
+- '%{_datadir}/applications/%{name}.desktop'
+- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
+- /usr/bin
+- /usr/share/OpenVPNUI
+- /usr/share/applications
+- /usr/share/icons/hicolor/86x86/apps
 PkgBR: []
index 3588f7b..12ca3f1 100644 (file)
@@ -15,18 +15,19 @@ VPNControl::VPNControl(QObject *parent) :
 {
     // Read in the settings
     QSettings settings;
+    settings.setValue("showAll", false);
 
+    // Read configuration settings
     server = settings.value("server", "127.0.0.1").toString();
     port = settings.value("port", 1194).toInt();
     compressed = settings.value("compressed", true).toBool();
     useTLS = settings.value("useTLS", true).toBool();
     tlsDirection = settings.value("tlsDirection", 1).toInt();
     caCertFile = settings.value("caCertFile", "").toString();
-    clientCertFile = settings.value("clientCertFile", "").toString();;
-    clientKeyFile = settings.value("clientKeyFile", "").toString();;
-    tlsKeyFile = settings.value("tlsKeyFile", "").toString();;
-
-    settings.setValue("showAll", false);
+    clientCertFile = settings.value("clientCertFile", "").toString();
+    clientKeyFile = settings.value("clientKeyFile", "").toString();
+    tlsKeyFile = settings.value("tlsKeyFile", "").toString();
+    configFile = settings.value("configFile", "").toString();
 }
 
 void VPNControl::initialise()
@@ -152,6 +153,15 @@ void VPNControl::setTlsKeyFile(const QString &value)
     }
 }
 
+void VPNControl::setConfigFile(const QString &value)
+{
+    if (value != configFile) {
+        configFile = value;
+        settingsSetValue("configFile", value);
+        emit tlsKeyFileChanged(configFile);
+    }
+}
+
 QString VPNControl::getClientCertFile () const
 {
     return clientCertFile;
@@ -167,6 +177,11 @@ QString VPNControl::getTlsKeyFile () const
     return tlsKeyFile;
 }
 
+QString VPNControl::getConfigFile () const
+{
+    return configFile;
+}
+
 QString VPNControl::getLogText() const
 {
     return logText;
@@ -214,7 +229,7 @@ void VPNControl::vpnConnect() {
 void VPNControl::collectArguments () {
     arguments.clear();
 
-    addArgumentNonempty("config", "/home/nemo/Documents/Configure/OpenVPN/config.ovpn");
+    addArgumentNonempty("config", configFile);
     addArgumentNonempty("remote", server);
     addArgumentNonempty("port", QString::number(port));
     addOption("comp-lzo", compressed);
index 12ff248..d89120f 100644 (file)
@@ -20,6 +20,10 @@ class VPNControl : public QObject
 {
     Q_OBJECT
 
+    // General properties
+    Q_PROPERTY (QString logText READ getLogText WRITE setLogText NOTIFY logTextChanged)
+
+    // Configuration properties
     Q_PROPERTY (QString server READ getServer WRITE setServer NOTIFY serverChanged)
     Q_PROPERTY (unsigned int port READ getPort WRITE setPort NOTIFY portChanged)
     Q_PROPERTY (bool compressed READ getCompressed WRITE setCompressed NOTIFY compressedChanged)
@@ -29,10 +33,10 @@ class VPNControl : public QObject
     Q_PROPERTY (QString clientCertFile READ getClientCertFile WRITE setClientCertFile NOTIFY clientCertFileChanged)
     Q_PROPERTY (QString clientKeyFile READ getClientKeyFile WRITE setClientKeyFile NOTIFY clientKeyFileChanged)
     Q_PROPERTY (QString tlsKeyFile READ getTlsKeyFile WRITE setTlsKeyFile NOTIFY tlsKeyFileChanged)
-
-    Q_PROPERTY (QString logText READ getLogText WRITE setLogText NOTIFY logTextChanged)
+    Q_PROPERTY (QString configFile READ getConfigFile WRITE setConfigFile NOTIFY configFileChanged)
 
 private:
+    // General variables
     QProcess * vpnProcess;
     VPNSTATUS vpnStatus;
     QStringList arguments;
@@ -48,7 +52,9 @@ private:
     QString clientCertFile;
     QString clientKeyFile;
     QString tlsKeyFile;
+    QString configFile;
 
+    // Internal methods
     void collectArguments ();
     void setStatus (VPNSTATUS newStatus);
     void addArgument (QString key, QString value);
@@ -60,8 +66,12 @@ private:
     void settingsSetValue (QString key, int value);
 
 public:
+    // General methods
     explicit VPNControl(QObject *parent = 0);
     void initialise();
+    QString getLogText() const;
+
+    // Configuration retreival methods
     QString getServer() const;
     unsigned int getPort() const;
     bool getCompressed() const;
@@ -71,11 +81,14 @@ public:
     QString getClientCertFile () const;
     QString getClientKeyFile () const;
     QString getTlsKeyFile () const;
-
-    QString getLogText() const;
+    QString getConfigFile () const;
 
 signals:
+    // General signals
     void statusChanged(int status);
+    void logTextChanged (QString &logText);
+
+    // Configuration change signals
     void serverChanged(QString &server);
     void portChanged(unsigned int port);
     void compressedChanged(bool compressed);
@@ -85,10 +98,10 @@ signals:
     void clientCertFileChanged(QString &clientCertFile);
     void clientKeyFileChanged(QString &clientKeyFile);
     void tlsKeyFileChanged(QString &tlsKeyFile);
-
-    void logTextChanged (QString &logText);
+    void configFileChanged(QString &configFile);
 
 public slots:
+    // General methods
     void vpnConnect ();
     void vpnDisconnect ();
     void readData ();
@@ -96,6 +109,10 @@ public slots:
     void finished (int code);
     void readError (QProcess::ProcessError error);
     void updateConfiguration ();
+    void setLogText(const QString &value);
+    void logAppend(const QString &text);
+
+    // Configuration setting
     void setServer(const QString &value);
     void setPort(unsigned int value);
     void setCompressed(bool value);
@@ -105,9 +122,7 @@ public slots:
     void setClientCertFile(const QString &value);
     void setClientKeyFile(const QString &value);
     void setTlsKeyFile(const QString &value);
-
-    void setLogText(const QString &value);
-    void logAppend(const QString &text);
+    void setConfigFile(const QString &value);
 };
 
 #endif // VPNCONTROL_H