2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2013-11-18 16:58:43 +01:00
|
|
|
#pragma once
|
2012-04-16 16:47:33 +02:00
|
|
|
|
|
|
|
typedef struct Inhibitor Inhibitor;
|
|
|
|
|
|
|
|
typedef enum InhibitWhat {
|
2019-01-07 17:48:28 +01:00
|
|
|
INHIBIT_SHUTDOWN = 1 << 0,
|
|
|
|
INHIBIT_SLEEP = 1 << 1,
|
|
|
|
INHIBIT_IDLE = 1 << 2,
|
|
|
|
INHIBIT_HANDLE_POWER_KEY = 1 << 3,
|
|
|
|
INHIBIT_HANDLE_SUSPEND_KEY = 1 << 4,
|
|
|
|
INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5,
|
|
|
|
INHIBIT_HANDLE_LID_SWITCH = 1 << 6,
|
2020-08-14 13:10:18 +02:00
|
|
|
INHIBIT_HANDLE_REBOOT_KEY = 1 << 7,
|
|
|
|
_INHIBIT_WHAT_MAX = 1 << 8,
|
2019-01-07 17:48:28 +01:00
|
|
|
_INHIBIT_WHAT_INVALID = -1
|
2012-04-16 16:47:33 +02:00
|
|
|
} InhibitWhat;
|
|
|
|
|
2012-05-05 00:34:48 +02:00
|
|
|
typedef enum InhibitMode {
|
|
|
|
INHIBIT_BLOCK,
|
|
|
|
INHIBIT_DELAY,
|
|
|
|
_INHIBIT_MODE_MAX,
|
|
|
|
_INHIBIT_MODE_INVALID = -1
|
|
|
|
} InhibitMode;
|
|
|
|
|
2012-05-08 19:02:25 +02:00
|
|
|
#include "logind.h"
|
|
|
|
|
2012-04-16 16:47:33 +02:00
|
|
|
struct Inhibitor {
|
|
|
|
Manager *manager;
|
|
|
|
|
2013-11-05 01:10:21 +01:00
|
|
|
sd_event_source *event_source;
|
|
|
|
|
2019-07-23 12:40:52 +02:00
|
|
|
const char *id;
|
2012-04-16 16:47:33 +02:00
|
|
|
char *state_file;
|
|
|
|
|
|
|
|
bool started;
|
|
|
|
|
|
|
|
InhibitWhat what;
|
|
|
|
char *who;
|
|
|
|
char *why;
|
2012-05-05 00:34:48 +02:00
|
|
|
InhibitMode mode;
|
2012-04-16 16:47:33 +02:00
|
|
|
|
|
|
|
pid_t pid;
|
|
|
|
uid_t uid;
|
|
|
|
|
2012-04-16 17:05:15 +02:00
|
|
|
dual_timestamp since;
|
|
|
|
|
2012-04-16 16:47:33 +02:00
|
|
|
char *fifo_path;
|
|
|
|
int fifo_fd;
|
|
|
|
};
|
|
|
|
|
2019-07-23 10:27:19 +02:00
|
|
|
int inhibitor_new(Inhibitor **ret, Manager *m, const char* id);
|
|
|
|
Inhibitor* inhibitor_free(Inhibitor *i);
|
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Inhibitor*, inhibitor_free);
|
2012-04-16 16:47:33 +02:00
|
|
|
|
|
|
|
int inhibitor_load(Inhibitor *i);
|
|
|
|
|
|
|
|
int inhibitor_start(Inhibitor *i);
|
2019-07-23 10:32:41 +02:00
|
|
|
void inhibitor_stop(Inhibitor *i);
|
2012-04-16 16:47:33 +02:00
|
|
|
|
|
|
|
int inhibitor_create_fifo(Inhibitor *i);
|
|
|
|
|
2019-07-23 10:33:39 +02:00
|
|
|
bool inhibitor_is_orphan(Inhibitor *i);
|
|
|
|
|
2012-05-05 00:34:48 +02:00
|
|
|
InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm);
|
2013-11-27 02:38:06 +01:00
|
|
|
bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid, Inhibitor **offending);
|
2012-04-16 16:47:33 +02:00
|
|
|
|
|
|
|
const char *inhibit_what_to_string(InhibitWhat k);
|
2020-07-29 11:47:38 +02:00
|
|
|
int inhibit_what_from_string(const char *s);
|
2012-04-16 16:47:33 +02:00
|
|
|
|
2012-05-05 00:34:48 +02:00
|
|
|
const char *inhibit_mode_to_string(InhibitMode k);
|
|
|
|
InhibitMode inhibit_mode_from_string(const char *s);
|