chiark / gitweb /
logind: expose linger state on User object
authorLennart Poettering <lennart@poettering.net>
Tue, 5 Nov 2013 00:27:27 +0000 (01:27 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 5 Nov 2013 00:27:27 +0000 (01:27 +0100)
src/login/logind-user-dbus.c
src/login/logind-user.c
src/login/logind-user.h

index fc71fcf..dbd617f 100644 (file)
@@ -151,6 +151,27 @@ static int property_get_idle_since_hint(
         return sd_bus_message_append(reply, "t", k);
 }
 
+static int property_get_linger(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *reply,
+                sd_bus_error *error,
+                void *userdata) {
+
+        User *u = userdata;
+        int r;
+
+        assert(bus);
+        assert(reply);
+        assert(u);
+
+        r = user_check_linger_file(u);
+
+        return sd_bus_message_append(reply, "b", r > 0);
+}
+
 static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata) {
         User *u = userdata;
         int r;
@@ -206,6 +227,7 @@ const sd_bus_vtable user_vtable[] = {
         SD_BUS_PROPERTY("IdleHint", "b", property_get_idle_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
         SD_BUS_PROPERTY("IdleSinceHint", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
         SD_BUS_PROPERTY("IdleSinceHintMonotonic", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+        SD_BUS_PROPERTY("Linger", "b", property_get_linger, 0, 0),
 
         SD_BUS_METHOD("Terminate", NULL, NULL, method_terminate, 0),
         SD_BUS_METHOD("Kill", "i", NULL, method_kill, 0),
index bfbdfaf..6ba8d98 100644 (file)
@@ -587,7 +587,7 @@ int user_get_idle_hint(User *u, dual_timestamp *t) {
         return idle_hint;
 }
 
-static int user_check_linger_file(User *u) {
+int user_check_linger_file(User *u) {
         _cleanup_free_ char *cc = NULL;
         char *p = NULL;
 
index de7ba6d..8d396c6 100644 (file)
@@ -79,6 +79,7 @@ int user_get_idle_hint(User *u, dual_timestamp *t);
 int user_save(User *u);
 int user_load(User *u);
 int user_kill(User *u, int signo);
+int user_check_linger_file(User *u);
 
 extern const sd_bus_vtable user_vtable[];
 int user_node_enumerator(sd_bus *bus, const char *path, char ***nodes, void *userdata);