aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-11-10 23:46:39 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-11-21 15:53:57 -0800
commit029b583a9d5c615d941c42916d1750bee5c84eab (patch)
tree7a34d3d550eb970b8f9ee96aa80b7b7091c10408
parentf679e8238131daa18a23efe232710730ba27ea67 (diff)
tbtnavi: add interface to agl-service-navigation
Add interface to agl-service-navigation via libqtappfw to replace navicore DBus completely. Bug-AGL: SPEC-2880 Change-Id: Idf3afcdd3c7424b8adb91a9aaf14df662d7fe107 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--app/app.pro6
-rw-r--r--app/main.cpp14
-rw-r--r--app/navigation_client.cpp50
-rw-r--r--app/navigation_client.h31
-rw-r--r--package/config.xml1
5 files changed, 99 insertions, 3 deletions
diff --git a/app/app.pro b/app/app.pro
index a2f7283..2928e7e 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -1,8 +1,8 @@
TARGET = tbtnavi
TEMPLATE = app
-QT += qml network quick positioning location widgets
-PKGCONFIG += qlibhomescreen qlibwindowmanager
+QT = qml network quick positioning location widgets websockets
+PKGCONFIG += qlibhomescreen qlibwindowmanager qtappfw
CONFIG += c++1z link_pkgconfig
@@ -10,11 +10,13 @@ include(app.pri)
SOURCES += \
main.cpp \
+ navigation_client.cpp \
qcheapruler.cpp \
file_operation.cpp
HEADERS += \
qcheapruler.hpp \
+ navigation_client.h \
file_operation.h
INCLUDEPATH += \
diff --git a/app/main.cpp b/app/main.cpp
index 43e8586..5ef2e7a 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -9,7 +9,9 @@
#include <QtQuick/QQuickWindow>
#include <qlibwindowmanager.h>
#include <qlibhomescreen.h>
+#include <navigation.h>
+#include "navigation_client.h"
#include "qcheapruler.hpp"
#include "file_operation.h"
@@ -30,12 +32,17 @@ int main(int argc, char *argv[])
parser.addVersionOption();
parser.process(app);
QStringList positionalArguments = parser.positionalArguments();
+ QUrl bindingAddress;
int port = 0;
QString token;
if (positionalArguments.length() == 2) {
port = positionalArguments.takeFirst().toInt();
token = positionalArguments.takeFirst();
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
}
fprintf(stderr, "[tbtnavi] app_name: %s, port: %d, token: %s.\n",
graphic_role.toStdString().c_str(),
@@ -72,8 +79,13 @@ int main(int argc, char *argv[])
qmlRegisterType<QCheapRuler>("com.mapbox.cheap_ruler", 1, 0, "CheapRuler");
+ QQmlContext *context = engine.rootContext();
+
File_Operation file;
- engine.rootContext()->setContextProperty("fileOperation", &file);
+ context->setContextProperty("fileOperation", &file);
+
+ Navigation *navigation = new Navigation(bindingAddress, context);
+ new navigation_client(navigation);
engine.load(QUrl(QStringLiteral("qrc:qml/Main.qml")));
QObject *root = engine.rootObjects().first();
diff --git a/app/navigation_client.cpp b/app/navigation_client.cpp
new file mode 100644
index 0000000..f07f6c7
--- /dev/null
+++ b/app/navigation_client.cpp
@@ -0,0 +1,50 @@
+#include "navigation_client.h"
+
+navigation_client::navigation_client(Navigation *navigation, QObject *parent) :
+ m_navigation(navigation)
+{
+ QObject::connect(m_navigation, &Navigation::statusEvent, this, &navigation_client::statusEvent);
+ QObject::connect(m_navigation, &Navigation::positionEvent, this, &navigation_client::positionEvent);
+}
+
+navigation_client::~navigation_client(){}
+
+void navigation_client::statusEvent(QVariantMap data)
+{
+ if (!data.contains("state"))
+ return;
+
+ QString state = data["state"].toString();
+
+ if (state == "arrived")
+ emit arrivedestQml();
+
+ if (state == "stopped" || state == "stop")
+ emit stopdemoQml();
+}
+
+void navigation_client::positionEvent(QVariantMap data)
+{
+ if (!data.contains("position"))
+ return;;
+
+ QString position = data["position"].toString();
+
+ if (position == "route") {
+ double route_Lat_s = data["latitude"].toDouble();
+ double route_Lon_s = data["longitude"].toDouble();
+ double route_Lat_e = data["route_latitude"].toDouble();
+ double route_Lon_e = data["route_longitude"].toDouble();
+
+ emit addRoutePointsQml(route_Lat_s, route_Lon_s, route_Lat_e, route_Lon_e);
+ }
+
+ if (position == "car") {
+ double cur_Lat_p = data["latitude"].toDouble();
+ double cur_Lon_p = data["longitude"].toDouble();
+ double cur_direction = data["direction"].toDouble();
+ double cur_distance = data["distance"].toDouble();
+
+ emit positionQml(cur_Lat_p, cur_Lon_p, cur_direction, cur_distance);
+ }
+}
diff --git a/app/navigation_client.h b/app/navigation_client.h
new file mode 100644
index 0000000..cdd9396
--- /dev/null
+++ b/app/navigation_client.h
@@ -0,0 +1,31 @@
+#ifndef NAVIGATION_CLIENT_H
+#define NAVIGATION_CLIENT_H
+
+#include <navigation.h>
+#include <QtQml/QQmlApplicationEngine>
+
+class navigation_client : public QObject {
+ Q_OBJECT
+
+ Navigation *m_navigation;
+
+public:
+ navigation_client(Navigation *navigation, QObject *parent = nullptr);
+ ~navigation_client();
+
+signals:
+ //notify add routepoints signal to qml
+ void addRoutePointsQml(QVariant, QVariant, QVariant, QVariant);
+ //notify current position signal to qml
+ void positionQml(QVariant, QVariant,QVariant, QVariant);
+ //notify stop demo signal to qml
+ void stopdemoQml();
+ //notify arrive destination signal to qml
+ void arrivedestQml();
+
+private slots:
+
+ void statusEvent(QVariantMap data);
+ void positionEvent(QVariantMap data);
+};
+#endif // NAVIGATION_CLIENT_H
diff --git a/package/config.xml b/package/config.xml
index ed4aafc..37f6067 100644
--- a/package/config.xml
+++ b/package/config.xml
@@ -9,6 +9,7 @@
<feature name="urn:AGL:widget:required-api">
<param name="windowmanager" value="ws"/>
<param name="homescreen" value="ws"/>
+ <param name="navigation" value="ws"/>
</feature>
<feature name="urn:AGL:widget:required-permission">
<param name="urn:AGL:permission::public:no-htdocs" value="required" />