Added configurable path to extra configuration file.
[openvpnui.git] / src / vpncontrol.h
index e994b83..d89120f 100644 (file)
@@ -20,40 +20,88 @@ 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)
     Q_PROPERTY (bool useTLS READ getUseTLS WRITE setUseTLS NOTIFY useTLSChanged)
     Q_PROPERTY (int tlsDirection READ getTlsDirection WRITE setTlsDirection NOTIFY tlsDirectionChanged)
+    Q_PROPERTY (QString caCertFile READ getCaCertFile WRITE setCaCertFile NOTIFY caCertFileChanged)
+    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 configFile READ getConfigFile WRITE setConfigFile NOTIFY configFileChanged)
 
 private:
+    // General variables
     QProcess * vpnProcess;
     VPNSTATUS vpnStatus;
-    void setStatus (VPNSTATUS newStatus);
+    QStringList arguments;
+    QString logText;
+
+    // Configuration options
     QString server;
     unsigned int port;
     bool compressed;
     bool useTLS;
     int tlsDirection;
+    QString caCertFile;
+    QString clientCertFile;
+    QString clientKeyFile;
+    QString tlsKeyFile;
+    QString configFile;
+
+    // Internal methods
+    void collectArguments ();
+    void setStatus (VPNSTATUS newStatus);
+    void addArgument (QString key, QString value);
+    void addArgument (QString key);
+    void addArgumentNonempty (QString key, QString value);
+    void addOption (QString key, bool add);
+    void addValue (QString key);
+    void settingsSetValue (QString key, QString value);
+    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;
     bool getUseTLS() const;
     int getTlsDirection() const;
+    QString getCaCertFile () const;
+    QString getClientCertFile () const;
+    QString getClientKeyFile () const;
+    QString getTlsKeyFile () const;
+    QString getConfigFile () const;
 
 signals:
+    // General signals
     void statusChanged(int status);
-    void serverChanged(QString server);
+    void logTextChanged (QString &logText);
+
+    // Configuration change signals
+    void serverChanged(QString &server);
     void portChanged(unsigned int port);
     void compressedChanged(bool compressed);
     void useTLSChanged(bool useTLS);
-    void tlsDirectionChanged (int direction);
+    void tlsDirectionChanged(int direction);
+    void caCertFileChanged(QString &caCertFile);
+    void clientCertFileChanged(QString &clientCertFile);
+    void clientKeyFileChanged(QString &clientKeyFile);
+    void tlsKeyFileChanged(QString &tlsKeyFile);
+    void configFileChanged(QString &configFile);
 
 public slots:
+    // General methods
     void vpnConnect ();
     void vpnDisconnect ();
     void readData ();
@@ -61,11 +109,20 @@ 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);
     void setUseTLS(bool value);
     void setTlsDirection(int value);
+    void setCaCertFile(const QString &value);
+    void setClientCertFile(const QString &value);
+    void setClientKeyFile(const QString &value);
+    void setTlsKeyFile(const QString &value);
+    void setConfigFile(const QString &value);
 };
 
 #endif // VPNCONTROL_H