[gnome-shell] dbusServices/screensaver: Split out public ScreenSaver service
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] dbusServices/screensaver: Split out public ScreenSaver service
- Date: Mon, 7 Dec 2020 16:27:43 +0000 (UTC)
commit af5aff32514d7236d3261670a5ed0c087ee3abdd
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Dec 4 20:40:13 2020 +0100
dbusServices/screensaver: Split out public ScreenSaver service
Commit 799bbdb50 split out the public Fdo notification service, so
that any app with permission to talk to org.freedesktop.Notifications
will in fact be limited to that service.
To a somewhat lesser extent this applies to the org.gnome.ScreenSaver
service as well, which some applications still use instead of the
Inhibit portal.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3452
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1520>
js/dbusServices/meson.build | 1 +
.../org.gnome.ScreenSaver.src.gresource.xml | 11 ++++
js/dbusServices/screensaver/main.js | 11 ++++
js/dbusServices/screensaver/screenSaverService.js | 68 ++++++++++++++++++++++
js/ui/shellDBus.js | 3 +-
5 files changed, 93 insertions(+), 1 deletion(-)
---
diff --git a/js/dbusServices/meson.build b/js/dbusServices/meson.build
index 2f047bb527..68e8bd12de 100644
--- a/js/dbusServices/meson.build
+++ b/js/dbusServices/meson.build
@@ -6,6 +6,7 @@ launcherconf.set('libdir', libdir)
dbus_services = {
'org.gnome.Shell.Extensions': 'extensions',
'org.gnome.Shell.Notifications': 'notifications',
+ 'org.gnome.ScreenSaver': 'screensaver',
}
if enable_recorder
diff --git a/js/dbusServices/org.gnome.ScreenSaver.src.gresource.xml
b/js/dbusServices/org.gnome.ScreenSaver.src.gresource.xml
new file mode 100644
index 0000000000..834167b955
--- /dev/null
+++ b/js/dbusServices/org.gnome.ScreenSaver.src.gresource.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/ScreenSaver/js">
+ <file>main.js</file>
+ <file>screenSaverService.js</file>
+ <file>dbusService.js</file>
+
+ <file>misc/config.js</file>
+ <file>misc/fileUtils.js</file>
+ </gresource>
+</gresources>
diff --git a/js/dbusServices/screensaver/main.js b/js/dbusServices/screensaver/main.js
new file mode 100644
index 0000000000..2a08d14038
--- /dev/null
+++ b/js/dbusServices/screensaver/main.js
@@ -0,0 +1,11 @@
+/* exported main */
+
+const { DBusService } = imports.dbusService;
+const { ScreenSaverService } = imports.screenSaverService;
+
+function main() {
+ const service = new DBusService(
+ 'org.gnome.ScreenSaver',
+ new ScreenSaverService());
+ service.run();
+}
diff --git a/js/dbusServices/screensaver/screenSaverService.js
b/js/dbusServices/screensaver/screenSaverService.js
new file mode 100644
index 0000000000..571e64e50e
--- /dev/null
+++ b/js/dbusServices/screensaver/screenSaverService.js
@@ -0,0 +1,68 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+/* exported ScreenSaverService */
+
+const { Gio, GLib } = imports.gi;
+
+const { loadInterfaceXML } = imports.misc.fileUtils;
+const { ServiceImplementation } = imports.dbusService;
+
+const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver');
+const ScreenSaverProxy = Gio.DBusProxy.makeProxyWrapper(ScreenSaverIface);
+
+var ScreenSaverService = class extends ServiceImplementation {
+ constructor() {
+ super(ScreenSaverIface, '/org/gnome/ScreenSaver');
+
+ this._proxy = new ScreenSaverProxy(Gio.DBus.session,
+ 'org.gnome.Shell.ScreenShield',
+ '/org/gnome/ScreenSaver',
+ (proxy, error) => {
+ if (error)
+ log(error.message);
+ });
+
+ this._proxy.connectSignal('ActiveChanged',
+ (proxy, sender, params) => {
+ this._dbusImpl.emit_signal('ActiveChanged',
+ new GLib.Variant('(b)', params));
+ });
+ this._proxy.connectSignal('WakeUpScreen',
+ () => this._dbusImpl.emit_signal('WakeUpScreen', null));
+ }
+
+ LockAsync(params, invocation) {
+ this._proxy.LockRemote(...params, (res, error) => {
+ if (this._handleError(invocation, error))
+ return;
+
+ invocation.return_value(null);
+ });
+ }
+
+ GetActiveAsync(params, invocation) {
+ this._proxy.GetActiveRemote(...params, (res, error) => {
+ if (this._handleError(invocation, error))
+ return;
+
+ invocation.return_value(new GLib.Variant('(b)', res));
+ });
+ }
+
+ SetActiveAsync(params, invocation) {
+ this._proxy.SetActiveRemote(...params, (res, error) => {
+ if (this._handleError(invocation, error))
+ return;
+
+ invocation.return_value(null);
+ });
+ }
+
+ GetActiveTimeAsync(params, invocation) {
+ this._proxy.GetActiveTimeRemote(...params, (res, error) => {
+ if (this._handleError(invocation, error))
+ return;
+
+ invocation.return_value(new GLib.Variant('(u)', res));
+ });
+ }
+};
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index f7b542b290..181bd16310 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -367,7 +367,8 @@ var ScreenSaverDBus = class {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
- Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
+ Gio.DBus.session.own_name('org.gnome.Shell.ScreenShield',
+ Gio.BusNameOwnerFlags.NONE, null, null);
}
LockAsync(parameters, invocation) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]