components/gnome/gnome-shell/patches/01-consolekit.patch
author Niveditha Rau <Niveditha.Rau@Oracle.COM>
Fri, 28 Oct 2016 17:56:16 -0700
changeset 7206 23066e5fef27
permissions -rw-r--r--
23245637 Deliver gnome-shell 3.18.3 in Solaris PSARC/2016/396 GNOME 3 Window Manager Bundle

Restore support for ConsoleKit as an alternative to requiring systemd.

Not suitable for upstream as they deprecated & removed ConsoleKit support.

--- gnome-shell-3.18.0/js/misc/loginManager.js	Mon Nov  2 12:49:09 2015
+++ gnome-shell-3.18.0/js/misc/loginManager.js	Mon Nov  2 12:51:59 2015
@@ -46,6 +46,33 @@
 const SystemdLoginManager = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
 const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
 
+const ConsoleKitManagerIface = '<node> \
+<interface name="org.freedesktop.ConsoleKit.Manager"> \
+<method name="CanRestart"> \
+    <arg type="b" direction="out"/> \
+</method> \
+<method name="CanStop"> \
+    <arg type="b" direction="out"/> \
+</method> \
+<method name="Restart" /> \
+<method name="Stop" /> \
+<method name="GetCurrentSession"> \
+    <arg type="o" direction="out" /> \
+</method> \
+</interface> \
+</node>';
+
+const ConsoleKitSessionIface = '<node> \
+<interface name="org.freedesktop.ConsoleKit.Session"> \
+<signal name="Lock" /> \
+<signal name="Unlock" /> \
+</interface> \
+</node>';
+
+const ConsoleKitSession = Gio.DBusProxy.makeProxyWrapper(ConsoleKitSessionIface);
+const ConsoleKitManager = Gio.DBusProxy.makeProxyWrapper(ConsoleKitManagerIface);
+
+
 function haveSystemd() {
     return GLib.access("/run/systemd/seats", 0) >= 0;
 }
@@ -75,7 +102,7 @@
                                                -1, null);
 
         let version = result.deep_unpack()[0].deep_unpack();
-        return haveSystemd() && versionCompare('3.5.91', version);
+        return versionCompare('3.5.91', version);
     } catch(e) {
         return false;
     }
@@ -93,7 +120,7 @@
         if (haveSystemd())
             _loginManager = new LoginManagerSystemd();
         else
-            _loginManager = new LoginManagerDummy();
+            _loginManager = new LoginManagerConsoleKit();
     }
 
     return _loginManager;
@@ -177,10 +204,35 @@
 });
 Signals.addSignalMethods(LoginManagerSystemd.prototype);
 
-const LoginManagerDummy = new Lang.Class({
-    Name: 'LoginManagerDummy',
+const LoginManagerConsoleKit = new Lang.Class({
+    Name: 'LoginManagerConsoleKit',
 
+    _init: function() {
+        this._proxy = new ConsoleKitManager(Gio.DBus.system,
+                                            'org.freedesktop.ConsoleKit',
+                                            '/org/freedesktop/ConsoleKit/Manager');
+    },
+
+    // Having this function is a bit of a hack since the Systemd and ConsoleKit
+    // session objects have different interfaces - but in both cases there are
+    // Lock/Unlock signals, and that's all we count upon at the moment.
     getCurrentSessionProxy: function(callback) {
+        if (this._currentSession) {
+            callback (this._currentSession);
+            return;
+        }
+
+        this._proxy.GetCurrentSessionRemote(Lang.bind(this,
+            function(result, error) {
+                if (error) {
+                    logError(error, 'Could not get a proxy for the current session');
+                } else {
+                    this._currentSession = new ConsoleKitSession(Gio.DBus.system,
+                                                                 'org.freedesktop.ConsoleKit',
+                                                                 result[0]);
+                    callback(this._currentSession);
+                }
+            }));
         // we could return a DummySession object that fakes whatever callers
         // expect (at the time of writing: connect() and connectSignal()
         // methods), but just never calling the callback should be safer
@@ -203,4 +255,4 @@
         callback(null);
     }
 });
-Signals.addSignalMethods(LoginManagerDummy.prototype);
+Signals.addSignalMethods(LoginManagerConsoleKit.prototype);