909f3b204dfc9a3424d95fdc020fbcd987f80ee0
[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 QStringList arguments;
33 QString server;
34 unsigned int port;
35 bool compressed;
36 bool useTLS;
37 int tlsDirection;
38 void collectArguments ();
39 void setStatus (VPNSTATUS newStatus);
40 void addArgument (QString key, QString value);
41 void addArgument (QString key);
42 void addOption (QString key, bool add);
43 void addValue (QString key);
44
45 public:
46 explicit VPNControl(QObject *parent = 0);
47 void initialise();
48 QString getServer() const;
49 unsigned int getPort() const;
50 bool getCompressed() const;
51 bool getUseTLS() const;
52 int getTlsDirection() const;
53
54 signals:
55 void statusChanged(int status);
56 void serverChanged(QString server);
57 void portChanged(unsigned int port);
58 void compressedChanged(bool compressed);
59 void useTLSChanged(bool useTLS);
60 void tlsDirectionChanged (int direction);
61
62 public slots:
63 void vpnConnect ();
64 void vpnDisconnect ();
65 void readData ();
66 void started ();
67 void finished (int code);
68 void readError (QProcess::ProcessError error);
69 void updateConfiguration ();
70 void setServer(const QString &value);
71 void setPort(unsigned int value);
72 void setCompressed(bool value);
73 void setUseTLS(bool value);
74 void setTlsDirection(int value);
75 };
76
77 #endif // VPNCONTROL_H