diff options
Diffstat (limited to 'src/logind-session-dbus.c')
-rw-r--r-- | src/logind-session-dbus.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/logind-session-dbus.c b/src/logind-session-dbus.c index 6bded6a454..edc96dd644 100644 --- a/src/logind-session-dbus.c +++ b/src/logind-session-dbus.c @@ -382,3 +382,40 @@ char *session_bus_path(Session *s) { return r; } + +int session_send_signal(Session *s, bool new_session) { + DBusMessage *m; + int r = -ENOMEM; + char *p = NULL; + + assert(s); + + m = dbus_message_new_signal("/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + new_session ? "SessionNew" : "SessionRemoved"); + + if (!m) + return -ENOMEM; + + p = session_bus_path(s); + if (!p) + goto finish; + + if (!dbus_message_append_args( + m, + DBUS_TYPE_STRING, &s->id, + DBUS_TYPE_OBJECT_PATH, &p, + DBUS_TYPE_INVALID)) + goto finish; + + if (!dbus_connection_send(s->manager->bus, m, NULL)) + goto finish; + + r = 0; + +finish: + dbus_message_unref(m); + free(p); + + return r; +} |