Explorar o código

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.
Georges Basile Stavracas Neto %!s(int64=4) %!d(string=hai) anos
pai
achega
7f27963caa
Modificáronse 1 ficheiros con 9 adicións e 5 borrados
  1. 9 5
      libobs/util/platform-nix-dbus.c

+ 9 - 5
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,