]> git.proxmox.com Git - systemd.git/blame - src/login/logind-inhibit.h
Imported Upstream version 220
[systemd.git] / src / login / logind-inhibit.h
CommitLineData
663996b3
MS
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
60f067b4 3#pragma once
663996b3
MS
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
663996b3
MS
26
27typedef enum InhibitWhat {
28 INHIBIT_SHUTDOWN = 1,
29 INHIBIT_SLEEP = 2,
30 INHIBIT_IDLE = 4,
31 INHIBIT_HANDLE_POWER_KEY = 8,
32 INHIBIT_HANDLE_SUSPEND_KEY = 16,
33 INHIBIT_HANDLE_HIBERNATE_KEY = 32,
34 INHIBIT_HANDLE_LID_SWITCH = 64,
35 _INHIBIT_WHAT_MAX = 128,
36 _INHIBIT_WHAT_INVALID = -1
37} InhibitWhat;
38
39typedef enum InhibitMode {
40 INHIBIT_BLOCK,
41 INHIBIT_DELAY,
42 _INHIBIT_MODE_MAX,
43 _INHIBIT_MODE_INVALID = -1
44} InhibitMode;
45
46#include "logind.h"
663996b3
MS
47
48struct Inhibitor {
49 Manager *manager;
50
60f067b4
JS
51 sd_event_source *event_source;
52
663996b3
MS
53 char *id;
54 char *state_file;
55
56 bool started;
57
58 InhibitWhat what;
59 char *who;
60 char *why;
61 InhibitMode mode;
62
63 pid_t pid;
64 uid_t uid;
65
66 dual_timestamp since;
67
68 char *fifo_path;
69 int fifo_fd;
70};
71
72Inhibitor* inhibitor_new(Manager *m, const char *id);
73void inhibitor_free(Inhibitor *i);
74
75int inhibitor_save(Inhibitor *i);
76int inhibitor_load(Inhibitor *i);
77
78int inhibitor_start(Inhibitor *i);
79int inhibitor_stop(Inhibitor *i);
80
81int inhibitor_create_fifo(Inhibitor *i);
82void inhibitor_remove_fifo(Inhibitor *i);
83
84InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm);
60f067b4 85bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid, Inhibitor **offending);
663996b3
MS
86
87const char *inhibit_what_to_string(InhibitWhat k);
88InhibitWhat inhibit_what_from_string(const char *s);
89
90const char *inhibit_mode_to_string(InhibitMode k);
91InhibitMode inhibit_mode_from_string(const char *s);