2 * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
3 * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <QGuiApplication>
19 #include <QCommandLineParser>
20 #include <QtCore/QUrlQuery>
21 #include <QtGui/QGuiApplication>
22 #include <QtQml/QQmlApplicationEngine>
23 #include <QtQml/QQmlContext>
24 #include <QtQml/qqml.h>
25 #include <QQuickWindow>
28 #include "applicationmodel.h"
30 #include "homescreenhandler.h"
31 #include "hmi-debug.h"
32 #include "shell-desktop.h"
34 int main(int argc, char *argv[])
36 QString myname = QString("launcher");
37 QGuiApplication a(argc, argv);
39 //QCoreApplication::setOrganizationDomain("LinuxFoundation");
40 //QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
41 //QCoreApplication::setApplicationName(myname);
42 //QCoreApplication::setApplicationVersion("0.1.0");
44 // necessary to identify correctly by app_id
45 a.setDesktopFileName(myname);
47 QCommandLineParser parser;
48 parser.addPositionalArgument("port", a.translate("main", "port for binding"));
49 parser.addPositionalArgument("secret", a.translate("main", "secret for binding"));
50 parser.addHelpOption();
51 parser.addVersionOption();
53 QStringList positionalArguments = parser.positionalArguments();
58 if (positionalArguments.length() == 2) {
59 port = positionalArguments.takeFirst().toInt();
60 token = positionalArguments.takeFirst();
63 HMI_DEBUG("launcher","port = %d, token = %s", port, token.toStdString().c_str());
65 // import C++ class to QML
66 qmlRegisterType<ApplicationModel>("AppModel", 1, 0, "ApplicationModel");
68 HomescreenHandler* homescreenHandler = new HomescreenHandler();
69 homescreenHandler->init(port, token.toStdString().c_str(), myname);
72 bindingAddress.setScheme(QStringLiteral("ws"));
73 bindingAddress.setHost(QStringLiteral("localhost"));
74 bindingAddress.setPort(port);
75 bindingAddress.setPath(QStringLiteral("/api"));
78 query.addQueryItem(QStringLiteral("token"), token);
79 bindingAddress.setQuery(query);
82 QQmlApplicationEngine engine;
83 engine.rootContext()->setContextProperty(QStringLiteral("homescreenHandler"), homescreenHandler);
84 engine.load(QUrl(QStringLiteral("qrc:/Launcher.qml")));
85 homescreenHandler->getRunnables();