From 3aba2d3bed67a9d91350393dd4772f566aca7db1 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 16 Feb 2014 21:27:30 +0000 Subject: [PATCH] Initial OpenVPNUI project files. --- OpenVPNUI.desktop | 7 + OpenVPNUI.png | Bin 0 -> 2965 bytes OpenVPNUI.pro | 26 ++ OpenVPNUI.pro.user | 529 ++++++++++++++++++++++++++++++++++++ qml/OpenVPNUI.qml | 41 +++ qml/cover/CoverPage.qml | 126 +++++++++ qml/pages/ConfigurePage.qml | 149 ++++++++++ qml/pages/ConnectPage.qml | 152 +++++++++++ rpm/OpenVPNUI.spec | 75 +++++ rpm/OpenVPNUI.yaml | 29 ++ src/OpenVPNUI.cpp | 76 ++++++ src/vpncontrol.cpp | 97 +++++++ src/vpncontrol.h | 43 +++ 13 files changed, 1350 insertions(+) create mode 100644 OpenVPNUI.desktop create mode 100644 OpenVPNUI.png create mode 100644 OpenVPNUI.pro create mode 100644 OpenVPNUI.pro.user create mode 100644 qml/OpenVPNUI.qml create mode 100644 qml/cover/CoverPage.qml create mode 100644 qml/pages/ConfigurePage.qml create mode 100644 qml/pages/ConnectPage.qml create mode 100644 rpm/OpenVPNUI.spec create mode 100644 rpm/OpenVPNUI.yaml create mode 100644 src/OpenVPNUI.cpp create mode 100644 src/vpncontrol.cpp create mode 100644 src/vpncontrol.h diff --git a/OpenVPNUI.desktop b/OpenVPNUI.desktop new file mode 100644 index 0000000..245e577 --- /dev/null +++ b/OpenVPNUI.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +X-Nemo-Application-Type=silica-qt5 +Name=OpenVPNUI +Icon=OpenVPNUI +Exec=OpenVPNUI + diff --git a/OpenVPNUI.png b/OpenVPNUI.png new file mode 100644 index 0000000000000000000000000000000000000000..4c883a0ec7f3c6c6c18fa9e376d98d9d2520c161 GIT binary patch literal 2965 zcmV;G3u^R`swkjYCBG_9ZR+~d{teRWJ$Ijz5VvrEy=F>{{6dGMiDcmG4ld0FTh^i8UJ#WgHRO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 0000000..b0f1141 --- /dev/null +++ b/OpenVPNUI.pro @@ -0,0 +1,26 @@ +# The name of your app. +# NOTICE: name defined in TARGET has a corresponding QML filename. +# If name defined in TARGET is changed, following needs to be +# done to match new name: +# - corresponding QML filename must be changed +# - desktop icon filename must be changed +# - desktop filename must be changed +# - icon definition filename in desktop file must be changed +TARGET = OpenVPNUI + +CONFIG += sailfishapp + +SOURCES += src/OpenVPNUI.cpp \ + src/vpncontrol.cpp + +OTHER_FILES += qml/OpenVPNUI.qml \ + qml/cover/CoverPage.qml \ + rpm/OpenVPNUI.spec \ + rpm/OpenVPNUI.yaml \ + OpenVPNUI.desktop \ + qml/pages/ConnectPage.qml \ + qml/pages/ConfigurePage.qml + +HEADERS += \ + src/vpncontrol.h + diff --git a/OpenVPNUI.pro.user b/OpenVPNUI.pro.user new file mode 100644 index 0000000..ec57259 --- /dev/null +++ b/OpenVPNUI.pro.user @@ -0,0 +1,529 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + MerSDK-SailfishOS-armv7hl + MerSDK-SailfishOS-armv7hl + {d509da11-0d11-4fad-8b14-f7a950fad5bf} + 0 + 2 + 0 + + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/flypig/Documents/Development/SailfishOS/build-OpenVPNUI-MerSDK_SailfishOS_armv7hl-Debug + true + + + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/flypig/Documents/Development/SailfishOS/build-OpenVPNUI-MerSDK_SailfishOS_armv7hl-Release + true + + 2 + + + + true + Rpm + + Qt4ProjectManager.MerRpmBuildStep + + 1 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Building An RPM Package + + Qt4ProjectManager.MerArmDeployConfiguration + + + + + true + Rsync + + Qt4ProjectManager.MerRsyncDeployStep + + 1 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Copying Binaries + + Qt4ProjectManager.MerRSyncDeployConfiguration + + + + + true + Rpm + + Qt4ProjectManager.MerRpmDeployStep + + 1 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy As RPM Package + + Qt4ProjectManager.MerRpmDeployConfiguration + + 3 + + + true + + false + false + false + false + true + 0.01 + 10 + true + 25 + + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 1 + + OpenVPNUI (on Remote Device) + + Qt4ProjectManager.MerRunConfiguration:/home/flypig/Documents/Development/SailfishOS/OpenVPNUI/OpenVPNUI.pro + + OpenVPNUI.pro + + false + + 3768 + true + false + false + true + false + + 1 + + + + ProjectExplorer.Project.Target.1 + + MerSDK-SailfishOS-i486-x86 + MerSDK-SailfishOS-i486-x86 + {afe67e8f-9b68-41c9-a78e-976c32346149} + 0 + 0 + 0 + + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/flypig/Documents/Development/SailfishOS/build-OpenVPNUI-MerSDK_SailfishOS_i486_x86-Debug + true + + + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/flypig/Documents/Development/SailfishOS/build-OpenVPNUI-MerSDK_SailfishOS_i486_x86-Release + true + + 2 + + + + true + Start Emulator + + Qt4ProjectManager.MerEmulatorStartStep + + + true + Rsync + + Qt4ProjectManager.MerRsyncDeployStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy By Copying Binaries + + Qt4ProjectManager.MerRSyncDeployConfiguration + + + + + true + Start Emulator + + Qt4ProjectManager.MerEmulatorStartStep + + + true + Rpm + + Qt4ProjectManager.MerRpmDeployStep + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy As RPM Package + + Qt4ProjectManager.MerRpmDeployConfiguration + + 2 + + + true + + false + false + false + false + true + 0.01 + 10 + true + 25 + + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + -1 + + OpenVPNUI (on Remote Device) + + Qt4ProjectManager.MerRunConfiguration:/home/flypig/Documents/Development/SailfishOS/OpenVPNUI/OpenVPNUI.pro + + OpenVPNUI.pro + + false + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.EnvironmentId + {551e7bc8-ec93-459f-bb3a-08a2bffda2a5} + + + ProjectExplorer.Project.Updater.FileVersion + 14 + + diff --git a/qml/OpenVPNUI.qml b/qml/OpenVPNUI.qml new file mode 100644 index 0000000..032e488 --- /dev/null +++ b/qml/OpenVPNUI.qml @@ -0,0 +1,41 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "pages" + +ApplicationWindow +{ + initialPage: Qt.resolvedUrl("pages/ConnectPage.qml") + cover: Qt.resolvedUrl("cover/CoverPage.qml") +} + + diff --git a/qml/cover/CoverPage.qml b/qml/cover/CoverPage.qml new file mode 100644 index 0000000..ba922be --- /dev/null +++ b/qml/cover/CoverPage.qml @@ -0,0 +1,126 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +CoverBackground { + id: cover + + Connections { + target:VpnControl + onStatusChanged: { + updateStatus(status) + } + } + + Column { + anchors.centerIn: parent + spacing: Theme.paddingSmall + Label { + text: "OpenVPN" + color: Theme.highlightColor + font.pixelSize: Theme.fontSizeSmall + width: parent.parent.width - Theme.paddingMedium + wrapMode: Text.Wrap + horizontalAlignment: Text.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + } + Label { + id: coverStatus + text: "Disconnected" + color: Theme.highlightColor + font.pixelSize: Theme.fontSizeMedium + width: parent.parent.width - Theme.paddingMedium + wrapMode: Text.Wrap + horizontalAlignment: Text.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + } + } + + function updateStatus(status) { + switch (status) { + case 0: + coverStatus.text = "Disconnected" + coverActionConnect.enabled = true; + coverActionDisconnect.enabled = false; + break + case 1: + coverStatus.text = "Initialising" + coverActionConnect.enabled = false; + coverActionDisconnect.enabled = false; + break + case 2: + coverStatus.text = "Connecting" + coverActionConnect.enabled = false; + coverActionDisconnect.enabled = true; + break + case 3: + coverStatus.text = "Connected" + coverActionConnect.enabled = false; + coverActionDisconnect.enabled = true; + break + case 4: + coverStatus.text = "Disconnecting" + coverActionConnect.enabled = false; + coverActionDisconnect.enabled = false; + break + default: + coverStatus.text = "Invalid" + coverActionConnect.enabled = true; + coverActionDisconnect.enabled = false; + break + } + } + + CoverActionList { + id: coverActionConnect + + enabled: true + + CoverAction { + iconSource: "image://theme/icon-cover-next" + onTriggered: VpnControl.vpnConnect() + } + } + + CoverActionList { + id: coverActionDisconnect + + enabled: false + + CoverAction { + iconSource: "image://theme/icon-cover-cancel" + onTriggered: VpnControl.vpnDisconnect() + } + } +} + + diff --git a/qml/pages/ConfigurePage.qml b/qml/pages/ConfigurePage.qml new file mode 100644 index 0000000..b6ad3da --- /dev/null +++ b/qml/pages/ConfigurePage.qml @@ -0,0 +1,149 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + + +Dialog { + id: configurePage + canAccept: true + acceptDestinationAction: PageStackAction.Pop + + SilicaFlickable { + // ComboBox requires a flickable ancestor + width: parent.width + height: parent.height + interactive: true + + anchors.fill: parent + contentHeight: configureColumn.height + Theme.paddingLarge + + VerticalScrollDecorator {} + + Column { + id: configureColumn + width: parent.width + spacing: Theme.paddingLarge + + DialogHeader { + acceptText: "Accept" + } + + TextField { + id: configureAddress + width: parent.width + label: "Server address" + placeholderText: "Server address" + focus: true + EnterKey.onClicked: configurePort.focus = true + } + + TextField { + id: configurePort + width: parent.width + inputMethodHints: Qt.ImhFormattedNumbersOnly + label: "Port number" + placeholderText: "Port number" + EnterKey.onClicked: parent.focus = true + } + + TextSwitch { + id: configureCompression + text: "Use Compression" + } + + TextSwitch { + id: configureTLS + text: "Use TLS authentication" + onCheckedChanged: { + configureTLSdirection.enabled = checked + configureTLSinfo.visible = checked + } + } + // set currentIndex to change the selected value + ComboBox { + id: configureTLSdirection + width: parent.width + label: "TLS direction" + currentIndex: 1 + enabled: false + + menu: ContextMenu { + MenuItem { text: "0" } + MenuItem { text: "1" } + } + } + + Label { + text: "Place key files on SD card:" + color: Theme.secondaryColor + font.pixelSize: Theme.fontSizeSmall + x: Theme.paddingLarge + } + Label { + text: "\tca.crt" + color: Theme.secondaryColor + font.pixelSize: Theme.fontSizeSmall + x: Theme.paddingLarge + } + Label { + text: "\tclient.crt" + color: Theme.secondaryColor + font.pixelSize: Theme.fontSizeSmall + x: Theme.paddingLarge + } + Label { + text: "\tclient.key" + color: Theme.secondaryColor + font.pixelSize: Theme.fontSizeSmall + x: Theme.paddingLarge + } + Label { + id: configureTLSinfo + visible: false + text: "\tta.key" + color: Theme.secondaryColor + font.pixelSize: Theme.fontSizeSmall + x: Theme.paddingLarge + } + + } + } + + onAccepted: { + } + +} + + + + + diff --git a/qml/pages/ConnectPage.qml b/qml/pages/ConnectPage.qml new file mode 100644 index 0000000..88d0b8e --- /dev/null +++ b/qml/pages/ConnectPage.qml @@ -0,0 +1,152 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + + +Page { + id: connectPage + + Connections { + target:VpnControl + onStatusChanged: { + updateStatus(status) + } + } + + function updateStatus(status) { + switch (status) { + case 0: + statusText.text = "Disconnected" + busy.running = false + connect.enabled = true + disconnect.enabled = false + break + case 1: + statusText.text = "Initialising" + busy.running = true + connect.enabled = false + disconnect.enabled = true + break + case 2: + statusText.text = "Connecting" + busy.running = true + connect.enabled = false + disconnect.enabled = true + break + case 3: + statusText.text = "Connected" + busy.running = false + connect.enabled = false + disconnect.enabled = true + break + case 4: + statusText.text = "Disconnecting" + busy.running = true + connect.enabled = false + disconnect.enabled = false + break + default: + statusText.text = "Invalid" + busy.running = false + connect.enabled = true + disconnect.enabled = false + break + } + } + + // To enable PullDownMenu, place our content in a SilicaFlickable + SilicaFlickable { + anchors.fill: parent + + // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView + PullDownMenu { + MenuItem { + text: "Configure" + onClicked: pageStack.push(Qt.resolvedUrl("ConfigurePage.qml")) + } + } + + contentHeight: column.height + Theme.paddingLarge + + // Why is this necessary? + contentWidth: parent.width + + VerticalScrollDecorator {} + // Place our content in a Column. The PageHeader is always placed at the top + // of the page, followed by our content. + Column { + id: column + + width: parent.width + spacing: Theme.paddingLarge + + PageHeader { + title: "OpenVPN Control" + } + Row { + spacing: Theme.paddingLarge + anchors.horizontalCenter: parent.horizontalCenter + Button { + id: connect + text: "Connect" + enabled: true + onClicked: VpnControl.vpnConnect() + } + Button { + id : disconnect + text: "Disconnect" + enabled: true + onClicked: VpnControl.vpnDisconnect(); + } + } + Label { + id: statusText + text: "No status" + color: Theme.highlightColor + anchors.horizontalCenter: parent.horizontalCenter + font.family: Theme.fontFamilyHeading + } + Row { + spacing: Theme.paddingLarge + anchors.horizontalCenter: parent.horizontalCenter + BusyIndicator { + id: busy + running: false + size: BusyIndicatorSize.Large + anchors.verticalCenter: parent.verticalCenter + } + } + } + } +} + + diff --git a/rpm/OpenVPNUI.spec b/rpm/OpenVPNUI.spec new file mode 100644 index 0000000..ed8c99d --- /dev/null +++ b/rpm/OpenVPNUI.spec @@ -0,0 +1,75 @@ +# +# Do NOT Edit the Auto-generated Part! +# Generated by: spectacle version 0.27 +# + +Name: OpenVPNUI + +# >> macros +# << macros + +%{!?qtc_qmake:%define qtc_qmake %qmake} +%{!?qtc_qmake5:%define qtc_qmake5 %qmake5} +%{!?qtc_make:%define qtc_make make} +%{?qtc_builddir:%define _builddir %qtc_builddir} +Summary: OpenVPN User Interface +Version: 0.1 +Release: 1 +Group: Qt/Qt +License: LICENSE +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: desktop-file-utils + +%description +Short description of my SailfishOS Application + + +%prep +%setup -q -n %{name}-%{version} + +# >> setup +# << setup + +%build +# >> build pre +# << build pre + +%qtc_qmake5 + +%qtc_make %{?_smp_mflags} + +# >> build post +# << build post + +%install +rm -rf %{buildroot} +# >> install pre +# << install pre +%qmake5_install + +# >> install post +# << install post + +desktop-file-install --delete-original \ + --dir %{buildroot}%{_datadir}/applications \ + %{buildroot}%{_datadir}/applications/*.desktop + +%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} +# >> files +# << files diff --git a/rpm/OpenVPNUI.yaml b/rpm/OpenVPNUI.yaml new file mode 100644 index 0000000..4b63770 --- /dev/null +++ b/rpm/OpenVPNUI.yaml @@ -0,0 +1,29 @@ +Name: OpenVPNUI +Summary: OpenVPN User Interface +Version: 0.1 +Release: 1 +Group: Qt/Qt +URL: http://example.org/ +License: LICENSE +Sources: +- '%{name}-%{version}.tar.bz2' +Description: | + Short description of my SailfishOS Application +Configure: none +Builder: qtc5 +PkgConfigBR: +- sailfishapp >= 0.0.10 +- Qt5Core +- Qt5Qml +- Qt5Quick +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}' diff --git a/src/OpenVPNUI.cpp b/src/OpenVPNUI.cpp new file mode 100644 index 0000000..7575cb3 --- /dev/null +++ b/src/OpenVPNUI.cpp @@ -0,0 +1,76 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef QT_QML_DEBUG +#include +#endif + +#include +#include "vpncontrol.h" + +int main(int argc, char *argv[]) +{ + int result; + + setuid(0); + seteuid(0); + + // SailfishApp::main() will display "qml/template.qml", if you need more + // control over initialization, you can use: + // + // - SailfishApp::application(int, char *[]) to get the QGuiApplication * + // - SailfishApp::createView() to get a new QQuickView * instance + // - SailfishApp::pathTo(QString) to get a QUrl to a resource file + // + // To display the view, call "show()" (will show fullscreen on device). + + QScopedPointer app(SailfishApp::application(argc, argv)); + QScopedPointer view(SailfishApp::createView()); + + view->setSource(SailfishApp::pathTo("qml/OpenVPNUI.qml")); + + VPNControl * vpnControl = new VPNControl (); + + view->rootContext()->setContextProperty("VpnControl", vpnControl); + + vpnControl->initialise(); + //QObject * page = view->findChild(QString("page"),Qt::FindChildrenRecursively); + + //QObject::connect(vpnControl, SIGNAL(statusChanged(int)), page, SLOT(updateStatus(int))); + + view->show(); + + result = app->exec(); + + delete vpnControl; + + return result; +} + diff --git a/src/vpncontrol.cpp b/src/vpncontrol.cpp new file mode 100644 index 0000000..8b0c79a --- /dev/null +++ b/src/vpncontrol.cpp @@ -0,0 +1,97 @@ +#include "vpncontrol.h" +#include "stdio.h" + +VPNControl::VPNControl(QObject *parent) : + QObject(parent), + vpnProcess(NULL), + vpnStatus(VPNSTATUS_INVALID) +{ +} + +void VPNControl::initialise() +{ + setStatus(VPNSTATUS_UNINITIALISED); +} + +void VPNControl::setStatus(VPNSTATUS newStatus) +{ + if (vpnStatus != newStatus) { + vpnStatus = newStatus; + emit statusChanged(newStatus); + printf ("Emitting status %d\n", newStatus); + } +} + +void VPNControl::vpnConnect() { + if (vpnProcess != NULL) { + printf ("Process already running.\n"); + } + else { + printf ("Connect\n"); + + vpnProcess = new QProcess(); + //QString program = "/home/nemo/Documents/Development/Projects/Stooge/stooge"; + QString program = "openvpn"; + QStringList arguments; + arguments << "/home/nemo/Documents/Configure/OpenVPN/client.ovpn"; + + vpnProcess->setReadChannel(QProcess::StandardOutput); + connect(vpnProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(readError(QProcess::ProcessError))); + connect(vpnProcess, SIGNAL(readyRead()), this, SLOT(readData())); + connect(vpnProcess, SIGNAL(started()), this, SLOT(started())); + connect(vpnProcess, SIGNAL(finished(int)), this, SLOT(finished(int))); + + vpnProcess->start(program, arguments); + vpnProcess->closeWriteChannel(); + setStatus(VPNSTATUS_INITIALISING); + } +} + +void VPNControl::vpnDisconnect() { + if (vpnProcess != NULL) { + printf ("Disconnect\n"); + + vpnProcess->terminate(); + setStatus(VPNSTATUS_DISCONNECTING); + } +} + +void VPNControl::readData() { + while (vpnProcess->canReadLine()) { + QByteArray read = vpnProcess->readLine(); + printf ("Output: %s", read.data()); + if (read.endsWith("Initialization Sequence Completed\n")) { + printf ("We're connected!\n"); + setStatus(VPNSTATUS_CONNECTED); + } + } +} + +void VPNControl::started() { + printf ("Started\n"); + setStatus(VPNSTATUS_CONNECTING); +} + +void VPNControl::finished(int code) { + printf ("Finished with code %d\n", code); + if (vpnProcess != NULL) { + //delete vpnProcess; + vpnProcess = NULL; + } + setStatus(VPNSTATUS_UNINITIALISED); +} + +void VPNControl::readError(QProcess::ProcessError error) +{ + printf ("Error: %d\n", error); + if (vpnProcess != NULL) { + QByteArray dataOut = vpnProcess->readAllStandardOutput(); + QByteArray errorOut = vpnProcess->readAllStandardError(); + + printf ("Output text: %s\n", dataOut.data()); + printf ("Error text: %s\n", errorOut.data()); + } + + // Disconnect + vpnDisconnect(); +} diff --git a/src/vpncontrol.h b/src/vpncontrol.h new file mode 100644 index 0000000..d73f344 --- /dev/null +++ b/src/vpncontrol.h @@ -0,0 +1,43 @@ +#ifndef VPNCONTROL_H +#define VPNCONTROL_H + +#include +#include + +enum VPNSTATUS { + VPNSTATUS_INVALID = -1, + + VPNSTATUS_UNINITIALISED, + VPNSTATUS_INITIALISING, + VPNSTATUS_CONNECTING, + VPNSTATUS_CONNECTED, + VPNSTATUS_DISCONNECTING, + + VPNSTATUS_NUM +}; + +class VPNControl : public QObject +{ + Q_OBJECT +private: + QProcess * vpnProcess; + VPNSTATUS vpnStatus; + void setStatus (VPNSTATUS newStatus); + +public: + explicit VPNControl(QObject *parent = 0); + void initialise(); + +signals: + void statusChanged(int status); + +public slots: + void vpnConnect (); + void vpnDisconnect (); + void readData (); + void started (); + void finished (int code); + void readError (QProcess::ProcessError error); +}; + +#endif // VPNCONTROL_H -- 2.25.1