summaryrefslogtreecommitdiff
path: root/plugins/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dbus')
-rw-r--r--plugins/dbus/abstractdbusinterface.cpp3
-rw-r--r--plugins/dbus/automotivemanager.cpp5
-rw-r--r--plugins/dbus/dbusinterfacemanager.cpp2
-rw-r--r--plugins/dbus/dbusplugin.cpp13
-rw-r--r--plugins/dbus/dbusplugin.h4
5 files changed, 23 insertions, 4 deletions
diff --git a/plugins/dbus/abstractdbusinterface.cpp b/plugins/dbus/abstractdbusinterface.cpp
index f4c575c1..684b8ff0 100644
--- a/plugins/dbus/abstractdbusinterface.cpp
+++ b/plugins/dbus/abstractdbusinterface.cpp
@@ -17,6 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "abstractdbusinterface.h"
+#include "dbusplugin.h"
#include <abstractroutingengine.h>
#include <debugout.h>
@@ -37,7 +38,7 @@ PropertyList AbstractDBusInterface::mimplementedProperties;
const uint getPid(const char *owner)
{
GError* error = nullptr;
- GDBusProxy* dbus = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ GDBusProxy* dbus = g_dbus_proxy_new_for_bus_sync(bustype, G_DBUS_PROXY_FLAGS_NONE, NULL,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
diff --git a/plugins/dbus/automotivemanager.cpp b/plugins/dbus/automotivemanager.cpp
index a6b1ca25..d5c56b06 100644
--- a/plugins/dbus/automotivemanager.cpp
+++ b/plugins/dbus/automotivemanager.cpp
@@ -1,3 +1,4 @@
+#include "dbusplugin.h"
#include "automotivemanager.h"
#include "abstractdbusinterface.h"
#include "listplusplus.h"
@@ -380,7 +381,7 @@ static void signalCallback( GDBusConnection *connection,
for(auto itr = i.second.begin(); itr != i.second.end(); itr++)
{
std::string n = *itr;
- if(n == name)
+ if(n == name && !persistent)
{
DebugOut()<<"unreferencing "<<n<<" from the subscription of "<<iface->objectPath()<<endl;
itr = manager->subscribedProcesses[iface].erase(itr);
@@ -445,7 +446,7 @@ AutomotiveManager::AutomotiveManager(GDBusConnection *connection)
g_assert(regId > 0);
- g_dbus_connection_signal_subscribe(g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL,NULL), "org.freedesktop.DBus", "org.freedesktop.DBus",
+ g_dbus_connection_signal_subscribe(g_bus_get_sync(bustype, NULL,NULL), "org.freedesktop.DBus", "org.freedesktop.DBus",
"NameOwnerChanged", "/org/freedesktop/DBus", NULL, G_DBUS_SIGNAL_FLAGS_NONE,
signalCallback, this, NULL);
}
diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp
index 0fff219e..87976cfc 100644
--- a/plugins/dbus/dbusinterfacemanager.cpp
+++ b/plugins/dbus/dbusinterfacemanager.cpp
@@ -158,7 +158,7 @@ on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data
DBusInterfaceManager::DBusInterfaceManager(AbstractRoutingEngine* engine,std::map<std::string,std::string> config)
:AbstractSink(engine,config),re(engine), connection(nullptr)
{
- ownerId = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+ ownerId = g_bus_own_name(bustype,
DBusServiceName,
G_BUS_NAME_OWNER_FLAGS_NONE,
on_bus_acquired,
diff --git a/plugins/dbus/dbusplugin.cpp b/plugins/dbus/dbusplugin.cpp
index ed950268..3bd10285 100644
--- a/plugins/dbus/dbusplugin.cpp
+++ b/plugins/dbus/dbusplugin.cpp
@@ -24,8 +24,21 @@
#include "debugout.h"
#include "listplusplus.h"
+bool persistent=false;
+GBusType bustype=G_BUS_TYPE_SYSTEM;
+
extern "C" AbstractSinkManager * create(AbstractRoutingEngine* routingengine, map<string, string> config)
{
+ if(config.find("sessionbus") != config.end())
+ {
+ bustype=G_BUS_TYPE_SESSION;
+ }
+
+ if(config.find("persistent") != config.end())
+ {
+ persistent=true;
+ }
+
return new DBusSinkManager(routingengine, config);
}
diff --git a/plugins/dbus/dbusplugin.h b/plugins/dbus/dbusplugin.h
index 74128dfe..11f8c0c4 100644
--- a/plugins/dbus/dbusplugin.h
+++ b/plugins/dbus/dbusplugin.h
@@ -27,6 +27,10 @@
#include <map>
#include <type_traits>
+extern GBusType bustype;
+extern bool persistent;
+
+
class DBusSink : public AbstractSink, public AbstractDBusInterface
{