[gnome-shell] loginManager: Move UnlockDialog.isSupported() here



commit 9a83662a18c352164510d67e995f9c4e19310719
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Mar 4 19:20:12 2013 +0100

    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

 js/misc/loginManager.js |   29 +++++++++++++++++++++++++++++
 js/ui/main.js           |    4 ++--
 js/ui/unlockDialog.js   |   29 -----------------------------
 3 files changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/js/misc/loginManager.js b/js/misc/loginManager.js
index 435496c..00e269b 100644
--- a/js/misc/loginManager.js
+++ b/js/misc/loginManager.js
@@ -75,6 +75,35 @@ function haveSystemd() {
     return GLib.access("/sys/fs/cgroup/systemd", 0) >= 0;
 }
 
+function versionCompare(required, reference) {
+    required = required.split('.');
+    reference = reference.split('.');
+
+    for (let i = 0; i < required.length; i++) {
+        if (required[i] != reference[i])
+            return required[i] < reference[i];
+    }
+
+    return true;
+}
+
+function canLock() {
+    try {
+        let params = GLib.Variant.new('(ss)', ['org.gnome.DisplayManager.Manager', 'Version']);
+        let result = Gio.DBus.system.call_sync('org.gnome.DisplayManager',
+                                               '/org/gnome/DisplayManager/Manager',
+                                               'org.freedesktop.DBus.Properties',
+                                               'Get', params, null,
+                                               Gio.DBusCallFlags.NONE,
+                                               -1, null);
+
+        let version = result.deep_unpack()[0].deep_unpack();
+        return versionCompare('3.5.91', version);
+    } catch(e) {
+        return false;
+    }
+}
+
 let _loginManager = null;
 
 /**
diff --git a/js/ui/main.js b/js/ui/main.js
index df40300..229acc4 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -24,6 +24,7 @@ const Panel = imports.ui.panel;
 const Params = imports.misc.params;
 const RunDialog = imports.ui.runDialog;
 const Layout = imports.ui.layout;
+const LoginManager = imports.misc.loginManager;
 const LookingGlass = imports.ui.lookingGlass;
 const NotificationDaemon = imports.ui.notificationDaemon;
 const WindowAttentionHandler = imports.ui.windowAttentionHandler;
@@ -32,7 +33,6 @@ const Scripting = imports.ui.scripting;
 const SessionMode = imports.ui.sessionMode;
 const ShellDBus = imports.ui.shellDBus;
 const ShellMountOperation = imports.ui.shellMountOperation;
-const UnlockDialog = imports.ui.unlockDialog;
 const WindowManager = imports.ui.windowManager;
 const Magnifier = imports.ui.magnifier;
 const XdndHandler = imports.ui.xdndHandler;
@@ -140,7 +140,7 @@ function startSession() {
     overview = new Overview.Overview();
     wm = new WindowManager.WindowManager();
     magnifier = new Magnifier.Magnifier();
-    if (UnlockDialog.isSupported())
+    if (LoginManager.canLock())
         screenShield = new ScreenShield.ScreenShield();
     else
         screenShield = new ScreenShield.ScreenShieldFallback();
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index 1296308..775cab5 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -27,35 +27,6 @@ const LoginDialog = imports.gdm.loginDialog;
 // The timeout before going back automatically to the lock screen (in seconds)
 const IDLE_TIMEOUT = 2 * 60;
 
-function versionCompare(required, reference) {
-    required = required.split('.');
-    reference = reference.split('.');
-
-    for (let i = 0; i < required.length; i++) {
-        if (required[i] != reference[i])
-            return required[i] < reference[i];
-    }
-
-    return true;
-}
-
-function isSupported() {
-    try {
-        let params = GLib.Variant.new('(ss)', ['org.gnome.DisplayManager.Manager', 'Version']);
-        let result = Gio.DBus.system.call_sync('org.gnome.DisplayManager',
-                                               '/org/gnome/DisplayManager/Manager',
-                                               'org.freedesktop.DBus.Properties',
-                                               'Get', params, null,
-                                               Gio.DBusCallFlags.NONE,
-                                               -1, null);
-
-        let version = result.deep_unpack()[0].deep_unpack();
-        return versionCompare('3.5.91', version);
-    } catch(e) {
-        return false;
-    }
-}
-
 const UnlockDialog = new Lang.Class({
     Name: 'UnlockDialog',
     Extends: ModalDialog.ModalDialog,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]