From 55c2e2e5595586e975caa5ee9928deb7f796cea7 Mon Sep 17 00:00:00 2001 From: Roland Rossgotterer Date: Thu, 22 Nov 2018 11:53:33 +0100 Subject: [PATCH] [XSwiftBus] Add getVersionNumber to DBus API This allows to get the version number of XSwiftBus itself. It maintains the same version as swift (e.g. 0.8.7 without the time stamp) and can be used to compare it for compatibility reasons. ref T394 --- src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp | 5 +++++ src/plugins/simulator/xplane/xswiftbusserviceproxy.h | 3 +++ src/xswiftbus/org.swift_project.xswiftbus.service.xml | 3 +++ src/xswiftbus/service.cpp | 9 ++++++++- src/xswiftbus/service.h | 3 +++ src/xswiftbus/xswiftbus.pro | 2 ++ 6 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp b/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp index 0ee4a745a..599912589 100644 --- a/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp +++ b/src/plugins/simulator/xplane/xswiftbusserviceproxy.cpp @@ -39,6 +39,11 @@ namespace BlackSimPlugin } } + QString CXSwiftBusServiceProxy::getVersionNumber() + { + return m_dbusInterface->callDBusRet(QLatin1String("getVersionNumber")); + } + void CXSwiftBusServiceProxy::getOwnAircraftSituationData(XPlaneData *o_xplaneData) { QPointer myself(this); diff --git a/src/plugins/simulator/xplane/xswiftbusserviceproxy.h b/src/plugins/simulator/xplane/xswiftbusserviceproxy.h index d770caaf1..864676660 100644 --- a/src/plugins/simulator/xplane/xswiftbusserviceproxy.h +++ b/src/plugins/simulator/xplane/xswiftbusserviceproxy.h @@ -96,6 +96,9 @@ namespace BlackSimPlugin void airportsInRangeUpdated(const QStringList &icaoCodes, const QStringList &names, const QList &lats, const QList &lons, const QList &alts); public slots: + //! Get XSwiftBus version number + QString getVersionNumber(); + //! Get own aircraft situation data void getOwnAircraftSituationData(XPlaneData *o_xplaneData); diff --git a/src/xswiftbus/org.swift_project.xswiftbus.service.xml b/src/xswiftbus/org.swift_project.xswiftbus.service.xml index 47b409db2..2da8e498b 100644 --- a/src/xswiftbus/org.swift_project.xswiftbus.service.xml +++ b/src/xswiftbus/org.swift_project.xswiftbus.service.xml @@ -1,5 +1,8 @@ R"( + + + diff --git a/src/xswiftbus/service.cpp b/src/xswiftbus/service.cpp index 81cbcba01..3f032eabc 100644 --- a/src/xswiftbus/service.cpp +++ b/src/xswiftbus/service.cpp @@ -207,7 +207,14 @@ namespace XSwiftBus } else if (message.getInterfaceName() == XSWIFTBUS_SERVICE_INTERFACENAME) { - if (message.getMethodName() == "addTextMessage") + if (message.getMethodName() == "getVersionNumber") + { + queueDBusCall([ = ]() + { + sendDBusReply(sender, serial, getVersionNumber()); + }); + } + else if (message.getMethodName() == "addTextMessage") { maybeSendEmptyDBusReply(wantsReply, sender, serial); std::string text; diff --git a/src/xswiftbus/service.h b/src/xswiftbus/service.h index 37fc7a122..cbffa05c8 100644 --- a/src/xswiftbus/service.h +++ b/src/xswiftbus/service.h @@ -61,6 +61,9 @@ namespace XSwiftBus //! Called by XPluginReceiveMessage when the model changes. void onAircraftModelChanged(); + //! Returns the XSwiftBus version number + std::string getVersionNumber() const { return XSWIFTBUS_VERSION; } + //! Add a text message to the on-screen display, with RGB components in the range [0,1] void addTextMessage(const std::string &text, double red, double green, double blue); diff --git a/src/xswiftbus/xswiftbus.pro b/src/xswiftbus/xswiftbus.pro index 7a09f5656..87cd9cf9a 100644 --- a/src/xswiftbus/xswiftbus.pro +++ b/src/xswiftbus/xswiftbus.pro @@ -72,6 +72,8 @@ DEFINES += XPLM210=1 DEFINES += XPMP_CLIENT_NAME=\\\"xswiftbus\\\" DEFINES += XPMP_CLIENT_LONGNAME=\\\"xswiftbus\\\" +DEFINES += XSWIFTBUS_VERSION=\\\"$${BLACK_VERSION}\\\" + # X-Plane plugins must follow a prescribed filename and directory structure. TARGET_EXT = .xpl win32:TARGET = win