40e28ef45f0d9560c5d5f9377b717380854861cb
[openvpnui.git] / src / OpenVPNUI.cpp
1 /*
2 Copyright (C) 2014 David Llewellyn-Jones
3 Contact: David Llewellyn-Jones <david@flypig.co.uk>
4 All rights reserved.
5
6 You may use this file under the terms of BSD license as follows:
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 * Neither the name of the Jolla Ltd nor the
16 names of its contributors may be used to endorse or promote products
17 derived from this software without specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
23 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 Built using the standard template from Jolla
31 Copyright (C) 2013 Jolla Ltd.
32 Contact: Thomas Perl <thomas.perl@jollamobile.com>
33 */
34
35 #ifdef QT_QML_DEBUG
36 #include <QtQuick>
37 #endif
38
39 #include <sailfishapp.h>
40 #include "vpncontrol.h"
41
42 int main(int argc, char *argv[])
43 {
44 int result;
45
46 setuid(0);
47 seteuid(0);
48
49 // SailfishApp::main() will display "qml/template.qml", if you need more
50 // control over initialization, you can use:
51 //
52 // - SailfishApp::application(int, char *[]) to get the QGuiApplication *
53 // - SailfishApp::createView() to get a new QQuickView * instance
54 // - SailfishApp::pathTo(QString) to get a QUrl to a resource file
55 //
56 // To display the view, call "show()" (will show fullscreen on device).
57
58 QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
59
60 // These values are used by QSettings to access the config file in
61 // /home/nemo/.local/share/flypig/OpenVPNUI.conf
62 QCoreApplication::setOrganizationName("flypig");
63 QCoreApplication::setOrganizationDomain("www.flypig.co.uk");
64 QCoreApplication::setApplicationName("OpenVPNUI");
65
66 QScopedPointer<QQuickView> view(SailfishApp::createView());
67
68 view->setSource(SailfishApp::pathTo("qml/OpenVPNUI.qml"));
69
70 VPNControl * vpnControl = new VPNControl ();
71
72 view->rootContext()->setContextProperty("VpnControl", vpnControl);
73
74 vpnControl->initialise();
75 //QObject * page = view->findChild(QString("page"),Qt::FindChildrenRecursively);
76
77 //QObject::connect(vpnControl, SIGNAL(statusChanged(int)), page, SLOT(updateStatus(int)));
78
79 view->show();
80
81 result = app->exec();
82
83 delete vpnControl;
84
85 return result;
86 }
87