Rename Testservice DBus variables

This commit is contained in:
Roland Winklmeier
2016-02-09 10:13:00 +01:00
parent b1fa85b00f
commit bf787478ad
3 changed files with 17 additions and 15 deletions

View File

@@ -62,14 +62,14 @@ namespace BlackMiscTest
void ServiceTool::dataTransferTestServer(BlackMisc::CDBusServer *dBusServer) void ServiceTool::dataTransferTestServer(BlackMisc::CDBusServer *dBusServer)
{ {
QDBusConnection sessionBusConnection = QDBusConnection::sessionBus(); QDBusConnection sessionBusConnection = QDBusConnection::sessionBus();
if (sessionBusConnection.interface()->isServiceRegistered(Testservice::ServiceName)) if (sessionBusConnection.interface()->isServiceRegistered(Testservice::InterfaceName))
{ {
qFatal("Testservice already registed on session bus"); qFatal("Testservice already registed on session bus");
} }
// as this is the receiver side, the slots can be debugged too // as this is the receiver side, the slots can be debugged too
Testservice *testservice = ServiceTool::registerTestservice(sessionBusConnection, QCoreApplication::instance()); Testservice *testservice = ServiceTool::registerTestservice(sessionBusConnection, QCoreApplication::instance());
dBusServer->addObject(Testservice::ServicePath, testservice); dBusServer->addObject(Testservice::ObjectPath, testservice);
} }
void ServiceTool::dataTransferTestClient(const QString &address) void ServiceTool::dataTransferTestClient(const QString &address)
@@ -185,7 +185,7 @@ namespace BlackMiscTest
Testservice *ServiceTool::registerTestservice(QDBusConnection &connection, QObject *parent) Testservice *ServiceTool::registerTestservice(QDBusConnection &connection, QObject *parent)
{ {
Testservice *pTestservice = new Testservice(parent); // just a QObject with signals / slots and Q_CLASSINFO("D-Bus Interface", some service name) Testservice *pTestservice = new Testservice(parent); // just a QObject with signals / slots and Q_CLASSINFO("D-Bus Interface", some service name)
if (!connection.registerService(Testservice::ServiceName)) if (!connection.registerService(Testservice::InterfaceName))
{ {
QDBusError err = connection.lastError(); QDBusError err = connection.lastError();
qWarning() << err.message(); qWarning() << err.message();
@@ -195,7 +195,7 @@ namespace BlackMiscTest
qFatal("Could not register service!"); qFatal("Could not register service!");
} }
if (!connection.registerObject(Testservice::ServicePath, pTestservice, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAdaptors)) if (!connection.registerObject(Testservice::ObjectPath, pTestservice, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAdaptors))
{ {
qFatal("Could not register service object!"); qFatal("Could not register service object!");
} }
@@ -205,7 +205,7 @@ namespace BlackMiscTest
QString service; // service not needed QString service; // service not needed
if (connection.connect( if (connection.connect(
service, Testservice::ServicePath, Testservice::ServiceName, service, Testservice::ObjectPath, Testservice::InterfaceName,
"sendStringMessage", pTestservice, SLOT(receiveStringMessage(const QString &)))) "sendStringMessage", pTestservice, SLOT(receiveStringMessage(const QString &))))
{ {
qDebug() << "Connected object with bus sendStringMessage"; qDebug() << "Connected object with bus sendStringMessage";
@@ -220,7 +220,7 @@ namespace BlackMiscTest
void ServiceTool::sendDataToTestservice(const QDBusConnection &connection) void ServiceTool::sendDataToTestservice(const QDBusConnection &connection)
{ {
// on the client's side // on the client's side
TestServiceInterface testserviceInterface(Testservice::ServiceName, Testservice::ServicePath, connection); TestServiceInterface testserviceInterface(Testservice::InterfaceName, Testservice::ObjectPath, connection);
CSpeed speed(200, CSpeedUnit::km_h()); CSpeed speed(200, CSpeedUnit::km_h());
CSpeed speedNull(0, CSpeedUnit::nullUnit()); CSpeed speedNull(0, CSpeedUnit::nullUnit());
@@ -231,7 +231,7 @@ namespace BlackMiscTest
while (true) while (true)
{ {
QDBusMessage m = QDBusMessage::createSignal( QDBusMessage m = QDBusMessage::createSignal(
Testservice::ServicePath, Testservice::ServiceName, Testservice::ObjectPath, Testservice::InterfaceName,
"sendStringMessage"); "sendStringMessage");
// The << operator is used to add the parameters for the slot // The << operator is used to add the parameters for the slot

View File

@@ -21,8 +21,8 @@ using namespace BlackMisc::Network;
namespace BlackMiscTest namespace BlackMiscTest
{ {
const QString Testservice::ServiceName = QString(BLACKMISCKTEST_TESTSERVICE_INTERFACENAME); const QString Testservice::InterfaceName = QString(BLACKSAMPLE_TESTSERVICE_INTERFACENAME);
const QString Testservice::ServicePath = QString(BLACKMISCKTEST_TESTSERVICE_SERVICEPATH); const QString Testservice::ObjectPath = QString(BLACKSAMPLE_TESTSERVICE_OBJECTPATH);
/* /*
* Constructor * Constructor
@@ -208,7 +208,7 @@ namespace BlackMiscTest
QList<QDBusObjectPath> paths; QList<QDBusObjectPath> paths;
for (int i = 0; i < number; i++) for (int i = 0; i < number; i++)
{ {
paths.append(QDBusObjectPath(BLACKMISCKTEST_TESTSERVICE_SERVICEPATH)); paths.append(QDBusObjectPath(BLACKSAMPLE_TESTSERVICE_OBJECTPATH));
} }
return paths; return paths;
} }

View File

@@ -30,8 +30,8 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusObjectPath> #include <QDBusObjectPath>
#define BLACKMISCKTEST_TESTSERVICE_INTERFACENAME "blackmisctest.testservice" #define BLACKSAMPLE_TESTSERVICE_INTERFACENAME "blackmisctest.testservice"
#define BLACKMISCKTEST_TESTSERVICE_SERVICEPATH "/ts" #define BLACKSAMPLE_TESTSERVICE_OBJECTPATH "/ts"
namespace BlackMiscTest namespace BlackMiscTest
{ {
@@ -40,7 +40,7 @@ namespace BlackMiscTest
class Testservice : public QObject class Testservice : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_CLASSINFO("D-Bus Interface", BLACKMISCKTEST_TESTSERVICE_INTERFACENAME) Q_CLASSINFO("D-Bus Interface", BLACKSAMPLE_TESTSERVICE_INTERFACENAME)
// For some reasons the interface name in the XML is not set correctly // For some reasons the interface name in the XML is not set correctly
// to the above name // to the above name
@@ -169,8 +169,10 @@ namespace BlackMiscTest
QList<QDBusObjectPath> getObjectPaths(int number) const; QList<QDBusObjectPath> getObjectPaths(int number) const;
public: public:
static const QString ServiceName; //! DBus interface name
static const QString ServicePath; static const QString InterfaceName;
//! DBus object path
static const QString ObjectPath;
//! Constructor //! Constructor
explicit Testservice(QObject *parent = nullptr); explicit Testservice(QObject *parent = nullptr);