summaryrefslogtreecommitdiff
path: root/src/logind-session-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-06-21 20:43:34 +0200
committerLennart Poettering <lennart@poettering.net>2011-06-21 20:43:34 +0200
commitda11939561b1e6eeb1131b68dbf43042fd633a05 (patch)
tree56b654d78e646a0de6a0db4656da9b758e49258c /src/logind-session-dbus.c
parente1c9c2d53606f987110b4215cf08c236af637ff1 (diff)
logind: send dbus signals when sessions/users/seats come and go
Diffstat (limited to 'src/logind-session-dbus.c')
-rw-r--r--src/logind-session-dbus.c37
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;
+}