1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include "conf-parser.h"
5 
6 typedef enum HandleAction {
7         HANDLE_IGNORE,
8         HANDLE_POWEROFF,
9         HANDLE_REBOOT,
10         HANDLE_HALT,
11         HANDLE_KEXEC,
12         HANDLE_SUSPEND,
13         HANDLE_HIBERNATE,
14         HANDLE_HYBRID_SLEEP,
15         HANDLE_SUSPEND_THEN_HIBERNATE,
16         HANDLE_LOCK,
17         HANDLE_FACTORY_RESET,
18         _HANDLE_ACTION_MAX,
19         _HANDLE_ACTION_INVALID = -EINVAL,
20 } HandleAction;
21 
22 typedef struct HandleActionData HandleActionData;
23 
24 #include "logind-inhibit.h"
25 #include "logind.h"
26 #include "sleep-config.h"
27 
handle_action_valid(HandleAction a)28 static inline bool handle_action_valid(HandleAction a) {
29         return a >= 0 && a < _HANDLE_ACTION_MAX;
30 }
31 
32 struct HandleActionData {
33         HandleAction handle;
34         const char *target;
35         InhibitWhat inhibit_what;
36         const char *polkit_action;
37         const char *polkit_action_multiple_sessions;
38         const char *polkit_action_ignore_inhibit;
39         SleepOperation sleep_operation;
40         const char* message_id;
41         const char* message;
42         const char* log_verb;
43 };
44 
45 int manager_handle_action(
46                 Manager *m,
47                 InhibitWhat inhibit_key,
48                 HandleAction handle,
49                 bool ignore_inhibited,
50                 bool is_edge);
51 
52 const char* handle_action_to_string(HandleAction h) _const_;
53 HandleAction handle_action_from_string(const char *s) _pure_;
54 
55 const HandleActionData* handle_action_lookup(HandleAction handle);
56 
57 CONFIG_PARSER_PROTOTYPE(config_parse_handle_action);
58