diff options
author | 2019-11-11 01:05:35 -0800 | |
---|---|---|
committer | 2019-11-21 16:09:32 -0800 | |
commit | 88e15ced63c6beb2758c3880457398a6db225e07 (patch) | |
tree | f52027530e50c0267b229e598516d5d3bbba3f3d /app/main.cpp | |
parent | 64f5edda50fc53e70d5467c8d731db13620df5b4 (diff) |
ondemandnavi: add agl-service-navigation interface
Switch from the application providing DBus objects to consumers
with using afb binding with proper JSON responses.
Bug-AGL: SPEC-2880
Change-Id: If587ddeaea9a0f28e71c2bee790acbf53425de9f
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app/main.cpp')
-rwxr-xr-x | app/main.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/app/main.cpp b/app/main.cpp index cbd121c..b2b9185 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -27,6 +27,7 @@ #include <QtQml/QQmlContext> #include <QtQuickControls2/QQuickStyle> #include <QQuickWindow> +#include <navigation.h> #include "markermodel.h" #include "guidance_module.h" #include "file_operation.h" @@ -47,10 +48,29 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); parser.process(app); + + // Load qml + QQmlApplicationEngine engine; + QQmlContext *context = engine.rootContext(); + + File_Operation file; + context->setContextProperty("fileOperation", &file); + QStringList positionalArguments = parser.positionalArguments(); if (positionalArguments.length() == 2) { port = positionalArguments.takeFirst().toInt(); token = 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"), token); + bindingAddress.setQuery(query); + + Navigation *navigation = new Navigation(bindingAddress, context); + context->setContextProperty("navigation", navigation); } fprintf(stderr, "[navigation] app_name: %s, port: %d, token: %s.\n", graphic_role.toStdString().c_str(), @@ -81,17 +101,12 @@ int main(int argc, char *argv[]) qDebug("Surface %s got showWindow\n", graphic_role.toStdString().c_str()); qwmHandler->activateWindow(graphic_role); }); - // Load qml - QQmlApplicationEngine engine; MarkerModel model; - engine.rootContext()->setContextProperty("markerModel", &model); + context->setContextProperty("markerModel", &model); Guidance_Module guidance; - engine.rootContext()->setContextProperty("guidanceModule", &guidance); - - File_Operation file; - engine.rootContext()->setContextProperty("fileOperation", &file); + context->setContextProperty("guidanceModule", &guidance); engine.load(QUrl(QStringLiteral("qrc:/navigation.qml"))); QObject *root = engine.rootObjects().first(); |