[Pkg-xfce-commits] r8134 - in /desktop/branches/experimental/xfce4-power-manager: ./ debian/ debian/patches/
Yves-Alexis Perez
corsac at moszumanska.debian.org
Sun Dec 29 22:02:00 UTC 2013
Author: corsac
Date: Sun Dec 29 22:02:00 2013
New Revision: 8134
URL: http://svn.debian.org/wsvn/pkg-xfce/?sc=1&rev=8134
Log:
try to add experimental systemd/logind support to xfpm
Added:
desktop/branches/experimental/xfce4-power-manager/
- copied from r8089, desktop/trunk/xfce4-power-manager/
desktop/branches/experimental/xfce4-power-manager/debian/patches/04_add-systemd-logind-support-for-suspend_hibernate.patch
desktop/branches/experimental/xfce4-power-manager/debian/patches/05_dont-allow-systemd-to-handle-suspend-hibernate-events.patch
desktop/branches/experimental/xfce4-power-manager/debian/patches/06_add-shutdown-reboot-functionality-for-systemd.patch
Modified:
desktop/branches/experimental/xfce4-power-manager/debian/changelog
desktop/branches/experimental/xfce4-power-manager/debian/control
desktop/branches/experimental/xfce4-power-manager/debian/patches/series
desktop/branches/experimental/xfce4-power-manager/debian/rules
Modified: desktop/branches/experimental/xfce4-power-manager/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/branches/experimental/xfce4-power-manager/debian/changelog?rev=8134&op=diff
==============================================================================
--- desktop/branches/experimental/xfce4-power-manager/debian/changelog (original)
+++ desktop/branches/experimental/xfce4-power-manager/debian/changelog Sun Dec 29 22:02:00 2013
@@ -13,6 +13,17 @@
* Create manpages for xfce4-power-information
and xfpm-power-backlight-helper
+ [ Yves-Alexis Perez ]
+ * debian/patches:
+ - 04_add-systemd-logind-support-for-suspend_hibernate added, switch from
+ upower to logind for suspend and hibernate.
+ - 05_dont-allow-systemd-to-handle-suspend-hibernate-events added, inhibit
+ systemd doing suspend/hibernate by itself, to let xfpm do its job (like
+ locking the screen)
+ - 06_add-shutdown-reboot-functionality-for-systemd added, handle
+ shutdown/reboot when running under systemd.
+
+
-- Jackson Doak <noskcaj at ubuntu.com> Sun, 18 Aug 2013 19:48:55 +1000
xfce4-power-manager (1.2.0-2) unstable; urgency=low
Modified: desktop/branches/experimental/xfce4-power-manager/debian/control
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/branches/experimental/xfce4-power-manager/debian/control?rev=8134&op=diff
==============================================================================
--- desktop/branches/experimental/xfce4-power-manager/debian/control (original)
+++ desktop/branches/experimental/xfce4-power-manager/debian/control Sun Dec 29 22:02:00 2013
@@ -7,7 +7,7 @@
libdbus-1-dev, libdbus-glib-1-dev, libxfconf-0-dev (>= 4.10.0),
libxfce4ui-1-dev (>= 4.10.0), libnotify-dev, xfce4-panel-dev (>= 4.10.0),
libpolkit-gobject-1-dev, libxext-dev, libx11-dev, dpkg-dev (>= 1.16.1),
- xfce4-dev-tools, libtool, dh-autoreconf
+ xfce4-dev-tools, libtool, dh-autoreconf, libsystemd-daemon-dev
Standards-Version: 3.9.4
Vcs-Svn: svn://anonscm.debian.org/pkg-xfce/goodies/trunk/xfce4-power-manager/
Vcs-Browser: http://anonscm.debian.org/viewvc/pkg-xfce/goodies/trunk/xfce4-power-manager/
Added: desktop/branches/experimental/xfce4-power-manager/debian/patches/04_add-systemd-logind-support-for-suspend_hibernate.patch
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/branches/experimental/xfce4-power-manager/debian/patches/04_add-systemd-logind-support-for-suspend_hibernate.patch?rev=8134&op=file
==============================================================================
--- desktop/branches/experimental/xfce4-power-manager/debian/patches/04_add-systemd-logind-support-for-suspend_hibernate.patch (added)
+++ desktop/branches/experimental/xfce4-power-manager/debian/patches/04_add-systemd-logind-support-for-suspend_hibernate.patch Sun Dec 29 22:02:00 2013
@@ -0,0 +1,186 @@
+From 244d0f09561eace29cbef819c2deb55b13701e25 Mon Sep 17 00:00:00 2001
+From: Mikhail Efremov <sem at altlinux.org>
+Date: Mon, 8 Apr 2013 21:04:30 +0400
+Subject: [PATCH] Add systemd-logind support for suspend/hibernate.
+
+---
+ configure.ac.in | 20 +++++++++++++++++
+ src/xfpm-power-common.h | 8 +++++++
+ src/xfpm-power.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++-
+ 3 files changed, 84 insertions(+), 1 deletion(-)
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -148,6 +148,25 @@ fi
+ AC_MSG_RESULT([$ac_network_manager])
+
+ #=======================================================#
++# Suspend/hibernate support #
++#=======================================================#
++AC_ARG_WITH([sleep-manager], AS_HELP_STRING([--with-sleep-manager=systemd|upower],
++ [Build with specific suspend/hibernate support (default: systemd)]),
++ [], [with_sleep_manager=systemd])
++AC_MSG_CHECKING([for suspend/hibernate support])
++case "$with_sleep_manager" in
++ systemd)
++ ;;
++ upower)
++ AC_DEFINE(WITH_SLEEP_MANAGER_UPOWER, 1 , [Use upower for suspend/hibernate])
++ ;;
++ *)
++ AC_MSG_ERROR(--with-sleep-manager must be one of [upower, systemd])
++ ;;
++esac
++AC_MSG_RESULT([$with_sleep_manager])
++
++#=======================================================#
+ # Panel plugins ? #
+ #=======================================================#
+ AC_ARG_ENABLE([panel_plugins],
+@@ -252,6 +271,7 @@ echo "xdg autostart: ${sysconfdir}/xdg/
+ echo "POLKIT: ${polkit}"
+ echo "DPMS: ${have_dpms}"
+ echo "Network manager: ${ac_network_manager}"
++echo "Suspend/hibernate: ${with_sleep_manager}"
+ echo "Build panel plugins: ${build_panel_plugins}"
+ echo "Debug: ${enable_debug}"
+ echo "Configuration finished, type make to compile"
+--- a/src/xfpm-power-common.h
++++ b/src/xfpm-power-common.h
+@@ -33,9 +33,17 @@
+ #define UPOWER_PATH_WAKEUPS "/org/freedesktop/UPower/Wakeups"
+ #define UPOWER_IFACE_WAKEUPS "org.freedesktop.UPower.Wakeups"
+
++#ifdef WITH_SLEEP_MANAGER_UPOWER
+ #define POLKIT_AUTH_SUSPEND "org.freedesktop.upower.suspend"
+ #define POLKIT_AUTH_HIBERNATE "org.freedesktop.upower.hibernate"
++#else
++#define LOGIND_NAME "org.freedesktop.login1"
++#define LOGIND_PATH "/org/freedesktop/login1"
++#define LOGIND_IFACE "org.freedesktop.login1.Manager"
+
++#define POLKIT_AUTH_SUSPEND "org.freedesktop.login1.suspend"
++#define POLKIT_AUTH_HIBERNATE "org.freedesktop.login1.hibernate"
++#endif
+
+ GPtrArray *xfpm_power_enumerate_devices (DBusGProxy *proxy);
+
+--- a/src/xfpm-power.c
++++ b/src/xfpm-power.c
+@@ -72,7 +72,10 @@ struct XfpmPowerPrivate
+
+ DBusGProxy *proxy;
+ DBusGProxy *proxy_prop;
+-
++#ifndef WITH_SLEEP_MANAGER_UPOWER
++ DBusGProxy *proxy_logind;
++#endif
++
+ GHashTable *hash;
+
+ XfpmConsoleKit *console;
+@@ -153,6 +156,7 @@ xfpm_power_check_polkit_auth (XfpmPower
+ }
+ #endif
+
++#ifdef WITH_SLEEP_MANAGER_UPOWER
+ static void
+ xfpm_power_check_pm (XfpmPower *power, GHashTable *props)
+ {
+@@ -186,6 +190,33 @@ xfpm_power_check_pm (XfpmPower *power, G
+ power->priv->can_hibernate = ret;
+ }
+ }
++#else
++static gboolean
++xfpm_power_can_sleep_method (XfpmPower *power, const char *method)
++{
++ GError *error = NULL;
++ char *retstr = NULL;
++ gboolean ret = FALSE;
++
++ if (!dbus_g_proxy_call (power->priv->proxy_logind, method, &error,
++ G_TYPE_INVALID,
++ G_TYPE_STRING, &retstr,
++ G_TYPE_INVALID))
++ {
++ g_warning ("Unable to check %s method: %s", method, error->message);
++ g_error_free (error);
++
++ return FALSE;
++ }
++
++ if ((g_strcmp0 (retstr, "yes") == 0) ||
++ (g_strcmp0 (retstr, "challenge") == 0))
++ ret = TRUE;
++ g_free (retstr);
++
++ return ret;
++}
++#endif
+
+ static void
+ xfpm_power_check_power (XfpmPower *power, GHashTable *props)
+@@ -276,7 +307,12 @@ xfpm_power_get_properties (XfpmPower *po
+
+ props = xfpm_power_get_interface_properties (power->priv->proxy_prop, UPOWER_IFACE);
+
++#ifdef WITH_SLEEP_MANAGER_UPOWER
+ xfpm_power_check_pm (power, props);
++#else
++ power->priv->can_suspend = xfpm_power_can_sleep_method (power, "CanSuspend");
++ power->priv->can_hibernate = xfpm_power_can_sleep_method (power, "CanHibernate");
++#endif
+ xfpm_power_check_lid (power, props);
+ xfpm_power_check_power (power, props);
+
+@@ -347,9 +383,16 @@ xfpm_power_sleep (XfpmPower *power, cons
+ xfpm_lock_screen ();
+ }
+
++#ifdef WITH_SLEEP_MANAGER_UPOWER
+ dbus_g_proxy_call (power->priv->proxy, sleep_time, &error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
++#else
++ dbus_g_proxy_call (power->priv->proxy_logind, sleep_time, &error,
++ G_TYPE_BOOLEAN, TRUE,
++ G_TYPE_INVALID,
++ G_TYPE_INVALID);
++#endif
+
+ if ( error )
+ {
+@@ -1361,12 +1404,20 @@ xfpm_power_init (XfpmPower *power)
+ UPOWER_NAME,
+ UPOWER_PATH,
+ DBUS_INTERFACE_PROPERTIES);
++
+ if (power->priv->proxy_prop == NULL)
+ {
+ g_critical ("Unable to create proxy for %s", UPOWER_NAME);
+ goto out;
+ }
+
++#ifndef WITH_SLEEP_MANAGER_UPOWER
++ power->priv->proxy_logind = dbus_g_proxy_new_for_name (power->priv->bus,
++ LOGIND_NAME,
++ LOGIND_PATH,
++ LOGIND_IFACE);
++#endif
++
+ xfpm_power_get_power_devices (power);
+ xfpm_power_get_properties (power);
+ #ifdef ENABLE_POLKIT
+@@ -1468,6 +1519,11 @@ xfpm_power_finalize (GObject *object)
+ if ( power->priv->proxy_prop )
+ g_object_unref (power->priv->proxy_prop);
+
++#ifndef WITH_SLEEP_MANAGER_UPOWER
++ if ( power->priv->proxy_logind )
++ g_object_unref (power->priv->proxy_logind);
++#endif
++
+ g_hash_table_destroy (power->priv->hash);
+
+ #ifdef ENABLE_POLKIT
Added: desktop/branches/experimental/xfce4-power-manager/debian/patches/05_dont-allow-systemd-to-handle-suspend-hibernate-events.patch
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/branches/experimental/xfce4-power-manager/debian/patches/05_dont-allow-systemd-to-handle-suspend-hibernate-events.patch?rev=8134&op=file
==============================================================================
--- desktop/branches/experimental/xfce4-power-manager/debian/patches/05_dont-allow-systemd-to-handle-suspend-hibernate-events.patch (added)
+++ desktop/branches/experimental/xfce4-power-manager/debian/patches/05_dont-allow-systemd-to-handle-suspend-hibernate-events.patch Sun Dec 29 22:02:00 2013
@@ -0,0 +1,126 @@
+From 3d721db740dc0016da71e323eac4d8caef6439a3 Mon Sep 17 00:00:00 2001
+From: Mikhail Efremov <sem at altlinux.org>
+Date: Thu, 21 Feb 2013 15:03:44 +0400
+Subject: [PATCH] Don't allow systemd to handle suspend/hibernate events.
+
+---
+ src/xfpm-main.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 85 insertions(+), 2 deletions(-)
+
+diff --git a/src/xfpm-main.c b/src/xfpm-main.c
+index a98583b..f23f1ce 100644
+--- a/src/xfpm-main.c
++++ b/src/xfpm-main.c
+@@ -194,16 +194,96 @@ xfpm_dump_remote (DBusGConnection *bus)
+ g_hash_table_destroy (hash);
+ }
+
++static gint
++xfpm_inhibit_sleep_systemd (DBusGConnection *bus)
++{
++ DBusConnection *bus_connection;
++ DBusMessage *message = NULL, *reply = NULL;
++ DBusError error;
++ gint fd = -1;
++ const char *what = "handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch";
++ const char *who = "xfce4-power-manager";
++ const char *why = "xfce4-power-manager handles these events";
++ const char *mode = "block";
++
++ bus_connection = dbus_g_connection_get_connection (bus);
++ if (!xfpm_dbus_name_has_owner (bus_connection, "org.freedesktop.login1"))
++ return -1;
++
++ dbus_error_init (&error);
++
++ message = dbus_message_new_method_call ("org.freedesktop.login1",
++ "/org/freedesktop/login1",
++ "org.freedesktop.login1.Manager",
++ "Inhibit");
++
++ if (!message)
++ {
++ g_warning ("Unable to call Inhibit()");
++ goto done;
++ }
++
++
++ if (!dbus_message_append_args (message,
++ DBUS_TYPE_STRING, &what,
++ DBUS_TYPE_STRING, &who,
++ DBUS_TYPE_STRING, &why,
++ DBUS_TYPE_STRING, &mode,
++ DBUS_TYPE_INVALID))
++ {
++ g_warning ("Unable to call Inhibit()");
++ goto done;
++ }
++
++
++ reply = dbus_connection_send_with_reply_and_block (bus_connection, message, -1, &error);
++ if (!reply)
++ {
++ g_warning ("Unable to inhibit systemd sleep: %s", error.message);
++ goto done;
++ }
++
++ if (!dbus_message_get_args (reply, &error,
++ DBUS_TYPE_UNIX_FD, &fd,
++ DBUS_TYPE_INVALID))
++ {
++ g_warning ("Inhibit() reply parsing failed: %s", error.message);
++ }
++
++done:
++
++ if (message)
++ dbus_message_unref (message);
++ if (reply)
++ dbus_message_unref (reply);
++ dbus_error_free (&error);
++
++ return fd;
++}
++
+ static void G_GNUC_NORETURN
+ xfpm_start (DBusGConnection *bus, const gchar *client_id, gboolean dump)
+ {
++ DBusGConnection *system_bus;
+ XfpmManager *manager;
+ GError *error = NULL;
++ gint inhibit_fd = -1;
+
+ XFPM_DEBUG ("Starting the power manager");
+
+ manager = xfpm_manager_new (bus, client_id);
+-
++
++ /* Don't allow systemd to handle power/suspend/hibernate buttons
++ * and lid-switch */
++ system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
++ if (system_bus)
++ inhibit_fd = xfpm_inhibit_sleep_systemd (system_bus);
++ else
++ {
++ g_warning ("Unable connect to system bus: %s", error->message);
++ g_clear_error (&error);
++ }
++
+ if ( xfce_posix_signal_handler_init (&error))
+ {
+ xfce_posix_signal_handler_set_handler (SIGHUP,
+@@ -238,7 +318,10 @@ xfpm_start (DBusGConnection *bus, const gchar *client_id, gboolean dump)
+ gtk_main ();
+
+ g_object_unref (manager);
+-
++
++ if (inhibit_fd >= 0)
++ close (inhibit_fd);
++
+ exit (EXIT_SUCCESS);
+ }
+
+--
+1.8.1.3
+
Added: desktop/branches/experimental/xfce4-power-manager/debian/patches/06_add-shutdown-reboot-functionality-for-systemd.patch
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/branches/experimental/xfce4-power-manager/debian/patches/06_add-shutdown-reboot-functionality-for-systemd.patch?rev=8134&op=file
==============================================================================
--- desktop/branches/experimental/xfce4-power-manager/debian/patches/06_add-shutdown-reboot-functionality-for-systemd.patch (added)
+++ desktop/branches/experimental/xfce4-power-manager/debian/patches/06_add-shutdown-reboot-functionality-for-systemd.patch Sun Dec 29 22:02:00 2013
@@ -0,0 +1,626 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -100,6 +100,8 @@ if test "x$ac_cv_enable_polkit" = "xno";
+ polkit="no"
+ else
+ AC_MSG_RESULT([yes])
++ XDT_CHECK_OPTIONAL_PACKAGE([SYSTEMD], [polkit-gobject-1], [0.100],
++ [systemd], [Systemd support (through polkit)])
+ AC_DEFINE(ENABLE_POLKIT, 1 , [PolicyKit support])
+ polkit="yes"
+ fi
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -39,6 +39,12 @@ xfce4_power_manager_SOURCES =
+ xfpm-errors.c \
+ xfpm-errors.h
+
++if HAVE_SYSTEMD
++xfce4_power_manager_SOURCES += \
++ xfpm-systemd.c \
++ xfpm-systemd.h
++endif
++
+ xfce4_power_manager_CFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/common \
+@@ -52,6 +58,7 @@ xfce4_power_manager_CFLAGS =
+ $(LIBXFCE4UI_CFLAGS) \
+ $(XFCONF_CFLAGS) \
+ $(LIBNOTIFY_CFLAGS) \
++ $(SYSTEMD_CFLAGS) \
+ $(XRANDR_CFLAGS) \
+ $(DPMS_CFLAGS) \
+ $(PLATFORM_CPPFLAGS) \
+@@ -70,6 +77,7 @@ xfce4_power_manager_LDADD =
+ $(LIBXFCE4UI_LIBS) \
+ $(XFCONF_LIBS) \
+ $(LIBNOTIFY_LIBS) \
++ $(SYSTEMD_LIBS) \
+ $(XRANDR_LIBS) \
+ $(DPMS_LIBS)
+
+--- a/src/xfpm-manager.c
++++ b/src/xfpm-manager.c
+@@ -58,6 +58,10 @@
+ #include "xfpm-enum-types.h"
+ #include "xfpm-dbus-monitor.h"
+
++#ifdef HAVE_SYSTEMD
++#include "xfpm-systemd.h"
++#endif
++
+ static void xfpm_manager_finalize (GObject *object);
+
+ static void xfpm_manager_dbus_class_init (XfpmManagerClass *klass);
+@@ -80,6 +84,9 @@ struct XfpmManagerPrivate
+ XfpmButton *button;
+ XfpmXfconf *conf;
+ XfpmBacklight *backlight;
++#ifdef HAVE_SYSTEMD
++ XfpmSystemd *systemd;
++#endif
+ XfpmConsoleKit *console;
+ XfpmDBusMonitor *monitor;
+ XfpmDisks *disks;
+@@ -131,7 +138,12 @@ xfpm_manager_finalize (GObject *object)
+ g_object_unref (manager->priv->button);
+ g_object_unref (manager->priv->conf);
+ g_object_unref (manager->priv->client);
+- g_object_unref (manager->priv->console);
++#ifdef HAVE_SYSTEMD
++ if ( manager->priv->systemd != NULL )
++ g_object_unref (manager->priv->systemd);
++#endif
++ if ( manager->priv->console != NULL )
++ g_object_unref (manager->priv->console);
+ g_object_unref (manager->priv->monitor);
+ g_object_unref (manager->priv->disks);
+ g_object_unref (manager->priv->inhibit);
+@@ -201,6 +213,11 @@ static void
+ xfpm_manager_shutdown (XfpmManager *manager)
+ {
+ GError *error = NULL;
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ xfpm_systemd_shutdown (manager->priv->systemd, &error );
++ else
++#endif
+ xfpm_console_kit_shutdown (manager->priv->console, &error );
+
+ if ( error )
+@@ -517,10 +534,17 @@ void xfpm_manager_start (XfpmManager *ma
+ dbus_g_error_domain_register (XFPM_ERROR,
+ NULL,
+ XFPM_TYPE_ERROR);
+-
++
+ manager->priv->power = xfpm_power_get ();
+ manager->priv->button = xfpm_button_new ();
+ manager->priv->conf = xfpm_xfconf_new ();
++#ifdef HAVE_SYSTEMD
++ manager->priv->console = NULL;
++ manager->priv->systemd = NULL;
++ if ( LOGIND_RUNNING () )
++ manager->priv->systemd = xfpm_systemd_new ();
++ else
++#endif
+ manager->priv->console = xfpm_console_kit_new ();
+ manager->priv->monitor = xfpm_dbus_monitor_new ();
+ manager->priv->disks = xfpm_disks_new ();
+@@ -603,6 +627,13 @@ GHashTable *xfpm_manager_get_config (Xfp
+
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ g_object_get (G_OBJECT (manager->priv->systemd),
++ "can-shutdown", &can_shutdown,
++ NULL);
++ else
++#endif
+ g_object_get (G_OBJECT (manager->priv->console),
+ "can-shutdown", &can_shutdown,
+ NULL);
+--- a/src/xfpm-power.c
++++ b/src/xfpm-power.c
+@@ -51,6 +51,10 @@
+ #include "xfpm-enum-types.h"
+ #include "egg-idletime.h"
+
++#ifdef HAVE_SYSTEMD
++#include "xfpm-systemd.h"
++#endif
++
+ static void xfpm_power_finalize (GObject *object);
+
+ static void xfpm_power_get_property (GObject *object,
+@@ -78,6 +82,9 @@ struct XfpmPowerPrivate
+
+ GHashTable *hash;
+
++#ifdef HAVE_SYSTEMD
++ XfpmSystemd *systemd;
++#endif
+ XfpmConsoleKit *console;
+ XfpmInhibit *inhibit;
+ XfpmXfconf *conf;
+@@ -723,10 +730,17 @@ xfpm_power_add_actions_to_notification (
+ {
+ gboolean can_shutdown;
+
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ g_object_get (G_OBJECT (power->priv->systemd),
++ "can-shutdown", &can_shutdown,
++ NULL);
++ else
++#endif
+ g_object_get (G_OBJECT (power->priv->console),
+ "can-shutdown", &can_shutdown,
+ NULL);
+-
++
+ if ( power->priv->can_hibernate && power->priv->auth_hibernate )
+ {
+ xfpm_notify_add_action_to_notification(
+@@ -799,10 +813,17 @@ xfpm_power_show_critical_action_gtk (Xfp
+ const gchar *message;
+ gboolean can_shutdown;
+
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ g_object_get (G_OBJECT (power->priv->systemd),
++ "can-shutdown", &can_shutdown,
++ NULL);
++ else
++#endif
+ g_object_get (G_OBJECT (power->priv->console),
+ "can-shutdown", &can_shutdown,
+ NULL);
+-
++
+ message = _("System is running on low power. "\
+ "Save your work to avoid losing data");
+
+@@ -1371,6 +1392,13 @@ xfpm_power_init (XfpmPower *power)
+ power->priv->inhibit = xfpm_inhibit_new ();
+ power->priv->notify = xfpm_notify_new ();
+ power->priv->conf = xfpm_xfconf_new ();
++#ifdef HAVE_SYSTEMD
++ power->priv->systemd = NULL;
++ power->priv->console = NULL;
++ if ( LOGIND_RUNNING () )
++ power->priv->systemd = xfpm_systemd_new ();
++ else
++#endif
+ power->priv->console = xfpm_console_kit_new ();
+
+ g_signal_connect_swapped (power->priv->conf, "notify::" SHOW_TRAY_ICON_CFG,
+@@ -1497,7 +1525,12 @@ xfpm_power_finalize (GObject *object)
+ g_object_unref (power->priv->inhibit);
+ g_object_unref (power->priv->notify);
+ g_object_unref (power->priv->conf);
+- g_object_unref (power->priv->console);
++#ifdef HAVE_SYSTEMD
++ if ( power->priv->systemd != NULL )
++ g_object_unref (power->priv->systemd);
++#endif
++ if ( power->priv->console != NULL )
++ g_object_unref (power->priv->console);
+
+ xfpm_power_hide_adapter_icon (power);
+
+@@ -1664,10 +1697,17 @@ static gboolean xfpm_power_dbus_shutdown
+ {
+ gboolean can_reboot;
+
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ g_object_get (G_OBJECT (power->priv->systemd),
++ "can-shutdown", &can_reboot,
++ NULL);
++ else
++#endif
+ g_object_get (G_OBJECT (power->priv->console),
+ "can-shutdown", &can_reboot,
+ NULL);
+-
++
+ if ( !can_reboot)
+ {
+ g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
+@@ -1675,6 +1715,11 @@ static gboolean xfpm_power_dbus_shutdown
+ return FALSE;
+ }
+
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ xfpm_systemd_shutdown (power->priv->systemd, error);
++ else
++#endif
+ xfpm_console_kit_shutdown (power->priv->console, error);
+
+ return TRUE;
+@@ -1685,10 +1730,17 @@ static gboolean xfpm_power_dbus_reboot
+ {
+ gboolean can_reboot;
+
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ g_object_get (G_OBJECT (power->priv->systemd),
++ "can-restart", &can_reboot,
++ NULL);
++ else
++#endif
+ g_object_get (G_OBJECT (power->priv->console),
+ "can-restart", &can_reboot,
+ NULL);
+-
++
+ if ( !can_reboot)
+ {
+ g_set_error (error, XFPM_ERROR, XFPM_ERROR_PERMISSION_DENIED,
+@@ -1696,7 +1748,12 @@ static gboolean xfpm_power_dbus_reboot
+ return FALSE;
+ }
+
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ xfpm_systemd_reboot (power->priv->systemd, error);
++#else
+ xfpm_console_kit_reboot (power->priv->console, error);
++#endif
+
+ return TRUE;
+ }
+@@ -1751,10 +1808,17 @@ static gboolean xfpm_power_dbus_can_rebo
+ gboolean * OUT_can_reboot,
+ GError ** error)
+ {
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ g_object_get (G_OBJECT (power->priv->systemd),
++ "can-reboot", OUT_can_reboot,
++ NULL);
++ else
++#endif
+ g_object_get (G_OBJECT (power->priv->console),
+ "can-reboot", OUT_can_reboot,
+ NULL);
+-
++
+ return TRUE;
+ }
+
+@@ -1762,9 +1826,17 @@ static gboolean xfpm_power_dbus_can_shut
+ gboolean * OUT_can_shutdown,
+ GError ** error)
+ {
++#ifdef HAVE_SYSTEMD
++ if ( LOGIND_RUNNING () )
++ g_object_get (G_OBJECT (power->priv->systemd),
++ "can-shutdown", OUT_can_shutdown,
++ NULL);
++ else
++#endif
+ g_object_get (G_OBJECT (power->priv->console),
+ "can-shutdown", OUT_can_shutdown,
+ NULL);
++
+ return TRUE;
+ }
+
+--- /dev/null
++++ b/src/xfpm-systemd.c
+@@ -0,0 +1,245 @@
++/*
++ * * Copyright (C) 2009-2011 Ali <aliov at xfce.org>
++ * * Copyright (C) 2013 Andreas Müller <schnitzeltony at googlemail.com>
++ *
++ * Licensed under the GNU General Public License Version 2
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifdef HAVE_CONFIG_H
++#include <config.h>
++#endif
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#include <dbus/dbus-glib.h>
++#include <polkit/polkit.h>
++
++#include "xfpm-systemd.h"
++
++
++static void xfpm_systemd_finalize (GObject *object);
++
++static void xfpm_systemd_get_property (GObject *object,
++ guint prop_id,
++ GValue *value,
++ GParamSpec *pspec);
++
++#define XFPM_SYSTEMD_GET_PRIVATE(o) \
++(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_SYSTEMD, XfpmSystemdPrivate))
++
++struct XfpmSystemdPrivate
++{
++ gboolean can_shutdown;
++ gboolean can_restart;
++
++ PolkitAuthority *authority;
++ PolkitSubject *subject;
++};
++
++enum
++{
++ PROP_0,
++ PROP_CAN_RESTART,
++ PROP_CAN_SHUTDOWN
++};
++
++G_DEFINE_TYPE (XfpmSystemd, xfpm_systemd, G_TYPE_OBJECT)
++
++#define SYSTEMD_DBUS_NAME "org.freedesktop.login1"
++#define SYSTEMD_DBUS_PATH "/org/freedesktop/login1"
++#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager"
++#define SYSTEMD_REBOOT_ACTION "Reboot"
++#define SYSTEMD_POWEROFF_ACTION "PowerOff"
++#define SYSTEMD_REBOOT_TEST "org.freedesktop.login1.reboot"
++#define SYSTEMD_POWEROFF_TEST "org.freedesktop.login1.power-off"
++
++static void
++xfpm_systemd_class_init (XfpmSystemdClass *klass)
++{
++ GObjectClass *object_class = G_OBJECT_CLASS (klass);
++
++ object_class->finalize = xfpm_systemd_finalize;
++
++ object_class->get_property = xfpm_systemd_get_property;
++
++ g_object_class_install_property (object_class,
++ PROP_CAN_RESTART,
++ g_param_spec_boolean ("can-restart",
++ NULL, NULL,
++ FALSE,
++ G_PARAM_READABLE));
++
++ g_object_class_install_property (object_class,
++ PROP_CAN_SHUTDOWN,
++ g_param_spec_boolean ("can-shutdown",
++ NULL, NULL,
++ FALSE,
++ G_PARAM_READABLE));
++
++ g_type_class_add_private (klass, sizeof (XfpmSystemdPrivate));
++}
++
++static gboolean
++xfpm_systemd_can_method (XfpmSystemd *systemd,
++ gboolean *can_method,
++ const gchar *method)
++{
++ PolkitAuthorizationResult *res;
++ GError *local_error = NULL;
++
++ *can_method = FALSE;
++ res = polkit_authority_check_authorization_sync (systemd->priv->authority,
++ systemd->priv->subject,
++ method,
++ NULL,
++ POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
++ NULL,
++ &local_error);
++ if ( local_error )
++ {
++ g_critical ("Unable to get %s : %s", method, local_error->message);
++ g_error_free (local_error);
++ }
++
++ if(res)
++ {
++ *can_method = polkit_authorization_result_get_is_authorized (res) ||
++ polkit_authorization_result_get_is_challenge (res);
++ g_object_unref (G_OBJECT (res));
++ }
++
++ return TRUE;
++}
++
++static void
++xfpm_systemd_init (XfpmSystemd *systemd)
++{
++ systemd->priv = XFPM_SYSTEMD_GET_PRIVATE (systemd);
++ systemd->priv->authority = polkit_authority_get_sync (NULL, NULL);
++ systemd->priv->subject = polkit_unix_process_new (getpid());
++ systemd->priv->can_shutdown = FALSE;
++ systemd->priv->can_restart = FALSE;
++
++ if(systemd->priv->authority && systemd->priv->subject)
++ {
++ xfpm_systemd_can_method (systemd,
++ &systemd->priv->can_shutdown,
++ SYSTEMD_POWEROFF_TEST);
++ xfpm_systemd_can_method (systemd,
++ &systemd->priv->can_restart,
++ SYSTEMD_REBOOT_TEST);
++ }
++}
++
++static void xfpm_systemd_get_property (GObject *object,
++ guint prop_id,
++ GValue *value,
++ GParamSpec *pspec)
++{
++ XfpmSystemd *systemd;
++ systemd = XFPM_SYSTEMD (object);
++
++ switch (prop_id)
++ {
++ case PROP_CAN_SHUTDOWN:
++ g_value_set_boolean (value, systemd->priv->can_shutdown);
++ break;
++ case PROP_CAN_RESTART:
++ g_value_set_boolean (value, systemd->priv->can_restart);
++ break;
++ default:
++ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
++ break;
++ }
++}
++
++static void
++xfpm_systemd_finalize (GObject *object)
++{
++ XfpmSystemd *systemd;
++
++ systemd = XFPM_SYSTEMD (object);
++
++ if(systemd->priv->authority)
++ g_object_unref (G_OBJECT (systemd->priv->authority));
++ if(systemd->priv->subject)
++ g_object_unref (G_OBJECT (systemd->priv->subject));
++
++ G_OBJECT_CLASS (xfpm_systemd_parent_class)->finalize (object);
++}
++
++XfpmSystemd *
++xfpm_systemd_new (void)
++{
++ static gpointer systemd_obj = NULL;
++
++ if ( G_LIKELY (systemd_obj != NULL ) )
++ {
++ g_object_ref (systemd_obj);
++ }
++ else
++ {
++ systemd_obj = g_object_new (XFPM_TYPE_SYSTEMD, NULL);
++ g_object_add_weak_pointer (systemd_obj, &systemd_obj);
++ }
++
++ return XFPM_SYSTEMD (systemd_obj);
++}
++
++static void
++xfpm_systemd_try_method (XfpmSystemd *systemd,
++ const gchar *method,
++ GError **error)
++{
++ GDBusConnection *bus;
++ GError *local_error = NULL;
++
++ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
++ if (G_LIKELY (bus != NULL))
++ {
++ g_dbus_connection_call_sync (bus,
++ SYSTEMD_DBUS_NAME,
++ SYSTEMD_DBUS_PATH,
++ SYSTEMD_DBUS_INTERFACE,
++ method,
++ g_variant_new ("(b)", TRUE),
++ NULL, 0, G_MAXINT, NULL,
++ &local_error);
++ g_object_unref (G_OBJECT (bus));
++
++ if (local_error != NULL)
++ {
++ g_propagate_error (error, local_error);
++ }
++ }
++}
++
++void xfpm_systemd_shutdown (XfpmSystemd *systemd, GError **error)
++{
++ xfpm_systemd_try_method (systemd,
++ SYSTEMD_POWEROFF_ACTION,
++ error);
++}
++
++void xfpm_systemd_reboot (XfpmSystemd *systemd, GError **error)
++{
++ xfpm_systemd_try_method (systemd,
++ SYSTEMD_REBOOT_ACTION,
++ error);
++}
+--- /dev/null
++++ b/src/xfpm-systemd.h
+@@ -0,0 +1,62 @@
++/*
++ * * Copyright (C) 2009-2011 Ali <aliov at xfce.org>
++ * * Copyright (C) 2013 Andreas Müller <schnitzeltony at googlemail.com>
++ *
++ * Licensed under the GNU General Public License Version 2
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef __XFPM_SYSTEMD_H
++#define __XFPM_SYSTEMD_H
++
++#include <glib-object.h>
++
++G_BEGIN_DECLS
++
++#define LOGIND_RUNNING() (access ("/run/systemd/seats/", F_OK) >= 0)
++
++#define XFPM_TYPE_SYSTEMD (xfpm_systemd_get_type () )
++#define XFPM_SYSTEMD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_SYSTEMD, XfpmSystemd))
++#define XFPM_IS_SYSTEMD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_SYSTEMD))
++
++typedef struct XfpmSystemdPrivate XfpmSystemdPrivate;
++
++typedef struct
++{
++ GObject parent;
++ XfpmSystemdPrivate *priv;
++
++} XfpmSystemd;
++
++typedef struct
++{
++ GObjectClass parent_class;
++
++} XfpmSystemdClass;
++
++GType xfpm_systemd_get_type (void) G_GNUC_CONST;
++
++XfpmSystemd *xfpm_systemd_new (void);
++
++void xfpm_systemd_shutdown (XfpmSystemd *systemd,
++ GError **error);
++
++void xfpm_systemd_reboot (XfpmSystemd *systemd,
++ GError **error);
++
++G_END_DECLS
++
++#endif /* __XFPM_SYSTEMD_H */
Modified: desktop/branches/experimental/xfce4-power-manager/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/branches/experimental/xfce4-power-manager/debian/patches/series?rev=8134&op=diff
==============================================================================
--- desktop/branches/experimental/xfce4-power-manager/debian/patches/series (original)
+++ desktop/branches/experimental/xfce4-power-manager/debian/patches/series Sun Dec 29 22:02:00 2013
@@ -1,3 +1,6 @@
01_Remove_custom_OSD_brightness_popup,_use_libnotify_instead.patch
02_translations-fix-invalid-format-strings.patch
03_fix-insert-battery.patch
+04_add-systemd-logind-support-for-suspend_hibernate.patch
+05_dont-allow-systemd-to-handle-suspend-hibernate-events.patch
+06_add-shutdown-reboot-functionality-for-systemd.patch
Modified: desktop/branches/experimental/xfce4-power-manager/debian/rules
URL: http://svn.debian.org/wsvn/pkg-xfce/desktop/branches/experimental/xfce4-power-manager/debian/rules?rev=8134&op=diff
==============================================================================
--- desktop/branches/experimental/xfce4-power-manager/debian/rules (original)
+++ desktop/branches/experimental/xfce4-power-manager/debian/rules Sun Dec 29 22:02:00 2013
@@ -5,10 +5,10 @@
override_dh_auto_configure:
NOCONFIGURE=1 xdt-autogen
- dh_auto_configure
+ dh_auto_configure -- --disable-silent-rules
override_dh_install:
dh_install --fail-missing
%:
- dh $@ --parallel --with autoreconf
+ dh $@ --parallel
More information about the Pkg-xfce-commits
mailing list