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