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