logind-session.h revision d9eb81f9844f6d28b52e44b2c0e6e280a61d8200
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek#pragma once
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek/***
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek This file is part of systemd.
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek Copyright 2011 Lennart Poettering
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek (at your option) any later version.
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek***/
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmektypedef struct Session Session;
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmektypedef enum KillWho KillWho;
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek#include "list.h"
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek#include "util.h"
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek#include "logind.h"
613b411c947635136637f8cdd66b94512f761eabLennart Poettering#include "logind-seat.h"
613b411c947635136637f8cdd66b94512f761eabLennart Poettering#include "logind-session-device.h"
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek#include "logind-user.h"
613b411c947635136637f8cdd66b94512f761eabLennart Poettering#include "login-shared.h"
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poetteringtypedef enum SessionState {
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek SESSION_OPENING, /* Session scope is being created */
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_ONLINE, /* Logged in */
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_ACTIVE, /* Logged in and in the fg */
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek SESSION_CLOSING, /* Logged out, but scope is still there */
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _SESSION_STATE_MAX,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _SESSION_STATE_INVALID = -1
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek} SessionState;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poetteringtypedef enum SessionClass {
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_USER,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_GREETER,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_LOCK_SCREEN,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_BACKGROUND,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _SESSION_CLASS_MAX,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _SESSION_CLASS_INVALID = -1
613b411c947635136637f8cdd66b94512f761eabLennart Poettering} SessionClass;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poetteringtypedef enum SessionType {
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_UNSPECIFIED,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_TTY,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_X11,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SESSION_WAYLAND,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _SESSION_TYPE_MAX,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _SESSION_TYPE_INVALID = -1
613b411c947635136637f8cdd66b94512f761eabLennart Poettering} SessionType;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poetteringenum KillWho {
613b411c947635136637f8cdd66b94512f761eabLennart Poettering KILL_LEADER,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering KILL_ALL,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _KILL_WHO_MAX,
613b411c947635136637f8cdd66b94512f761eabLennart Poettering _KILL_WHO_INVALID = -1
613b411c947635136637f8cdd66b94512f761eabLennart Poettering};
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poetteringstruct Session {
613b411c947635136637f8cdd66b94512f761eabLennart Poettering Manager *manager;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *id;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering unsigned int pos;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SessionType type;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering SessionClass class;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *state_file;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering User *user;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering dual_timestamp timestamp;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *tty;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *display;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering bool remote;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *remote_user;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *remote_host;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *service;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *scope;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *scope_job;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering Seat *seat;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering unsigned int vtnr;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering int vtfd;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering sd_event_source *vt_source;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering pid_t leader;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering uint32_t audit_id;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering int fifo_fd;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *fifo_path;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering sd_event_source *fifo_event_source;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering bool idle_hint;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering dual_timestamp idle_hint_timestamp;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering bool in_gc_queue:1;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering bool started:1;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering sd_bus_message *create_message;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering char *controller;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering Hashmap *devices;
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
613b411c947635136637f8cdd66b94512f761eabLennart Poettering LIST_FIELDS(Session, sessions_by_user);
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek LIST_FIELDS(Session, sessions_by_seat);
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek LIST_FIELDS(Session, gc_queue);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poettering};
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poettering
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart PoetteringSession *session_new(Manager *m, const char *id);
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmekvoid session_free(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringvoid session_set_user(Session *s, User *u);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringbool session_check_gc(Session *s, bool drop_not_started);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringvoid session_add_to_gc_queue(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_activate(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringbool session_is_active(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_get_idle_hint(Session *s, dual_timestamp *t);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringvoid session_set_idle_hint(Session *s, bool b);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_create_fifo(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringvoid session_remove_fifo(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_start(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_stop(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_finalize(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_save(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_load(Session *s);
6b46ea73e3b1d8a1e65f58ac04772821bd4a72fbLennart Poetteringint session_kill(Session *s, KillWho who, int signo);
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmek
613b411c947635136637f8cdd66b94512f761eabLennart PoetteringSessionState session_get_state(Session *u);
613b411c947635136637f8cdd66b94512f761eabLennart Poettering
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmekextern const sd_bus_vtable session_vtable[];
d8c9d3a468e61ee2a2b2c3454e662398b0885411Zbigniew Jędrzejewski-Szmekint session_node_enumerator(sd_bus *bus, const char *path,void *userdata, char ***nodes, sd_bus_error *error);
int session_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error);
char *session_bus_path(Session *s);
int session_send_signal(Session *s, bool new_session);
int session_send_changed(Session *s, const char *properties, ...) _sentinel_;
int session_send_lock(Session *s, bool lock);
int session_send_lock_all(Manager *m, bool lock);
int session_send_create_reply(Session *s, sd_bus_error *error);
const char* session_state_to_string(SessionState t) _const_;
SessionState session_state_from_string(const char *s) _pure_;
const char* session_type_to_string(SessionType t) _const_;
SessionType session_type_from_string(const char *s) _pure_;
const char* session_class_to_string(SessionClass t) _const_;
SessionClass session_class_from_string(const char *s) _pure_;
const char *kill_who_to_string(KillWho k) _const_;
KillWho kill_who_from_string(const char *s) _pure_;
void session_mute_vt(Session *s);
void session_restore_vt(Session *s);
bool session_is_controller(Session *s, const char *sender);
int session_set_controller(Session *s, const char *sender, bool force);
void session_drop_controller(Session *s);