1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
diff --git a/plugins/dbus/abstractdbusinterface.cpp b/plugins/dbus/abstractdbusinterface.cpp
index 9dd8566..19ef606 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 @@ list<string> 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 b5fb149..edbe1bd 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"
@@ -341,7 +342,7 @@ static void signalCallback( GDBusConnection *connection,
AbstractDBusInterface* iface = i.first;
for(auto n : i.second)
{
- if(n == name)
+ if(n == name && !persistent)
{
DebugOut()<<"unreferencing "<<n<<" from the subscription of "<<iface->objectPath()<<endl;
manager->subscribedProcesses[iface].remove(n);
@@ -398,7 +399,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 0c8a645..07e6786 100644
--- a/plugins/dbus/dbusinterfacemanager.cpp
+++ b/plugins/dbus/dbusinterfacemanager.cpp
@@ -236,7 +236,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 7fa31c1..0b75d69 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 337f2f6..92e6255 100644
--- a/plugins/dbus/dbusplugin.h
+++ b/plugins/dbus/dbusplugin.h
@@ -29,6 +29,9 @@
typedef std::map<VehicleProperty::Property, VariantType*> PropertyDBusMap;
+extern GBusType bustype;
+extern bool persistent;
+
class DBusSink : public AbstractSink, public AbstractDBusInterface
{
diff --git a/tests/amb-get b/tests/amb-get
index 0835a64..7fb48ea 100755
--- a/tests/amb-get
+++ b/tests/amb-get
@@ -5,12 +5,17 @@ import sys
import argparse
parser = argparse.ArgumentParser()
+parser.add_argument("--sessionbus", help="use session bus", action='store_true')
parser.add_argument("get", help="get {objectName}")
args = parser.parse_args()
objectName = args.get
-bus = dbus.SystemBus()
+if (args.sessionbus):
+ bus = dbus.SessionBus()
+else:
+ bus = dbus.SystemBus()
+
managerObject = bus.get_object("org.automotive.message.broker", "/");
managerInterface = dbus.Interface(managerObject, "org.automotive.Manager")
|