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