[libraries/kunifiedpush] /: adds the possibility to choose the created service name via env variable

Dominique MICHEL <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit c35241800c1247a8a421c405dd16fd477d9dd22d by Dominique  MICHEL, on behalf of Noham Devillers.
Committed on 10/08/2026 at 15:20.
Pushed by aloeil into branch 'master'.

adds the possibility to choose the created service name via env variable

M  +4    -0    README.md
M  +3    -1    src/distributor/main.cpp
M  +6    -2    src/kcm/kcmpushnotifications.cpp

https://invent.kde.org/libraries/kunifiedpush/-/commit/c35241800c1247a8a421c405dd16fd477d9dd22d

diff --git a/README.md b/README.md
index 1d6b401..baef09e 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,10 @@ between the server-side application and the push provider, but not the one betwe
 the push provider and the distributor. Supporting different push providers therefore
 requires provider specific code and configuration.
 
+The default name of the created service is `org.unifiedpush.Distributor.kde`.
+The part of the name after the prefix `org.unifiedpush.Distributor.` can be changed
+using the `KDE_DISTRIBUTOR_SERVICE_NAME` environment variable.
+
 ### Configuration
 
 There is a configuration KCM, alternatively this can be configured via
diff --git a/src/distributor/main.cpp b/src/distributor/main.cpp
index e2e20ea..5f535f1 100644
--- a/src/distributor/main.cpp
+++ b/src/distributor/main.cpp
@@ -30,7 +30,9 @@ int main(int argc, char **argv)
     KCrash::initialize();
 
     KUnifiedPush::Distributor distributor;
-    if (!QDBusConnection::sessionBus().registerService(KDE_DISTRIBUTOR_SERVICE_NAME)) {
+    const auto serviceName = qEnvironmentVariableIsEmpty("KDE_DISTRIBUTOR_SERVICE_NAME") ? QString::fromLatin1(KDE_DISTRIBUTOR_SERVICE_NAME)
+        : UP_DISTRIBUTOR_SERVICE_NAME_PREFIX + qEnvironmentVariable("KDE_DISTRIBUTOR_SERVICE_NAME");
+    if (!QDBusConnection::sessionBus().registerService(serviceName)) {
         qCCritical(Log) << "Distributor service name already in use - aborting!";
         return 1;
     }
diff --git a/src/kcm/kcmpushnotifications.cpp b/src/kcm/kcmpushnotifications.cpp
index 3a0d39c..669da26 100644
--- a/src/kcm/kcmpushnotifications.cpp
+++ b/src/kcm/kcmpushnotifications.cpp
@@ -34,7 +34,9 @@ KCMPushNotifications::KCMPushNotifications(QObject *parent, const KPluginMetaDat
     m_nam.enableStrictTransportSecurityStore(true, QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/org.kde.kunifiedpush/hsts/"));
 
     // TODO do this only when we are using the KDE distributor
-    m_mgmtIface = new OrgKdeKunifiedpushManagementInterface(KDE_DISTRIBUTOR_SERVICE_NAME, KDE_DISTRIBUTOR_MANAGEMENT_PATH, QDBusConnection::sessionBus(), this);
+    const auto serviceName = qEnvironmentVariableIsEmpty("KDE_DISTRIBUTOR_SERVICE_NAME") ? QString::fromLatin1(KDE_DISTRIBUTOR_SERVICE_NAME)
+        : UP_DISTRIBUTOR_SERVICE_NAME_PREFIX + qEnvironmentVariable("KDE_DISTRIBUTOR_SERVICE_NAME");
+    m_mgmtIface = new OrgKdeKunifiedpushManagementInterface(serviceName, KDE_DISTRIBUTOR_MANAGEMENT_PATH, QDBusConnection::sessionBus(), this);
     connect(m_mgmtIface, &OrgKdeKunifiedpushManagementInterface::statusChanged, this, &KCMPushNotifications::distributorStatusChanged);
     connect(m_mgmtIface, &OrgKdeKunifiedpushManagementInterface::errorMessageChanged, this, &KCMPushNotifications::distributorErrorMessageChanged);
     connect(m_mgmtIface, &OrgKdeKunifiedpushManagementInterface::pushProviderChanged, this, &KCMPushNotifications::pushProviderChanged);
@@ -66,7 +68,9 @@ bool KCMPushNotifications::hasDistributor() const
 
 bool KCMPushNotifications::hasKDEDistributor() const
 {
-    return ConnectorUtils::selectDistributor() == KDE_DISTRIBUTOR_SERVICE_NAME;
+    const auto serviceName = qEnvironmentVariableIsEmpty("KDE_DISTRIBUTOR_SERVICE_NAME") ? QString::fromLatin1(KDE_DISTRIBUTOR_SERVICE_NAME)
+        : UP_DISTRIBUTOR_SERVICE_NAME_PREFIX + qEnvironmentVariable("KDE_DISTRIBUTOR_SERVICE_NAME");
+    return ConnectorUtils::selectDistributor() == serviceName;
 }
 
 int KCMPushNotifications::distributorStatus() const
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.