chiark / gitweb /
Prep v239: Add support for the new 'suspend-then-hibernate' method.
[elogind.git] / src / login / logind.h
index 41b48ef74b8b29fb9704feaf5683f7915ef0356b..3f17d5d6d9a6dc2025495e709ed2673052a21a6f 100644 (file)
@@ -1,24 +1,6 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-/***
-  This file is part of systemd.
-
-  Copyright 2011 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
 #include <stdbool.h>
 
 #if 0 /// elogind needs the systems udev header
@@ -29,7 +11,7 @@
 #include "sd-bus.h"
 #include "sd-event.h"
 
-#include "cgroup-util.h"
+//#include "conf-parser.h"
 #include "hashmap.h"
 #include "list.h"
 #include "set.h"
@@ -40,8 +22,14 @@ typedef struct Manager Manager;
 #include "logind-button.h"
 #include "logind-device.h"
 #include "logind-inhibit.h"
-#include "logind-sleep.h"
 
+/// Additional includes needed by elogind
+#include "cgroup-util.h"
+
+#if 1 /// elogind has to ident itself
+#define MANAGER_IS_SYSTEM(m) ((m)->is_system)
+#define MANAGER_IS_USER(m) (!((m)->is_system))
+#endif // 1
 struct Manager {
         sd_event *event;
         sd_bus *bus;
@@ -78,8 +66,13 @@ struct Manager {
          * file system */
         int pin_cgroupfs_fd;
 
+        /* fd for handling cgroup socket if elogind is its own cgroups manager */
+        int cgroups_agent_fd;
+        sd_event_source *cgroups_agent_event_source;
+
         /* Flags */
-        bool test_run:1;
+        unsigned test_run_flags;
+        bool is_system:1; /* true if elogind is its own cgroups manager */
 
         /* Data specific to the cgroup subsystem */
         CGroupMask cgroup_supported;
@@ -123,7 +116,7 @@ struct Manager {
         char **suspend_state,      **suspend_mode;
         char **hibernate_state,    **hibernate_mode;
         char **hybrid_sleep_state, **hybrid_sleep_mode;
-
+        usec_t hibernate_delay_sec;
 #endif // 0
         sd_event_source *inhibit_timeout_source;
 
@@ -150,6 +143,7 @@ struct Manager {
         HandleAction handle_suspend_key;
         HandleAction handle_hibernate_key;
         HandleAction handle_lid_switch;
+        HandleAction handle_lid_switch_ep;
         HandleAction handle_lid_switch_docked;
 
         bool power_key_ignore_inhibited;
@@ -164,12 +158,15 @@ struct Manager {
         usec_t holdoff_timeout_usec;
         sd_event_source *lid_switch_ignore_event_source;
 
-        size_t runtime_dir_size;
+        uint64_t runtime_dir_size;
         uint64_t user_tasks_max;
         uint64_t sessions_max;
         uint64_t inhibitors_max;
 };
 
+void manager_reset_config(Manager *m);
+int manager_parse_config_file(Manager *m);
+
 int manager_add_device(Manager *m, const char *sysfs, bool master, Device **_device);
 int manager_add_button(Manager *m, const char *name, Button **_button);
 int manager_add_seat(Manager *m, const char *id, Seat **_seat);
@@ -194,6 +191,8 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **user);
 int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session);
 
 bool manager_is_docked_or_external_displays(Manager *m);
+bool manager_is_on_external_power(void);
+bool manager_all_buttons_ignored(Manager *m);
 
 extern const sd_bus_vtable manager_vtable[];
 
@@ -213,8 +212,7 @@ int bus_manager_shutdown_or_sleep_now_or_later(Manager *m, HandleAction action,
 int manager_send_changed(Manager *manager, const char *property, ...) _sentinel_;
 
 #if 0 /// UNNEEDED by elogind
-int manager_start_slice(Manager *manager, const char *slice, const char *description, const char *after, const char *after2, uint64_t tasks_max, sd_bus_error *error, char **job);
-int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, const char *after2, uint64_t tasks_max, sd_bus_error *error, char **job);
+int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, const char *after2, sd_bus_message *more_properties, sd_bus_error *error, char **job);
 int manager_start_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
 int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job);
 int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *error);
@@ -228,8 +226,8 @@ const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE
 
 int manager_set_lid_switch_ignore(Manager *m, usec_t until);
 
-int config_parse_tmpfs_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int config_parse_user_tasks_max(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+CONFIG_PARSER_PROTOTYPE(config_parse_n_autovts);
+CONFIG_PARSER_PROTOTYPE(config_parse_tmpfs_size);
 
 int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret);
 int manager_get_user_from_creds(Manager *m, sd_bus_message *message, uid_t uid, sd_bus_error *error, User **ret);