Browse Source

Use defines for dbus name, path, interface

That gives some meaning to the strings and makes it easier to see
what the arguments of sd_bus_call_method mean without checking the
function docs.
Christian Kellner 5 years ago
parent
commit
536d687c9a
1 changed files with 8 additions and 3 deletions
  1. 8 3
      lib/client_impl.c

+ 8 - 3
lib/client_impl.c

@@ -39,6 +39,11 @@ POSSIBILITY OF SUCH DAMAGE.
 #include <systemd/sd-bus.h>
 #include <unistd.h>
 
+// D-Bus name, path, iface
+#define DAEMON_DBUS_NAME "com.feralinteractive.GameMode"
+#define DAEMON_DBUS_PATH "/com/feralinteractive/GameMode"
+#define DAEMON_DBUS_IFACE "com.feralinteractive.GameMode"
+
 // Storage for error strings
 static char error_string[512] = { 0 };
 
@@ -62,9 +67,9 @@ static int gamemode_request(const char *function, int arg)
 	} else {
 		// Attempt to send the requested function
 		ret = sd_bus_call_method(bus,
-		                         "com.feralinteractive.GameMode",
-		                         "/com/feralinteractive/GameMode",
-		                         "com.feralinteractive.GameMode",
+		                         DAEMON_DBUS_NAME,
+		                         DAEMON_DBUS_PATH,
+		                         DAEMON_DBUS_IFACE,
 		                         function,
 		                         &err,
 		                         &msg,