commit 0864d0d4c718754b3f431dec0e07f6c05c7b2cbb
Author: Jan RÄ™korajski <[email protected]>
Date:   Thu Apr 18 22:16:47 2013 +0200

    - add systemd-logind support
    
    initial Patch from arch linux / 
https://bugzilla.xfce.org/show_bug.cgi?id=8729
    fedpra added suspend,hibernate support

 xfce4-session-add-systemd-support.patch | 413 ++++++++++++++++++++++++++++++++
 1 file changed, 413 insertions(+)
---
diff --git a/xfce4-session-add-systemd-support.patch 
b/xfce4-session-add-systemd-support.patch
new file mode 100644
index 0000000..ec44190
--- /dev/null
+++ b/xfce4-session-add-systemd-support.patch
@@ -0,0 +1,413 @@
+diff -up xfce4-session-4.10.0/configure.in.systemd 
xfce4-session-4.10.0/configure.in
+--- xfce4-session-4.10.0/configure.in.systemd  2012-04-28 15:43:29.000000000 
-0500
++++ xfce4-session-4.10.0/configure.in  2013-03-29 14:29:28.468230742 -0500
+@@ -101,6 +101,33 @@ XDT_CHECK_PACKAGE([DBUS], [dbus-1], [1.1
+ XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.84])
+ XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.9.0])
+ 
++dnl systemd integration
++AC_ARG_ENABLE([systemd],
++              AS_HELP_STRING([--enable-systemd], [Use systemd]),
++              [with_systemd=$enableval],
++              [with_systemd=auto])
++PKG_CHECK_MODULES(SYSTEMD,
++                  [libsystemd-login polkit-gobject-1],
++                  [have_systemd=yes], [have_systemd=no])
++AC_MSG_CHECKING([whether to use systemd])
++if test x$with_systemd = xauto ; then
++        if test x$have_systemd = xno ; then
++                with_systemd=no
++        else
++                with_systemd=yes
++        fi
++fi
++AC_MSG_RESULT($with_systemd)
++if test x$with_systemd = xyes; then
++        if test x$have_systemd = xno; then
++                AC_MSG_ERROR([Systemd support explicitly required, but 
systemd not found])
++        fi
++        AC_DEFINE(HAVE_SYSTEMD, 1, [Define if systemd is used for session 
tracking])
++fi
++AC_SUBST(SYSTEMD_CFLAGS)
++AC_SUBST(SYSTEMD_LIBS)
++AM_CONDITIONAL(WITH_SYSTEMD, [test "$with_systemd" = "yes"], [Using systemd])
++
+ dnl Check for gnome support
+ XDT_CHECK_OPTIONAL_PACKAGE([GNOME_KEYRING], [gnome-keyring-1], [2.22],
+                            [libgnome-keyring],
+diff -up xfce4-session-4.10.0/xfce4-session/Makefile.am.systemd 
xfce4-session-4.10.0/xfce4-session/Makefile.am
+--- xfce4-session-4.10.0/xfce4-session/Makefile.am.systemd     2012-04-28 
15:43:27.000000000 -0500
++++ xfce4-session-4.10.0/xfce4-session/Makefile.am     2013-03-29 
14:29:28.468230742 -0500
+@@ -38,8 +38,6 @@ xfce4_session_SOURCES =                                      
                \
+       xfsm-compat-gnome.h                                             \
+       xfsm-compat-kde.c                                               \
+       xfsm-compat-kde.h                                               \
+-      xfsm-consolekit.c                                               \
+-      xfsm-consolekit.h                                               \
+       xfsm-dns.c                                                      \
+       xfsm-dns.h                                                      \
+       xfsm-error.c                                                    \
+@@ -65,6 +63,16 @@ xfce4_session_SOURCES =                                     
                \
+       xfsm-upower.c                                                   \
+       xfsm-upower.h
+ 
++if WITH_SYSTEMD
++xfce4_session_SOURCES +=                                              \
++      xfsm-systemd.c                                                  \
++      xfsm-systemd.h
++else
++xfce4_session_SOURCES +=                                              \
++      xfsm-consolekit.c                                               \
++      xfsm-consolekit.h
++endif
++
+ xfce4_session_CFLAGS =                                                        
\
+       $(GNOME_KEYRING_CFLAGS)                                         \
+       $(LIBSM_CFLAGS)                                                 \
+@@ -73,6 +81,7 @@ xfce4_session_CFLAGS =                                       
                \
+       $(DBUS_CFLAGS)                                                  \
+       $(DBUS_GLIB_CFLAGS)                                             \
+       $(LIBWNCK_CFLAGS)                                               \
++      $(SYSTEMD_CFLAGS)                                               \
+       $(XFCONF_CFLAGS)                                                \
+       $(GMODULE_CFLAGS)                                               \
+       $(PLATFORM_CFLAGS)
+@@ -92,6 +101,7 @@ xfce4_session_LDADD =                                       
                \
+       $(DBUS_LIBS)                                                    \
+       $(DBUS_GLIB_LIBS)                                               \
+       $(LIBWNCK_LIBS)                                                 \
++      $(SYSTEMD_LIBS)                                                 \
+       $(XFCONF_LIBS)                                                  \
+       $(GNOME_KEYRING_LIBS)                                           \
+       -lm
+diff -up xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c.systemd 
xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c
+--- xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c.systemd 2012-04-28 
15:43:27.000000000 -0500
++++ xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c 2013-03-29 
14:34:40.377331342 -0500
+@@ -66,10 +66,13 @@
+ #include <xfce4-session/xfsm-fadeout.h>
+ #include <xfce4-session/xfsm-global.h>
+ #include <xfce4-session/xfsm-legacy.h>
+-#include <xfce4-session/xfsm-consolekit.h>
+ #include <xfce4-session/xfsm-upower.h>
+ 
+-
++#ifdef HAVE_SYSTEMD
++#include <xfce4-session/xfsm-systemd.h>
++#else
++#include <xfce4-session/xfsm-consolekit.h>
++#endif
+ 
+ static void xfsm_shutdown_finalize  (GObject      *object);
+ static void xfsm_shutdown_sudo_free (XfsmShutdown *shutdown);
+@@ -93,7 +96,11 @@ struct _XfsmShutdown
+ {
+   GObject __parent__;
+ 
+-  XfsmConsolekit *consolekit;
++#ifdef HAVE_SYSTEMD
++  SystemdProxy   *systemd_proxy;
++#else
++   XfsmConsolekit *consolekit;
++#endif
+   XfsmUPower     *upower;
+ 
+   /* kiosk settings */
+@@ -130,8 +137,11 @@ static void
+ xfsm_shutdown_init (XfsmShutdown *shutdown)
+ {
+   XfceKiosk *kiosk;
+-
++#ifdef HAVE_SYSTEMD
++  shutdown->systemd_proxy = systemd_proxy_new ();
++#else
+   shutdown->consolekit = xfsm_consolekit_get ();
++#endif
+   shutdown->upower = xfsm_upower_get ();
+   shutdown->helper_state = SUDO_NOT_INITIAZED;
+   shutdown->helper_require_password = FALSE;
+@@ -150,7 +160,11 @@ xfsm_shutdown_finalize (GObject *object)
+ {
+   XfsmShutdown *shutdown = XFSM_SHUTDOWN (object);
+ 
++#ifdef HAVE_SYSTEMD
++  systemd_proxy_free (shutdown->systemd_proxy);
++#else
+   g_object_unref (G_OBJECT (shutdown->consolekit));
++#endif
+   g_object_unref (G_OBJECT (shutdown->upower));
+ 
+   /* close down helper */
+@@ -641,7 +655,11 @@ xfsm_shutdown_try_restart (XfsmShutdown
+   if (shutdown->helper_state == SUDO_AVAILABLE)
+     return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_RESTART, 
error);
+   else
++#ifdef HAVE_SYSTEMD
++    return systemd_proxy_restart (shutdown->systemd_proxy, error);
++#else
+     return xfsm_consolekit_try_restart (shutdown->consolekit, error);
++#endif
+ }
+ 
+ 
+@@ -658,7 +676,11 @@ xfsm_shutdown_try_shutdown (XfsmShutdown
+   if (shutdown->helper_state == SUDO_AVAILABLE)
+     return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_SHUTDOWN, 
error);
+   else
++#ifdef HAVE_SYSTEMD
++    return systemd_proxy_shutdown (shutdown->systemd_proxy, error);
++#else
+     return xfsm_consolekit_try_shutdown (shutdown->consolekit, error);
++#endif
+ }
+ 
+ 
+@@ -669,7 +691,11 @@ xfsm_shutdown_try_suspend (XfsmShutdown
+ {
+   g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE);
+ 
++#ifdef HAVE_SYSTEMD
++  return systemd_proxy_suspend (shutdown->systemd_proxy, error);
++#else
+   return xfsm_upower_try_suspend (shutdown->upower, error);
++#endif
+ }
+ 
+ 
+@@ -680,7 +706,11 @@ xfsm_shutdown_try_hibernate (XfsmShutdow
+ {
+   g_return_val_if_fail (XFSM_IS_SHUTDOWN (shutdown), FALSE);
+ 
++#ifdef HAVE_SYSTEMD
++  return systemd_proxy_hibernate (shutdown->systemd_proxy, error);
++#else
+   return xfsm_upower_try_hibernate (shutdown->upower, error);
++#endif
+ }
+ 
+ 
+@@ -697,8 +727,11 @@ xfsm_shutdown_can_restart (XfsmShutdown
+       *can_restart = FALSE;
+       return TRUE;
+     }
+-
++#ifdef HAVE_SYSTEMD
++  if (systemd_proxy_can_restart (shutdown->systemd_proxy, can_restart, error))
++#else
+   if (xfsm_consolekit_can_restart (shutdown->consolekit, can_restart, error))
++#endif
+     return TRUE;
+ 
+   if (xfsm_shutdown_sudo_init (shutdown, error))
+@@ -724,8 +757,11 @@ xfsm_shutdown_can_shutdown (XfsmShutdown
+       *can_shutdown = FALSE;
+       return TRUE;
+     }
+-
++#ifdef HAVE_SYSTEMD
++  if (systemd_proxy_can_shutdown (shutdown->systemd_proxy, can_shutdown, 
error))
++#else
+   if (xfsm_consolekit_can_shutdown (shutdown->consolekit, can_shutdown, 
error))
++#endif
+     return TRUE;
+ 
+   if (xfsm_shutdown_sudo_init (shutdown, error))
+diff -up xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c.systemd 
xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c
+--- xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c.systemd  2013-03-29 
14:29:28.469230730 -0500
++++ xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c  2013-03-29 
14:39:52.551428628 -0500
+@@ -0,0 +1,146 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
++ *
++ * Copyright (C) 2012 Christian Hesse
++ *
++ * 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.
++ */
++
++#include <config.h>
++
++#include <gio/gio.h>
++#include <polkit/polkit.h>
++
++#include "xfsm-systemd.h"
++
++#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   "org.freedesktop.login1.reboot"
++#define SYSTEMD_SHUTDOWN_ACTION "org.freedesktop.login1.power-off"
++#define SYSTEMD_SUSPEND_ACTION  "org.freedesktop.login1.suspend"
++#define SYSTEMD_HIBERNATE_ACTION "org.freedesktop.login1.hibernate"
++
++struct _SystemdProxy {
++        PolkitAuthority *authority;
++        PolkitSubject *subject;
++};
++
++SystemdProxy *
++systemd_proxy_new (void)
++{
++        SystemdProxy *proxy;
++
++        proxy = g_new0 (SystemdProxy, 1);
++
++        proxy->authority = polkit_authority_get_sync (NULL, NULL);
++        proxy->subject = polkit_unix_process_new (getpid());
++
++        return proxy;
++}
++
++void
++systemd_proxy_free (SystemdProxy *proxy)
++{
++        g_object_unref (proxy->authority);
++        g_object_unref (proxy->subject);
++
++        g_free (proxy);
++}
++
++gboolean systemd_proxy_can_method (SystemdProxy *proxy, gboolean *can_method, 
const gchar *method, GError **error)
++{
++        PolkitAuthorizationResult *res;
++        GError *local_error = NULL;
++
++        *can_method = FALSE;
++        res = polkit_authority_check_authorization_sync (proxy->authority,
++                                                         proxy->subject,
++                                                         method,
++                                                         NULL,
++                                                         
POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
++                                                         NULL,
++                                                         &local_error);
++        if (res == NULL) {
++                g_propagate_error (error, local_error);
++                return FALSE;
++        }
++
++        *can_method = polkit_authorization_result_get_is_authorized (res) ||
++                       polkit_authorization_result_get_is_challenge (res);
++
++        g_object_unref (res);
++
++        return TRUE;
++}
++
++gboolean systemd_proxy_can_restart (SystemdProxy *proxy, gboolean 
*can_restart, GError **error)
++{
++      return systemd_proxy_can_method(proxy, can_restart, 
SYSTEMD_REBOOT_ACTION, error);
++}
++
++gboolean systemd_proxy_can_shutdown (SystemdProxy *proxy, gboolean 
*can_shutdown, GError **error)
++{
++      return systemd_proxy_can_method(proxy, can_shutdown, 
SYSTEMD_SHUTDOWN_ACTION, error);
++}
++
++gboolean systemd_proxy_can_suspend (SystemdProxy *proxy, gboolean 
*can_suspend, GError **error)
++{
++        return systemd_proxy_can_method(proxy, can_suspend, 
SYSTEMD_SUSPEND_ACTION, error);
++}
++
++gboolean systemd_proxy_can_hibernate (SystemdProxy *proxy, gboolean 
*can_hibernate, GError **error)
++{
++        return systemd_proxy_can_method(proxy, can_hibernate, 
SYSTEMD_HIBERNATE_ACTION, error);
++}
++
++gboolean systemd_proxy_method (SystemdProxy *proxy, const gchar *method, 
GError **error)
++{
++        GDBusConnection *bus;
++
++        bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, 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, NULL);
++        g_object_unref (bus);
++
++        return TRUE;
++}
++
++gboolean systemd_proxy_restart (SystemdProxy *proxy, GError **error)
++{
++      return systemd_proxy_method(proxy, "Reboot", error);
++}
++
++gboolean systemd_proxy_shutdown (SystemdProxy *proxy, GError **error)
++{
++      return systemd_proxy_method(proxy, "PowerOff", error);
++}
++
++gboolean systemd_proxy_suspend (SystemdProxy *proxy, GError **error)
++{
++        return systemd_proxy_method(proxy, "Suspend", error);
++}
++
++gboolean systemd_proxy_hibernate (SystemdProxy *proxy, GError **error)
++{
++        return systemd_proxy_method(proxy, "Hibernate", error);
++}
++
+diff -up xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h.systemd 
xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h
+--- xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h.systemd  2013-03-29 
14:29:28.469230730 -0500
++++ xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h  2013-03-29 
14:35:54.549404063 -0500
+@@ -0,0 +1,46 @@
++/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
++ *
++ * Copyright (C) 2012 Christian Hesse
++ *
++ * 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 __SYSTEMD_PROXY_H__
++#define __SYSTEMD_PROXY_H__
++
++#include <glib.h>
++
++G_BEGIN_DECLS
++
++typedef struct _SystemdProxy SystemdProxy;
++
++SystemdProxy *systemd_proxy_new (void);
++void          systemd_proxy_free (SystemdProxy *proxy);
++gboolean      systemd_proxy_can_method (SystemdProxy *proxy, gboolean 
*can_method, const char *method, GError **error);
++gboolean      systemd_proxy_can_restart (SystemdProxy *proxy, gboolean 
*can_restart, GError **error);
++gboolean      systemd_proxy_can_shutdown (SystemdProxy *proxy, gboolean 
*can_shutdown, GError **error);
++gboolean      systemd_proxy_can_suspend (SystemdProxy *proxy, gboolean 
*can_suspend, GError **error);
++gboolean      systemd_proxy_can_hibernate (SystemdProxy *proxy, gboolean 
*can_hibernate, GError **error);
++gboolean      systemd_proxy_method (SystemdProxy *proxy, const char *method, 
GError **error);
++gboolean      systemd_proxy_restart (SystemdProxy *proxy, GError **error);
++gboolean      systemd_proxy_shutdown (SystemdProxy *proxy, GError **error);
++gboolean      systemd_proxy_suspend (SystemdProxy *proxy, GError **error);
++gboolean      systemd_proxy_hibernate (SystemdProxy *proxy, GError **error);
++
++G_END_DECLS
++
++#endif  /* __SYSTEMD_PROXY_H__ */
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/xfce4-session.git/commitdiff/de01b6fcf74f90d4896db556d1b1a6e3b0263c1d

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to