chiark / gitweb /
logind: implement delay inhibitor locks in addition to block inhibitor locks
[elogind.git] / src / login / logind.h
index a4b460267589b5ddcc81dab4f00dbe3b2b8d4813..2c0545206d628f831f8b222b34e2f7f6919ddd75 100644 (file)
@@ -9,16 +9,16 @@
   Copyright 2011 Lennart Poettering
 
   systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
   (at your option) any later version.
 
   systemd is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
+  Lesser General Public License for more details.
 
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
@@ -28,6 +28,7 @@
 #include <libudev.h>
 
 #include "util.h"
+#include "audit.h"
 #include "list.h"
 #include "hashmap.h"
 #include "cgroup-util.h"
@@ -38,6 +39,7 @@ typedef struct Manager Manager;
 #include "logind-seat.h"
 #include "logind-session.h"
 #include "logind-user.h"
+#include "logind-inhibit.h"
 
 struct Manager {
         DBusConnection *bus;
@@ -46,6 +48,7 @@ struct Manager {
         Hashmap *seats;
         Hashmap *sessions;
         Hashmap *users;
+        Hashmap *inhibitors;
 
         LIST_HEAD(Seat, seat_gc_queue);
         LIST_HEAD(Session, session_gc_queue);
@@ -73,9 +76,19 @@ struct Manager {
         bool kill_user_processes;
 
         unsigned long session_counter;
+        unsigned long inhibit_counter;
 
         Hashmap *cgroups;
-        Hashmap *fifo_fds;
+        Hashmap *session_fds;
+        Hashmap *inhibitor_fds;
+
+        /* If a shutdown was delayed due to a inhibitor this contains
+           the unit name we are supposed to start after the delay is
+           over */
+        const char *delayed_shutdown;
+        usec_t delayed_shutdown_timestamp;
+
+        usec_t inhibit_delay_max;
 };
 
 enum {
@@ -95,6 +108,7 @@ int manager_add_session(Manager *m, User *u, const char *id, Session **_session)
 int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
 int manager_add_user_by_name(Manager *m, const char *name, User **_user);
 int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
+int manager_add_inhibitor(Manager *m, const char* id, Inhibitor **_inhibitor);
 
 int manager_process_seat_device(Manager *m, struct udev_device *d);
 int manager_dispatch_seat_udev(Manager *m);
@@ -105,6 +119,7 @@ int manager_enumerate_devices(Manager *m);
 int manager_enumerate_seats(Manager *m);
 int manager_enumerate_sessions(Manager *m);
 int manager_enumerate_users(Manager *m);
+int manager_enumerate_inhibitors(Manager *m);
 
 int manager_startup(Manager *m);
 int manager_run(Manager *m);
@@ -125,6 +140,8 @@ DBusHandlerResult bus_message_filter(DBusConnection *c, DBusMessage *message, vo
 
 int manager_send_changed(Manager *manager, const char *properties);
 
+int manager_dispatch_delayed_shutdown(Manager *manager);
+
 /* gperf lookup function */
 const struct ConfigPerfItem* logind_gperf_lookup(const char *key, unsigned length);