diff --git a/share/dbus-1/session.conf b/share/dbus-1/session.conf
new file mode 100644
index 000000000..fbbed19e1
--- /dev/null
+++ b/share/dbus-1/session.conf
@@ -0,0 +1,80 @@
+
+
+
+
+
+ session
+
+
+
+
+ autolaunch:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ../../etc/dbus-1/session.conf
+
+
+ session.d
+
+ ../../etc/dbus-1/session.d
+
+
+ ../../etc/dbus-1/session-local.conf
+
+ contexts/dbus_contexts
+
+
+
+
+ 1000000000
+ 250000000
+ 1000000000
+ 250000000
+ 1000000000
+
+ 120000
+ 240000
+ 150000
+ 100000
+ 10000
+ 100000
+ 10000
+ 50000
+ 50000
+ 50000
+
+
diff --git a/src/blackcore/dbus_server.cpp b/src/blackcore/dbus_server.cpp
index 277467727..6e484de7b 100644
--- a/src/blackcore/dbus_server.cpp
+++ b/src/blackcore/dbus_server.cpp
@@ -10,7 +10,7 @@
#include "blackmisc/logmessage.h"
#include "blackmisc/network/networkutils.h"
#include "dbus_server.h"
-#include
+#include
#include
using namespace BlackMisc;
@@ -35,6 +35,12 @@ namespace BlackCore
// we use a session bus connection instead of a real P2P connection
this->m_serverMode = CDBusServer::SERVERMODE_SESSIONBUS;
QDBusConnection connection = QDBusConnection::connectToBus(QDBusConnection::SessionBus, ServiceName());
+ if (!connection.isConnected())
+ {
+ launchDbusDaemon();
+ connection = QDBusConnection::connectToBus(QDBusConnection::SessionBus, ServiceName());
+ }
+
if (!connection.registerService(service))
{
// registration fails can either mean something wrong with DBus or service already exists
@@ -48,6 +54,12 @@ namespace BlackCore
// we use a system bus connection instead of a real P2P connection
this->m_serverMode = CDBusServer::SERVERMODE_SYSTEMBUS;
QDBusConnection connection = QDBusConnection::systemBus();
+ if (!connection.isConnected())
+ {
+ launchDbusDaemon();
+ connection = QDBusConnection::systemBus();
+ }
+
if (!connection.registerService(service))
{
// registration fails can either mean something wrong with DBus or service already exists
@@ -91,6 +103,14 @@ namespace BlackCore
return sn;
}
+ void CDBusServer::launchDbusDaemon()
+ {
+ const QString program = QStringLiteral("dbus-daemon");
+ const QStringList arguments = { QStringLiteral("--config-file=../share/dbus-1/session.conf") };
+ bool success = QProcess::startDetached(program, arguments);
+ if (!success) { CLogMessage(this).warning("Failed to launch dbus-daemon!"); }
+ }
+
/*
* Check for P2P address
*/
diff --git a/src/blackcore/dbus_server.h b/src/blackcore/dbus_server.h
index 20c790e80..25c51af34 100644
--- a/src/blackcore/dbus_server.h
+++ b/src/blackcore/dbus_server.h
@@ -113,6 +113,9 @@ namespace BlackCore
QMap m_objects; //!< Mapping of all exposed objects, for P2P registration when connection establishes, also to later unregister objects
QMap m_DBusConnections; //!< Mapping of all DBusConnection objects
+ //! Manually launch our shipped dbus daemon
+ void launchDbusDaemon();
+
//! Check if address means a real server with P2P connection
static bool isP2P(const QString &address);