Commit d58d65eb authored by Max Kellermann's avatar Max Kellermann

lib/dbus/Glue: use private connection

Avoid interfering with libraries also using the shared connection.
parent adf2d3af
......@@ -43,6 +43,15 @@ ODBus::Connection::GetSystem()
}
ODBus::Connection
ODBus::Connection::GetSystemPrivate()
{
ODBus::Error error;
auto *c = dbus_bus_get_private(DBUS_BUS_SYSTEM, error);
error.CheckThrow("DBus connection error");
return Connection(c);
}
ODBus::Connection
ODBus::Connection::Open(const char *address)
{
ODBus::Error error;
......
......@@ -69,6 +69,7 @@ public:
}
static Connection GetSystem();
static Connection GetSystemPrivate();
static Connection Open(const char *address);
operator DBusConnection *() noexcept {
......@@ -78,6 +79,10 @@ public:
operator bool() const noexcept {
return c != nullptr;
}
void Close() noexcept {
dbus_connection_close(c);
}
};
} /* namespace ODBus */
......
......@@ -25,7 +25,7 @@ namespace ODBus {
void
Glue::Connect()
{
watch.SetConnection(Connection::GetSystem());
watch.SetConnection(Connection::GetSystemPrivate());
dbus_connection_set_exit_on_disconnect(GetConnection(), false);
}
......@@ -33,6 +33,8 @@ Glue::Connect()
void
Glue::Disconnect()
{
GetConnection().Close();
watch.SetConnection(Connection());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment