/* Copyright (C) 2014 David Llewellyn-Jones Contact: David Llewellyn-Jones 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. Built using the standard template from Jolla Copyright (C) 2013 Jolla Ltd. Contact: Thomas Perl */ import QtQuick 2.0 import Sailfish.Silica 1.0 import "../components" import "../filebrowse/pages/functions.js" as Functions Dialog { id: configurePage canAccept: true acceptDestinationAction: PageStackAction.Pop property int _fileDialogue: 0 Connections { target:VpnControl } // connect signals from engine to panels Connections { target: engine onSelectedFilenameChanged: { switch (_fileDialogue) { case 1: caCertFilename.value = engine.selectedFilename break; case 2: clientCertFilename.value = engine.selectedFilename break; case 3: clientKeyFilename.value = engine.selectedFilename break; case 4: tlsKeyFilename.value = engine.selectedFilename break; case 5: configFilename.value = engine.selectedFilename break; } _fileDialogue = 0; } } 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 text: VpnControl.server label: "Server address" placeholderText: "Server address" focus: true EnterKey.onClicked: configurePort.focus = true } TextField { id: configurePort width: parent.width text: VpnControl.port; inputMethodHints: Qt.ImhFormattedNumbersOnly label: "Port number" placeholderText: "Port number" EnterKey.onClicked: parent.focus = true } TextSwitch { id: configureCompression text: "Use Compression" checked: VpnControl.compressed automaticCheck: true } TextSwitch { id: configureTLS text: "Use TLS authentication" checked: VpnControl.useTLS automaticCheck: true } // set currentIndex to change the selected value ComboBox { id: configureTLSdirection width: parent.width label: "TLS direction" currentIndex: VpnControl.tlsDirection; enabled: configureTLS.checked menu: ContextMenu { MenuItem { text: "0" } MenuItem { text: "1" } } } ValueButtonAlignRight { id: caCertFilename label: "CA cert" value: VpnControl.caCertFile placeholderText: "Select" width: parent.width onClicked: { _fileDialogue = 1 Functions.goToInitial(Functions.folderFromFile(value), "crt") } } ValueButtonAlignRight { id: clientCertFilename label: "Client cert" value: VpnControl.clientCertFile placeholderText: "Select" width: parent.width onClicked: { _fileDialogue = 2; Functions.goToInitial(Functions.folderFromFile(value), "crt") } } ValueButtonAlignRight { id: clientKeyFilename label: "Client key" value: VpnControl.clientKeyFile placeholderText: "Select" width: parent.width onClicked: { _fileDialogue = 3; Functions.goToInitial(Functions.folderFromFile(value), "key") } } ValueButtonAlignRight { id: tlsKeyFilename label: "TLS key" value: VpnControl.tlsKeyFile placeholderText: "Select" width: parent.width enabled: configureTLS.checked onClicked: { _fileDialogue = 4; Functions.goToInitial(Functions.folderFromFile(value), "key") } } ValueButtonAlignRight { id: configFilename label: "Extra options" value: VpnControl.configFile placeholderText: "Select" width: parent.width onClicked: { _fileDialogue = 5; Functions.goToInitial(Functions.folderFromFile(value), "ovpn") } } } } onAccepted: { VpnControl.setServer(configureAddress.text) VpnControl.setPort(configurePort.text) VpnControl.setCompressed(configureCompression.checked) VpnControl.setUseTLS(configureTLS.checked) VpnControl.setTlsDirection(configureTLSdirection.currentIndex) VpnControl.updateConfiguration() VpnControl.setCaCertFile(caCertFilename.value) VpnControl.setClientCertFile(clientCertFilename.value) VpnControl.setClientKeyFile(clientKeyFilename.value) VpnControl.setTlsKeyFile(tlsKeyFilename.value) VpnControl.setConfigFile(configFilename.value) } }