Commit Graph

24 Commits

Author SHA1 Message Date
Florian Müllner
3b1330880f cleanup: Use Function.prototype.bind()
When not using arrow notation with anonymous functions, we use Lang.bind()
to bind `this` to named callbacks. However since ES5, this functionality
is already provided by Function.prototype.bind() - in fact, Lang.bind()
itself uses it when no extra arguments are specified. Just use the built-in
function directly where possible, and use arrow notation in the few places
where we pass additional arguments.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:02 +00:00
Florian Müllner
213e38c2ef cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base
to bind `this` to anonymous functions, replacing the more overbose
Lang.bind(this, function() {}).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:55:00 +00:00
Florian Müllner
76f09b1e49 cleanup: Use method syntax
Modern javascript has a short-hand for function properties, embrace
it for better readability and to prepare for an eventual port to
ES6 classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
2018-02-21 13:54:58 +00:00
Florian Müllner
de4c0bdca6 loginManager: Handle unset XDG_SESSION_ID more gracefully
While certain functionality won't be available when running outside a
(logind) user session, that's still better than crashing ...

https://bugzilla.gnome.org/show_bug.cgi?id=788046
2017-09-22 18:46:01 +02:00
Florian Müllner
2582d16ca7 Define classes with 'var' instead of 'const'
Any symbols (including class properties) that should be visible
outside the module it's defined in need to be defined as global.
For now gjs still allows the access for 'const', but get rid of
the warnings spill now by changing it.

https://bugzilla.gnome.org/show_bug.cgi?id=785084
2017-07-18 21:52:06 +02:00
Florian Müllner
1cb644529f loginManager: Extend canSuspend() callback
The underlying logind API does not only indicate whether suspend is
available, but also whether the user is eligible for executing the
operation without further authentication. This information can be
relevant, so pass it to the callback.

https://bugzilla.gnome.org/show_bug.cgi?id=725960
2016-05-27 17:04:46 +02:00
Victor Toso
ddea54a539 ScreenShield: set LockedHint property from systemd
Logind recently got support for a hint property in Session Object to
inform if session is Locked or not. It is up to desktop environments
to keep this property up to date.

https://bugzilla.gnome.org/show_bug.cgi?id=764773
2016-05-12 15:24:06 +02:00
Mario Sanchez Prada
be78f0f36a misc: Add missing check on reply from systemd's CanSuspend D-Bus method
According to systemd logind's documentation, the CanSuspend() method
"returns 'na' in case "the operation is not available because hardware,
kernel or drivers do not support it", while "'no' is returned if the
operation is available but the user is not allowed to execute it".

See http://www.freedesktop.org/wiki/Software/systemd/logind

Thus, we need to return true here when the reply for the CanSuspend
method is neither 'no' nor 'na', or we would providing false positives
in cases where suspension is simply unsupported.

https://bugzilla.gnome.org/show_bug.cgi?id=748338
2015-04-22 23:17:45 +01:00
Florian Müllner
a244c1e987 loginManager: Kill ConsoleKit support
The code path is completely unmaintained and untested (and probably
unused as well, considering that nobody has complained about accessing
the session object's Active property which does not exist in the
ConsoleKit case).
Most of our ConsoleKit code is already a dummy anyway, just do the
same for the remaining functionality.

https://bugzilla.gnome.org/show_bug.cgi?id=686626
2014-04-25 15:53:45 +02:00
Jasper St. Pierre
70d75ca311 loginManager: Don't pass too many args to steal_fds 2014-04-15 17:53:37 -04:00
Jasper St. Pierre
be291ee4f9 loginScreen: reset greeter when coming back to login screen
When a user logs in to a wayland session, we keep the login screen
running on the X server with the login screen running in a deactivated mode.

This commit makes sure it get reactivated when the user comes back to
the VT (from user switching, logout or just ctrl-alt-f1).

https://bugzilla.gnome.org/show_bug.cgi?id=726989
2014-03-25 10:41:12 -04:00
Tim Lunn
b908a3d70a Stringify the xml definitions for E4X removal
https://bugzilla.gnome.org/show_bug.cgi?id=691409
2013-10-25 08:57:27 +11:00
Ray Strode
609a31ea46 loginManager: fix versionCompare function
It's important to compare the version components as integers,
not strings, so "10" evaulates as greater than "5"

