chiark / gitweb /
logind: add PreparingForShutdown/PreparingForSleep properties
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Jun 2012 17:38:35 +0000 (19:38 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 29 Jun 2012 17:38:35 +0000 (19:38 +0200)
TODO
src/login/logind-dbus.c

diff --git a/TODO b/TODO
index d816bf92bba32bb0ec53a08242c3cb9da847ce29..4b7dad95eddfe86bd5b8d5160d05b7f97742fce4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -36,9 +36,7 @@ Features:
         - Update Syslog Interface docs
         - Journal C API manual pages
 
         - 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
 
 
 * support debian's console-setup logic
 
index 3cde83166f21208424f87fa1fd8e43255e8c441c..a2ead8609bd1158e62dd81f88d20e56ec052e296 100644 (file)
         "  <property name=\"HandlePowerKey\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"HandleSleepKey\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"HandleLidSwitch\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"HandlePowerKey\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"HandleSleepKey\" type=\"s\" access=\"read\"/>\n" \
         "  <property name=\"HandleLidSwitch\" type=\"s\" access=\"read\"/>\n" \
+        "  <property name=\"PreparingForShutdown\" type=\"b\" access=\"read\"/>\n" \
+        "  <property name=\"PreparingForSleep\" type=\"b\" access=\"read\"/>\n" \
         " </interface>\n"
 
 #define INTROSPECTION_BEGIN                                             \
         " </interface>\n"
 
 #define INTROSPECTION_BEGIN                                             \
@@ -273,6 +275,22 @@ static int bus_manager_append_inhibited(DBusMessageIter *i, const char *property
         return 0;
 }
 
         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;
 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)   },
         { "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, }
 };
 
         { NULL, }
 };