fixes #269 added parameter to CDBusServer constructor to choose a different service name,

allows two servers running on the same bus, needed when running xbus and sample_blackcore
This commit is contained in:
Mathew Sutcliffe
2014-06-17 21:20:15 +01:00
parent c4a0207e4f
commit 072667b3b4
6 changed files with 25 additions and 18 deletions

View File

@@ -13,7 +13,7 @@
namespace BlackCore
{
const QString CDBusServer::ServiceName = QString(BLACKCORE_DBUSERVER_SERVICENAME);
const QString CDBusServer::ServiceName = QString(BLACKCORE_RUNTIME_SERVICENAME);
/*
* Constructor
@@ -21,7 +21,7 @@ namespace BlackCore
* see http://download.froglogic.com/public/qt5-squishcoco-report/QtBase/source_241_preprocessed.html
* DBus config: http://dbus.freedesktop.org/doc/dbus-daemon.1.html
*/
CDBusServer::CDBusServer(const QString &address, QObject *parent) :
CDBusServer::CDBusServer(const QString &service, const QString &address, QObject *parent) :
QObject(parent), m_busServer(CDBusServer::isQtDBusAddress(address) ? address : "tcp:host=127.0.0.1,port=45000", // "unix:tmpdir=/tmp",
parent), m_serverMode(CDBusServer::SERVERMODE_P2P)
{
@@ -34,7 +34,7 @@ namespace BlackCore
// we use a session bus connection instead of a real P2P connection
this->m_serverMode = CDBusServer::SERVERMODE_SESSIONBUS;
QDBusConnection con = QDBusConnection::sessionBus();
if (!con.registerService(CDBusServer::ServiceName))
if (!con.registerService(service))
{
qCritical() << con.lastError().message();
qFatal("Cannot register DBus service, server started? dbus-daemon.exe --session --address=tcp:host=192.168.0.133,port=45000");
@@ -46,7 +46,7 @@ namespace BlackCore
// we use a system bus connection instead of a real P2P connection
this->m_serverMode = CDBusServer::SERVERMODE_SYSTEMBUS;
QDBusConnection con = QDBusConnection::systemBus();
if (!con.registerService(CDBusServer::ServiceName))
if (!con.registerService(service))
{
qCritical() << con.lastError().message();
qFatal("Cannot register DBus service, server started? dbus-daemon.exe --system --address=tcp:host=192.168.0.133,port=45000");

View File

@@ -14,7 +14,7 @@
#include <QStringList>
#include <QMap>
#define BLACKCORE_DBUSERVER_SERVICENAME "org.vatsim.pilotClient"
#define BLACKCORE_RUNTIME_SERVICENAME "net.vatsim.pilotClient"
namespace BlackCore
@@ -27,7 +27,7 @@ namespace BlackCore
class CDBusServer : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", BLACKCORE_DBUSERVER_SERVICENAME)
Q_CLASSINFO("D-Bus Interface", BLACKCORE_RUNTIME_SERVICENAME)
public:
//! \brief Service name of DBus serve
@@ -61,10 +61,13 @@ namespace BlackCore
}
public:
//! Constructor
//! Construct a server for the BlackCore runtime
//! \remarks We are using address and not ServerMode, as on some systems we need to pass in some specific configuration string
//! \sa QDBusServer
CDBusServer(const QString &address, QObject *parent = nullptr);
CDBusServer(const QString &address, QObject *parent = nullptr) : CDBusServer(CDBusServer::ServiceName, address, parent) {}
//! Construct a server for some arbitrary service
CDBusServer(const QString &service, const QString &address, QObject *parent = nullptr);
//!! Adds a QObject to be exposed to DBus
void addObject(const QString &name, QObject *object);