logind-session.h revision 405e0255d5e6950180d9563f1a26294b5360db03
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#pragma once
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2011 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef struct Session Session;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef enum KillWho KillWho;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "list.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering#include "util.h"
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering#include "logind.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "logind-seat.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "logind-user.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef enum SessionState {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_OPENING, /* Session scope is being created */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_ONLINE, /* Logged in */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_ACTIVE, /* Logged in and in the fg */
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering SESSION_CLOSING, /* Logged out, but scope is still there */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _SESSION_STATE_MAX,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _SESSION_STATE_INVALID = -1
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering} SessionState;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef enum SessionClass {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_USER,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_GREETER,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_LOCK_SCREEN,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_BACKGROUND,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _SESSION_CLASS_MAX,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _SESSION_CLASS_INVALID = -1
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering} SessionClass;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef enum SessionType {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SESSION_UNSPECIFIED,
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering SESSION_TTY,
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering SESSION_X11,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _SESSION_TYPE_MAX,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _SESSION_TYPE_INVALID = -1
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering} SessionType;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringenum KillWho {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering KILL_LEADER,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering KILL_ALL,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _KILL_WHO_MAX,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _KILL_WHO_INVALID = -1
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering};
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringstruct Session {
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering Manager *manager;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *id;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SessionType type;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering SessionClass class;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering char *state_file;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering User *user;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering dual_timestamp timestamp;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *tty;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *display;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering bool remote;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *remote_user;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *remote_host;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *service;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *scope;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *scope_job;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering int vtnr;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Seat *seat;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering pid_t leader;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering uint32_t audit_id;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering int fifo_fd;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *fifo_path;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering bool idle_hint;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering dual_timestamp idle_hint_timestamp;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering bool in_gc_queue:1;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering bool started:1;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering bool closing:1;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering DBusMessage *create_message;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering LIST_FIELDS(Session, sessions_by_user);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering LIST_FIELDS(Session, sessions_by_seat);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering LIST_FIELDS(Session, gc_queue);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering};
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poettering
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart PoetteringSession *session_new(Manager *m, const char *id);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringvoid session_free(Session *s);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringvoid session_set_user(Session *s, User *u);
7e8e0422aeb16f2a09a40546c61df753d10029b6Lennart Poetteringint session_check_gc(Session *s, bool drop_not_started);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringvoid session_add_to_gc_queue(Session *s);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint session_activate(Session *s);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringbool session_is_active(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_get_idle_hint(Session *s, dual_timestamp *t);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringvoid session_set_idle_hint(Session *s, bool b);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_create_fifo(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringvoid session_remove_fifo(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_start(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_stop(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_finalize(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_save(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_load(Session *s);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint session_kill(Session *s, KillWho who, int signo);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringchar *session_bus_path(Session *s);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart PoetteringSessionState session_get_state(Session *u);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringextern const DBusObjectPathVTable bus_session_vtable;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringint session_send_signal(Session *s, bool new_session);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringint session_send_changed(Session *s, const char *properties);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint session_send_lock(Session *s, bool lock);
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringint session_send_lock_all(Manager *m, bool lock);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint session_send_create_reply(Session *s, DBusError *error);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poetteringconst char* session_state_to_string(SessionState t) _const_;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart PoetteringSessionState session_state_from_string(const char *s) _pure_;
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringconst char* session_type_to_string(SessionType t) _const_;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart PoetteringSessionType session_type_from_string(const char *s) _pure_;
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
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_;