linux: Make system D-Bus connection available (in addition to session).

This commit is contained in:
Ryan C. Gordon 2017-05-28 07:08:10 -04:00
parent e5918acf46
commit 191f578b57
2 changed files with 14 additions and 6 deletions

View File

@ -112,14 +112,15 @@ SDL_DBus_Init(void)
DBusError err;
dbus.error_init(&err);
dbus.session_conn = dbus.bus_get_private(DBUS_BUS_SESSION, &err);
if (!dbus.error_is_set(&err)) {
dbus.system_conn = dbus.bus_get_private(DBUS_BUS_SYSTEM, &err);
}
if (dbus.error_is_set(&err)) {
dbus.error_free(&err);
if (dbus.session_conn) {
dbus.connection_unref(dbus.session_conn);
dbus.session_conn = NULL;
}
SDL_DBus_Quit();
return; /* oh well */
}
dbus.connection_set_exit_on_disconnect(dbus.system_conn, 0);
dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0);
}
}
@ -127,12 +128,18 @@ SDL_DBus_Init(void)
void
SDL_DBus_Quit(void)
{
if (dbus.system_conn) {
dbus.connection_close(dbus.system_conn);
dbus.connection_unref(dbus.system_conn);
}
if (dbus.session_conn) {
dbus.connection_close(dbus.session_conn);
dbus.connection_unref(dbus.session_conn);
dbus.shutdown();
SDL_memset(&dbus, 0, sizeof(dbus));
}
if (dbus.shutdown) {
dbus.shutdown();
}
SDL_zero(dbus);
UnloadDBUSLibrary();
}

View File

@ -32,6 +32,7 @@
typedef struct SDL_DBusContext {
DBusConnection *session_conn;
DBusConnection *system_conn;
DBusConnection *(*bus_get_private)(DBusBusType, DBusError *);
dbus_bool_t (*bus_register)(DBusConnection *, DBusError *);