diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-10-17 06:34:09 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-11-11 01:05:08 -0800 |
commit | ca2db695f1258e0b325c7454a8f79c6d7b2eb48b (patch) | |
tree | 57a1779ae7e8c4ae6e6946f76e81a81512f7d4e2 /app | |
parent | 7d7a2abc459456aa261f53d1f07ff54a2e6a810a (diff) |
ondemandnavi: remove DBus interface
For proper afb interfae to function the DBus support needs
to be removed.
Bug-AGL: SPEC-2880
Change-Id: Ib501583e5cb3821bf5479d875e447411477c7da3
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/app.pro | 12 | ||||
-rw-r--r-- | app/dbus_server.cpp | 108 | ||||
-rw-r--r-- | app/dbus_server.h | 33 | ||||
-rw-r--r-- | app/dbus_server_navigationcore.cpp | 175 | ||||
-rw-r--r-- | app/dbus_server_navigationcore.h | 48 | ||||
-rw-r--r-- | app/main.cpp | 14 |
6 files changed, 2 insertions, 388 deletions
diff --git a/app/app.pro b/app/app.pro index f04b4f8..c53e922 100644 --- a/app/app.pro +++ b/app/app.pro @@ -3,29 +3,21 @@ QT = quick qml PKGCONFIG += qlibhomescreen qlibwindowmanager QT += positioning -QT += dbus QT += core CONFIG += c++11 link_pkgconfig HEADERS += \ markermodel.h \ - dbus_server.h \ guidance_module.h \ - file_operation.h \ - dbus_server_navigationcore.h + file_operation.h SOURCES += main.cpp \ - dbus_server.cpp \ - file_operation.cpp \ - dbus_server_navigationcore.cpp + file_operation.cpp RESOURCES += \ navigation.qrc \ images/images.qrc -LIBS += $$OUT_PWD/../dbus_interface/libdbus_interface.a -INCLUDEPATH += $$OUT_PWD/../dbus_interface - include(app.pri) DISTFILES += diff --git a/app/dbus_server.cpp b/app/dbus_server.cpp deleted file mode 100644 index 99ae363..0000000 --- a/app/dbus_server.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include"dbus_server.h" -#include <QDebug> - -DBus_Server::DBus_Server(QObject *parent) : - m_serverName("naviapi"), - m_pathName("org.agl.naviapi"), - m_objName("/org/agl/naviapi") -{ - initDBus(); - initAPIs(parent); -} - -DBus_Server::~DBus_Server(){ - QDBusConnection::sessionBus().unregisterObject(m_objName); - QDBusConnection::sessionBus().unregisterService(m_pathName); -} - -void DBus_Server::initDBus(){ - - new NaviapiAdaptor(this); - - if (!QDBusConnection::sessionBus().registerService(m_pathName)) - qWarning() << m_serverName << "registerService() failed"; - - if (!QDBusConnection::sessionBus().registerObject(m_objName, this)) - qWarning() << m_serverName << "registerObject() failed"; - - QDBusConnection sessionBus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_serverName); - if (!sessionBus.isConnected()) { - qWarning() << m_serverName << "connectToBus() failed"; - } - - //for receive dbus signal - org::agl::naviapi *mInterface; - mInterface = new org::agl::naviapi(QString(),QString(),QDBusConnection::sessionBus(),this); - if (!connect(mInterface,SIGNAL(getRouteInfo()),this,SLOT(getRouteInfoSlot()))){ - qWarning() << m_serverName << "sessionBus.connect():getRouteInfoSlot failed"; - } - -} - -void DBus_Server::initAPIs(QObject *parent){ - - if(!QObject::connect(this,SIGNAL(doGetRouteInfo()), - parent,SLOT(doGetRouteInfoSlot()))) { - qWarning() << m_serverName << "cppSIGNAL:doGetRouteInfo to qmlSLOT:doGetRouteInfoSlot connect failed"; - } - - if(!QObject::connect(parent,SIGNAL(qmlSignalRouteInfo(double,double,double,double)), - this,SLOT(sendSignalRouteInfo(double,double,double,double)))) { - qWarning() << m_serverName << "qmlSIGNAL:qmlSignalRouteInfo to cppSLOT:sendSignalRouteInfo connect failed"; - } - - if(!QObject::connect(parent,SIGNAL(qmlSignalPosInfo(double,double,double,double)), - this,SLOT(sendSignalPosInfo(double,double,double,double)))) { - qWarning() << m_serverName << "qmlSIGNAL:qmlSignalPosInfo to cppSLOT:sendSignalPosInfo connect failed"; - } - - if(!QObject::connect(parent,SIGNAL(qmlSignalStopDemo()), - this,SLOT(sendSignalStopDemo()))) { - qWarning() << m_serverName << "qmlSIGNAL:qmlSignalStopDemo to cppSLOT:sendSignalStopDemo connect failed"; - } - - if(!QObject::connect(parent,SIGNAL(qmlSignalArrived()), - this,SLOT(sendSignalArrived()))) { - qWarning() << m_serverName << "qmlSIGNAL:qmlSignalArrived to cppSLOT:sendSignalArrived connect failed"; - } -} - -void DBus_Server::getRouteInfoSlot(){ - emit doGetRouteInfo(); - return; -} - -// Signal -void DBus_Server::sendSignalRouteInfo(double srt_lat, double srt_lon, double end_lat, double end_lon){ - QDBusMessage message = QDBusMessage::createSignal(m_objName, - org::agl::naviapi::staticInterfaceName(), - "signalRouteInfo"); - message << srt_lat << srt_lon << end_lat << end_lon; - QDBusConnection::sessionBus().send(message); - return; -} - -void DBus_Server::sendSignalPosInfo(double lat, double lon, double drc, double dst){ - QDBusMessage message = QDBusMessage::createSignal(m_objName, - org::agl::naviapi::staticInterfaceName(), - "signalPosInfo"); - message << lat << lon << drc << dst; - QDBusConnection::sessionBus().send(message); - return; -} - -void DBus_Server::sendSignalStopDemo(void){ - QDBusMessage message = QDBusMessage::createSignal(m_objName, - org::agl::naviapi::staticInterfaceName(), - "signalStopDemo"); - QDBusConnection::sessionBus().send(message); - return; -} - -void DBus_Server::sendSignalArrived(void){ - QDBusMessage message = QDBusMessage::createSignal(m_objName, - org::agl::naviapi::staticInterfaceName(), - "signalArrived"); - QDBusConnection::sessionBus().send(message); - return; -} diff --git a/app/dbus_server.h b/app/dbus_server.h deleted file mode 100644 index aaa4d73..0000000 --- a/app/dbus_server.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef DBUS_SERVER_H -#define DBUS_SERVER_H -#include "org.agl.naviapi_interface.h" -#include "org.agl.naviapi_adaptor.h" -#include <QtQml/QQmlApplicationEngine> - -class DBus_Server : public QObject{ - - Q_OBJECT - - QString m_serverName; - QString m_pathName; - QString m_objName; - -public: - DBus_Server(QObject *parent = nullptr); - ~DBus_Server(); - -private: - void initDBus(); - void initAPIs(QObject*); - -signals: - void doGetRouteInfo(); - -public slots: - void getRouteInfoSlot(); - void sendSignalRouteInfo(double srt_lat,double srt_lon,double end_lat,double end_lon); - void sendSignalPosInfo(double lat,double lon,double drc,double dst); - void sendSignalStopDemo(); - void sendSignalArrived(); -}; -#endif // DBUS_SERVER_H diff --git a/app/dbus_server_navigationcore.cpp b/app/dbus_server_navigationcore.cpp deleted file mode 100644 index e8f7a37..0000000 --- a/app/dbus_server_navigationcore.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include "dbus_server_navigationcore.h" -#include <QDebug> -#include <QDBusVariant> -#include <QDBusConnectionInterface> -#include <QGeoCoordinate> - -dbus_server_navigationcore::dbus_server_navigationcore(QObject *parent) : - m_pathName("org.agl.naviapi"), - m_objName("/org/genivi/navicore"), - m_serverName("mapmatchedposition"), - m_object(parent) -{ - setupDBus(); - setupApi(); -} - -dbus_server_navigationcore::~dbus_server_navigationcore(){ - QDBusConnection::sessionBus().unregisterObject(m_objName); -} - -void dbus_server_navigationcore::setupDBus() -{ - qDBusRegisterMetaType<qPositionPairElm>(); - qDBusRegisterMetaType<qPosition>(); - qDBusRegisterMetaType<qValuesToReturn>(); - qDBusRegisterMetaType<qWaypointsList>(); - qDBusRegisterMetaType<qSessionsListElm>(); - qDBusRegisterMetaType<qSessionsList>(); - - - if (!QDBusConnection::sessionBus().registerService(m_pathName)) - qDebug() << m_serverName << "registerService() failed"; - - if (!QDBusConnection::sessionBus().registerObject(m_objName, this)) - qDebug() << m_serverName << "registerObject() failed"; - - new MapMatchedPositionAdaptor(this); - new RoutingAdaptor(this); - new SessionAdaptor(this); -} - -void dbus_server_navigationcore::setupApi(){ - - if(!QObject::connect(this,SIGNAL(doPauseSimulation()), - m_object,SLOT(doPauseSimulationSlot()))) { - qDebug() << m_serverName << "cppSIGNAL:doPauseSimulation to qmlSLOT:doPauseSimulationSlot connect is failed"; - } - -} - -// Method -qPosition dbus_server_navigationcore::GetPosition(const qValuesToReturn &valuesToReturn){ - double Latitude =0; - double Longitude =0; - qPosition result; - qPositionPairElm Pair_1,Pair_2; - QVariant m_Variant = m_object->property("currentpostion"); - if(m_Variant.canConvert<QGeoCoordinate>()){ - QGeoCoordinate coordinate = m_Variant.value<QGeoCoordinate>(); - Latitude = coordinate.latitude(); - Longitude = coordinate.longitude(); - } - - for(int i = 0; i < valuesToReturn.size(); i++){ - switch(valuesToReturn[i]){ - case 160: - Pair_1.key = 160; - Pair_1.value = QDBusVariant(Latitude); - result.insert(160,Pair_1); - break; - case 161: - Pair_2.key = 161; - Pair_2.value = QDBusVariant(Longitude); - result.insert(161,Pair_2); - break; - default: - break; - } - } - return result; -} - -void dbus_server_navigationcore::PauseSimulation(uint sessionHandle){ - qDebug() << m_serverName << sessionHandle << "call PauseSimulation"; - emit doPauseSimulation(); - return; -} - -void dbus_server_navigationcore::SetSimulationMode(uint sessionHandle, bool activate){ - qDebug() << m_serverName << sessionHandle << activate << "call SetSimulationMode"; - return; -} - -void dbus_server_navigationcore::CalculateRoute(uint sessionHandle, uint routeHandle){ - qDebug() << m_objName << sessionHandle << routeHandle << "call dbus_server_routing"; - return; -} - -void dbus_server_navigationcore::CancelRouteCalculation(uint sessionHandle, uint routeHandle){ - qDebug() << m_objName << sessionHandle << routeHandle << "call CancelRouteCalculation"; - return; -} - -uint dbus_server_navigationcore::CreateRoute(uint sessionHandle){ - qDebug() << m_objName << sessionHandle << "call CreateRoute"; - QVariant returnvalue; - uint result; - - // call qml function - if(!QMetaObject::invokeMethod(m_object,"doGetAllRoutesSlot",Q_RETURN_ARG(QVariant, returnvalue))) - qDebug() << m_objName << "invokeMethod doGetAllRoutesSlot failed."; - - // we only manage 1 route for now - result = (uint)returnvalue.toInt(); - return result; -} - -qRoutesList dbus_server_navigationcore::GetAllRoutes(){ - qDebug() << m_objName << "call GetAllRoutes"; - QVariant returnvalue; - qRoutesList result; - - // call qml function - if(!QMetaObject::invokeMethod(m_object,"doGetAllRoutesSlot",Q_RETURN_ARG(QVariant, returnvalue))) - qDebug() << m_objName << "invokeMethod doGetAllRoutesSlot failed."; - - // we only manage 1 route for now - int ret = returnvalue.toInt(); - if(ret == 1){ - result.append(ret); - } - return result; -} - -void dbus_server_navigationcore::SetWaypoints(uint sessionHandle, uint routeHandle, bool startFromCurrentPosition, qWaypointsList waypointsList){ - qDebug() << m_objName << sessionHandle << routeHandle << startFromCurrentPosition << "call SetWaypoints"; - double Latitude =0; - double Longitude =0; - - // analize waypointlist only manage 1 waypoint - for(int i = 0; i < 1; i++){ - QMap<int32_t,qPositionPairElm>::const_iterator itr = waypointsList[i].constBegin(); - while(itr != waypointsList[i].constEnd()){ - switch(itr.key()){ - case 160: - Latitude = itr.value().value.variant().toDouble(); - itr++; - break; - case 161: - Longitude = itr.value().value.variant().toDouble(); - itr++; - break; - default: - break; - } - } - } - - // call qml function - if(!QMetaObject::invokeMethod(m_object,"doSetWaypointsSlot",Q_ARG(QVariant, Latitude),Q_ARG(QVariant, Longitude),Q_ARG(QVariant, startFromCurrentPosition))) - qDebug() << m_objName << "invokeMethod doSetWaypointsSlot failed."; - - return; -} - -qSessionsList dbus_server_navigationcore::GetAllSessions(){ - qDebug() << m_objName << "call GetAllSessions"; - qSessionsList result; - qSessionsListElm element; - element.key = 1; - element.value = "dummy"; - result.append(element); - return result; -} - diff --git a/app/dbus_server_navigationcore.h b/app/dbus_server_navigationcore.h deleted file mode 100644 index 3f62dbb..0000000 --- a/app/dbus_server_navigationcore.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef DBUS_SERVER_NAVIGATIONCORE_H -#define DBUS_SERVER_NAVIGATIONCORE_H - -#include <QtDBus/QDBusConnection> -#include <QtCore/QObject> -#include <QtDBus/QtDBus> - -#include "org.genivi.navigationcore_adaptor.h" -#include "org.genivi.navigationcore_interface.h" - -class dbus_server_navigationcore : public QObject -{ - Q_OBJECT - - QString m_pathName; - QString m_objName; - QString m_serverName; - QObject *m_object; - -public: - dbus_server_navigationcore(QObject *parent = 0); - ~dbus_server_navigationcore(); - -public slots: - // mapmatchedposition - qPosition GetPosition(const qValuesToReturn &valuesToReturn); - void PauseSimulation(uint sessionHandle); - void SetSimulationMode(uint sessionHandle, bool activate); - // routing - void CalculateRoute(uint sessionHandle, uint routeHandle); - void CancelRouteCalculation(uint sessionHandle, uint routeHandle); - uint CreateRoute(uint sessionHandle); - qRoutesList GetAllRoutes(); - void SetWaypoints(uint sessionHandle, uint routeHandle, bool startFromCurrentPosition, qWaypointsList waypointsList); - // session - qSessionsList GetAllSessions(); - -signals: - void doPauseSimulation(); - -private: - void setupDBus(); - void setupApi(); - -}; - -#endif // DBUS_SERVER_NAVIGATIONCORE_H - diff --git a/app/main.cpp b/app/main.cpp index aa7768b..cbd121c 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -27,23 +27,12 @@ #include <QtQml/QQmlContext> #include <QtQuickControls2/QQuickStyle> #include <QQuickWindow> -#include <QtDBus/QDBusConnection> #include "markermodel.h" -#include "dbus_server.h" -#include "dbus_server_navigationcore.h" #include "guidance_module.h" #include "file_operation.h" int main(int argc, char *argv[]) { - - // for dbusIF - if (!QDBusConnection::sessionBus().isConnected()) { - qWarning("Cannot connect to the D-Bus session bus.\n" - "Please check your system settings and try again.\n"); - return 1; - } - QGuiApplication app(argc, argv); QString graphic_role = QString("navigation"); int port = 1700; @@ -108,9 +97,6 @@ int main(int argc, char *argv[]) QObject *root = engine.rootObjects().first(); QQuickWindow *window = qobject_cast<QQuickWindow *>(root); QObject::connect(window, SIGNAL(frameSwapped()), qwmHandler, SLOT(slotActivateSurface())); - QObject *map = engine.rootObjects().first()->findChild<QObject*>("map"); - DBus_Server dbus(map); - dbus_server_navigationcore dbus_navigationcore(map); return app.exec(); } |