[gdm/wip/wayland-rebase: 8/13] slave: add ability to reset launch environment
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/wip/wayland-rebase: 8/13] slave: add ability to reset launch environment
- Date: Wed, 12 Feb 2014 20:30:19 +0000 (UTC)
commit f35df90d147e3608856009f12516437bd55ffb46
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Feb 11 12:50:30 2014 -0500
slave: add ability to reset launch environment
This is useful if we want to kill a greeter and start a new
one on the same X server.
daemon/gdm-display.c | 6 +++
daemon/gdm-display.h | 1 +
daemon/gdm-launch-environment.c | 87 +++++++++++++++++++++++++++++++--------
daemon/gdm-launch-environment.h | 2 +
daemon/gdm-simple-slave.c | 28 ++++++++++++
daemon/gdm-slave.c | 6 +++
daemon/gdm-slave.h | 2 +
7 files changed, 114 insertions(+), 18 deletions(-)
---
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index 14fa3a4..9c87ff6 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -1403,6 +1403,12 @@ gdm_display_start_initial_session (GdmDisplay *display)
}
void
+gdm_display_reset_initial_session (GdmDisplay *display)
+{
+ gdm_slave_reset_initial_session (display->priv->slave);
+}
+
+void
gdm_display_stop_initial_session (GdmDisplay *display,
const char *username)
{
diff --git a/daemon/gdm-display.h b/daemon/gdm-display.h
index abab3d4..2db40b5 100644
--- a/daemon/gdm-display.h
+++ b/daemon/gdm-display.h
@@ -143,6 +143,7 @@ gboolean gdm_display_remove_user_authorization (GdmDisplay *disp
void gdm_display_set_up_initial_session (GdmDisplay *display,
char **username);
void gdm_display_start_initial_session (GdmDisplay *display);
+void gdm_display_reset_initial_session (GdmDisplay *display);
void gdm_display_stop_initial_session (GdmDisplay *display,
const char *username);
gboolean gdm_display_run_pre_session_script (GdmDisplay *display);
diff --git a/daemon/gdm-launch-environment.c b/daemon/gdm-launch-environment.c
index 932cc06..cdd5fe4 100644
--- a/daemon/gdm-launch-environment.c
+++ b/daemon/gdm-launch-environment.c
@@ -73,6 +73,7 @@ struct GdmLaunchEnvironmentPrivate
char *x11_authority_file;
char *dbus_session_bus_address;
gboolean x11_display_is_local;
+ gboolean resetting;
};
enum {
@@ -93,6 +94,7 @@ enum {
enum {
OPENED,
STARTED,
+ RESET,
STOPPED,
EXITED,
DIED,
@@ -329,7 +331,9 @@ on_session_opened (GdmSession *session,
{
launch_environment->priv->session_id = g_strdup (session_id);
- g_signal_emit (G_OBJECT (launch_environment), signals [OPENED], 0);
+ if (!launch_environment->priv->resetting) {
+ g_signal_emit (G_OBJECT (launch_environment), signals [OPENED], 0);
+ }
gdm_session_start_session (launch_environment->priv->session, service_name);
}
@@ -340,7 +344,12 @@ on_session_started (GdmSession *session,
GdmLaunchEnvironment *launch_environment)
{
launch_environment->priv->pid = pid;
- g_signal_emit (G_OBJECT (launch_environment), signals [STARTED], 0);
+ if (!launch_environment->priv->resetting) {
+ g_signal_emit (G_OBJECT (launch_environment), signals [STARTED], 0);
+ } else {
+ launch_environment->priv->resetting = FALSE;
+ g_signal_emit (G_OBJECT (launch_environment), signals [RESET], 0);
+ }
}
static void
@@ -348,9 +357,15 @@ on_session_exited (GdmSession *session,
int exit_code,
GdmLaunchEnvironment *launch_environment)
{
+ if (session != launch_environment->priv->session) {
+ return;
+ }
+
gdm_session_stop_conversation (launch_environment->priv->session, "gdm-launch-environment");
- g_signal_emit (G_OBJECT (launch_environment), signals [EXITED], 0, exit_code);
+ if (!launch_environment->priv->resetting) {
+ g_signal_emit (G_OBJECT (launch_environment), signals [EXITED], 0, exit_code);
+ }
}
static void
@@ -358,9 +373,15 @@ on_session_died (GdmSession *session,
int signal_number,
GdmLaunchEnvironment *launch_environment)
{
+ if (session != launch_environment->priv->session) {
+ return;
+ }
+
gdm_session_stop_conversation (launch_environment->priv->session, "gdm-launch-environment");
- g_signal_emit (G_OBJECT (launch_environment), signals [DIED], 0, signal_number);
+ if (!launch_environment->priv->resetting) {
+ g_signal_emit (G_OBJECT (launch_environment), signals [DIED], 0, signal_number);
+ }
}
static void
@@ -396,7 +417,9 @@ on_conversation_stopped (GdmSession *session,
if (launch_environment->priv->pid > 1) {
gdm_signal_pid (-launch_environment->priv->pid, SIGTERM);
- g_signal_emit (G_OBJECT (launch_environment), signals [STOPPED], 0);
+ if (!launch_environment->priv->resetting) {
+ g_signal_emit (G_OBJECT (launch_environment), signals [STOPPED], 0);
+ }
}
if (conversation_session != NULL) {
@@ -426,6 +449,23 @@ ensure_directory_with_uid_gid (const char *path,
return TRUE;
}
+static void
+start_program (GdmLaunchEnvironment *launch_environment)
+{
+ gdm_session_start_conversation (launch_environment->priv->session, "gdm-launch-environment");
+
+ if (launch_environment->priv->dbus_session_bus_address) {
+ gdm_session_select_program (launch_environment->priv->session,
launch_environment->priv->command);
+ } else {
+ /* wrap it in dbus-launch */
+ char *command = g_strdup_printf ("%s %s", DBUS_LAUNCH_COMMAND,
launch_environment->priv->command);
+
+ gdm_session_select_program (launch_environment->priv->session, command);
+ g_free (command);
+ }
+
+}
+
/**
* gdm_launch_environment_start:
* @disp: Pointer to a GdmDisplay structure
@@ -502,18 +542,7 @@ gdm_launch_environment_start (GdmLaunchEnvironment *launch_environment)
"session-died",
G_CALLBACK (on_session_died),
launch_environment);
-
- gdm_session_start_conversation (launch_environment->priv->session, "gdm-launch-environment");
-
- if (launch_environment->priv->dbus_session_bus_address) {
- gdm_session_select_program (launch_environment->priv->session,
launch_environment->priv->command);
- } else {
- /* wrap it in dbus-launch */
- char *command = g_strdup_printf ("%s %s", DBUS_LAUNCH_COMMAND,
launch_environment->priv->command);
-
- gdm_session_select_program (launch_environment->priv->session, command);
- g_free (command);
- }
+ start_program (launch_environment);
res = TRUE;
out:
@@ -525,6 +554,16 @@ gdm_launch_environment_start (GdmLaunchEnvironment *launch_environment)
}
gboolean
+gdm_launch_environment_reset (GdmLaunchEnvironment *launch_environment)
+{
+ launch_environment->priv->resetting = TRUE;
+ gdm_launch_environment_stop (launch_environment);
+ gdm_launch_environment_start (launch_environment);
+
+ return TRUE;
+}
+
+gboolean
gdm_launch_environment_stop (GdmLaunchEnvironment *launch_environment)
{
if (launch_environment->priv->pid > 1) {
@@ -537,7 +576,9 @@ gdm_launch_environment_stop (GdmLaunchEnvironment *launch_environment)
g_clear_object (&launch_environment->priv->session);
}
- g_signal_emit (G_OBJECT (launch_environment), signals [STOPPED], 0);
+ if (!launch_environment->priv->resetting) {
+ g_signal_emit (G_OBJECT (launch_environment), signals [STOPPED], 0);
+ }
}
return TRUE;
@@ -850,6 +891,16 @@ gdm_launch_environment_class_init (GdmLaunchEnvironmentClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+ signals [RESET] =
+ g_signal_new ("reset",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GdmLaunchEnvironmentClass, reset),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
signals [STOPPED] =
g_signal_new ("stopped",
G_OBJECT_CLASS_TYPE (object_class),
diff --git a/daemon/gdm-launch-environment.h b/daemon/gdm-launch-environment.h
index 8f27643..2de1e37 100644
--- a/daemon/gdm-launch-environment.h
+++ b/daemon/gdm-launch-environment.h
@@ -54,6 +54,7 @@ typedef struct
/* signals */
void (* opened) (GdmLaunchEnvironment *launch_environment);
void (* started) (GdmLaunchEnvironment *launch_environment);
+ void (* reset) (GdmLaunchEnvironment *launch_environment);
void (* stopped) (GdmLaunchEnvironment *launch_environment);
void (* exited) (GdmLaunchEnvironment *launch_environment,
int exit_code);
@@ -64,6 +65,7 @@ typedef struct
GType gdm_launch_environment_get_type (void);
gboolean gdm_launch_environment_start (GdmLaunchEnvironment *launch_environment);
+gboolean gdm_launch_environment_reset (GdmLaunchEnvironment *launch_environment);
gboolean gdm_launch_environment_stop (GdmLaunchEnvironment *launch_environment);
GdmSession * gdm_launch_environment_get_session (GdmLaunchEnvironment *launch_environment);
char * gdm_launch_environment_get_session_id (GdmLaunchEnvironment *launch_environment);
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 341b3a9..15390ba 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -363,6 +363,19 @@ on_greeter_environment_session_opened (GdmLaunchEnvironment *greeter_environment
}
static void
+on_greeter_environment_session_reset (GdmLaunchEnvironment *greeter_environment,
+ GdmSimpleSlave *slave)
+{
+ char *session_id;
+
+ g_debug ("GdmSimpleSlave: Greeter reset");
+ session_id = gdm_launch_environment_get_session_id (GDM_LAUNCH_ENVIRONMENT (greeter_environment));
+
+ g_object_set (GDM_SLAVE (slave), "session-id", session_id, NULL);
+ g_free (session_id);
+}
+
+static void
on_greeter_environment_session_started (GdmLaunchEnvironment *greeter_environment,
GdmSimpleSlave *slave)
{
@@ -610,6 +623,10 @@ start_launch_environment (GdmSimpleSlave *slave,
G_CALLBACK (on_greeter_environment_session_opened),
slave);
g_signal_connect (slave->priv->greeter_environment,
+ "reset",
+ G_CALLBACK (on_greeter_environment_session_reset),
+ slave);
+ g_signal_connect (slave->priv->greeter_environment,
"started",
G_CALLBACK (on_greeter_environment_session_started),
slave);
@@ -754,6 +771,16 @@ gdm_simple_slave_start_initial_session (GdmSlave *slave)
}
}
+static void
+gdm_simple_slave_reset_initial_session (GdmSlave *slave)
+{
+ GdmSimpleSlave *self = GDM_SIMPLE_SLAVE (slave);
+
+ if (self->priv->greeter_environment != NULL) {
+ gdm_launch_environment_reset (GDM_LAUNCH_ENVIRONMENT (self->priv->greeter_environment));
+ }
+}
+
static gboolean
idle_connect_to_display (GdmSimpleSlave *slave)
{
@@ -1021,6 +1048,7 @@ gdm_simple_slave_class_init (GdmSimpleSlaveClass *klass)
slave_class->stop = gdm_simple_slave_stop;
slave_class->set_up_initial_session = gdm_simple_slave_set_up_initial_session;
slave_class->start_initial_session = gdm_simple_slave_start_initial_session;
+ slave_class->reset_initial_session = gdm_simple_slave_reset_initial_session;
slave_class->stop_initial_session = gdm_simple_slave_stop_initial_session;
g_type_class_add_private (klass, sizeof (GdmSimpleSlavePrivate));
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index 1a3ee99..5fd2826 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -1044,6 +1044,12 @@ gdm_slave_start_initial_session (GdmSlave *slave)
}
void
+gdm_slave_reset_initial_session (GdmSlave *slave)
+{
+ GDM_SLAVE_GET_CLASS (slave)->reset_initial_session (slave);
+}
+
+void
gdm_slave_stop_initial_session (GdmSlave *slave,
const char *username)
{
diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h
index d33a6df..5456c44 100644
--- a/daemon/gdm-slave.h
+++ b/daemon/gdm-slave.h
@@ -53,6 +53,7 @@ typedef struct
void (* set_up_initial_session) (GdmSlave *slave,
char **username);
void (* start_initial_session) (GdmSlave *slave);
+ void (* reset_initial_session) (GdmSlave *slave);
void (* stop_initial_session) (GdmSlave *slave,
const char *username);
@@ -93,6 +94,7 @@ gboolean gdm_slave_run_script (GdmSlave *slave,
void gdm_slave_set_up_initial_session (GdmSlave *slave,
char **username);
void gdm_slave_start_initial_session (GdmSlave *slave);
+void gdm_slave_reset_initial_session (GdmSlave *slave);
void gdm_slave_stop_initial_session (GdmSlave *slave,
const char *username);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]