1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- 2 * 3 * Copyright (C) 2006 Ray Strode <rstrode@redhat.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2, or (at your option) 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 * 02110-1301, USA. 19 */ 20 21 #ifndef __GDM_SESSION_H 22 #define __GDM_SESSION_H 23 24 #include <glib-object.h> 25 #include <sys/types.h> 26 27 G_BEGIN_DECLS 28 29 #define GDM_TYPE_SESSION (gdm_session_get_type ()) 30 #define GDM_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDM_TYPE_SESSION, GdmSession)) 31 #define GDM_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDM_TYPE_SESSION, GdmSessionClass)) 32 #define GDM_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDM_TYPE_SESSION)) 33 #define GDM_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDM_TYPE_SESSION)) 34 #define GDM_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GDM_TYPE_SESSION, GdmSessionClass)) 35 36 typedef struct _GdmSessionPrivate GdmSessionPrivate; 37 38 typedef enum 39 { 40 GDM_SESSION_VERIFICATION_MODE_LOGIN, 41 GDM_SESSION_VERIFICATION_MODE_CHOOSER, 42 GDM_SESSION_VERIFICATION_MODE_REAUTHENTICATE 43 } GdmSessionVerificationMode; 44 45 typedef enum { 46 /* We reuse the existing display server, e.g. X server 47 * in "classic" mode from the greeter for the first seat. */ 48 GDM_SESSION_DISPLAY_MODE_REUSE_VT, 49 50 /* Doesn't know anything about VTs. Tries to set DRM 51 * master and will throw a tantrum if something bad 52 * happens. e.g. weston-launch or mutter-launch. */ 53 GDM_SESSION_DISPLAY_MODE_NEW_VT, 54 55 /* Uses logind sessions to manage itself. We need to set an 56 * XDG_VTNR and it will switch to the correct VT on startup. 57 * e.g. mutter-wayland with logind integration, X server with 58 * logind integration. */ 59 GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED, 60 } GdmSessionDisplayMode; 61 62 GdmSessionDisplayMode gdm_session_display_mode_from_string (const char *str); 63 const char * gdm_session_display_mode_to_string (GdmSessionDisplayMode mode); 64 65 typedef struct 66 { 67 GObject parent; 68 GdmSessionPrivate *priv; 69 } GdmSession; 70 71 typedef struct 72 { 73 GObjectClass parent_class; 74 75 /* Signals */ 76 void (* client_ready_for_session_to_start) (GdmSession *session, 77 const char *service_name, 78 gboolean client_is_ready); 79 80 void (* cancelled) (GdmSession *session); 81 void (* client_rejected) (GdmSession *session); 82 void (* client_connected) (GdmSession *session); 83 void (* client_disconnected) (GdmSession *session); 84 void (* disconnected) (GdmSession *session); 85 void (* verification_complete) (GdmSession *session, 86 const char *service_name); 87 void (* authentication_failed) (GdmSession *session, 88 const char *service_name, 89 GPid worker_pid); 90 void (* session_opened) (GdmSession *session, 91 const char *service_name, 92 const char *session_id); 93 void (* session_started) (GdmSession *session, 94 const char *service_name, 95 const char *session_id, 96 int pid); 97 void (* session_start_failed) (GdmSession *session, 98 const char *service_name, 99 const char *message); 100 void (* session_exited) (GdmSession *session, 101 int exit_code); 102 void (* session_died) (GdmSession *session, 103 int signal_number); 104 void (* reauthentication_started) (GdmSession *session, 105 GPid pid_of_caller); 106 void (* reauthenticated) (GdmSession *session, 107 const char *service_name); 108 void (* conversation_started) (GdmSession *session, 109 const char *service_name); 110 void (* conversation_stopped) (GdmSession *session, 111 const char *service_name); 112 void (* setup_complete) (GdmSession *session, 113 const char *service_name); 114 } GdmSessionClass; 115 116 GType gdm_session_get_type (void); 117 118 GdmSession *gdm_session_new (GdmSessionVerificationMode verification_mode, 119 uid_t allowed_user, 120 const char *display_name, 121 const char *display_hostname, 122 const char *display_device, 123 const char *display_seat_id, 124 const char *display_x11_authority_file, 125 gboolean display_is_local, 126 const char * const *environment); 127 uid_t gdm_session_get_allowed_user (GdmSession *session); 128 void gdm_session_start_reauthentication (GdmSession *session, 129 GPid pid_of_caller, 130 uid_t uid_of_caller); 131 132 const char *gdm_session_get_server_address (GdmSession *session); 133 const char *gdm_session_get_username (GdmSession *session); 134 const char *gdm_session_get_display_device (GdmSession *session); 135 const char *gdm_session_get_display_seat_id (GdmSession *session); 136 const char *gdm_session_get_session_id (GdmSession *session); 137 gboolean gdm_session_bypasses_xsession (GdmSession *session); 138 GdmSessionDisplayMode gdm_session_get_display_mode (GdmSession *session); 139 140 #ifdef ENABLE_WAYLAND_SUPPORT 141 void gdm_session_set_ignore_wayland (GdmSession *session, 142 gboolean ignore_wayland); 143 #endif 144 gboolean gdm_session_start_conversation (GdmSession *session, 145 const char *service_name); 146 void gdm_session_stop_conversation (GdmSession *session, 147 const char *service_name); 148 const char *gdm_session_get_conversation_session_id (GdmSession *session, 149 const char *service_name); 150 void gdm_session_setup (GdmSession *session, 151 const char *service_name); 152 void gdm_session_setup_for_user (GdmSession *session, 153 const char *service_name, 154 const char *username); 155 void gdm_session_setup_for_program (GdmSession *session, 156 const char *service_name, 157 const char *username, 158 const char *log_file); 159 void gdm_session_set_environment_variable (GdmSession *session, 160 const char *key, 161 const char *value); 162 void gdm_session_send_environment (GdmSession *self, 163 const char *service_name); 164 void gdm_session_reset (GdmSession *session); 165 void gdm_session_cancel (GdmSession *session); 166 void gdm_session_authenticate (GdmSession *session, 167 const char *service_name); 168 void gdm_session_authorize (GdmSession *session, 169 const char *service_name); 170 void gdm_session_accredit (GdmSession *session, 171 const char *service_name); 172 void gdm_session_open_session (GdmSession *session, 173 const char *service_name); 174 void gdm_session_start_session (GdmSession *session, 175 const char *service_name); 176 void gdm_session_close (GdmSession *session); 177 178 void gdm_session_answer_query (GdmSession *session, 179 const char *service_name, 180 const char *text); 181 void gdm_session_select_program (GdmSession *session, 182 const char *command_line); 183 void gdm_session_select_session_type (GdmSession *session, 184 const char *session_type); 185 void gdm_session_select_session (GdmSession *session, 186 const char *session_name); 187 void gdm_session_select_user (GdmSession *session, 188 const char *username); 189 void gdm_session_set_timed_login_details (GdmSession *session, 190 const char *username, 191 int delay); 192 gboolean gdm_session_client_is_connected (GdmSession *session); 193 gboolean gdm_session_is_running (GdmSession *session); 194 GPid gdm_session_get_pid (GdmSession *session); 195 196 G_END_DECLS 197 198 #endif /* GDM_SESSION_H */ 199