From 1cb644529f49db0ff378dcd39ad555a35b763294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 26 May 2016 22:20:50 +0200 Subject: [PATCH] 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 --- js/misc/loginManager.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js index 7db94d406..3e3df3753 100644 --- a/js/misc/loginManager.js +++ b/js/misc/loginManager.js @@ -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) {