lib/dbus/Glue: use private connection
Avoid interfering with libraries also using the shared connection.
This commit is contained in:
parent
adf2d3aff2
commit
d58d65ebf0
|
@ -42,6 +42,15 @@ ODBus::Connection::GetSystem()
|
|||
return Connection(c);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue