chiark / gitweb /
logind: remove some unused labels
[elogind.git] / src / logind.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foologindhfoo
4 #define foologindhfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2011 Lennart Poettering
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 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   General Public License for more details.
20
21   You should have received a copy of the GNU General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <stdbool.h>
26 #include <inttypes.h>
27 #include <dbus/dbus.h>
28 #include <libudev.h>
29
30 #include "util.h"
31 #include "list.h"
32 #include "hashmap.h"
33 #include "cgroup-util.h"
34
35 /* TODO:
36  *
37  * spawn user systemd
38  * direct client API
39  *
40  * udev:
41  * drop redundant udev_device_get_is_initialized() use as soon as libudev is fixed
42  * use device_has_tag() as soon as it is available
43  * enumerate recursively with libudev when triggering
44  * use sysfs in device hash table, not sysname, when fb driver is fixed
45  *
46  * non-local X11 server
47  * reboot/shutdown halt management
48  */
49
50 typedef struct Manager Manager;
51
52 #include "logind-device.h"
53 #include "logind-seat.h"
54 #include "logind-session.h"
55 #include "logind-user.h"
56
57 struct Manager {
58         DBusConnection *bus;
59
60         Hashmap *devices;
61         Hashmap *seats;
62         Hashmap *sessions;
63         Hashmap *users;
64
65         LIST_HEAD(Seat, seat_gc_queue);
66         LIST_HEAD(Session, session_gc_queue);
67         LIST_HEAD(User, user_gc_queue);
68
69         struct udev *udev;
70         struct udev_monitor *udev_seat_monitor, *udev_vcsa_monitor;
71
72         int udev_seat_fd;
73         int udev_vcsa_fd;
74
75         int console_active_fd;
76         int bus_fd;
77         int epoll_fd;
78
79         unsigned n_autovts;
80
81         Seat *vtconsole;
82
83         char *cgroup_path;
84         char **controllers, **reset_controllers;
85
86         char **kill_only_users, **kill_exclude_users;
87
88         bool kill_user_processes;
89
90         unsigned long session_counter;
91
92         Hashmap *cgroups;
93         Hashmap *fifo_fds;
94 };
95
96 enum {
97         FD_SEAT_UDEV,
98         FD_VCSA_UDEV,
99         FD_CONSOLE,
100         FD_BUS,
101         FD_FIFO_BASE
102 };
103
104 Manager *manager_new(void);
105 void manager_free(Manager *m);
106
107 int manager_add_device(Manager *m, const char *sysfs, Device **_device);
108 int manager_add_seat(Manager *m, const char *id, Seat **_seat);
109 int manager_add_session(Manager *m, User *u, const char *id, Session **_session);
110 int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
111 int manager_add_user_by_name(Manager *m, const char *name, User **_user);
112 int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
113
114 int manager_process_seat_device(Manager *m, struct udev_device *d);
115 int manager_dispatch_seat_udev(Manager *m);
116 int manager_dispatch_vcsa_udev(Manager *m);
117 int manager_dispatch_console(Manager *m);
118
119 int manager_enumerate_devices(Manager *m);
120 int manager_enumerate_seats(Manager *m);
121 int manager_enumerate_sessions(Manager *m);
122 int manager_enumerate_users(Manager *m);
123
124 int manager_startup(Manager *m);
125 int manager_run(Manager *m);
126 int manager_spawn_autovt(Manager *m, int vtnr);
127
128 void manager_cgroup_notify_empty(Manager *m, const char *cgroup);
129
130 void manager_gc(Manager *m, bool drop_not_started);
131
132 int manager_get_idle_hint(Manager *m, dual_timestamp *t);
133
134 extern const DBusObjectPathVTable bus_manager_vtable;
135
136 DBusHandlerResult bus_message_filter(DBusConnection *c, DBusMessage *message, void *userdata);
137
138 int manager_send_changed(Manager *manager, const char *properties);
139
140 #endif