Merge lp:~3v1n0/unity-settings-daemon/redirect-fdo-screensaver-calls into lp:unity-settings-daemon

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 4146
Merged at revision: 4139
Proposed branch: lp:~3v1n0/unity-settings-daemon/redirect-fdo-screensaver-calls
Merge into: lp:unity-settings-daemon
Prerequisite: lp:~3v1n0/unity-settings-daemon/remove-duplicated-dbus-proxies
Diff against target: 199 lines (+89/-28)
2 files modified
gnome-settings-daemon/org.gnome.ScreenSaver.xml (+43/-0)
plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c (+46/-28)
To merge this branch: bzr merge lp:~3v1n0/unity-settings-daemon/redirect-fdo-screensaver-calls
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+295370@code.launchpad.net

Commit message

ScreensaverProxy: redirect supported calls to gnome screensaver APIs

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work, some small questions/comments inline.

Seems like you included some small cleanups unrelated to the changeset, it's fine but it might make review easier/more sense to split that in a different commit/(upstreamable)merge request next time?

review: Needs Information
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I was actually thinking of sending upstream the whole thing, since I don't see this wrong even in Gnome environment, but I'd like to discuss with upstream.

I don't know if they just disable this plugin in gnome-shell leaving the implementation of this to the shell.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ah, code updated as well.

Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'gnome-settings-daemon/org.gnome.ScreenSaver.xml'
--- gnome-settings-daemon/org.gnome.ScreenSaver.xml 1970-01-01 00:00:00 +0000
+++ gnome-settings-daemon/org.gnome.ScreenSaver.xml 2016-05-30 18:37:12 +0000
@@ -0,0 +1,43 @@
1<!DOCTYPE node PUBLIC
2 "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
3 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
4
5<!--
6 Copyright (C) 2013 Red Hat, Inc.
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General
19 Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20-->
21
22<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
23 <!--
24 org.gnome.ScreenSaver:
25
26 An interface used for managing the lock screen.
27 -->
28 <interface name="org.gnome.ScreenSaver">
29 <method name="Lock" />
30 <method name="GetActive">
31 <arg name="active" direction="out" type="b" />
32 </method>
33 <method name="SetActive">
34 <arg name="value" direction="in" type="b" />
35 </method>
36 <method name="GetActiveTime">
37 <arg name="value" direction="out" type="u" />
38 </method>
39 <signal name="ActiveChanged">
40 <arg name="new_value" type="b" />
41 </signal>
42 </interface>
43</node>
044
=== modified file 'plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c'
--- plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c 2016-05-30 18:37:11 +0000
+++ plugins/screensaver-proxy/gsd-screensaver-proxy-manager.c 2016-05-30 18:37:12 +0000
@@ -28,15 +28,12 @@
28#include <string.h>28#include <string.h>
29#include <errno.h>29#include <errno.h>
3030
31#include <locale.h>31#include <gio/gio.h>
32
33#include <glib.h>
34#include <glib/gi18n.h>
35#include <gdk/gdk.h>
3632
37#include "gnome-settings-bus.h"33#include "gnome-settings-bus.h"
38#include "gnome-settings-profile.h"34#include "gnome-settings-profile.h"
39#include "gsd-screensaver-proxy-manager.h"35#include "gsd-screensaver-proxy-manager.h"
36#include "gsd-idle-monitor.h"
4037
41#define GSD_SCREENSAVER_PROXY_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_SCREENSAVER_PROXY_MANAGER, GsdScreensaverProxyManagerPrivate))38#define GSD_SCREENSAVER_PROXY_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_SCREENSAVER_PROXY_MANAGER, GsdScreensaverProxyManagerPrivate))
4239
@@ -135,6 +132,7 @@
135struct GsdScreensaverProxyManagerPrivate132struct GsdScreensaverProxyManagerPrivate
136{133{
137 GsdSessionManager *session;134 GsdSessionManager *session;
135 GsdScreenSaver *screensaver;
138 GDBusConnection *connection;136 GDBusConnection *connection;
139 GCancellable *bus_cancellable;137 GCancellable *bus_cancellable;
140 GDBusNodeInfo *introspection_data;138 GDBusNodeInfo *introspection_data;
@@ -194,18 +192,19 @@
194 gpointer user_data)192 gpointer user_data)
195{193{
196 GsdScreensaverProxyManager *manager = GSD_SCREENSAVER_PROXY_MANAGER (user_data);194 GsdScreensaverProxyManager *manager = GSD_SCREENSAVER_PROXY_MANAGER (user_data);
195 GError *error = NULL;
196 GVariant *ret = NULL;
197197
198 /* Check session pointer as a proxy for whether the manager is in the198 /* Check session pointer as a proxy for whether the manager is in the
199 start or stop state */199 start or stop state */
200 if (manager->priv->session == NULL) {200 if (manager->priv->session == NULL || manager->priv->screensaver == NULL) {
201 return;201 goto unimplemented;
202 }202 }
203203
204 g_debug ("Calling method '%s.%s' for ScreenSaver Proxy",204 g_debug ("Calling method '%s.%s' for ScreenSaver Proxy",
205 interface_name, method_name);205 interface_name, method_name);
206206
207 if (g_strcmp0 (method_name, "Inhibit") == 0) {207 if (g_strcmp0 (method_name, "Inhibit") == 0) {
208 GVariant *ret;
209 const char *app_id;208 const char *app_id;
210 const char *reason;209 const char *reason;
211 guint cookie;210 guint cookie;
@@ -213,12 +212,12 @@
213 g_variant_get (parameters,212 g_variant_get (parameters,
214 "(ss)", &app_id, &reason);213 "(ss)", &app_id, &reason);
215214
216 ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (G_DBUS_PROXY (manager->priv->session)),215 ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->priv->session),
217 "Inhibit",216 "Inhibit",
218 g_variant_new ("(susu)",217 g_variant_new ("(susu)",
219 app_id, 0, reason, GSM_INHIBITOR_FLAG_IDLE),218 app_id, 0, reason, GSM_INHIBITOR_FLAG_IDLE),
220 G_DBUS_CALL_FLAGS_NONE,219 G_DBUS_CALL_FLAGS_NONE,
221 -1, NULL, NULL);220 -1, NULL, &error);
222 g_variant_get (ret, "(u)", &cookie);221 g_variant_get (ret, "(u)", &cookie);
223 g_hash_table_insert (manager->priv->cookie_ht,222 g_hash_table_insert (manager->priv->cookie_ht,
224 GUINT_TO_POINTER (cookie),223 GUINT_TO_POINTER (cookie),
@@ -237,7 +236,6 @@
237 g_strdup (sender),236 g_strdup (sender),
238 GUINT_TO_POINTER (watch_id));237 GUINT_TO_POINTER (watch_id));
239 }238 }
240 g_dbus_method_invocation_return_value (invocation, ret);
241 } else if (g_strcmp0 (method_name, "UnInhibit") == 0) {239 } else if (g_strcmp0 (method_name, "UnInhibit") == 0) {
242 guint cookie;240 guint cookie;
243241
@@ -249,24 +247,41 @@
249 -1, NULL, NULL);247 -1, NULL, NULL);
250 g_debug ("Removing cookie %u from the list for %s", cookie, sender);248 g_debug ("Removing cookie %u from the list for %s", cookie, sender);
251 g_hash_table_remove (manager->priv->cookie_ht, GUINT_TO_POINTER (cookie));249 g_hash_table_remove (manager->priv->cookie_ht, GUINT_TO_POINTER (cookie));
252 g_dbus_method_invocation_return_value (invocation, NULL);250 } else if (g_strcmp0 (method_name, "Lock") == 0 ||
253 } else if (g_strcmp0 (method_name, "Throttle") == 0) {251 g_strcmp0 (method_name, "SimulateUserActivity") == 0 ||
254 g_dbus_method_invocation_return_value (invocation, NULL);252 g_strcmp0 (method_name, "GetActive") == 0 ||
255 } else if (g_strcmp0 (method_name, "UnThrottle") == 0) {253 g_strcmp0 (method_name, "GetActiveTime") == 0 ||
256 g_dbus_method_invocation_return_value (invocation, NULL);254 g_strcmp0 (method_name, "SetActive") == 0) {
257 } else if (g_strcmp0 (method_name, "Lock") == 0) {255
258 goto unimplemented;256 ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (manager->priv->screensaver),
259 } else if (g_strcmp0 (method_name, "SimulateUserActivity") == 0) {257 method_name,
260 goto unimplemented;258 parameters,
261 } else if (g_strcmp0 (method_name, "GetActive") == 0) {259 G_DBUS_CALL_FLAGS_NONE,
262 goto unimplemented;260 -1, NULL, &error);
263 } else if (g_strcmp0 (method_name, "GetActiveTime") == 0) {261
264 goto unimplemented;262 if (error == NULL && g_strcmp0 (method_name, "SetActive") == 0) {
263 g_variant_unref (ret);
264
265 /* Returning the actual Activate state here is not possible,
266 * as calling GetActive at this point might return an invalid
267 * value if the activation process is still ongoing. */
268 ret = g_variant_ref (parameters);
269 }
265 } else if (g_strcmp0 (method_name, "GetSessionIdleTime") == 0) {270 } else if (g_strcmp0 (method_name, "GetSessionIdleTime") == 0) {
266 goto unimplemented;271 GsdIdleMonitor *idle_monitor = gsd_idle_monitor_get_core ();
267 } else if (g_strcmp0 (method_name, "SetActive") == 0) {272 gint64 idle_time_ms = gsd_idle_monitor_get_idletime (idle_monitor);
268 goto unimplemented;273 ret = g_variant_new ("(u)", idle_time_ms / 1000);
269 }274 } else {
275 goto unimplemented;
276 }
277
278 if (error != NULL) {
279 g_dbus_method_invocation_return_gerror (invocation, error);
280 g_error_free (error);
281 return;
282 }
283
284 g_dbus_method_invocation_return_value (invocation, ret);
270285
271 return;286 return;
272287
@@ -354,6 +369,8 @@
354 gnome_settings_profile_start (NULL);369 gnome_settings_profile_start (NULL);
355 manager->priv->session =370 manager->priv->session =
356 gnome_settings_bus_get_session_proxy ();371 gnome_settings_bus_get_session_proxy ();
372 manager->priv->screensaver =
373 gnome_settings_bus_get_screen_saver_proxy ();
357 manager->priv->watch_ht = g_hash_table_new_full (g_str_hash,374 manager->priv->watch_ht = g_hash_table_new_full (g_str_hash,
358 g_str_equal,375 g_str_equal,
359 (GDestroyNotify) g_free,376 (GDestroyNotify) g_free,
@@ -371,6 +388,7 @@
371{388{
372 g_debug ("Stopping screensaver_proxy manager");389 g_debug ("Stopping screensaver_proxy manager");
373 g_clear_object (&manager->priv->session);390 g_clear_object (&manager->priv->session);
391 g_clear_object (&manager->priv->screensaver);
374 g_clear_pointer (&manager->priv->watch_ht, g_hash_table_destroy);392 g_clear_pointer (&manager->priv->watch_ht, g_hash_table_destroy);
375 g_clear_pointer (&manager->priv->cookie_ht, g_hash_table_destroy);393 g_clear_pointer (&manager->priv->cookie_ht, g_hash_table_destroy);
376}394}

Subscribers

People subscribed via source and target branches