chiark / gitweb /
fileio: fix MIN/MAX mixup (#3896)
[elogind.git] / src / login / logind-user.h
1 #pragma once
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2011 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 typedef struct User User;
23
24 #include "list.h"
25 #include "logind.h"
26
27 typedef enum UserState {
28         USER_OFFLINE,    /* Not logged in at all */
29         USER_OPENING,    /* Is logging in */
30         USER_LINGERING,  /* Lingering has been enabled by the admin for this user */
31         USER_ONLINE,     /* User logged in */
32         USER_ACTIVE,     /* User logged in and has a session in the fg */
33         USER_CLOSING,    /* User logged out, but processes still remain and lingering is not enabled */
34         _USER_STATE_MAX,
35         _USER_STATE_INVALID = -1
36 } UserState;
37
38 struct User {
39         Manager *manager;
40         uid_t uid;
41         gid_t gid;
42         char *name;
43         char *state_file;
44         char *runtime_path;
45         char *slice;
46         char *service;
47
48 #if 0 /// UNNEEDED by elogind
49         char *service_job;
50         char *slice_job;
51 #endif // 0
52
53         Session *display;
54
55         dual_timestamp timestamp;
56
57         bool in_gc_queue:1;
58         bool started:1;
59         bool stopping:1;
60
61         LIST_HEAD(Session, sessions);
62         LIST_FIELDS(User, gc_queue);
63 };
64
65 int user_new(User **out, Manager *m, uid_t uid, gid_t gid, const char *name);
66 User *user_free(User *u);
67
68 DEFINE_TRIVIAL_CLEANUP_FUNC(User *, user_free);
69
70 bool user_check_gc(User *u, bool drop_not_started);
71 void user_add_to_gc_queue(User *u);
72 int user_start(User *u);
73 int user_stop(User *u, bool force);
74 int user_finalize(User *u);
75 UserState user_get_state(User *u);
76 int user_get_idle_hint(User *u, dual_timestamp *t);
77 int user_save(User *u);
78 int user_load(User *u);
79 int user_kill(User *u, int signo);
80 int user_check_linger_file(User *u);
81 void user_elect_display(User *u);
82
83 extern const sd_bus_vtable user_vtable[];
84 int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error);
85 int user_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
86 char *user_bus_path(User *s);
87
88 int user_send_signal(User *u, bool new_user);
89 int user_send_changed(User *u, const char *properties, ...) _sentinel_;
90
91 const char* user_state_to_string(UserState s) _const_;
92 UserState user_state_from_string(const char *s) _pure_;
93
94 int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error);
95 int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error);