2 * Copyright (C) 2016 The Qt Company Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <QtCore/QDebug>
18 #include <QtCore/QCommandLineParser>
19 #include <QtCore/QUrlQuery>
20 #include <QtGui/QGuiApplication>
21 #include <QtQml/QQmlApplicationEngine>
22 #include <QtQml/QQmlContext>
23 #include <QtQuickControls2/QQuickStyle>
25 #ifdef HAVE_LIBHOMESCREEN
26 #include <libhomescreen.hpp>
29 int main(int argc, char *argv[])
31 #ifdef HAVE_LIBHOMESCREEN
32 LibHomeScreen libHomeScreen;
34 if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) {
35 qWarning() << "renderAppToAreaAllowed is denied";
40 QGuiApplication app(argc, argv);
42 QQuickStyle::setStyle("AGL");
44 QQmlApplicationEngine engine;
46 QCommandLineParser parser;
47 parser.addPositionalArgument("port", app.translate("main", "port for binding"));
48 parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
49 parser.addHelpOption();
50 parser.addVersionOption();
52 QStringList positionalArguments = parser.positionalArguments();
53 if (positionalArguments.length() == 2) {
54 int port = positionalArguments.takeFirst().toInt();
55 QString secret = positionalArguments.takeFirst();
57 bindingAddress.setScheme(QStringLiteral("ws"));
58 bindingAddress.setHost(QStringLiteral("localhost"));
59 bindingAddress.setPort(port);
60 bindingAddress.setPath(QStringLiteral("/api"));
62 query.addQueryItem(QStringLiteral("token"), secret);
63 bindingAddress.setQuery(query);
65 QUrl bindingAddressSM;
66 bindingAddressSM.setScheme(QStringLiteral("ws"));
67 bindingAddressSM.setHost(QStringLiteral("localhost"));
68 bindingAddressSM.setPort(port);
69 bindingAddressSM.setPath(QStringLiteral("/api"));
70 bindingAddressSM.setQuery(query);
72 QQmlContext *context = engine.rootContext();
73 context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
74 context->setContextProperty(QStringLiteral("bindingAddressSM"), bindingAddressSM);
76 engine.load(QUrl(QStringLiteral("qrc:/Phone.qml")));