Submitted By: Armin K. Date: 2014-02-26 Initial Package Version: 4.10.1 Upstream Status: Submitted Upstream Origin: Upstream Bugzilla Description: Fixes suspend and hibernate when using systemd-logind instead of ConsoleKit. --- a/xfce4-session/Makefile.am 2013-05-05 17:33:55.000000000 +0200 +++ b/xfce4-session/Makefile.am 2014-02-26 22:29:23.071945784 +0100 @@ -59,9 +59,7 @@ xfsm-splash-screen.c \ xfsm-splash-screen.h \ xfsm-startup.c \ - xfsm-startup.h \ - xfsm-upower.c \ - xfsm-upower.h + xfsm-startup.h if HAVE_SYSTEMD xfce4_session_SOURCES += \ @@ -70,7 +68,9 @@ else xfce4_session_SOURCES += \ xfsm-consolekit.c \ - xfsm-consolekit.h + xfsm-consolekit.h \ + xfsm-upower.c \ + xfsm-upower.h endif xfce4_session_CFLAGS = \ --- a/xfce4-session/Makefile.in 2013-05-05 17:33:59.000000000 +0200 +++ b/xfce4-session/Makefile.in 2014-02-26 22:29:23.072945802 +0100 @@ -57,7 +57,9 @@ @HAVE_SYSTEMD_FALSE@am__append_2 = \ @HAVE_SYSTEMD_FALSE@ xfsm-consolekit.c \ -@HAVE_SYSTEMD_FALSE@ xfsm-consolekit.h +@HAVE_SYSTEMD_FALSE@ xfsm-consolekit.h \ +@HAVE_SYSTEMD_FALSE@ xfsm-upower.c \ +@HAVE_SYSTEMD_FALSE@ xfsm-upower.h subdir = xfce4-session DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ @@ -84,13 +86,14 @@ xfsm-manager.h xfsm-properties.c xfsm-properties.h \ xfsm-shutdown.c xfsm-shutdown.h xfsm-splash-screen.c \ xfsm-splash-screen.h xfsm-startup.c xfsm-startup.h \ - xfsm-upower.c xfsm-upower.h xfsm-systemd.c xfsm-systemd.h \ - xfsm-consolekit.c xfsm-consolekit.h + xfsm-systemd.c xfsm-systemd.h xfsm-consolekit.c \ + xfsm-consolekit.h xfsm-upower.c xfsm-upower.h am__objects_1 = xfce4_session-xfsm-marshal.$(OBJEXT) @HAVE_SYSTEMD_TRUE@am__objects_2 = \ @HAVE_SYSTEMD_TRUE@ xfce4_session-xfsm-systemd.$(OBJEXT) @HAVE_SYSTEMD_FALSE@am__objects_3 = \ -@HAVE_SYSTEMD_FALSE@ xfce4_session-xfsm-consolekit.$(OBJEXT) +@HAVE_SYSTEMD_FALSE@ xfce4_session-xfsm-consolekit.$(OBJEXT) \ +@HAVE_SYSTEMD_FALSE@ xfce4_session-xfsm-upower.$(OBJEXT) am_xfce4_session_OBJECTS = $(am__objects_1) \ xfce4_session-ice-layer.$(OBJEXT) xfce4_session-main.$(OBJEXT) \ xfce4_session-sm-layer.$(OBJEXT) \ @@ -108,8 +111,7 @@ xfce4_session-xfsm-properties.$(OBJEXT) \ xfce4_session-xfsm-shutdown.$(OBJEXT) \ xfce4_session-xfsm-splash-screen.$(OBJEXT) \ - xfce4_session-xfsm-startup.$(OBJEXT) \ - xfce4_session-xfsm-upower.$(OBJEXT) $(am__objects_2) \ + xfce4_session-xfsm-startup.$(OBJEXT) $(am__objects_2) \ $(am__objects_3) xfce4_session_OBJECTS = $(am_xfce4_session_OBJECTS) am__DEPENDENCIES_1 = @@ -444,8 +446,7 @@ xfsm-logout-dialog.h xfsm-manager.c xfsm-manager.h \ xfsm-properties.c xfsm-properties.h xfsm-shutdown.c \ xfsm-shutdown.h xfsm-splash-screen.c xfsm-splash-screen.h \ - xfsm-startup.c xfsm-startup.h xfsm-upower.c xfsm-upower.h \ - $(am__append_1) $(am__append_2) + xfsm-startup.c xfsm-startup.h $(am__append_1) $(am__append_2) xfce4_session_CFLAGS = \ $(LIBSM_CFLAGS) \ $(LIBX11_CFLAGS) \ @@ -897,20 +898,6 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-startup.obj `if test -f 'xfsm-startup.c'; then $(CYGPATH_W) 'xfsm-startup.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-startup.c'; fi` -xfce4_session-xfsm-upower.o: xfsm-upower.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-upower.o -MD -MP -MF $(DEPDIR)/xfce4_session-xfsm-upower.Tpo -c -o xfce4_session-xfsm-upower.o `test -f 'xfsm-upower.c' || echo '$(srcdir)/'`xfsm-upower.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xfce4_session-xfsm-upower.Tpo $(DEPDIR)/xfce4_session-xfsm-upower.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xfsm-upower.c' object='xfce4_session-xfsm-upower.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-upower.o `test -f 'xfsm-upower.c' || echo '$(srcdir)/'`xfsm-upower.c - -xfce4_session-xfsm-upower.obj: xfsm-upower.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-upower.obj -MD -MP -MF $(DEPDIR)/xfce4_session-xfsm-upower.Tpo -c -o xfce4_session-xfsm-upower.obj `if test -f 'xfsm-upower.c'; then $(CYGPATH_W) 'xfsm-upower.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-upower.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xfce4_session-xfsm-upower.Tpo $(DEPDIR)/xfce4_session-xfsm-upower.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xfsm-upower.c' object='xfce4_session-xfsm-upower.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-upower.obj `if test -f 'xfsm-upower.c'; then $(CYGPATH_W) 'xfsm-upower.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-upower.c'; fi` - xfce4_session-xfsm-systemd.o: xfsm-systemd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-systemd.o -MD -MP -MF $(DEPDIR)/xfce4_session-xfsm-systemd.Tpo -c -o xfce4_session-xfsm-systemd.o `test -f 'xfsm-systemd.c' || echo '$(srcdir)/'`xfsm-systemd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xfce4_session-xfsm-systemd.Tpo $(DEPDIR)/xfce4_session-xfsm-systemd.Po @@ -939,6 +926,20 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-consolekit.obj `if test -f 'xfsm-consolekit.c'; then $(CYGPATH_W) 'xfsm-consolekit.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-consolekit.c'; fi` +xfce4_session-xfsm-upower.o: xfsm-upower.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-upower.o -MD -MP -MF $(DEPDIR)/xfce4_session-xfsm-upower.Tpo -c -o xfce4_session-xfsm-upower.o `test -f 'xfsm-upower.c' || echo '$(srcdir)/'`xfsm-upower.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xfce4_session-xfsm-upower.Tpo $(DEPDIR)/xfce4_session-xfsm-upower.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xfsm-upower.c' object='xfce4_session-xfsm-upower.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-upower.o `test -f 'xfsm-upower.c' || echo '$(srcdir)/'`xfsm-upower.c + +xfce4_session-xfsm-upower.obj: xfsm-upower.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -MT xfce4_session-xfsm-upower.obj -MD -MP -MF $(DEPDIR)/xfce4_session-xfsm-upower.Tpo -c -o xfce4_session-xfsm-upower.obj `if test -f 'xfsm-upower.c'; then $(CYGPATH_W) 'xfsm-upower.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-upower.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/xfce4_session-xfsm-upower.Tpo $(DEPDIR)/xfce4_session-xfsm-upower.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='xfsm-upower.c' object='xfce4_session-xfsm-upower.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(xfce4_session_CFLAGS) $(CFLAGS) -c -o xfce4_session-xfsm-upower.obj `if test -f 'xfsm-upower.c'; then $(CYGPATH_W) 'xfsm-upower.c'; else $(CYGPATH_W) '$(srcdir)/xfsm-upower.c'; fi` + mostlyclean-libtool: -rm -f *.lo --- a/xfce4-session/xfsm-shutdown.c 2013-05-05 17:33:55.000000000 +0200 +++ b/xfce4-session/xfsm-shutdown.c 2014-02-26 22:29:23.072945802 +0100 @@ -66,12 +66,12 @@ #include #include #include -#include #ifdef HAVE_SYSTEMD #include #else #include +#include #endif static void xfsm_shutdown_finalize (GObject *object); @@ -100,8 +100,8 @@ XfsmSystemd *systemd; #else XfsmConsolekit *consolekit; -#endif XfsmUPower *upower; +#endif /* kiosk settings */ gboolean kiosk_can_shutdown; @@ -142,8 +142,8 @@ shutdown->systemd = xfsm_systemd_get (); #else shutdown->consolekit = xfsm_consolekit_get (); -#endif shutdown->upower = xfsm_upower_get (); +#endif shutdown->helper_state = SUDO_NOT_INITIAZED; shutdown->helper_require_password = FALSE; @@ -165,8 +165,8 @@ g_object_unref (G_OBJECT (shutdown->systemd)); #else g_object_unref (G_OBJECT (shutdown->consolekit)); -#endif g_object_unref (G_OBJECT (shutdown->upower)); +#endif /* close down helper */ xfsm_shutdown_sudo_free (shutdown); @@ -692,7 +692,11 @@ { g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); +#ifdef HAVE_SYSTEMD + return xfsm_systemd_try_suspend (shutdown->systemd, error); +#else return xfsm_upower_try_suspend (shutdown->upower, error); +#endif } @@ -703,7 +707,11 @@ { g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); +#ifdef HAVE_SYSTEMD + return xfsm_systemd_try_hibernate (shutdown->systemd, error); +#else return xfsm_upower_try_hibernate (shutdown->upower, error); +#endif } @@ -776,6 +784,8 @@ gboolean *auth_suspend, GError **error) { + gboolean ret; + g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); if (!xfsm_shutdown_kiosk_can_shutdown (shutdown, NULL)) @@ -784,8 +794,15 @@ return TRUE; } - return xfsm_upower_can_suspend (shutdown->upower, can_suspend, - auth_suspend, error); +#ifdef HAVE_SYSTEMD + ret = xfsm_systemd_can_suspend (shutdown->systemd, can_suspend, error); + *auth_suspend = *can_suspend; +#else + ret = xfsm_upower_can_suspend (shutdown->upower, can_suspend, + auth_suspend, error); +#endif + + return ret; } @@ -796,6 +813,8 @@ gboolean *auth_hibernate, GError **error) { + gboolean ret; + g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE); if (!xfsm_shutdown_kiosk_can_shutdown (shutdown, NULL)) @@ -804,8 +823,15 @@ return TRUE; } - return xfsm_upower_can_hibernate (shutdown->upower, can_hibernate, - auth_hibernate, error); +#ifdef HAVE_SYSTEMD + ret = xfsm_systemd_can_hibernate (shutdown->systemd, can_hibernate, error); + *auth_hibernate = *can_hibernate; +#else + ret = xfsm_upower_can_hibernate (shutdown->upower, can_hibernate, + auth_hibernate, error); +#endif + + return ret; } --- a/xfce4-session/xfsm-systemd.c 2013-05-05 17:33:55.000000000 +0200 +++ b/xfce4-session/xfsm-systemd.c 2014-02-26 22:29:23.072945802 +0100 @@ -33,8 +33,12 @@ #define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager" #define SYSTEMD_REBOOT_ACTION "Reboot" #define SYSTEMD_POWEROFF_ACTION "PowerOff" +#define SYSTEMD_SUSPEND_ACTION "Suspend" +#define SYSTEMD_HIBERNATE_ACTION "Hibernate" #define SYSTEMD_REBOOT_TEST "org.freedesktop.login1.reboot" #define SYSTEMD_POWEROFF_TEST "org.freedesktop.login1.power-off" +#define SYSTEMD_SUSPEND_TEST "org.freedesktop.login1.suspend" +#define SYSTEMD_HIBERNATE_TEST "org.freedesktop.login1.hibernate" @@ -205,6 +209,28 @@ gboolean +xfsm_systemd_try_suspend (XfsmSystemd *systemd, + GError **error) +{ + return xfsm_systemd_try_method (systemd, + SYSTEMD_SUSPEND_ACTION, + error); +} + + + +gboolean +xfsm_systemd_try_hibernate (XfsmSystemd *systemd, + GError **error) +{ + return xfsm_systemd_try_method (systemd, + SYSTEMD_HIBERNATE_ACTION, + error); +} + + + +gboolean xfsm_systemd_can_restart (XfsmSystemd *systemd, gboolean *can_restart, GError **error) @@ -227,3 +253,29 @@ SYSTEMD_POWEROFF_TEST, error); } + + + +gboolean +xfsm_systemd_can_suspend (XfsmSystemd *systemd, + gboolean *can_suspend, + GError **error) +{ + return xfsm_systemd_can_method (systemd, + can_suspend, + SYSTEMD_SUSPEND_TEST, + error); +} + + + +gboolean +xfsm_systemd_can_hibernate (XfsmSystemd *systemd, + gboolean *can_hibernate, + GError **error) +{ + return xfsm_systemd_can_method (systemd, + can_hibernate, + SYSTEMD_HIBERNATE_TEST, + error); +} --- a/xfce4-session/xfsm-systemd.h 2013-05-05 17:33:55.000000000 +0200 +++ b/xfce4-session/xfsm-systemd.h 2014-02-26 22:29:23.072945802 +0100 @@ -42,6 +42,12 @@ gboolean xfsm_systemd_try_shutdown (XfsmSystemd *systemd, GError **error); +gboolean xfsm_systemd_try_suspend (XfsmSystemd *systemd, + GError **error); + +gboolean xfsm_systemd_try_hibernate (XfsmSystemd *systemd, + GError **error); + gboolean xfsm_systemd_can_restart (XfsmSystemd *systemd, gboolean *can_restart, GError **error); @@ -50,6 +56,14 @@ gboolean *can_shutdown, GError **error); +gboolean xfsm_systemd_can_suspend (XfsmSystemd *systemd, + gboolean *can_suspend, + GError **error); + +gboolean xfsm_systemd_can_hibernate (XfsmSystemd *systemd, + gboolean *can_hibernate, + GError **error); + G_END_DECLS #endif /* __XFSM_SYSTEMD_H__ */