1 #include"dbus_server.h"
4 DBus_Server::DBus_Server(const QString &pathName,
5 const QString &objName,
6 const QString &serverName,
8 m_serverName(serverName),
9 m_pathName(pathName + serverName),
10 m_objName(objName + serverName)
15 DBus_Server::~DBus_Server(){}
17 void DBus_Server::initDBus(){
19 new NaviapiAdaptor(this);
21 if (!QDBusConnection::sessionBus().registerService(m_pathName))
22 qDebug() << m_pathName << "registerService() failed";
24 if (!QDBusConnection::sessionBus().registerObject(m_objName, this))
25 qDebug() << m_objName << "registerObject() failed";
27 QDBusConnection sessionBus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_serverName);
28 if (!sessionBus.isConnected()) {
29 qDebug() << m_serverName << "connectToBus() failed";
32 //for receive dbus signal
33 org::agl::naviapi *mInterface;
34 mInterface = new org::agl::naviapi(QString(),QString(),QDBusConnection::sessionBus(),this);
35 if (!connect(mInterface,SIGNAL(getRouteInfo()),this,SLOT(getRouteInfoSlot()))){
36 qDebug() << m_serverName << "sessionBus.connect():getRouteInfoSlot failed";
41 void DBus_Server::initAPIs(QObject *parent){
43 if(!QObject::connect(this,SIGNAL(doAddPOI(QVariant,QVariant,QVariant)),
44 parent,SLOT(addPoiIconSLOT(QVariant,QVariant,QVariant)))) {
45 qDebug() << m_serverName << "cppSIGNAL:doAddPOI to qmlSLOT:addPoiIcon connect is failed";
48 if(!QObject::connect(this,SIGNAL(doRemovePOIs(QVariant)),
49 parent,SLOT(removePoiIconsSLOT(QVariant)))) {
50 qDebug() << m_serverName << "cppSIGNAL:doRemovePOIs to qmlSLOT:removePoiIcons connect is failed";
53 if(!QObject::connect(this,SIGNAL(doGetRouteInfo()),
54 parent,SLOT(doGetRouteInfoSlot()))) {
55 qDebug() << m_serverName << "cppSIGNAL:doGetRouteInfo to qmlSLOT:doGetRouteInfoSlot connect is failed";
58 if(!QObject::connect(parent,SIGNAL(qmlSignalRouteInfo(double,double,double,double)),
59 this,SLOT(sendSignalRouteInfo(double,double,double,double)))) {
60 qDebug() << m_serverName << "qmlSIGNAL:qmlSignalRouteInfo to cppSLOT:sendSignalRouteInfo connect is failed";
63 if(!QObject::connect(parent,SIGNAL(qmlSignalPosInfo(double,double,double,double)),
64 this,SLOT(sendSignalPosInfo(double,double,double,double)))) {
65 qDebug() << m_serverName << "qmlSIGNAL:qmlSignalPosInfo to cppSLOT:sendSignalPosInfo connect is failed";
68 if(!QObject::connect(parent,SIGNAL(qmlSignalStopDemo()),
69 this,SLOT(sendSignalStopDemo()))) {
70 qDebug() << m_serverName << "qmlSIGNAL:qmlSignalStopDemo to cppSLOT:sendSignalStopDemo connect is failed";
73 if(!QObject::connect(parent,SIGNAL(qmlSignalArrvied()),
74 this,SLOT(sendSignalArrvied()))) {
75 qDebug() << m_serverName << "qmlSIGNAL:qmlSignalArrvied to cppSLOT:sendSignalArrvied connect is failed";
79 void DBus_Server::getRouteInfoSlot(){
80 qDebug() << "call getRouteInfoSlot ";
81 emit doGetRouteInfo();
86 void DBus_Server::sendSignalRouteInfo(double srt_lat, double srt_lon, double end_lat, double end_lon){
87 qDebug() << "call sendSignalRouteInfo ";
88 QDBusMessage message = QDBusMessage::createSignal(m_objName,
89 org::agl::naviapi::staticInterfaceName(),
91 message << srt_lat << srt_lon << end_lat << end_lon;
92 QDBusConnection::sessionBus().send(message);
96 void DBus_Server::sendSignalPosInfo(double lat, double lon, double drc, double dst){
97 // qDebug() << "call sendSignalPosInfo ";
98 QDBusMessage message = QDBusMessage::createSignal(m_objName,
99 org::agl::naviapi::staticInterfaceName(),
101 message << lat << lon << drc << dst;
102 QDBusConnection::sessionBus().send(message);
106 void DBus_Server::sendSignalStopDemo(){
107 qDebug() << "call sendSignalStopDemo ";
108 QDBusMessage message = QDBusMessage::createSignal(m_objName,
109 org::agl::naviapi::staticInterfaceName(),
111 QDBusConnection::sessionBus().send(message);
115 void DBus_Server::sendSignalArrvied(){
116 qDebug() << "call sendSignalArrvied ";
117 QDBusMessage message = QDBusMessage::createSignal(m_objName,
118 org::agl::naviapi::staticInterfaceName(),
120 QDBusConnection::sessionBus().send(message);
125 void DBus_Server::addPOI(uint category_id, double poi_Lat, double poi_Lon){
126 qDebug() << "call addPOI category_id: " << category_id << " poi_Lat: " << poi_Lat << " poi_Lon: " << poi_Lon;
127 emit doAddPOI(poi_Lat,poi_Lon,category_id);
130 void DBus_Server::removePOIs(uint category_id){
131 qDebug() << "call removePOIs category_id: " << category_id;
132 emit doRemovePOIs(category_id);