From 5e4a79da3ac3859c2a1295e019b95a1e5589b9c1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 29 Jun 2012 19:38:35 +0200 Subject: [PATCH] logind: add PreparingForShutdown/PreparingForSleep properties --- TODO | 4 +--- src/login/logind-dbus.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index d816bf92b..4b7dad95e 100644 --- a/TODO +++ b/TODO @@ -36,9 +36,7 @@ Features: - Update Syslog Interface docs - Journal C API manual pages -* logind: export a bool property that tells user whether a - suspend/shutdown is currently scheduled, i.e. where are between - PrepareForSuspend(true) and PrepareForSuspend(false) +* wiki: document logind's PreparingForShutdown, PreparingForSleep * support debian's console-setup logic diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 3cde83166..a2ead8609 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -209,6 +209,8 @@ " \n" \ " \n" \ " \n" \ + " \n" \ + " \n" \ " \n" #define INTROSPECTION_BEGIN \ @@ -273,6 +275,22 @@ static int bus_manager_append_inhibited(DBusMessageIter *i, const char *property return 0; } +static int bus_manager_append_preparing(DBusMessageIter *i, const char *property, void *data) { + Manager *m = data; + dbus_bool_t b; + + assert(i); + assert(property); + + if (streq(property, "PreparingForShutdown")) + b = !!(m->delayed_what & INHIBIT_SHUTDOWN); + else + b = !!(m->delayed_what & INHIBIT_SLEEP); + + dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b); + return 0; +} + static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMessage **_reply) { Session *session = NULL; User *user = NULL; @@ -1266,6 +1284,8 @@ static const BusProperty bus_login_manager_properties[] = { { "HandlePowerKey", bus_manager_append_handle_button, "s", offsetof(Manager, handle_power_key) }, { "HandleSleepKey", bus_manager_append_handle_button, "s", offsetof(Manager, handle_sleep_key) }, { "HandleLidSwitch", bus_manager_append_handle_button, "s", offsetof(Manager, handle_lid_switch) }, + { "PreparingForShutdown", bus_manager_append_preparing, "b", 0 }, + { "PreparingForSleep", bus_manager_append_preparing, "b", 0 }, { NULL, } }; -- 2.30.2