]>
Commit | Line | Data |
---|---|---|
05d3a176 | 1 | #pragma once |
f8e2fb7b LP |
2 | |
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2012 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | typedef struct Inhibitor Inhibitor; | |
23 | ||
f8e2fb7b LP |
24 | |
25 | typedef enum InhibitWhat { | |
26 | INHIBIT_SHUTDOWN = 1, | |
4943c1c9 | 27 | INHIBIT_SLEEP = 2, |
f8e2fb7b | 28 | INHIBIT_IDLE = 4, |
beaafb2e | 29 | INHIBIT_HANDLE_POWER_KEY = 8, |
8e7fd6ad LP |
30 | INHIBIT_HANDLE_SUSPEND_KEY = 16, |
31 | INHIBIT_HANDLE_HIBERNATE_KEY = 32, | |
32 | INHIBIT_HANDLE_LID_SWITCH = 64, | |
33 | _INHIBIT_WHAT_MAX = 128, | |
f8e2fb7b LP |
34 | _INHIBIT_WHAT_INVALID = -1 |
35 | } InhibitWhat; | |
36 | ||
eecd1362 LP |
37 | typedef enum InhibitMode { |
38 | INHIBIT_BLOCK, | |
39 | INHIBIT_DELAY, | |
40 | _INHIBIT_MODE_MAX, | |
41 | _INHIBIT_MODE_INVALID = -1 | |
42 | } InhibitMode; | |
43 | ||
d889a206 | 44 | #include "logind.h" |
d889a206 | 45 | |
f8e2fb7b LP |
46 | struct Inhibitor { |
47 | Manager *manager; | |
48 | ||
cc377381 LP |
49 | sd_event_source *event_source; |
50 | ||
f8e2fb7b LP |
51 | char *id; |
52 | char *state_file; | |
53 | ||
54 | bool started; | |
55 | ||
56 | InhibitWhat what; | |
57 | char *who; | |
58 | char *why; | |
eecd1362 | 59 | InhibitMode mode; |
f8e2fb7b LP |
60 | |
61 | pid_t pid; | |
62 | uid_t uid; | |
63 | ||
c7b5eb98 LP |
64 | dual_timestamp since; |
65 | ||
f8e2fb7b LP |
66 | char *fifo_path; |
67 | int fifo_fd; | |
68 | }; | |
69 | ||
70 | Inhibitor* inhibitor_new(Manager *m, const char *id); | |
71 | void inhibitor_free(Inhibitor *i); | |
72 | ||
73 | int inhibitor_save(Inhibitor *i); | |
74 | int inhibitor_load(Inhibitor *i); | |
75 | ||
76 | int inhibitor_start(Inhibitor *i); | |
77 | int inhibitor_stop(Inhibitor *i); | |
78 | ||
79 | int inhibitor_create_fifo(Inhibitor *i); | |
80 | void inhibitor_remove_fifo(Inhibitor *i); | |
81 | ||
eecd1362 | 82 | InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm); |
85a428c6 | 83 | bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid, Inhibitor **offending); |
f8e2fb7b LP |
84 | |
85 | const char *inhibit_what_to_string(InhibitWhat k); | |
86 | InhibitWhat inhibit_what_from_string(const char *s); | |
87 | ||
eecd1362 LP |
88 | const char *inhibit_mode_to_string(InhibitMode k); |
89 | InhibitMode inhibit_mode_from_string(const char *s); |