diff --git a/data/dbus-1/io.guh.nymead.conf b/data/dbus-1/io.guh.nymead.conf
index 4106861d..fb105701 100644
--- a/data/dbus-1/io.guh.nymead.conf
+++ b/data/dbus-1/io.guh.nymead.conf
@@ -2,6 +2,7 @@
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
@@ -11,4 +12,3 @@
-
diff --git a/data/dbus-1/io.nymea.nymead.conf b/data/dbus-1/io.nymea.nymead.conf
new file mode 100644
index 00000000..ece63163
--- /dev/null
+++ b/data/dbus-1/io.nymea.nymead.conf
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/debian-qt5/nymead.install.in b/debian-qt5/nymead.install.in
index 44020ab4..8ae0d6a4 100644
--- a/debian-qt5/nymead.install.in
+++ b/debian-qt5/nymead.install.in
@@ -2,5 +2,6 @@ usr/bin/nymead
data/systemd/nymead.service /lib/systemd/system/
data/systemd/influxdb.service.d/nymea-env.conf /etc/systemd/system/influxdb.service.d/
data/logrotate/nymead /etc/logrotate.d/
+data/dbus-1/io.nymea.nymead.conf /etc/dbus-1/system.d/
data/dbus-1/io.guh.nymead.conf /etc/dbus-1/system.d/
data/dpkg/nymea-upgrade-helper /usr/libexec/
diff --git a/libnymea/nymeadbusservice.cpp b/libnymea/nymeadbusservice.cpp
index 68111548..1b7bd60c 100644
--- a/libnymea/nymeadbusservice.cpp
+++ b/libnymea/nymeadbusservice.cpp
@@ -27,27 +27,72 @@
NYMEA_LOGGING_CATEGORY(dcDBus, "DBus")
+namespace {
+const QString kNymeaInterface = QStringLiteral("io.nymea.nymead");
+const QString kLegacyInterface = QStringLiteral("io.guh.nymead");
+const QString kNymeaNamespace = QStringLiteral("/io/nymea/");
+const QString kLegacyNamespace = QStringLiteral("/io/guh/");
+bool gLegacyServiceWarningLogged = false;
+bool gLegacyObjectWarningLogged = false;
+}
+
QDBusConnection::BusType NymeaDBusService::s_busType = QDBusConnection::SystemBus;
NymeaDBusService::NymeaDBusService(const QString &objectPath, QObject *parent):
QObject(parent),
m_connection(s_busType == QDBusConnection::SystemBus ? QDBusConnection::systemBus() : QDBusConnection::sessionBus())
{
- bool status = m_connection.registerService("io.guh.nymead");
+ bool status = m_connection.registerService(kNymeaInterface);
if (!status) {
- qCWarning(dcDBus()) << "Failed to register D-Bus service.";
+ qCWarning(dcDBus()) << "Failed to register D-Bus service" << kNymeaInterface;
return;
}
- QString finalObjectPath;
+
+ bool legacyServiceStatus = m_connection.registerService(kLegacyInterface);
+ if (!legacyServiceStatus) {
+ qCWarning(dcDBus()) << "Failed to register legacy D-Bus service" << kLegacyInterface << "- older clients might not be able to connect.";
+ } else if (!gLegacyServiceWarningLogged) {
+ qCWarning(dcDBus()) << "The D-Bus service" << kLegacyInterface << "is deprecated and kept only for backwards compatibility. Please migrate to" << kNymeaInterface << ".";
+ gLegacyServiceWarningLogged = true;
+ }
+
+ QString normalizedObjectPath;
foreach (const QString &part, objectPath.split(' ')) {
- finalObjectPath.append(part.at(0).toUpper());
- finalObjectPath.append(part.right(part.length() - 1));
+ normalizedObjectPath.append(part.at(0).toUpper());
+ normalizedObjectPath.append(part.right(part.length() - 1));
}
- status = m_connection.registerObject(finalObjectPath, "io.guh.nymead", parent, QDBusConnection::ExportScriptableSlots);
+
+ QString nymeaObjectPath = normalizedObjectPath;
+ QString legacyObjectPath;
+ bool registerLegacyObject = false;
+
+ if (normalizedObjectPath.contains(kNymeaNamespace)) {
+ legacyObjectPath = normalizedObjectPath;
+ legacyObjectPath.replace(kNymeaNamespace, kLegacyNamespace);
+ registerLegacyObject = true;
+ } else if (normalizedObjectPath.contains(kLegacyNamespace)) {
+ legacyObjectPath = normalizedObjectPath;
+ nymeaObjectPath = normalizedObjectPath;
+ nymeaObjectPath.replace(kLegacyNamespace, kNymeaNamespace);
+ registerLegacyObject = true;
+ }
+
+ status = m_connection.registerObject(nymeaObjectPath, kNymeaInterface, parent, QDBusConnection::ExportScriptableSlots);
if (!status) {
- qCWarning(dcDBus()) << "Failed to register D-Bus object:" << finalObjectPath;
+ qCWarning(dcDBus()) << "Failed to register D-Bus object:" << nymeaObjectPath;
return;
}
+
+ if (registerLegacyObject) {
+ bool legacyObjectStatus = m_connection.registerObject(legacyObjectPath, kLegacyInterface, parent, QDBusConnection::ExportScriptableSlots);
+ if (!legacyObjectStatus) {
+ qCWarning(dcDBus()) << "Failed to register deprecated legacy D-Bus object:" << legacyObjectPath;
+ } else if (!gLegacyObjectWarningLogged) {
+ qCWarning(dcDBus()) << "The D-Bus interface" << kLegacyInterface << "is deprecated and only kept for backwards compatibility.";
+ gLegacyObjectWarningLogged = true;
+ }
+ }
+
m_isValid = true;
}
@@ -68,4 +113,3 @@ void NymeaDBusService::setBusType(QDBusConnection::BusType busType)
{
s_busType = busType;
}
-
diff --git a/libnymea/nymeadbusservice.h b/libnymea/nymeadbusservice.h
index ad62ba66..c1475b3e 100644
--- a/libnymea/nymeadbusservice.h
+++ b/libnymea/nymeadbusservice.h
@@ -29,10 +29,13 @@
#include
#include
+/*! Helper to expose QObject subclasses on D-Bus under the nymea namespace.
+ * The legacy io.guh.nymead interface remains registered for backwards
+ * compatibility but is deprecated and will be removed in a future release. */
class NymeaDBusService : public QObject
{
Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "io.guh.nymead")
+ Q_CLASSINFO("D-Bus Interface", "io.nymea.nymead")
public:
explicit NymeaDBusService(const QString &objectPath, QObject *parent = nullptr);
diff --git a/tests/utils/pushbuttonagent.cpp b/tests/utils/pushbuttonagent.cpp
index 37e7e75d..bcd0e018 100644
--- a/tests/utils/pushbuttonagent.cpp
+++ b/tests/utils/pushbuttonagent.cpp
@@ -45,7 +45,7 @@ bool PushButtonAgent::init(QDBusConnection::BusType busType)
return false;
}
- QDBusMessage message = QDBusMessage::createMethodCall("io.guh.nymead", "/io/guh/nymead/UserManager", "io.guh.nymead", "RegisterButtonAgent");
+ QDBusMessage message = QDBusMessage::createMethodCall("io.nymea.nymead", "/io/nymea/nymead/UserManager", "io.nymea.nymead", "RegisterButtonAgent");
message << QVariant::fromValue(QDBusObjectPath("/nymea/pushbuttonhandler"));
QDBusMessage reply = bus.call(message);
if (!reply.errorName().isEmpty()) {