diff options
author | Scott Anderson <scott@anderso.nz> | 2019-11-03 13:35:28 +1300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-11-03 10:13:47 +0100 |
commit | 626c98d754253de10a7db0482e44459c7f75a85d (patch) | |
tree | fa7ed7583ed5594ef3d9c20b59238b85beb697eb | |
parent | 3ebf079a9a120a27fc1008a62e7f99d5d166b745 (diff) |
session/logind: Clean up add_signal_matches
The original signal matching was using the old interface before
sd_bus_match_signal was added, which the new code uses.
Change them all to use it now.
-rw-r--r-- | backend/session/logind.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/backend/session/logind.c b/backend/session/logind.c index 852b6ae5..9b7b9650 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -558,48 +558,45 @@ error: } static bool add_signal_matches(struct logind_session *session) { + static const char *logind = "org.freedesktop.login1"; + static const char *logind_path = "/org/freedesktop/login1"; + static const char *manager_interface = "org.freedesktop.login1.Manager"; + static const char *session_interface = "org.freedesktop.login1.Session"; + static const char *property_interface = "org.freedesktop.DBus.Properties"; int ret; - char str[256]; - const char fmt[] = "type='signal'," - "sender='org.freedesktop.login1'," - "interface='org.freedesktop.login1.%s'," - "member='%s'," - "path='%s'"; - - snprintf(str, sizeof(str), fmt, "Manager", "SessionRemoved", - "/org/freedesktop/login1"); - ret = sd_bus_add_match(session->bus, NULL, str, session_removed, session); + ret = sd_bus_match_signal(session->bus, NULL, logind, logind_path, + manager_interface, "SessionRemoved", session_removed, session); if (ret < 0) { wlr_log(WLR_ERROR, "Failed to add D-Bus match: %s", strerror(-ret)); return false; } - snprintf(str, sizeof(str), fmt, "Session", "PauseDevice", session->path); - ret = sd_bus_add_match(session->bus, NULL, str, pause_device, session); + ret = sd_bus_match_signal(session->bus, NULL, logind, session->path, + session_interface, "PauseDevice", pause_device, session); if (ret < 0) { wlr_log(WLR_ERROR, "Failed to add D-Bus match: %s", strerror(-ret)); return false; } - snprintf(str, sizeof(str), fmt, "Session", "ResumeDevice", session->path); - ret = sd_bus_add_match(session->bus, NULL, str, resume_device, session); + ret = sd_bus_match_signal(session->bus, NULL, logind, session->path, + session_interface, "ResumeDevice", resume_device, session); if (ret < 0) { wlr_log(WLR_ERROR, "Failed to add D-Bus match: %s", strerror(-ret)); return false; } - ret = sd_bus_match_signal(session->bus, NULL, "org.freedesktop.login1", - session->path, "org.freedesktop.DBus.Properties", "PropertiesChanged", + ret = sd_bus_match_signal(session->bus, NULL, logind, session->path, + property_interface, "PropertiesChanged", session_properties_changed, session); if (ret < 0) { wlr_log(WLR_ERROR, "Failed to add D-Bus match: %s", strerror(-ret)); return false; } - ret = sd_bus_match_signal(session->bus, NULL, "org.freedesktop.login1", - session->seat_path, "org.freedesktop.DBus.Properties", - "PropertiesChanged", seat_properties_changed, session); + ret = sd_bus_match_signal(session->bus, NULL, logind, session->seat_path, + property_interface, "PropertiesChanged", + seat_properties_changed, session); if (ret < 0) { wlr_log(WLR_ERROR, "Failed to add D-Bus match: %s", strerror(-ret)); return false; |