Configuration values are passed between the interface and main code.
[openvpnui.git] / src / vpncontrol.h
1 #ifndef VPNCONTROL_H
2 #define VPNCONTROL_H
3
4 #include <QObject>
5 #include <QProcess>
6
7 enum VPNSTATUS {
8 VPNSTATUS_INVALID = -1,
9
10 VPNSTATUS_UNINITIALISED,
11 VPNSTATUS_INITIALISING,
12 VPNSTATUS_CONNECTING,
13 VPNSTATUS_CONNECTED,
14 VPNSTATUS_DISCONNECTING,
15
16 VPNSTATUS_NUM
17 };
18
19 class VPNControl : public QObject
20 {
21 Q_OBJECT
22
23 Q_PROPERTY (QString server READ getServer WRITE setServer NOTIFY serverChanged)
24 Q_PROPERTY (unsigned int port READ getPort WRITE setPort NOTIFY portChanged)
25 Q_PROPERTY (bool compressed READ getCompressed WRITE setCompressed NOTIFY compressedChanged)
26 Q_PROPERTY (bool useTLS READ getUseTLS WRITE setUseTLS NOTIFY useTLSChanged)
27 Q_PROPERTY (int tlsDirection READ getTlsDirection WRITE setTlsDirection NOTIFY tlsDirectionChanged)
28
29 private:
30 QProcess * vpnProcess;
31 VPNSTATUS vpnStatus;
32 void setStatus (VPNSTATUS newStatus);
33 QString server;
34 unsigned int port;
35 bool compressed;
36 bool useTLS;
37 int tlsDirection;
38
39 public:
40 explicit VPNControl(QObject *parent = 0);
41 void initialise();
42 QString getServer() const;
43 unsigned int getPort() const;
44 bool getCompressed() const;
45 bool getUseTLS() const;
46 int getTlsDirection() const;
47
48 signals:
49 void statusChanged(int status);
50 void serverChanged(QString server);
51 void portChanged(unsigned int port);
52 void compressedChanged(bool compressed);
53 void useTLSChanged(bool useTLS);
54 void tlsDirectionChanged (int direction);
55
56 public slots:
57 void vpnConnect ();
58 void vpnDisconnect ();
59 void readData ();
60 void started ();
61 void finished (int code);
62 void readError (QProcess::ProcessError error);
63 void updateConfiguration ();
64 void setServer(const QString &value);
65 void setPort(unsigned int value);
66 void setCompressed(bool value);
67 void setUseTLS(bool value);
68 void setTlsDirection(int value);
69 };
70
71 #endif // VPNCONTROL_H