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
This commit is contained in:
Florian Müllner 2016-05-26 22:20:50 +02:00
parent 6cff0fd994
commit 1cb644529f

View File

@ -134,10 +134,13 @@ const LoginManagerSystemd = new Lang.Class({
canSuspend: function(asyncCallback) {
this._proxy.CanSuspendRemote(function(result, error) {
if (error)
asyncCallback(false);
else
asyncCallback(result[0] != 'no' && result[0] != 'na');
if (error) {
asyncCallback(false, false);
} else {
let needsAuth = result[0] == 'challenge';
let canSuspend = needsAuth || result[0] == 'yes';
asyncCallback(canSuspend, needsAuth);
}
});
},
@ -190,7 +193,7 @@ const LoginManagerDummy = new Lang.Class({
},
canSuspend: function(asyncCallback) {
asyncCallback(false);
asyncCallback(false, false);
},
listSessions: function(asyncCallback) {