chiark / gitweb /
tree-wide: drop license boilerplate
[elogind.git] / src / login / logind-inhibit.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5   This file is part of systemd.
6
7   Copyright 2012 Lennart Poettering
8 ***/
9
10 typedef struct Inhibitor Inhibitor;
11
12
13 typedef enum InhibitWhat {
14         INHIBIT_SHUTDOWN = 1,
15         INHIBIT_SLEEP = 2,
16         INHIBIT_IDLE = 4,
17         INHIBIT_HANDLE_POWER_KEY = 8,
18         INHIBIT_HANDLE_SUSPEND_KEY = 16,
19         INHIBIT_HANDLE_HIBERNATE_KEY = 32,
20         INHIBIT_HANDLE_LID_SWITCH = 64,
21         _INHIBIT_WHAT_MAX = 128,
22         _INHIBIT_WHAT_INVALID = -1
23 } InhibitWhat;
24
25 typedef enum InhibitMode {
26         INHIBIT_BLOCK,
27         INHIBIT_DELAY,
28         _INHIBIT_MODE_MAX,
29         _INHIBIT_MODE_INVALID = -1
30 } InhibitMode;
31
32 #include "logind.h"
33
34 struct Inhibitor {
35         Manager *manager;
36
37         sd_event_source *event_source;
38
39         char *id;
40         char *state_file;
41
42         bool started;
43
44         InhibitWhat what;
45         char *who;
46         char *why;
47         InhibitMode mode;
48
49         pid_t pid;
50         uid_t uid;
51
52         dual_timestamp since;
53
54         char *fifo_path;
55         int fifo_fd;
56 };
57
58 Inhibitor* inhibitor_new(Manager *m, const char *id);
59 void inhibitor_free(Inhibitor *i);
60
61 int inhibitor_save(Inhibitor *i);
62 int inhibitor_load(Inhibitor *i);
63
64 int inhibitor_start(Inhibitor *i);
65 int inhibitor_stop(Inhibitor *i);
66
67 int inhibitor_create_fifo(Inhibitor *i);
68 void inhibitor_remove_fifo(Inhibitor *i);
69
70 InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm);
71 bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid, Inhibitor **offending);
72
73 const char *inhibit_what_to_string(InhibitWhat k);
74 InhibitWhat inhibit_what_from_string(const char *s);
75
76 const char *inhibit_mode_to_string(InhibitMode k);
77 InhibitMode inhibit_mode_from_string(const char *s);