mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-29 04:35:41 +08:00
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:
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include <QMetaMethod>
|
||||
|
||||
#define XBUS_SERVICE_SERVICENAME "net.vatsim.xbus"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
@@ -14,7 +16,7 @@ namespace BlackSimPlugin
|
||||
|
||||
CXBusServiceProxy::CXBusServiceProxy(QDBusConnection &connection, QObject *parent, bool dummy) : QObject(parent)
|
||||
{
|
||||
m_dbusInterface = new BlackMisc::CGenericDBusInterface(BlackCore::CDBusServer::ServiceName, ObjectPath(), InterfaceName(), connection, this);
|
||||
m_dbusInterface = new BlackMisc::CGenericDBusInterface(XBUS_SERVICE_SERVICENAME, ObjectPath(), InterfaceName(), connection, this);
|
||||
if (! dummy) { relaySignals(); }
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
#include "blackmisc/genericdbusinterface.h"
|
||||
|
||||
//! \private
|
||||
#define XBUS_SERVICE_INTERFACENAME "net.vatsim.PilotClient.XBus"
|
||||
//! \private
|
||||
#define XBUS_SERVICE_OBJECTPATH "/XBus"
|
||||
//! \cond PRIVATE
|
||||
#define XBUS_SERVICE_INTERFACENAME "net.vatsim.xbus.service"
|
||||
#define XBUS_SERVICE_OBJECTPATH "/xbus"
|
||||
//! \endcond
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
#define XBUS_SERVICE_SERVICENAME "net.vatsim.xbus"
|
||||
|
||||
namespace XBus
|
||||
{
|
||||
|
||||
@@ -21,7 +23,7 @@ namespace XBus
|
||||
Q_ASSERT(! m_server);
|
||||
for (auto &item : m_startServerMenuItems) { item.setEnabled(false); }
|
||||
|
||||
m_server = new BlackCore::CDBusServer(address, this);
|
||||
m_server = new BlackCore::CDBusServer(XBUS_SERVICE_SERVICENAME, address, this);
|
||||
m_service = new CService(this);
|
||||
m_server->addObject(CService::ObjectPath(), m_service);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "datarefs.h"
|
||||
#include <QObject>
|
||||
|
||||
//! \private
|
||||
#define XBUS_SERVICE_INTERFACENAME "net.vatsim.PilotClient.XBus"
|
||||
//! \private
|
||||
#define XBUS_SERVICE_OBJECTPATH "/XBus"
|
||||
//! \cond PRIVATE
|
||||
#define XBUS_SERVICE_INTERFACENAME "net.vatsim.xbus.service"
|
||||
#define XBUS_SERVICE_OBJECTPATH "/xbus"
|
||||
//! \endcond
|
||||
|
||||
namespace XBus
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user