canAccept: true
acceptDestinationAction: PageStackAction.Pop
+ Connections {
+ target:VpnControl
+ }
+
SilicaFlickable {
// ComboBox requires a flickable ancestor
width: parent.width
TextField {
id: configureAddress
width: parent.width
+ text: VpnControl.server
label: "Server address"
placeholderText: "Server address"
focus: true
TextField {
id: configurePort
width: parent.width
+ text: VpnControl.port;
inputMethodHints: Qt.ImhFormattedNumbersOnly
label: "Port number"
placeholderText: "Port number"
TextSwitch {
id: configureCompression
text: "Use Compression"
+ checked: VpnControl.compressed
+ automaticCheck: true
}
TextSwitch {
id: configureTLS
text: "Use TLS authentication"
+ checked: VpnControl.useTLS
onCheckedChanged: {
configureTLSdirection.enabled = checked
configureTLSinfo.visible = checked
}
+ automaticCheck: true
}
// set currentIndex to change the selected value
ComboBox {
id: configureTLSdirection
width: parent.width
label: "TLS direction"
- currentIndex: 1
+ currentIndex: VpnControl.tlsDirection;
enabled: false
menu: ContextMenu {
}
onAccepted: {
+ VpnControl.setServer(configureAddress.text)
+ VpnControl.setPort(configurePort.text)
+ VpnControl.setCompressed(configureCompression.checked)
+ VpnControl.setUseTLS(configureTLS.checked)
+ VpnControl.setTlsDirection(configureTLSdirection.currentIndex)
+ VpnControl.updateConfiguration()
}
}
VPNControl::VPNControl(QObject *parent) :
QObject(parent),
vpnProcess(NULL),
- vpnStatus(VPNSTATUS_INVALID)
+ vpnStatus(VPNSTATUS_INVALID),
+ server(""),
+ port(1174),
+ compressed(true),
+ useTLS(true),
+ tlsDirection(1)
{
}
printf ("Emitting status %d\n", newStatus);
}
}
+int VPNControl::getTlsDirection() const
+{
+ return tlsDirection;
+}
+
+void VPNControl::setTlsDirection(int value)
+{
+ printf ("TLS direction set to %d\n", value);
+ tlsDirection = value;
+ emit tlsDirectionChanged (value);
+}
+
+bool VPNControl::getUseTLS() const
+{
+ return useTLS;
+}
+
+void VPNControl::setUseTLS(bool value)
+{
+ printf ("Use TLS set to %d\n", value);
+ useTLS = value;
+ emit useTLSChanged(useTLS);
+}
+
+bool VPNControl::getCompressed() const
+{
+ return compressed;
+}
+
+void VPNControl::setCompressed(bool value)
+{
+ printf ("Use compression set to %d\n", value);
+ compressed = value;
+ emit compressedChanged(compressed);
+}
+
+unsigned int VPNControl::getPort() const
+{
+ return port;
+}
+
+void VPNControl::setPort(unsigned int value)
+{
+ printf ("Port set to %d\n", value);
+ port = value;
+ emit portChanged(port);
+}
+
+QString VPNControl::getServer() const
+{
+ return server;
+}
+
+void VPNControl::setServer(const QString &value)
+{
+ printf ("Server set to %s\n", value.toUtf8().constData());
+ server = value;
+ emit serverChanged(server);
+}
+
void VPNControl::vpnConnect() {
if (vpnProcess != NULL) {
// Disconnect
vpnDisconnect();
}
+
+void VPNControl::updateConfiguration()
+{
+ printf ("Update configuration\n");
+}
class VPNControl : public QObject
{
Q_OBJECT
+
+ 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)
+
private:
QProcess * vpnProcess;
VPNSTATUS vpnStatus;
void setStatus (VPNSTATUS newStatus);
+ QString server;
+ unsigned int port;
+ bool compressed;
+ bool useTLS;
+ int tlsDirection;
public:
explicit VPNControl(QObject *parent = 0);
void initialise();
+ QString getServer() const;
+ unsigned int getPort() const;
+ bool getCompressed() const;
+ bool getUseTLS() const;
+ int getTlsDirection() const;
signals:
void statusChanged(int status);
+ void serverChanged(QString server);
+ void portChanged(unsigned int port);
+ void compressedChanged(bool compressed);
+ void useTLSChanged(bool useTLS);
+ void tlsDirectionChanged (int direction);
public slots:
void vpnConnect ();
void started ();
void finished (int code);
void readError (QProcess::ProcessError error);
+ void updateConfiguration ();
+ void setServer(const QString &value);
+ void setPort(unsigned int value);
+ void setCompressed(bool value);
+ void setUseTLS(bool value);
+ void setTlsDirection(int value);
};
#endif // VPNCONTROL_H