diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2012-02-09 16:33:51 +1100 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2012-02-09 16:33:51 +1100 |
commit | 070f8c5a5ea91573507de655df886f538c82a85b (patch) | |
tree | 344760e8ec2d10c64b7c9205fa050d8702091f9f /src | |
parent | 58e07cc142715296b06f226ba0fe0fa9edc2b164 (diff) | |
download | lightdm-070f8c5a5ea91573507de655df886f538c82a85b.tar.gz |
Add Lock D-Bus method that locks the seat and provides a hint to the greeter to be in lock mode
Diffstat (limited to 'src')
-rw-r--r-- | src/display.c | 12 | ||||
-rw-r--r-- | src/display.h | 2 | ||||
-rw-r--r-- | src/lightdm.c | 7 | ||||
-rw-r--r-- | src/seat.c | 32 | ||||
-rw-r--r-- | src/seat.h | 2 |
5 files changed, 47 insertions, 8 deletions
diff --git a/src/display.c b/src/display.c index 2cf75a2c..a9b17396 100644 --- a/src/display.c +++ b/src/display.c @@ -55,6 +55,9 @@ struct DisplayPrivate /* TRUE if the user list should be shown */ gboolean greeter_hide_users; + /* TRUE if the greeter is a lock screen */ + gboolean greeter_is_lock; + /* Session requested to log into */ gchar *user_session; @@ -194,6 +197,13 @@ display_set_hide_users_hint (Display *display, gboolean hide_users) } void +display_set_lock_hint (Display *display, gboolean is_lock) +{ + g_return_if_fail (display != NULL); + display->priv->greeter_is_lock = is_lock; +} + +void display_set_user_session (Display *display, const gchar *session_name) { g_return_if_fail (display != NULL); @@ -661,6 +671,8 @@ start_greeter_session (Display *display) greeter_set_allow_guest (display->priv->greeter, display->priv->allow_guest); greeter_set_hint (display->priv->greeter, "has-guest-account", display->priv->allow_guest ? "true" : "false"); greeter_set_hint (display->priv->greeter, "hide-users", display->priv->greeter_hide_users ? "true" : "false"); + if (display->priv->greeter_is_lock) + greeter_set_hint (display->priv->greeter, "lock-screen", "true"); start_result = FALSE; g_signal_emit (display, signals[START_GREETER], 0, &start_result); diff --git a/src/display.h b/src/display.h index f011616c..eb563974 100644 --- a/src/display.h +++ b/src/display.h @@ -70,6 +70,8 @@ void display_set_select_user_hint (Display *display, const gchar *username, gboo void display_set_hide_users_hint (Display *display, gboolean hide_users); +void display_set_lock_hint (Display *display, gboolean is_lock); + void display_set_user_session (Display *display, const gchar *session_name); gboolean display_start (Display *display); diff --git a/src/lightdm.c b/src/lightdm.c index 2f640063..bbdf7034 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -417,6 +417,12 @@ handle_seat_call (GDBusConnection *connection, seat_switch_to_guest (seat, session_name); g_dbus_method_invocation_return_value (invocation, NULL); } + else if (g_strcmp0 (method_name, "Lock") == 0) + { + /* FIXME: Should only allow locks if have a session on this seat */ + seat_lock (seat); + g_dbus_method_invocation_return_value (invocation, NULL); + } } static GVariant * @@ -666,6 +672,7 @@ bus_acquired_cb (GDBusConnection *connection, " <method name='SwitchToGuest'>" " <arg name='session-name' direction='in' type='s'/>" " </method>" + " <method name='Lock'/>" " </interface>" "</node>"; const gchar *session_interface = @@ -192,7 +192,7 @@ switch_to_user (Seat *seat, const gchar *username, gboolean unlock) /* If already logged in, then switch to that display */ if (g_strcmp0 (display_get_username (display), username) == 0) { - if (username) + if (username) g_debug ("Switching to existing session for user %s", username); else g_debug ("Switching to existing greeter"); @@ -432,7 +432,7 @@ display_stopped_cb (Display *display, Seat *seat) } static gboolean -switch_to_user_or_start_greeter (Seat *seat, const gchar *username, gboolean is_guest, const gchar *session_name, gboolean autologin) +switch_to_user_or_start_greeter (Seat *seat, const gchar *username, gboolean is_guest, const gchar *session_name, gboolean is_lock, gboolean autologin) { Display *display; DisplayServer *display_server; @@ -457,6 +457,8 @@ switch_to_user_or_start_greeter (Seat *seat, const gchar *username, gboolean is_ g_debug ("Starting new display for greeter with guest selected"); else if (username) g_debug ("Starting new display for greeter with user %s selected", username); + else if (is_lock) + g_debug ("Starting new display for greeter (lock screen)"); else g_debug ("Starting new display for greeter"); } @@ -478,6 +480,8 @@ switch_to_user_or_start_greeter (Seat *seat, const gchar *username, gboolean is_ display_set_greeter_session (display, seat_get_string_property (seat, "greeter-session")); display_set_session_wrapper (display, seat_get_string_property (seat, "session-wrapper")); display_set_hide_users_hint (display, seat_get_boolean_property (seat, "greeter-hide-users")); + if (is_lock) + display_set_lock_hint (display, TRUE); display_set_allow_guest (display, seat_get_allow_guest (seat)); if (autologin) display_set_autologin_user (display, username, is_guest, 0); @@ -506,7 +510,7 @@ seat_switch_to_greeter (Seat *seat) return FALSE; g_debug ("Switching to greeter"); - return switch_to_user_or_start_greeter (seat, NULL, FALSE, NULL, FALSE); + return switch_to_user_or_start_greeter (seat, NULL, FALSE, NULL, FALSE, FALSE); } gboolean @@ -519,7 +523,7 @@ seat_switch_to_user (Seat *seat, const gchar *username, const gchar *session_nam return FALSE; g_debug ("Switching to user %s", username); - return switch_to_user_or_start_greeter (seat, username, FALSE, session_name, FALSE); + return switch_to_user_or_start_greeter (seat, username, FALSE, session_name, FALSE, FALSE); } gboolean @@ -534,7 +538,19 @@ seat_switch_to_guest (Seat *seat, const gchar *session_name) g_debug ("Switching to existing guest account %s", seat->priv->guest_username); else g_debug ("Switching to new guest account"); - return switch_to_user_or_start_greeter (seat, seat->priv->guest_username, TRUE, session_name, TRUE); + return switch_to_user_or_start_greeter (seat, seat->priv->guest_username, TRUE, session_name, FALSE, TRUE); +} + +gboolean +seat_lock (Seat *seat) +{ + g_return_val_if_fail (seat != NULL, FALSE); + + if (!seat->priv->can_switch) + return FALSE; + + g_debug ("Locking seat"); + return switch_to_user_or_start_greeter (seat, NULL, FALSE, NULL, TRUE, FALSE); } void @@ -575,11 +591,11 @@ seat_real_start (Seat *seat) autologin_username = NULL; if (autologin_username) - return switch_to_user_or_start_greeter (seat, autologin_username, FALSE, NULL, TRUE); + return switch_to_user_or_start_greeter (seat, autologin_username, FALSE, NULL, FALSE, TRUE); else if (seat_get_boolean_property (seat, "autologin-guest")) - return switch_to_user_or_start_greeter (seat, NULL, TRUE, NULL, TRUE); + return switch_to_user_or_start_greeter (seat, NULL, TRUE, NULL, FALSE, TRUE); else - return switch_to_user_or_start_greeter (seat, NULL, FALSE, NULL, FALSE); + return switch_to_user_or_start_greeter (seat, NULL, FALSE, NULL, FALSE, FALSE); } static void @@ -83,6 +83,8 @@ gboolean seat_switch_to_user (Seat *seat, const gchar *username, const gchar *se gboolean seat_switch_to_guest (Seat *seat, const gchar *session_name); +gboolean seat_lock (Seat *seat); + void seat_stop (Seat *seat); gboolean seat_get_is_stopping (Seat *seat); |