This fixes the login screen in gnome 3.10.

https://bugzilla.gnome.org/show_bug.cgi?id=708691
2013-09-24 14:22:09 -04:00
Jasper St. Pierre
ce768241da loginManager: Remove login manager versions of PowerOff/Reboot
These don't go through gnome-session, so they don't properly update
its state machine. We should use these in the future when we want to
use logind user sessions, but for now, they're just a trap.

https://bugzilla.gnome.org/show_bug.cgi?id=706612
2013-08-22 16:40:52 -04:00
Martin Pitt
a7cd4657f5 loginManager.js: Check for logind, not for systemd
It is possible to build systemd without logind, in which case
/sys/fs/cgroup/systemd would still exist. Check for /run/systemd/seats instead,
as recommended by systemd upstream.

For details, see:
<https://mail.gnome.org/archives/desktop-devel-list/2013-March/msg00092.html>

https://bugzilla.gnome.org/show_bug.cgi?id=696252
2013-03-29 11:00:52 +01:00
Cosimo Cecchi
869e1dc241 loginManager: listen to the correct object path
Use GetSession() to get the valid object path for the current
XDG_SESSION_ID.

https://bugzilla.gnome.org/show_bug.cgi?id=696287
2013-03-25 20:53:13 -04:00
Florian Müllner
9a83662a18 loginManager: Move UnlockDialog.isSupported() here
With fallback mode dropped, we can no longer rely on gnome-screensaver
to be installed, so we'll have cases where we are unable to lock the
screen. The user menu should not show the "Lock" item in this case,
but as UnlockDialog includes UserMenu, we cannot use the existing check
without creating a circular dependency; move the function to a more
generic place to fix.

https://bugzilla.gnome.org/show_bug.cgi?id=693403
2013-03-06 16:22:07 +01:00
Adel Gadllah
b2fb84e361 Don't ask for a password on shutdown
Show a warning and the list of active users instead when
multiple sessions are present.

https://bugzilla.gnome.org/show_bug.cgi?id=693385
2013-02-11 19:39:00 +01:00
Florian Müllner
1bf996c705 loginManager: Fix canSuspend in non-logind path
It is supposed to be a NOP, but commit b91d9c2867 got it wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=693162
2013-02-08 17:29:33 +01:00
Florian Müllner
8747c0c58d loginManager: Add inhibitor API
If screen locking is enabled, the screen shield should drop down
on suspend. Currently this is achieved by either explicitly locking
the screen (when selecting "Suspend" from the user menu) or by
relying on g-s-d delaying the suspension enough time for the shield
to get into place (lid close, power button).
Systemd inhibitors offer a safer way to ensure that the screen is
locked before going to sleep, so add a small abstraction for them
in the loginManager - with inhibitors being a systemd-only feature,
the ConsoleKit path only has a dummy implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=686482
2013-02-06 01:01:52 +01:00
Florian Müllner
b91d9c2867 loginManager: Make suspend() a NOP in the ConsoleKit path
UPower will remove its suspend support eventually, and g-s-d already
depends on logind for power management.

https://bugzilla.gnome.org/show_bug.cgi?id=693162
2013-02-06 01:01:52 +01:00
Florian Müllner
e0c5a61be5 loginManager: Remove sessionActive property
It is unused after switching to GnomeSession:SessionIsActive, so
remove it together with shell_session_is_active_for_systemd().

https://bugzilla.gnome.org/show_bug.cgi?id=693161
2013-02-05 00:01:33 +01:00
Florian Müllner
1f183b8a4e loginManager: Add support for suspend()
Logind provides a Suspend method, which we should use instead of
the UPower API when available. Expose this in loginManager, using
the UPower API for the ConsoleKit implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=686482
2012-10-23 21:14:10 +02:00
Giovanni Campagna
9a7914eee9 Consolidate systemd and consolekit in a common abstract class
Various code around had different paths for ConsoleKit and
logind. Consolidate it by making an abstract class that all
callers can use, which hides the implementation details of the
two daemons.

https://bugzilla.gnome.org/show_bug.cgi?id=682096
2012-08-18 18:09:55 +02:00