summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/common/bluetooth5.cpp10
-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
6 files changed, 29 insertions, 8 deletions
diff --git a/plugins/common/bluetooth5.cpp b/plugins/common/bluetooth5.cpp
index f836b422..5bdbd2f1 100644
--- a/plugins/common/bluetooth5.cpp
+++ b/plugins/common/bluetooth5.cpp
@@ -6,6 +6,8 @@
#include <gio/gunixfdlist.h>
#include <string>
+GBusType bustype=G_BUS_TYPE_SYSTEM;
+
static const gchar introspection_xml[] =
"<node>"
" <interface name='org.bluez.Profile1'>"
@@ -121,7 +123,7 @@ std::string findDevice(std::string address, std::string adapterPath="")
std::string objectPath;
GError * proxyError = nullptr;
- auto managerProxy = amb::make_super(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ auto managerProxy = amb::make_super(g_dbus_proxy_new_for_bus_sync(bustype, G_DBUS_PROXY_FLAGS_NONE, NULL,
"org.bluez",
"/",
"org.freedesktop.DBus.ObjectManager",
@@ -215,7 +217,7 @@ Bluetooth5::Bluetooth5()
GDBusInterfaceInfo* mInterfaceInfo = g_dbus_node_info_lookup_interface(introspection, "org.bluez.Profile1");
- mConnection = amb::make_super(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &errorBus));
+ mConnection = amb::make_super(g_bus_get_sync(bustype, nullptr, &errorBus));
auto errorBusPtr = amb::make_super(errorBus);
@@ -308,7 +310,7 @@ void Bluetooth5::connect(ConnectedCallback onconnectedCallback)
GError* error = nullptr;
- auto deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
+ auto deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(bustype,G_DBUS_PROXY_FLAGS_NONE,NULL,
"org.bluez", mPath.c_str(), "org.bluez.Device1", nullptr, &error));
auto errorPtr = amb::make_super(error);
@@ -341,7 +343,7 @@ void Bluetooth5::disconnect()
{
GError* error = nullptr;
- auto deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,G_DBUS_PROXY_FLAGS_NONE,NULL,
+ auto deviceProxyPtr = amb::make_super(g_dbus_proxy_new_for_bus_sync(bustype,G_DBUS_PROXY_FLAGS_NONE,NULL,
"org.bluez", mPath.c_str(), "org.bluez.Device1", nullptr, &error));
auto errorPtr = amb::make_super(error);
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
{