From fe3ea128aade76fe759110dd3b801a14ee331ef6 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 23 Jun 2009 22:48:06 -0400 Subject: Add block-console-session-requests display property This property is just a hint for the display factory to queue SessionToAdd requests from consolekit instead of processing them immediately. This will be useful for the slave to lock a display during the critical moment after the login window session is closed before the user's session is opened. Note, the display factory doesn't look at the hint yet, and the slave doesn't set it, yet, either. --- daemon/gdm-display.c | 44 +++++++++++++++++++++++++++++++++++++++++ daemon/gdm-display.h | 5 +++++ daemon/gdm-display.xml | 4 ++++ daemon/gdm-slave.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ daemon/gdm-slave.h | 3 +++ 5 files changed, 109 insertions(+) diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c index ff0f2a70..24be2455 100644 --- a/daemon/gdm-display.c +++ b/daemon/gdm-display.c @@ -70,6 +70,7 @@ struct GdmDisplayPrivate gboolean is_local; gboolean is_dynamic; gboolean use_auth; + gboolean block_console_session_requests; guint finish_idle_id; GdmSlaveProxy *slave_proxy; @@ -93,6 +94,7 @@ enum { PROP_IS_DYNAMIC, PROP_USE_AUTH, PROP_SLAVE_COMMAND, + PROP_BLOCK_CONSOLE_SESSION_REQUESTS, }; static void gdm_display_class_init (GdmDisplayClass *klass); @@ -938,6 +940,13 @@ _gdm_display_set_slave_command (GdmDisplay *display, display->priv->slave_command = g_strdup (command); } +static void +_gdm_display_set_block_console_session_requests (GdmDisplay *display, + gboolean block_console_session_requests) +{ + display->priv->block_console_session_requests = block_console_session_requests; +} + static void gdm_display_set_property (GObject *object, guint prop_id, @@ -988,6 +997,9 @@ gdm_display_set_property (GObject *object, case PROP_SLAVE_COMMAND: _gdm_display_set_slave_command (self, g_value_get_string (value)); break; + case PROP_BLOCK_CONSOLE_SESSION_REQUESTS: + _gdm_display_set_block_console_session_requests (self, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1048,6 +1060,9 @@ gdm_display_get_property (GObject *object, case PROP_SLAVE_COMMAND: g_value_set_string (value, self->priv->slave_command); break; + case PROP_BLOCK_CONSOLE_SESSION_REQUESTS: + g_value_set_boolean (value, self->priv->block_console_session_requests); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1249,6 +1264,13 @@ gdm_display_class_init (GdmDisplayClass *klass) "slave command", DEFAULT_SLAVE_COMMAND, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, + PROP_BLOCK_CONSOLE_SESSION_REQUESTS, + g_param_spec_boolean ("block-console-session-requests", + "Block Console Session Requests", + "Block session requests from ConsoleKit", + FALSE, + G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_STATUS, g_param_spec_int ("status", @@ -1310,3 +1332,25 @@ gdm_display_finalize (GObject *object) G_OBJECT_CLASS (gdm_display_parent_class)->finalize (object); } + +gboolean +gdm_display_block_console_session_requests (GdmDisplay *display, + GError **error) +{ + if (!display->priv->block_console_session_requests) { + _gdm_display_set_block_console_session_requests (display, TRUE); + g_object_notify (G_OBJECT (display), "block-console-session-requests"); + } + return TRUE; +} + +gboolean +gdm_display_unblock_console_session_requests (GdmDisplay *display, + GError **error) +{ + if (display->priv->block_console_session_requests) { + _gdm_display_set_block_console_session_requests (display, FALSE); + g_object_notify (G_OBJECT (display), "block-console-session-requests"); + } + return TRUE; +} diff --git a/daemon/gdm-display.h b/daemon/gdm-display.h index 6c494fd1..d615af88 100644 --- a/daemon/gdm-display.h +++ b/daemon/gdm-display.h @@ -155,6 +155,11 @@ gboolean gdm_display_remove_user_authorization (GdmDisplay *disp gboolean gdm_display_set_slave_bus_name (GdmDisplay *display, const char *name, GError **error); +gboolean gdm_display_block_console_session_requests (GdmDisplay *display, + GError **error); + +gboolean gdm_display_unblock_console_session_requests (GdmDisplay *display, + GError **error); G_END_DECLS diff --git a/daemon/gdm-display.xml b/daemon/gdm-display.xml index 21b98c82..65e26b5f 100644 --- a/daemon/gdm-display.xml +++ b/daemon/gdm-display.xml @@ -25,6 +25,10 @@ + + + + diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c index e88111d9..513fcf9a 100644 --- a/daemon/gdm-slave.c +++ b/daemon/gdm-slave.c @@ -1231,6 +1231,59 @@ gdm_slave_switch_to_user_session (GdmSlave *slave, return ret; } +void +gdm_slave_block_console_session_requests_on_display (GdmSlave *slave) +{ + gboolean res; + GError *error; + + g_debug ("GdmSlave: Asking display to ignore ConsoleKit"); + + error = NULL; + res = dbus_g_proxy_call (slave->priv->display_proxy, + "BlockConsoleSessionRequests", + &error, + G_TYPE_INVALID, G_TYPE_INVALID); + + if (! res) { + if (error != NULL) { + g_warning ("Failed to get display to ignore ConsoleKit: %s", error->message); + g_error_free (error); + } else { + g_warning ("Failed to get display to ignore ConsoleKit"); + } + } else { + g_debug ("GdmSlave: Display is now ignoring ConsoleKit"); + } +} + +void +gdm_slave_unblock_console_session_requests_on_display (GdmSlave *slave) +{ + gboolean res; + GError *error; + + g_debug ("GdmSlave: Informing display to stop ignoring ConsoleKit"); + + error = NULL; + res = dbus_g_proxy_call (slave->priv->display_proxy, + "UnblockConsoleSessionRequests", + &error, + G_TYPE_INVALID, G_TYPE_INVALID); + + if (! res) { + if (error != NULL) { + g_warning ("Failed to get display to stop ignoring ConsoleKit: %s", error->message); + g_error_free (error); + } else { + g_warning ("Failed to get display to stop ignoring ConsoleKit"); + } + } else { + g_debug ("GdmSlave: Display is no longer ignoring ConsoleKit"); + } +} + + static void _gdm_slave_set_display_id (GdmSlave *slave, const char *id) diff --git a/daemon/gdm-slave.h b/daemon/gdm-slave.h index ca370267..3783c2aa 100644 --- a/daemon/gdm-slave.h +++ b/daemon/gdm-slave.h @@ -72,6 +72,9 @@ gboolean gdm_slave_add_user_authorization (GdmSlave *slave, gboolean gdm_slave_switch_to_user_session (GdmSlave *slave, const char *username); +void gdm_slave_block_console_session_requests_on_display (GdmSlave *slave); +void gdm_slave_unblock_console_session_requests_on_display (GdmSlave *slave); + gboolean gdm_slave_connect_to_x11_display (GdmSlave *slave); void gdm_slave_set_busy_cursor (GdmSlave *slave); gboolean gdm_slave_run_script (GdmSlave *slave, -- cgit v1.2.1