chiark / gitweb /
cdb612805f6e4111c00869d59ef51f7d091d2583
[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  * enumerate recursively with libudev when triggering
42  * use sysfs in device hash table, not sysname, when fb driver is fixed
43  *
44  * non-local X11 server
45  * reboot/shutdown halt management
46  */
47
48 typedef struct Manager Manager;
49
50 #include "logind-device.h"
51 #include "logind-seat.h"
52 #include "logind-session.h"
53 #include "logind-user.h"
54
55 struct Manager {
56         DBusConnection *bus;
57
58         Hashmap *devices;
59         Hashmap *seats;
60         Hashmap *sessions;
61         Hashmap *users;
62
63         LIST_HEAD(Seat, seat_gc_queue);
64         LIST_HEAD(Session, session_gc_queue);
65         LIST_HEAD(User, user_gc_queue);
66
67         struct udev *udev;
68         struct udev_monitor *udev_seat_monitor, *udev_vcsa_monitor;
69
70         int udev_seat_fd;
71         int udev_vcsa_fd;
72
73         int console_active_fd;
74         int bus_fd;
75         int epoll_fd;
76
77         unsigned n_autovts;
78
79         Seat *vtconsole;
80
81         char *cgroup_path;
82         char **controllers, **reset_controllers;
83
84         char **kill_only_users, **kill_exclude_users;
85
86         bool kill_user_processes;
87
88         unsigned long session_counter;
89
90         Hashmap *cgroups;
91         Hashmap *fifo_fds;
92 };
93
94 enum {
95         FD_SEAT_UDEV,
96         FD_VCSA_UDEV,
97         FD_CONSOLE,
98         FD_BUS,
99         FD_FIFO_BASE
100 };
101
102 Manager *manager_new(void);
103 void manager_free(Manager *m);
104
105 int manager_add_device(Manager *m, const char *sysfs, Device **_device);
106 int manager_add_seat(Manager *m, const char *id, Seat **_seat);
107 int manager_add_session(Manager *m, User *u, const char *id, Session **_session);
108 int manager_add_user(Manager *m, uid_t uid, gid_t gid, const char *name, User **_user);
109 int manager_add_user_by_name(Manager *m, const char *name, User **_user);
110 int manager_add_user_by_uid(Manager *m, uid_t uid, User **_user);
111
112 int manager_process_seat_device(Manager *m, struct udev_device *d);
113 int manager_dispatch_seat_udev(Manager *m);
114 int manager_dispatch_vcsa_udev(Manager *m);
115 int manager_dispatch_console(Manager *m);
116
117 int manager_enumerate_devices(Manager *m);
118 int manager_enumerate_seats(Manager *m);
119 int manager_enumerate_sessions(Manager *m);
120 int manager_enumerate_users(Manager *m);
121
122 int manager_startup(Manager *m);
123 int manager_run(Manager *m);
124 int manager_spawn_autovt(Manager *m, int vtnr);
125
126 void manager_cgroup_notify_empty(Manager *m, const char *cgroup);
127
128 void manager_gc(Manager *m, bool drop_not_started);
129
130 int manager_get_idle_hint(Manager *m, dual_timestamp *t);
131
132 extern const DBusObjectPathVTable bus_manager_vtable;
133
134 DBusHandlerResult bus_message_filter(DBusConnection *c, DBusMessage *message, void *userdata);
135
136 int manager_send_changed(Manager *manager, const char *properties);
137
138 #endif