summaryrefslogtreecommitdiffstats
path: root/app/main.cpp
blob: 09e501f4a50e22c4fef6f7a043a465f7eeb70b01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (C) 2016 The Qt Company Ltd.
 * Copyright (C) 2017 Konsulko Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <QtCore/QDebug>
#include <QtCore/QCommandLineParser>
#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
#include <QtQuickControls2/QQuickStyle>

#ifdef HAVE_LIBHOMESCREEN
#include <libhomescreen.hpp>
#endif

#include <telephony.h>
#include "phone.h"

int main(int argc, char *argv[])
{
#ifdef HAVE_LIBHOMESCREEN
    LibHomeScreen libHomeScreen;

    if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) {
        qWarning() << "renderAppToAreaAllowed is denied";
        return -1;
    }
#endif

    QGuiApplication app(argc, argv);

    QQuickStyle::setStyle("AGL");

    QQmlApplicationEngine engine;

    QCommandLineParser parser;
    parser.addPositionalArgument("port", app.translate("main", "port for binding"));
    parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
    parser.addHelpOption();
    parser.addVersionOption();
    parser.process(app);
    QStringList positionalArguments = parser.positionalArguments();
    if (positionalArguments.length() == 2) {
	int port = positionalArguments.takeFirst().toInt();
	QString secret = positionalArguments.takeFirst();
	QUrl bindingAddress;
	bindingAddress.setScheme(QStringLiteral("ws"));
	bindingAddress.setHost(QStringLiteral("localhost"));
	bindingAddress.setPort(port);
	bindingAddress.setPath(QStringLiteral("/api"));
	QUrlQuery query;
	query.addQueryItem(QStringLiteral("token"), secret);
	bindingAddress.setQuery(query);
	QQmlContext *context = engine.rootContext();
	context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
	Telephony *telephony = new Telephony(bindingAddress);
	context->setContextProperty("telephony", telephony);
	Phone *phone = new Phone(telephony);
	context->setContextProperty("phone", phone);
	QObject::connect(telephony, &Telephony::callStateChanged, phone, &Phone::onCallStateChanged);
    }

    engine.load(QUrl(QStringLiteral("qrc:/Phone.qml")));

    return app.exec();
}
remote="github" revision="88685736c4a2f27bc72e398c66d5acc4e5628ffa" upstream="dunfell"/> <!-- meta-python2 as stop-gap to allow chromium to build until upstream fixes the dependencies --> <project name="meta-python2" path="external/meta-python2" remote="openembedded" revision="e2ef0dd8fa13d6b96e44773b09d07e4817d0a44d" upstream="dunfell" /> <!-- BSPs --> <!-- Renesas Gen3 specific things --> <project name="renesas-rcar/meta-renesas" path="bsp/meta-renesas" remote="github" revision="6c12c043f93966ec704d3a19765fbe200d42715d" upstream="dunfell-dev-4.14"/> <project name="CogentEmbedded/meta-rcar" path="bsp/meta-rcar" remote="github" revision="0dad8fb30506f085df3057c11dbc465c489d7e45" upstream="dunfell-Yocto-v3.21.0-v2"/> <!-- consolidate on meta-freescale from git.yoctoproject.org --> <project name="meta-freescale" path="bsp/meta-freescale" remote="yocto" revision="6bc3d8825c20d21528e24a7237ff7392e01a81bd" upstream="dunfell"/> <project name="Freescale/meta-freescale-3rdparty" path="bsp/meta-freescale-3rdparty" remote="github" revision="9000d8b388de98a13d6db2a98cd21602e0a7b715" upstream="dunfell"/> <!-- TI Vayu / Jacinto 6 / DRA7 --> <project name="meta-arm" path="bsp/meta-arm" remote="yocto" revision="0bd9c740267c0926e89bcfdb489790b7bf1fbd4b" upstream="dunfell"/> <project name="meta-ti" path="bsp/meta-ti" remote="yocto" revision="f2b2b2095f1a9d3ef705f7518d9db1e3141da2fb" upstream="dunfell"/> <!-- Raspberry Pi 3, 3B+, and 4 --> <project name="meta-raspberrypi" path="bsp/meta-raspberrypi" remote="yocto" revision="89ca43fe6411a40d1ba8f5379e49affd78cdd644" upstream="dunfell"/> <!-- DragonBoard 410c specific things --> <project name="meta-qcom" path="bsp/meta-qcom" remote="yocto" revision="2778e164cd0427277e37fc03c8ed19179da1613b" upstream="dunfell"/> <!-- Altera SOCFPGA platform --> <!-- https://github.com/kraj/meta-altera --> <project name="kraj/meta-altera" path="bsp/meta-altera" remote="github" revision="1db773d79403c4439103f3fba51b6c42d5f7b266" upstream="master"/> <!-- Sancloud BSP layers --> <project name="SanCloudLtd/meta-sancloud" path="bsp/meta-sancloud" remote="github" revision="58ad2300f74acc92afa21eaeaef7fd47fcc2a61c" upstream="dunfell"/> <project name="EmbeddedAndroid/meta-rtlwifi" path="bsp/meta-rtlwifi" remote="github" revision="91dd94630dad98389bfe4e15207e771754bde75c" upstream="master"/> <!-- meta-synopsys - support for ARC HSDK board --> <project name="foss-for-synopsys-dwc-arc-processors/meta-synopsys" path="bsp/meta-synopsys" remote="github" revision="80656bf6551b2056c8cb02a74510e595e2553048" upstream="dunfell-agl"/> </manifest>