diff options
author | Andreas Müller <schnitzeltony@googlemail.com> | 2014-10-20 15:27:43 +0200 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2014-10-27 12:50:00 +0100 |
commit | 6c1ace80c0bdcb7c67cc766ea23c6ea9beab9164 (patch) | |
tree | 9a2303585b4fb4a01223e7c510cd6524df9662b5 /meta-xfce | |
parent | 0ee5bea84105040ae54bcbc5d2baac7be80bc801 (diff) | |
download | meta-openembedded-6c1ace80c0bdcb7c67cc766ea23c6ea9beab9164.tar.gz |
xfce4-power-manager: update to 1.4.1 to fix power button
with 1.2.0 pressing power button shuts down independent of the setting in
xfce4-power-manager
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-xfce')
-rw-r--r-- | meta-xfce/recipes-xfce/xfce4-power-manager/files/0001-Add-shutdown-reboot-functionality-for-systemd.patch | 677 | ||||
-rw-r--r-- | meta-xfce/recipes-xfce/xfce4-power-manager/xfce4-power-manager_1.4.1.bb (renamed from meta-xfce/recipes-xfce/xfce4-power-manager/xfce4-power-manager_1.2.0.bb) | 29 |
2 files changed, 19 insertions, 687 deletions
diff --git a/meta-xfce/recipes-xfce/xfce4-power-manager/files/0001-Add-shutdown-reboot-functionality-for-systemd.patch b/meta-xfce/recipes-xfce/xfce4-power-manager/files/0001-Add-shutdown-reboot-functionality-for-systemd.patch deleted file mode 100644 index d5c5487b8..000000000 --- a/meta-xfce/recipes-xfce/xfce4-power-manager/files/0001-Add-shutdown-reboot-functionality-for-systemd.patch +++ /dev/null | |||
@@ -1,677 +0,0 @@ | |||
1 | From 023333688f73ed26097c693d43f76e4b7d5698e2 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com> | ||
3 | Date: Fri, 7 Jun 2013 18:38:42 +0200 | ||
4 | Subject: [PATCH] Add shutdown/reboot functionality for systemd | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Upstream-Status: Submitted [2] | ||
10 | |||
11 | [1] http://git.xfce.org/xfce/xfce4-session/commit/?id=ae28aef315a7a6b90f1649ce6d1f30b842791cbf | ||
12 | [2] https://bugzilla.xfce.org/show_bug.cgi?id=10167 | ||
13 | |||
14 | Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com> | ||
15 | --- | ||
16 | configure.ac | 2 + | ||
17 | src/Makefile.am | 14 +++- | ||
18 | src/xfpm-manager.c | 29 ++++++- | ||
19 | src/xfpm-power.c | 66 ++++++++++++++- | ||
20 | src/xfpm-systemd.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
21 | src/xfpm-systemd.h | 60 +++++++++++++ | ||
22 | 6 files changed, 411 insertions(+), 5 deletions(-) | ||
23 | create mode 100644 src/xfpm-systemd.c | ||
24 | create mode 100644 src/xfpm-systemd.h | ||
25 | |||
26 | diff --git a/configure.ac b/configure.ac | ||
27 | index 633b340..1db2036 100644 | ||
28 | --- a/configure.ac | ||
29 | +++ b/configure.ac | ||
30 | @@ -95,6 +95,8 @@ if test "x$ac_cv_enable_polkit" = "xno"; then | ||
31 | polkit="no" | ||
32 | else | ||
33 | AC_MSG_RESULT([yes]) | ||
34 | + m4_define([polkit_minimum_version], [0.100]) | ||
35 | + XDT_CHECK_PACKAGE([SYSTEMD], [polkit-gobject-1], [polkit_minimum_version]) | ||
36 | AC_DEFINE(ENABLE_POLKIT, 1 , [PolicyKit support]) | ||
37 | polkit="yes" | ||
38 | fi | ||
39 | diff --git a/src/Makefile.am b/src/Makefile.am | ||
40 | index 0435bed..9b7fdd0 100644 | ||
41 | --- a/src/Makefile.am | ||
42 | +++ b/src/Makefile.am | ||
43 | @@ -18,8 +18,6 @@ xfce4_power_manager_SOURCES = \ | ||
44 | xfpm-xfconf.h \ | ||
45 | xfpm-disks.c \ | ||
46 | xfpm-disks.h \ | ||
47 | - xfpm-console-kit.c \ | ||
48 | - xfpm-console-kit.h \ | ||
49 | egg-idletime.c \ | ||
50 | egg-idletime.h \ | ||
51 | xfpm-backlight.c \ | ||
52 | @@ -39,6 +37,16 @@ xfce4_power_manager_SOURCES = \ | ||
53 | xfpm-errors.c \ | ||
54 | xfpm-errors.h | ||
55 | |||
56 | +if ENABLE_POLKIT | ||
57 | +xfce4_power_manager_SOURCES += \ | ||
58 | + xfpm-systemd.c \ | ||
59 | + xfpm-systemd.h | ||
60 | +else | ||
61 | +xfce4_power_manager_SOURCES += \ | ||
62 | + xfpm-console-kit.c \ | ||
63 | + xfpm-console-kit.h | ||
64 | +endif | ||
65 | + | ||
66 | xfce4_power_manager_CFLAGS = \ | ||
67 | -I$(top_srcdir) \ | ||
68 | -I$(top_srcdir)/common \ | ||
69 | @@ -52,6 +60,7 @@ xfce4_power_manager_CFLAGS = \ | ||
70 | $(LIBXFCE4UI_CFLAGS) \ | ||
71 | $(XFCONF_CFLAGS) \ | ||
72 | $(LIBNOTIFY_CFLAGS) \ | ||
73 | + $(SYSTEMD_CFLAGS) \ | ||
74 | $(XRANDR_CFLAGS) \ | ||
75 | $(DPMS_CFLAGS) \ | ||
76 | $(PLATFORM_CPPFLAGS) \ | ||
77 | @@ -70,6 +79,7 @@ xfce4_power_manager_LDADD = \ | ||
78 | $(LIBXFCE4UI_LIBS) \ | ||
79 | $(XFCONF_LIBS) \ | ||
80 | $(LIBNOTIFY_LIBS) \ | ||
81 | + $(SYSTEMD_LIBS) \ | ||
82 | $(XRANDR_LIBS) \ | ||
83 | $(DPMS_LIBS) | ||
84 | |||
85 | diff --git a/src/xfpm-manager.c b/src/xfpm-manager.c | ||
86 | index 472ee3e..9bfb53c 100644 | ||
87 | --- a/src/xfpm-manager.c | ||
88 | +++ b/src/xfpm-manager.c | ||
89 | @@ -43,7 +43,6 @@ | ||
90 | #include "xfpm-disks.h" | ||
91 | #include "xfpm-dpms.h" | ||
92 | #include "xfpm-manager.h" | ||
93 | -#include "xfpm-console-kit.h" | ||
94 | #include "xfpm-button.h" | ||
95 | #include "xfpm-backlight.h" | ||
96 | #include "xfpm-inhibit.h" | ||
97 | @@ -58,6 +57,12 @@ | ||
98 | #include "xfpm-enum-types.h" | ||
99 | #include "xfpm-dbus-monitor.h" | ||
100 | |||
101 | +#ifdef ENABLE_POLKIT | ||
102 | +#include "xfpm-systemd.h" | ||
103 | +#else | ||
104 | +#include "xfpm-console-kit.h" | ||
105 | +#endif | ||
106 | + | ||
107 | static void xfpm_manager_finalize (GObject *object); | ||
108 | |||
109 | static void xfpm_manager_dbus_class_init (XfpmManagerClass *klass); | ||
110 | @@ -80,7 +85,11 @@ struct XfpmManagerPrivate | ||
111 | XfpmButton *button; | ||
112 | XfpmXfconf *conf; | ||
113 | XfpmBacklight *backlight; | ||
114 | +#ifdef ENABLE_POLKIT | ||
115 | + XfpmSystemd *systemd; | ||
116 | +#else | ||
117 | XfpmConsoleKit *console; | ||
118 | +#endif | ||
119 | XfpmDBusMonitor *monitor; | ||
120 | XfpmDisks *disks; | ||
121 | XfpmInhibit *inhibit; | ||
122 | @@ -131,7 +140,11 @@ xfpm_manager_finalize (GObject *object) | ||
123 | g_object_unref (manager->priv->button); | ||
124 | g_object_unref (manager->priv->conf); | ||
125 | g_object_unref (manager->priv->client); | ||
126 | +#ifdef ENABLE_POLKIT | ||
127 | + g_object_unref (manager->priv->systemd); | ||
128 | +#else | ||
129 | g_object_unref (manager->priv->console); | ||
130 | +#endif | ||
131 | g_object_unref (manager->priv->monitor); | ||
132 | g_object_unref (manager->priv->disks); | ||
133 | g_object_unref (manager->priv->inhibit); | ||
134 | @@ -201,7 +214,11 @@ static void | ||
135 | xfpm_manager_shutdown (XfpmManager *manager) | ||
136 | { | ||
137 | GError *error = NULL; | ||
138 | +#ifdef ENABLE_POLKIT | ||
139 | + xfpm_systemd_shutdown (manager->priv->systemd, &error ); | ||
140 | +#else | ||
141 | xfpm_console_kit_shutdown (manager->priv->console, &error ); | ||
142 | +#endif | ||
143 | |||
144 | if ( error ) | ||
145 | { | ||
146 | @@ -521,7 +538,11 @@ void xfpm_manager_start (XfpmManager *manager) | ||
147 | manager->priv->power = xfpm_power_get (); | ||
148 | manager->priv->button = xfpm_button_new (); | ||
149 | manager->priv->conf = xfpm_xfconf_new (); | ||
150 | +#ifdef ENABLE_POLKIT | ||
151 | + manager->priv->systemd = xfpm_systemd_new (); | ||
152 | +#else | ||
153 | manager->priv->console = xfpm_console_kit_new (); | ||
154 | +#endif | ||
155 | manager->priv->monitor = xfpm_dbus_monitor_new (); | ||
156 | manager->priv->disks = xfpm_disks_new (); | ||
157 | manager->priv->inhibit = xfpm_inhibit_new (); | ||
158 | @@ -603,9 +624,15 @@ GHashTable *xfpm_manager_get_config (XfpmManager *manager) | ||
159 | |||
160 | hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); | ||
161 | |||
162 | +#ifdef ENABLE_POLKIT | ||
163 | + g_object_get (G_OBJECT (manager->priv->systemd), | ||
164 | + "can-shutdown", &can_shutdown, | ||
165 | + NULL); | ||
166 | +#else | ||
167 | g_object_get (G_OBJECT (manager->priv->console), | ||
168 | "can-shutdown", &can_shutdown, | ||
169 | NULL); | ||
170 | +#endif | ||
171 | |||
172 | g_object_get (G_OBJECT (manager->priv->power), | ||
173 | "auth-suspend", &auth_suspend, | ||
174 | diff --git a/src/xfpm-power.c b/src/xfpm-power.c | ||
175 | index 796bef8..391c7fc 100644 | ||
176 | --- a/src/xfpm-power.c | ||
177 | +++ b/src/xfpm-power.c | ||
178 | @@ -39,7 +39,6 @@ | ||
179 | #include "xfpm-xfconf.h" | ||
180 | #include "xfpm-notify.h" | ||
181 | #include "xfpm-errors.h" | ||
182 | -#include "xfpm-console-kit.h" | ||
183 | #include "xfpm-inhibit.h" | ||
184 | #include "xfpm-polkit.h" | ||
185 | #include "xfpm-network-manager.h" | ||
186 | @@ -51,6 +50,12 @@ | ||
187 | #include "xfpm-enum-types.h" | ||
188 | #include "egg-idletime.h" | ||
189 | |||
190 | +#ifdef ENABLE_POLKIT | ||
191 | +#include "xfpm-systemd.h" | ||
192 | +#else | ||
193 | +#include "xfpm-console-kit.h" | ||
194 | +#endif | ||
195 | + | ||
196 | static void xfpm_power_finalize (GObject *object); | ||
197 | |||
198 | static void xfpm_power_get_property (GObject *object, | ||
199 | @@ -75,7 +80,11 @@ struct XfpmPowerPrivate | ||
200 | |||
201 | GHashTable *hash; | ||
202 | |||
203 | +#ifdef ENABLE_POLKIT | ||
204 | + XfpmSystemd *systemd; | ||
205 | +#else | ||
206 | XfpmConsoleKit *console; | ||
207 | +#endif | ||
208 | XfpmInhibit *inhibit; | ||
209 | XfpmXfconf *conf; | ||
210 | GtkStatusIcon *adapter_icon; | ||
211 | @@ -680,9 +689,15 @@ xfpm_power_add_actions_to_notification (XfpmPower *power, NotifyNotification *n) | ||
212 | { | ||
213 | gboolean can_shutdown; | ||
214 | |||
215 | +#ifdef ENABLE_POLKIT | ||
216 | + g_object_get (G_OBJECT (power->priv->systemd), | ||
217 | + "can-shutdown", &can_shutdown, | ||
218 | + NULL); | ||
219 | +#else | ||
220 | g_object_get (G_OBJECT (power->priv->console), | ||
221 | "can-shutdown", &can_shutdown, | ||
222 | NULL); | ||
223 | +#endif | ||
224 | |||
225 | if ( power->priv->can_hibernate && power->priv->auth_hibernate ) | ||
226 | { | ||
227 | @@ -756,9 +771,15 @@ xfpm_power_show_critical_action_gtk (XfpmPower *power) | ||
228 | const gchar *message; | ||
229 | gboolean can_shutdown; | ||
230 | |||
231 | +#ifdef ENABLE_POLKIT | ||
232 | + g_object_get (G_OBJECT (power->priv->systemd), | ||
233 | + "can-shutdown", &can_shutdown, | ||
234 | + NULL); | ||
235 | +#else | ||
236 | g_object_get (G_OBJECT (power->priv->console), | ||
237 | "can-shutdown", &can_shutdown, | ||
238 | NULL); | ||
239 | +#endif | ||
240 | |||
241 | message = _("System is running on low power. "\ | ||
242 | "Save your work to avoid losing data"); | ||
243 | @@ -1327,7 +1348,11 @@ xfpm_power_init (XfpmPower *power) | ||
244 | power->priv->inhibit = xfpm_inhibit_new (); | ||
245 | power->priv->notify = xfpm_notify_new (); | ||
246 | power->priv->conf = xfpm_xfconf_new (); | ||
247 | +#ifdef ENABLE_POLKIT | ||
248 | + power->priv->systemd = xfpm_systemd_new (); | ||
249 | +#else | ||
250 | power->priv->console = xfpm_console_kit_new (); | ||
251 | +#endif | ||
252 | |||
253 | g_signal_connect_swapped (power->priv->conf, "notify::" SHOW_TRAY_ICON_CFG, | ||
254 | G_CALLBACK (xfpm_power_refresh_adaptor_visible), power); | ||
255 | @@ -1445,7 +1470,11 @@ xfpm_power_finalize (GObject *object) | ||
256 | g_object_unref (power->priv->inhibit); | ||
257 | g_object_unref (power->priv->notify); | ||
258 | g_object_unref (power->priv->conf); | ||
259 | +#ifdef ENABLE_POLKIT | ||
260 | + g_object_unref (power->priv->systemd); | ||
261 | +#else | ||
262 | g_object_unref (power->priv->console); | ||
263 | +#endif | ||
264 | |||
265 | xfpm_power_hide_adapter_icon (power); | ||
266 | |||
267 | @@ -1607,9 +1636,15 @@ static gboolean xfpm_power_dbus_shutdown (XfpmPower *power, | ||
268 | { | ||
269 | gboolean can_reboot; | ||
270 | |||
271 | +#ifdef ENABLE_POLKIT | ||
272 | + g_object_get (G_OBJECT (power->priv->systemd), | ||
273 | + "can-shutdown", &can_reboot, | ||
274 | + NULL); | ||
275 | +#else | ||
276 | g_object_get (G_OBJECT (power->priv->console), | ||
277 | "can-shutdown", &can_reboot, | ||
278 | NULL); | ||
279 | +#endif | ||
280 | |||
281 | if ( !can_reboot) | ||
282 | { | ||
283 | @@ -1618,7 +1653,11 @@ static gboolean xfpm_power_dbus_shutdown (XfpmPower *power, | ||
284 | return FALSE; | ||
285 | } | ||
286 | |||
287 | +#ifdef ENABLE_POLKIT | ||
288 | + xfpm_systemd_shutdown (power->priv->systemd, error); | ||
289 | +#else | ||
290 | xfpm_console_kit_shutdown (power->priv->console, error); | ||
291 | +#endif | ||
292 | |||
293 | return TRUE; | ||
294 | } | ||
295 | @@ -1628,9 +1667,15 @@ static gboolean xfpm_power_dbus_reboot (XfpmPower *power, | ||
296 | { | ||
297 | gboolean can_reboot; | ||
298 | |||
299 | +#ifdef ENABLE_POLKIT | ||
300 | + g_object_get (G_OBJECT (power->priv->systemd), | ||
301 | + "can-restart", &can_reboot, | ||
302 | + NULL); | ||
303 | +#else | ||
304 | g_object_get (G_OBJECT (power->priv->console), | ||
305 | "can-restart", &can_reboot, | ||
306 | NULL); | ||
307 | +#endif | ||
308 | |||
309 | if ( !can_reboot) | ||
310 | { | ||
311 | @@ -1639,7 +1684,11 @@ static gboolean xfpm_power_dbus_reboot (XfpmPower *power, | ||
312 | return FALSE; | ||
313 | } | ||
314 | |||
315 | +#ifdef ENABLE_POLKIT | ||
316 | + xfpm_systemd_reboot (power->priv->systemd, error); | ||
317 | +#else | ||
318 | xfpm_console_kit_reboot (power->priv->console, error); | ||
319 | +#endif | ||
320 | |||
321 | return TRUE; | ||
322 | } | ||
323 | @@ -1694,10 +1743,16 @@ static gboolean xfpm_power_dbus_can_reboot (XfpmPower * power, | ||
324 | gboolean * OUT_can_reboot, | ||
325 | GError ** error) | ||
326 | { | ||
327 | +#ifdef ENABLE_POLKIT | ||
328 | + g_object_get (G_OBJECT (power->priv->systemd), | ||
329 | + "can-reboot", OUT_can_reboot, | ||
330 | + NULL); | ||
331 | +#else | ||
332 | g_object_get (G_OBJECT (power->priv->console), | ||
333 | "can-reboot", OUT_can_reboot, | ||
334 | NULL); | ||
335 | - | ||
336 | +#endif | ||
337 | + | ||
338 | return TRUE; | ||
339 | } | ||
340 | |||
341 | @@ -1705,9 +1760,16 @@ static gboolean xfpm_power_dbus_can_shutdown (XfpmPower * power, | ||
342 | gboolean * OUT_can_shutdown, | ||
343 | GError ** error) | ||
344 | { | ||
345 | +#ifdef ENABLE_POLKIT | ||
346 | + g_object_get (G_OBJECT (power->priv->systemd), | ||
347 | + "can-shutdown", OUT_can_shutdown, | ||
348 | + NULL); | ||
349 | +#else | ||
350 | g_object_get (G_OBJECT (power->priv->console), | ||
351 | "can-shutdown", OUT_can_shutdown, | ||
352 | NULL); | ||
353 | +#endif | ||
354 | + | ||
355 | return TRUE; | ||
356 | } | ||
357 | |||
358 | diff --git a/src/xfpm-systemd.c b/src/xfpm-systemd.c | ||
359 | new file mode 100644 | ||
360 | index 0000000..cc1cba1 | ||
361 | --- /dev/null | ||
362 | +++ b/src/xfpm-systemd.c | ||
363 | @@ -0,0 +1,245 @@ | ||
364 | +/* | ||
365 | + * * Copyright (C) 2009-2011 Ali <aliov@xfce.org> | ||
366 | + * * Copyright (C) 2013 Andreas Müller <schnitzeltony@googlemail.com> | ||
367 | + * | ||
368 | + * Licensed under the GNU General Public License Version 2 | ||
369 | + * | ||
370 | + * This program is free software; you can redistribute it and/or modify | ||
371 | + * it under the terms of the GNU General Public License as published by | ||
372 | + * the Free Software Foundation; either version 2 of the License, or | ||
373 | + * (at your option) any later version. | ||
374 | + * | ||
375 | + * This program is distributed in the hope that it will be useful, | ||
376 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
377 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
378 | + * GNU General Public License for more details. | ||
379 | + * | ||
380 | + * You should have received a copy of the GNU General Public License | ||
381 | + * along with this program; if not, write to the Free Software | ||
382 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
383 | + */ | ||
384 | + | ||
385 | +#ifdef HAVE_CONFIG_H | ||
386 | +#include <config.h> | ||
387 | +#endif | ||
388 | + | ||
389 | +#include <stdio.h> | ||
390 | +#include <stdlib.h> | ||
391 | +#include <string.h> | ||
392 | + | ||
393 | +#include <dbus/dbus-glib.h> | ||
394 | +#include <polkit/polkit.h> | ||
395 | + | ||
396 | +#include "xfpm-systemd.h" | ||
397 | + | ||
398 | + | ||
399 | +static void xfpm_systemd_finalize (GObject *object); | ||
400 | + | ||
401 | +static void xfpm_systemd_get_property (GObject *object, | ||
402 | + guint prop_id, | ||
403 | + GValue *value, | ||
404 | + GParamSpec *pspec); | ||
405 | + | ||
406 | +#define XFPM_SYSTEMD_GET_PRIVATE(o) \ | ||
407 | +(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_SYSTEMD, XfpmSystemdPrivate)) | ||
408 | + | ||
409 | +struct XfpmSystemdPrivate | ||
410 | +{ | ||
411 | + gboolean can_shutdown; | ||
412 | + gboolean can_restart; | ||
413 | + | ||
414 | + PolkitAuthority *authority; | ||
415 | + PolkitSubject *subject; | ||
416 | +}; | ||
417 | + | ||
418 | +enum | ||
419 | +{ | ||
420 | + PROP_0, | ||
421 | + PROP_CAN_RESTART, | ||
422 | + PROP_CAN_SHUTDOWN | ||
423 | +}; | ||
424 | + | ||
425 | +G_DEFINE_TYPE (XfpmSystemd, xfpm_systemd, G_TYPE_OBJECT) | ||
426 | + | ||
427 | +#define SYSTEMD_DBUS_NAME "org.freedesktop.login1" | ||
428 | +#define SYSTEMD_DBUS_PATH "/org/freedesktop/login1" | ||
429 | +#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager" | ||
430 | +#define SYSTEMD_REBOOT_ACTION "Reboot" | ||
431 | +#define SYSTEMD_POWEROFF_ACTION "PowerOff" | ||
432 | +#define SYSTEMD_REBOOT_TEST "org.freedesktop.login1.reboot" | ||
433 | +#define SYSTEMD_POWEROFF_TEST "org.freedesktop.login1.power-off" | ||
434 | + | ||
435 | +static void | ||
436 | +xfpm_systemd_class_init (XfpmSystemdClass *klass) | ||
437 | +{ | ||
438 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
439 | + | ||
440 | + object_class->finalize = xfpm_systemd_finalize; | ||
441 | + | ||
442 | + object_class->get_property = xfpm_systemd_get_property; | ||
443 | + | ||
444 | + g_object_class_install_property (object_class, | ||
445 | + PROP_CAN_RESTART, | ||
446 | + g_param_spec_boolean ("can-restart", | ||
447 | + NULL, NULL, | ||
448 | + FALSE, | ||
449 | + G_PARAM_READABLE)); | ||
450 | + | ||
451 | + g_object_class_install_property (object_class, | ||
452 | + PROP_CAN_SHUTDOWN, | ||
453 | + g_param_spec_boolean ("can-shutdown", | ||
454 | + NULL, NULL, | ||
455 | + FALSE, | ||
456 | + G_PARAM_READABLE)); | ||
457 | + | ||
458 | + g_type_class_add_private (klass, sizeof (XfpmSystemdPrivate)); | ||
459 | +} | ||
460 | + | ||
461 | +static gboolean | ||
462 | +xfpm_systemd_can_method (XfpmSystemd *systemd, | ||
463 | + gboolean *can_method, | ||
464 | + const gchar *method) | ||
465 | +{ | ||
466 | + PolkitAuthorizationResult *res; | ||
467 | + GError *local_error = NULL; | ||
468 | + | ||
469 | + *can_method = FALSE; | ||
470 | + res = polkit_authority_check_authorization_sync (systemd->priv->authority, | ||
471 | + systemd->priv->subject, | ||
472 | + method, | ||
473 | + NULL, | ||
474 | + POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE, | ||
475 | + NULL, | ||
476 | + &local_error); | ||
477 | + if ( local_error ) | ||
478 | + { | ||
479 | + g_critical ("Unable to get %s : %s", method, local_error->message); | ||
480 | + g_error_free (local_error); | ||
481 | + } | ||
482 | + | ||
483 | + if(res) | ||
484 | + { | ||
485 | + *can_method = polkit_authorization_result_get_is_authorized (res) || | ||
486 | + polkit_authorization_result_get_is_challenge (res); | ||
487 | + g_object_unref (G_OBJECT (res)); | ||
488 | + } | ||
489 | +} | ||
490 | + | ||
491 | +static void | ||
492 | +xfpm_systemd_init (XfpmSystemd *systemd) | ||
493 | +{ | ||
494 | + PolkitAuthorizationResult *res; | ||
495 | + | ||
496 | + systemd->priv = XFPM_SYSTEMD_GET_PRIVATE (systemd); | ||
497 | + systemd->priv->authority = polkit_authority_get_sync (NULL, NULL); | ||
498 | + systemd->priv->subject = polkit_unix_process_new (getpid()); | ||
499 | + systemd->priv->can_shutdown = FALSE; | ||
500 | + systemd->priv->can_restart = FALSE; | ||
501 | + | ||
502 | + if(systemd->priv->authority && systemd->priv->subject) | ||
503 | + { | ||
504 | + xfpm_systemd_can_method (systemd, | ||
505 | + &systemd->priv->can_shutdown, | ||
506 | + SYSTEMD_POWEROFF_TEST); | ||
507 | + xfpm_systemd_can_method (systemd, | ||
508 | + &systemd->priv->can_restart, | ||
509 | + SYSTEMD_REBOOT_TEST); | ||
510 | + } | ||
511 | +} | ||
512 | + | ||
513 | +static void xfpm_systemd_get_property (GObject *object, | ||
514 | + guint prop_id, | ||
515 | + GValue *value, | ||
516 | + GParamSpec *pspec) | ||
517 | +{ | ||
518 | + XfpmSystemd *systemd; | ||
519 | + systemd = XFPM_SYSTEMD (object); | ||
520 | + | ||
521 | + switch (prop_id) | ||
522 | + { | ||
523 | + case PROP_CAN_SHUTDOWN: | ||
524 | + g_value_set_boolean (value, systemd->priv->can_shutdown); | ||
525 | + break; | ||
526 | + case PROP_CAN_RESTART: | ||
527 | + g_value_set_boolean (value, systemd->priv->can_restart); | ||
528 | + break; | ||
529 | + default: | ||
530 | + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
531 | + break; | ||
532 | + } | ||
533 | +} | ||
534 | + | ||
535 | +static void | ||
536 | +xfpm_systemd_finalize (GObject *object) | ||
537 | +{ | ||
538 | + XfpmSystemd *systemd; | ||
539 | + | ||
540 | + systemd = XFPM_SYSTEMD (object); | ||
541 | + | ||
542 | + if(systemd->priv->authority) | ||
543 | + g_object_unref (G_OBJECT (systemd->priv->authority)); | ||
544 | + if(systemd->priv->subject) | ||
545 | + g_object_unref (G_OBJECT (systemd->priv->subject)); | ||
546 | + | ||
547 | + G_OBJECT_CLASS (xfpm_systemd_parent_class)->finalize (object); | ||
548 | +} | ||
549 | + | ||
550 | +XfpmSystemd * | ||
551 | +xfpm_systemd_new (void) | ||
552 | +{ | ||
553 | + static gpointer systemd_obj = NULL; | ||
554 | + | ||
555 | + if ( G_LIKELY (systemd_obj != NULL ) ) | ||
556 | + { | ||
557 | + g_object_ref (systemd_obj); | ||
558 | + } | ||
559 | + else | ||
560 | + { | ||
561 | + systemd_obj = g_object_new (XFPM_TYPE_SYSTEMD, NULL); | ||
562 | + g_object_add_weak_pointer (systemd_obj, &systemd_obj); | ||
563 | + } | ||
564 | + | ||
565 | + return XFPM_SYSTEMD (systemd_obj); | ||
566 | +} | ||
567 | + | ||
568 | +static void | ||
569 | +xfpm_systemd_try_method (XfpmSystemd *systemd, | ||
570 | + const gchar *method, | ||
571 | + GError **error) | ||
572 | +{ | ||
573 | + GDBusConnection *bus; | ||
574 | + GError *local_error = NULL; | ||
575 | + | ||
576 | + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error); | ||
577 | + if (G_LIKELY (bus != NULL)) | ||
578 | + { | ||
579 | + g_dbus_connection_call_sync (bus, | ||
580 | + SYSTEMD_DBUS_NAME, | ||
581 | + SYSTEMD_DBUS_PATH, | ||
582 | + SYSTEMD_DBUS_INTERFACE, | ||
583 | + method, | ||
584 | + g_variant_new ("(b)", TRUE), | ||
585 | + NULL, 0, G_MAXINT, NULL, | ||
586 | + &local_error); | ||
587 | + g_object_unref (G_OBJECT (bus)); | ||
588 | + | ||
589 | + if (local_error != NULL) | ||
590 | + { | ||
591 | + g_propagate_error (error, local_error); | ||
592 | + } | ||
593 | + } | ||
594 | +} | ||
595 | + | ||
596 | +void xfpm_systemd_shutdown (XfpmSystemd *systemd, GError **error) | ||
597 | +{ | ||
598 | + xfpm_systemd_try_method (systemd, | ||
599 | + SYSTEMD_POWEROFF_ACTION, | ||
600 | + error); | ||
601 | +} | ||
602 | + | ||
603 | +void xfpm_systemd_reboot (XfpmSystemd *systemd, GError **error) | ||
604 | +{ | ||
605 | + xfpm_systemd_try_method (systemd, | ||
606 | + SYSTEMD_REBOOT_ACTION, | ||
607 | + error); | ||
608 | +} | ||
609 | diff --git a/src/xfpm-systemd.h b/src/xfpm-systemd.h | ||
610 | new file mode 100644 | ||
611 | index 0000000..2890e08 | ||
612 | --- /dev/null | ||
613 | +++ b/src/xfpm-systemd.h | ||
614 | @@ -0,0 +1,60 @@ | ||
615 | +/* | ||
616 | + * * Copyright (C) 2009-2011 Ali <aliov@xfce.org> | ||
617 | + * * Copyright (C) 2013 Andreas Müller <schnitzeltony@googlemail.com> | ||
618 | + * | ||
619 | + * Licensed under the GNU General Public License Version 2 | ||
620 | + * | ||
621 | + * This program is free software; you can redistribute it and/or modify | ||
622 | + * it under the terms of the GNU General Public License as published by | ||
623 | + * the Free Software Foundation; either version 2 of the License, or | ||
624 | + * (at your option) any later version. | ||
625 | + * | ||
626 | + * This program is distributed in the hope that it will be useful, | ||
627 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
628 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
629 | + * GNU General Public License for more details. | ||
630 | + * | ||
631 | + * You should have received a copy of the GNU General Public License | ||
632 | + * along with this program; if not, write to the Free Software | ||
633 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
634 | + */ | ||
635 | + | ||
636 | +#ifndef __XFPM_SYSTEMD_H | ||
637 | +#define __XFPM_SYSTEMD_H | ||
638 | + | ||
639 | +#include <glib-object.h> | ||
640 | + | ||
641 | +G_BEGIN_DECLS | ||
642 | + | ||
643 | +#define XFPM_TYPE_SYSTEMD (xfpm_systemd_get_type () ) | ||
644 | +#define XFPM_SYSTEMD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_SYSTEMD, XfpmSystemd)) | ||
645 | +#define XFPM_IS_SYSTEMD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_SYSTEMD)) | ||
646 | + | ||
647 | +typedef struct XfpmSystemdPrivate XfpmSystemdPrivate; | ||
648 | + | ||
649 | +typedef struct | ||
650 | +{ | ||
651 | + GObject parent; | ||
652 | + XfpmSystemdPrivate *priv; | ||
653 | + | ||
654 | +} XfpmSystemd; | ||
655 | + | ||
656 | +typedef struct | ||
657 | +{ | ||
658 | + GObjectClass parent_class; | ||
659 | + | ||
660 | +} XfpmSystemdClass; | ||
661 | + | ||
662 | +GType XFPM_SYSTEMD_get_type (void) G_GNUC_CONST; | ||
663 | + | ||
664 | +XfpmSystemd *XFPM_SYSTEMD_new (void); | ||
665 | + | ||
666 | +void XFPM_SYSTEMD_shutdown (XfpmSystemd *systemd, | ||
667 | + GError **error); | ||
668 | + | ||
669 | +void XFPM_SYSTEMD_reboot (XfpmSystemd *systemd, | ||
670 | + GError **error); | ||
671 | + | ||
672 | +G_END_DECLS | ||
673 | + | ||
674 | +#endif /* __XFPM_SYSTEMD_H */ | ||
675 | -- | ||
676 | 1.7.6.5 | ||
677 | |||
diff --git a/meta-xfce/recipes-xfce/xfce4-power-manager/xfce4-power-manager_1.2.0.bb b/meta-xfce/recipes-xfce/xfce4-power-manager/xfce4-power-manager_1.4.1.bb index 6e92186ab..a4aaf668d 100644 --- a/meta-xfce/recipes-xfce/xfce4-power-manager/xfce4-power-manager_1.2.0.bb +++ b/meta-xfce/recipes-xfce/xfce4-power-manager/xfce4-power-manager_1.4.1.bb | |||
@@ -10,9 +10,8 @@ inherit xfce | |||
10 | DEPENDS = "gtk+ glib-2.0 dbus-glib xfconf libxfce4ui libxfce4util libnotify \ | 10 | DEPENDS = "gtk+ glib-2.0 dbus-glib xfconf libxfce4ui libxfce4util libnotify \ |
11 | libxrandr virtual/libx11 libxext xfce4-panel" | 11 | libxrandr virtual/libx11 libxext xfce4-panel" |
12 | 12 | ||
13 | SRC_URI += "file://0001-Add-shutdown-reboot-functionality-for-systemd.patch" | 13 | SRC_URI[md5sum] = "808a2630487d75e6eae915e464b7fda3" |
14 | 14 | SRC_URI[sha256sum] = "16a9e9bf3e0f8480d05b248817fbdc59e701e9161d3d0c7e53f3de28ed491f58" | |
15 | RDEPENDS_${PN} = "networkmanager udisks upower ${@base_contains('DISTRO_FEATURES','systemd','','consolekit',d)}" | ||
16 | 15 | ||
17 | EXTRA_OECONF = " \ | 16 | EXTRA_OECONF = " \ |
18 | --enable-network-manager \ | 17 | --enable-network-manager \ |
@@ -22,12 +21,22 @@ EXTRA_OECONF = " \ | |||
22 | PACKAGECONFIG ??= "${@base_contains('DISTRO_FEATURES','systemd','systemd','',d)}" | 21 | PACKAGECONFIG ??= "${@base_contains('DISTRO_FEATURES','systemd','systemd','',d)}" |
23 | PACKAGECONFIG[systemd] = "--enable-polkit, --disable-polkit, polkit" | 22 | PACKAGECONFIG[systemd] = "--enable-polkit, --disable-polkit, polkit" |
24 | 23 | ||
25 | PACKAGES += "xfce4-brightness-plugin" | 24 | PACKAGES += "xfce4-powermanager-plugin" |
26 | FILES_${PN} += "${datadir}/polkit-1" | 25 | |
27 | FILES_xfce4-brightness-plugin = " \ | 26 | FILES_${PN} += " \ |
28 | ${libdir}/xfce4/panel-plugins/xfce4-brightness-plugin \ | 27 | ${datadir}/polkit-1 \ |
29 | ${datadir}/xfce4/panel-plugins/xfce4-brightness-plugin.desktop \ | 28 | ${datadir}/appdata \ |
30 | " | 29 | " |
31 | 30 | ||
32 | SRC_URI[md5sum] = "935599b7114b0a4b0e2c9a5d6c72524c" | 31 | FILES_xfce4-powermanager-plugin = " \ |
33 | SRC_URI[sha256sum] = "d7fb98a540284b62f4201527de17d4b24123f9d26c9f49131dd497c8387184e9" | 32 | ${libdir}/xfce4 \ |
33 | ${datadir}/xfce4 \ | ||
34 | " | ||
35 | |||
36 | RDEPENDS_xfce4-powermanager-plugin = "${PN}" | ||
37 | RDEPENDS_${PN} = "networkmanager udisks upower ${@base_contains('DISTRO_FEATURES','systemd','','consolekit',d)}" | ||
38 | |||
39 | # xfce4-brightness-plugin was replaced by xfce4-powermanager-plugin | ||
40 | RPROVIDES_xfce4-powermanager-plugin += "xfce4-brightness-plugin" | ||
41 | RREPLACES_xfce4-powermanager-plugin += "xfce4-brightness-plugin" | ||
42 | RCONFLICTS_xfce4-powermanager-plugin += "xfce4-brightness-plugin" | ||