From 1f875de1d513c733550401ee40fa289fb2acb57e Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Wed, 24 Jul 2019 12:09:40 -0400 Subject: Initial import from github Import from http://github.com/YoshitoMomiyama/aglqtnavigation.git as of commit a6930c2, with the following minor changes: - .gitignore tweaked to remove itself - .gitreview updated Bug-AGL: SPEC-2667 Signed-off-by: Scott Murray Change-Id: I91fed0f6349bf1952e41132058929b70a2b0fe5b --- app/dbus_server_navigationcore.cpp | 175 +++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 app/dbus_server_navigationcore.cpp (limited to 'app/dbus_server_navigationcore.cpp') diff --git a/app/dbus_server_navigationcore.cpp b/app/dbus_server_navigationcore.cpp new file mode 100644 index 0000000..e8f7a37 --- /dev/null +++ b/app/dbus_server_navigationcore.cpp @@ -0,0 +1,175 @@ +#include "dbus_server_navigationcore.h" +#include +#include +#include +#include + +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(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + + + 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 coordinate = m_Variant.value(); + 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::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; +} + -- cgit 1.2.3-korg