From 7f27963caa59f2fae2e823b400ddb018743a20de Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 17 Feb 2021 19:31:18 -0300 Subject: [PATCH] libobs/util: Split bus name from interface When calling D-Bus methods, three fields are required: * The bus name, which is what applications own when they want to expose themselves to D-Bus; * The object path, which represents a D-Bus object exported under a bus name; * The interface, which holds the methods and signals; While out of pure coincidence all the D-Bus buses have a matching interface name, it is technically incorrect to assume that. Add a new 'interface' field to service_info, and split the bus name. --- libobs/util/platform-nix-dbus.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libobs/util/platform-nix-dbus.c b/libobs/util/platform-nix-dbus.c index 0b4734ad4..8773d70e4 100644 --- a/libobs/util/platform-nix-dbus.c +++ b/libobs/util/platform-nix-dbus.c @@ -31,6 +31,7 @@ enum service_type { struct service_info { const char *name; const char *path; + const char *interface; const char *uninhibit; }; @@ -39,24 +40,28 @@ static const struct service_info services[] = { { .name = "org.freedesktop.ScreenSaver", .path = "/ScreenSaver", + .interface = "org.freedesktop.ScreenSaver", .uninhibit = "UnInhibit", }, [FREEDESKTOP_PM] = { .name = "org.freedesktop.PowerManagement.Inhibit", .path = "/org/freedesktop/PowerManagement", + .interface = "org.freedesktop.PowerManagement.Inhibit", .uninhibit = "UnInhibit", }, [MATE_SM] = { .name = "org.mate.SessionManager", .path = "/org/mate/SessionManager", + .interface = "org.mate.SessionManager", .uninhibit = "Uninhibit", }, [GNOME_SM] = { .name = "org.gnome.SessionManager", .path = "/org/gnome/SessionManager", + .interface = "org.gnome.SessionManager", .uninhibit = "Uninhibit", }, }; @@ -153,11 +158,10 @@ void dbus_inhibit_sleep(struct dbus_sleep_info *info, const char *reason, params = g_variant_new("(u)", info->cookie); } - reply = g_dbus_connection_call_sync(info->c, info->service->name, - info->service->path, - info->service->name, method, params, - NULL, G_DBUS_CALL_FLAGS_NONE, -1, - NULL, &error); + reply = g_dbus_connection_call_sync( + info->c, info->service->name, info->service->path, + info->service->interface, method, params, NULL, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error != NULL) { blog(LOG_ERROR, "Failed to call %s: %s", method,