[systemd-commits] src/login

Lennart Poettering lennart at kemper.freedesktop.org
Tue Nov 5 01:28:09 CET 2013


 src/login/logind-user-dbus.c |   22 ++++++++++++++++++++++
 src/login/logind-user.c      |    2 +-
 src/login/logind-user.h      |    1 +
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 3a9f7a30ce89b44097731310221802f6d72ea752
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Nov 5 01:27:27 2013 +0100

    logind: expose linger state on User object

diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index fc71fcf..dbd617f 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -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),
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index bfbdfaf..6ba8d98 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -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;
 
diff --git a/src/login/logind-user.h b/src/login/logind-user.h
index de7ba6d..8d396c6 100644
--- a/src/login/logind-user.h
+++ b/src/login/logind-user.h
@@ -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);



More information about the systemd-commits mailing list