aboutsummaryrefslogtreecommitdiffstats
path: root/app/dbus_server.cpp
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-07-24 12:09:40 -0400
committerScott Murray <scott.murray@konsulko.com>2019-07-24 12:09:40 -0400
commit1f875de1d513c733550401ee40fa289fb2acb57e (patch)
tree9e6764cd4de63021285435e956f260b295cdbd7b /app/dbus_server.cpp
parent33258140525123d6a38900811c2df3e14f4e8337 (diff)
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 <scott.murray@konsulko.com> Change-Id: I91fed0f6349bf1952e41132058929b70a2b0fe5b
Diffstat (limited to 'app/dbus_server.cpp')
-rw-r--r--app/dbus_server.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/app/dbus_server.cpp b/app/dbus_server.cpp
new file mode 100644
index 0000000..ea3acad
--- /dev/null
+++ b/app/dbus_server.cpp
@@ -0,0 +1,113 @@
+#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))
+ qDebug() << m_serverName << "registerService() failed";
+
+ if (!QDBusConnection::sessionBus().registerObject(m_objName, this))
+ qDebug() << m_serverName << "registerObject() failed";
+
+ QDBusConnection sessionBus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_serverName);
+ if (!sessionBus.isConnected()) {
+ qDebug() << 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()))){
+ qDebug() << m_serverName << "sessionBus.connect():getRouteInfoSlot failed";
+ }
+
+}
+
+void DBus_Server::initAPIs(QObject *parent){
+
+ if(!QObject::connect(this,SIGNAL(doGetRouteInfo()),
+ parent,SLOT(doGetRouteInfoSlot()))) {
+ qDebug() << m_serverName << "cppSIGNAL:doGetRouteInfo to qmlSLOT:doGetRouteInfoSlot connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalRouteInfo(double,double,double,double)),
+ this,SLOT(sendSignalRouteInfo(double,double,double,double)))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalRouteInfo to cppSLOT:sendSignalRouteInfo connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalPosInfo(double,double,double,double)),
+ this,SLOT(sendSignalPosInfo(double,double,double,double)))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalPosInfo to cppSLOT:sendSignalPosInfo connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalStopDemo()),
+ this,SLOT(sendSignalStopDemo()))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalStopDemo to cppSLOT:sendSignalStopDemo connect is failed";
+ }
+
+ if(!QObject::connect(parent,SIGNAL(qmlSignalArrvied()),
+ this,SLOT(sendSignalArrvied()))) {
+ qDebug() << m_serverName << "qmlSIGNAL:qmlSignalArrvied to cppSLOT:sendSignalArrvied connect is failed";
+ }
+}
+
+void DBus_Server::getRouteInfoSlot(){
+ qDebug() << "call getRouteInfoSlot ";
+ emit doGetRouteInfo();
+ return;
+}
+
+// Signal
+void DBus_Server::sendSignalRouteInfo(double srt_lat, double srt_lon, double end_lat, double end_lon){
+ qDebug() << "call sendSignalRouteInfo ";
+ 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(){
+ qDebug() << "call sendSignalStopDemo ";
+ QDBusMessage message = QDBusMessage::createSignal(m_objName,
+ org::agl::naviapi::staticInterfaceName(),
+ "signalStopDemo");
+ QDBusConnection::sessionBus().send(message);
+ return;
+}
+
+void DBus_Server::sendSignalArrvied(){
+ qDebug() << "call sendSignalArrvied ";
+ QDBusMessage message = QDBusMessage::createSignal(m_objName,
+ org::agl::naviapi::staticInterfaceName(),
+ "signalArrvied");
+ QDBusConnection::sessionBus().send(message);
+ return;
+}
+// Method