summaryrefslogtreecommitdiff
path: root/src/logind-user-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-user-dbus.c
parente1c9c2d53606f987110b4215cf08c236af637ff1 (diff)
logind: send dbus signals when sessions/users/seats come and go
Diffstat (limited to 'src/logind-user-dbus.c')
-rw-r--r--src/logind-user-dbus.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/logind-user-dbus.c b/src/logind-user-dbus.c
index 3be2c05d26..c8d47de0e7 100644
--- a/src/logind-user-dbus.c
+++ b/src/logind-user-dbus.c
@@ -313,3 +313,43 @@ char *user_bus_path(User *u) {
return s;
}
+
+int user_send_signal(User *u, bool new_user) {
+ DBusMessage *m;
+ int r = -ENOMEM;
+ char *p = NULL;
+ uint32_t uid;
+
+ assert(u);
+
+ m = dbus_message_new_signal("/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ new_user ? "UserNew" : "UserRemoved");
+
+ if (!m)
+ return -ENOMEM;
+
+ p = user_bus_path(u);
+ if (!p)
+ goto finish;
+
+ uid = u->uid;
+
+ if (!dbus_message_append_args(
+ m,
+ DBUS_TYPE_UINT32, &uid,
+ DBUS_TYPE_OBJECT_PATH, &p,
+ DBUS_TYPE_INVALID))
+ goto finish;
+
+ if (!dbus_connection_send(u->manager->bus, m, NULL))
+ goto finish;
+
+ r = 0;
+
+finish:
+ dbus_message_unref(m);
+ free(p);
+
+ return r;
+}