Magellan Linux

Annotation of /trunk/xfce4-session/patches/xfce4-session-4.10.0-systemd.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1893 - (hide annotations) (download)
Fri Sep 7 08:08:34 2012 UTC (11 years, 8 months ago) by niro
File size: 12412 byte(s)
-added systemd support patch
1 niro 1893 diff -Naur xfce4-session-4.10.0/configure.in xfce4-session-4.10.0-systemd/configure.in
2     --- xfce4-session-4.10.0/configure.in 2012-04-28 22:43:29.000000000 +0200
3     +++ xfce4-session-4.10.0-systemd/configure.in 2012-09-07 12:01:58.834983189 +0200
4     @@ -101,6 +101,33 @@
5     XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.84])
6     XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.9.0])
7    
8     +dnl systemd integration
9     +AC_ARG_ENABLE([systemd],
10     + AS_HELP_STRING([--enable-systemd], [Use systemd]),
11     + [with_systemd=$enableval],
12     + [with_systemd=auto])
13     +PKG_CHECK_MODULES(SYSTEMD,
14     + [libsystemd-login polkit-gobject-1],
15     + [have_systemd=yes], [have_systemd=no])
16     +AC_MSG_CHECKING([whether to use systemd])
17     +if test x$with_systemd = xauto ; then
18     + if test x$have_systemd = xno ; then
19     + with_systemd=no
20     + else
21     + with_systemd=yes
22     + fi
23     +fi
24     +AC_MSG_RESULT($with_systemd)
25     +if test x$with_systemd = xyes; then
26     + if test x$have_systemd = xno; then
27     + AC_MSG_ERROR([Systemd support explicitly required, but systemd not found])
28     + fi
29     + AC_DEFINE(HAVE_SYSTEMD, 1, [Define if systemd is used for session tracking])
30     +fi
31     +AC_SUBST(SYSTEMD_CFLAGS)
32     +AC_SUBST(SYSTEMD_LIBS)
33     +AM_CONDITIONAL(WITH_SYSTEMD, [test "$with_systemd" = "yes"], [Using systemd])
34     +
35     dnl Check for gnome support
36     XDT_CHECK_OPTIONAL_PACKAGE([GNOME_KEYRING], [gnome-keyring-1], [2.22],
37     [libgnome-keyring],
38     diff -Naur xfce4-session-4.10.0/xfce4-session/Makefile.am xfce4-session-4.10.0-systemd/xfce4-session/Makefile.am
39     --- xfce4-session-4.10.0/xfce4-session/Makefile.am 2012-04-28 22:43:27.000000000 +0200
40     +++ xfce4-session-4.10.0-systemd/xfce4-session/Makefile.am 2012-09-07 12:06:49.474983418 +0200
41     @@ -38,8 +38,6 @@
42     xfsm-compat-gnome.h \
43     xfsm-compat-kde.c \
44     xfsm-compat-kde.h \
45     - xfsm-consolekit.c \
46     - xfsm-consolekit.h \
47     xfsm-dns.c \
48     xfsm-dns.h \
49     xfsm-error.c \
50     @@ -65,6 +63,16 @@
51     xfsm-upower.c \
52     xfsm-upower.h
53    
54     +if WITH_SYSTEMD
55     +xfce4_session_SOURCES += \
56     + xfsm-systemd.c \
57     + xfsm-systemd.h
58     +else
59     +xfce4_session_SOURCES += \
60     + xfsm-consolekit.c \
61     + xfsm-consolekit.h
62     +endif
63     +
64     xfce4_session_CFLAGS = \
65     $(GNOME_KEYRING_CFLAGS) \
66     $(LIBSM_CFLAGS) \
67     @@ -73,6 +81,7 @@
68     $(DBUS_CFLAGS) \
69     $(DBUS_GLIB_CFLAGS) \
70     $(LIBWNCK_CFLAGS) \
71     + $(SYSTEMD_CFLAGS) \
72     $(XFCONF_CFLAGS) \
73     $(GMODULE_CFLAGS) \
74     $(PLATFORM_CFLAGS)
75     @@ -92,6 +101,7 @@
76     $(DBUS_LIBS) \
77     $(DBUS_GLIB_LIBS) \
78     $(LIBWNCK_LIBS) \
79     + $(SYSTEMD_LIBS) \
80     $(XFCONF_LIBS) \
81     $(GNOME_KEYRING_LIBS) \
82     -lm
83     diff -Naur xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c xfce4-session-4.10.0-systemd/xfce4-session/xfsm-shutdown.c
84     --- xfce4-session-4.10.0/xfce4-session/xfsm-shutdown.c 2012-04-28 22:43:27.000000000 +0200
85     +++ xfce4-session-4.10.0-systemd/xfce4-session/xfsm-shutdown.c 2012-09-07 12:07:35.136983115 +0200
86     @@ -66,10 +66,13 @@
87     #include <xfce4-session/xfsm-fadeout.h>
88     #include <xfce4-session/xfsm-global.h>
89     #include <xfce4-session/xfsm-legacy.h>
90     -#include <xfce4-session/xfsm-consolekit.h>
91     #include <xfce4-session/xfsm-upower.h>
92    
93     -
94     +#ifdef HAVE_SYSTEMD
95     +#include <xfce4-session/xfsm-systemd.h>
96     +#else
97     +#include <xfce4-session/xfsm-consolekit.h>
98     +#endif
99    
100     static void xfsm_shutdown_finalize (GObject *object);
101     static void xfsm_shutdown_sudo_free (XfsmShutdown *shutdown);
102     @@ -93,7 +96,11 @@
103     {
104     GObject __parent__;
105    
106     +#ifdef HAVE_SYSTEMD
107     + SystemdProxy *systemd_proxy;
108     +#else
109     XfsmConsolekit *consolekit;
110     +#endif
111     XfsmUPower *upower;
112    
113     /* kiosk settings */
114     @@ -131,7 +138,11 @@
115     {
116     XfceKiosk *kiosk;
117    
118     +#ifdef HAVE_SYSTEMD
119     + shutdown->systemd_proxy = systemd_proxy_new ();
120     +#else
121     shutdown->consolekit = xfsm_consolekit_get ();
122     +#endif
123     shutdown->upower = xfsm_upower_get ();
124     shutdown->helper_state = SUDO_NOT_INITIAZED;
125     shutdown->helper_require_password = FALSE;
126     @@ -150,7 +161,11 @@
127     {
128     XfsmShutdown *shutdown = XFSM_SHUTDOWN (object);
129    
130     +#ifdef HAVE_SYSTEMD
131     + systemd_proxy_free (shutdown->systemd_proxy);
132     +#else
133     g_object_unref (G_OBJECT (shutdown->consolekit));
134     +#endif
135     g_object_unref (G_OBJECT (shutdown->upower));
136    
137     /* close down helper */
138     @@ -641,7 +656,11 @@
139     if (shutdown->helper_state == SUDO_AVAILABLE)
140     return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_RESTART, error);
141     else
142     +#ifdef HAVE_SYSTEMD
143     + return systemd_proxy_restart (shutdown->systemd_proxy, error);
144     +#else
145     return xfsm_consolekit_try_restart (shutdown->consolekit, error);
146     +#endif
147     }
148    
149    
150     @@ -658,7 +677,11 @@
151     if (shutdown->helper_state == SUDO_AVAILABLE)
152     return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_SHUTDOWN, error);
153     else
154     +#ifdef HAVE_SYSTEMD
155     + return systemd_proxy_shutdown (shutdown->systemd_proxy, error);
156     +#else
157     return xfsm_consolekit_try_shutdown (shutdown->consolekit, error);
158     +#endif
159     }
160    
161    
162     @@ -698,7 +721,11 @@
163     return TRUE;
164     }
165    
166     +#ifdef HAVE_SYSTEMD
167     + if (systemd_proxy_can_restart (shutdown->systemd_proxy, can_restart, error))
168     +#else
169     if (xfsm_consolekit_can_restart (shutdown->consolekit, can_restart, error))
170     +#endif
171     return TRUE;
172    
173     if (xfsm_shutdown_sudo_init (shutdown, error))
174     @@ -725,7 +752,11 @@
175     return TRUE;
176     }
177    
178     +#ifdef HAVE_SYSTEMD
179     + if (systemd_proxy_can_shutdown (shutdown->systemd_proxy, can_shutdown, error))
180     +#else
181     if (xfsm_consolekit_can_shutdown (shutdown->consolekit, can_shutdown, error))
182     +#endif
183     return TRUE;
184    
185     if (xfsm_shutdown_sudo_init (shutdown, error))
186     diff -Naur xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c xfce4-session-4.10.0-systemd/xfce4-session/xfsm-systemd.c
187     --- xfce4-session-4.10.0/xfce4-session/xfsm-systemd.c 1970-01-01 01:00:00.000000000 +0100
188     +++ xfce4-session-4.10.0-systemd/xfce4-session/xfsm-systemd.c 2012-09-07 12:00:48.529983137 +0200
189     @@ -0,0 +1,123 @@
190     +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
191     + *
192     + * Copyright (C) 2012 Christian Hesse
193     + *
194     + * Licensed under the GNU General Public License Version 2
195     + *
196     + * This program is free software; you can redistribute it and/or modify
197     + * it under the terms of the GNU General Public License as published by
198     + * the Free Software Foundation; either version 2 of the License, or
199     + * (at your option) any later version.
200     + *
201     + * This program is distributed in the hope that it will be useful,
202     + * but WITHOUT ANY WARRANTY; without even the implied warranty of
203     + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
204     + * GNU General Public License for more details.
205     + *
206     + * You should have received a copy of the GNU General Public License
207     + * along with this program; if not, write to the Free Software
208     + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
209     + */
210     +
211     +#include <config.h>
212     +
213     +#include <gio/gio.h>
214     +#include <polkit/polkit.h>
215     +
216     +#include "xfsm-systemd.h"
217     +
218     +#define SYSTEMD_DBUS_NAME "org.freedesktop.login1"
219     +#define SYSTEMD_DBUS_PATH "/org/freedesktop/login1"
220     +#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager"
221     +#define SYSTEMD_REBOOT_ACTION "org.freedesktop.login1.reboot"
222     +#define SYSTEMD_SHUTDOWN_ACTION "org.freedesktop.login1.shutdown"
223     +
224     +struct _SystemdProxy {
225     + PolkitAuthority *authority;
226     + PolkitSubject *subject;
227     +};
228     +
229     +SystemdProxy *
230     +systemd_proxy_new (void)
231     +{
232     + SystemdProxy *proxy;
233     +
234     + proxy = g_new0 (SystemdProxy, 1);
235     +
236     + proxy->authority = polkit_authority_get_sync (NULL, NULL);
237     + proxy->subject = polkit_unix_session_new_for_process_sync (getpid(), NULL, NULL);
238     +
239     + return proxy;
240     +}
241     +
242     +void
243     +systemd_proxy_free (SystemdProxy *proxy)
244     +{
245     + g_object_unref (proxy->authority);
246     + g_object_unref (proxy->subject);
247     +
248     + g_free (proxy);
249     +}
250     +
251     +gboolean systemd_proxy_can_method (SystemdProxy *proxy, gboolean *can_method, const gchar *method, GError **error)
252     +{
253     + PolkitAuthorizationResult *res;
254     + GError *local_error = NULL;
255     +
256     + *can_method = FALSE;
257     + res = polkit_authority_check_authorization_sync (proxy->authority,
258     + proxy->subject,
259     + method,
260     + NULL,
261     + POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
262     + NULL,
263     + &local_error);
264     + if (res == NULL) {
265     + g_propagate_error (error, local_error);
266     + return FALSE;
267     + }
268     +
269     + *can_method = polkit_authorization_result_get_is_authorized (res) ||
270     + polkit_authorization_result_get_is_challenge (res);
271     +
272     + g_object_unref (res);
273     +
274     + return TRUE;
275     +}
276     +
277     +gboolean systemd_proxy_can_restart (SystemdProxy *proxy, gboolean *can_restart, GError **error)
278     +{
279     + return systemd_proxy_can_method(proxy, can_restart, SYSTEMD_REBOOT_ACTION, error);
280     +}
281     +
282     +gboolean systemd_proxy_can_shutdown (SystemdProxy *proxy, gboolean *can_shutdown, GError **error)
283     +{
284     + return systemd_proxy_can_method(proxy, can_shutdown, SYSTEMD_SHUTDOWN_ACTION, error);
285     +}
286     +
287     +gboolean systemd_proxy_method (SystemdProxy *proxy, const gchar *method, GError **error)
288     +{
289     + GDBusConnection *bus;
290     +
291     + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
292     + g_dbus_connection_call (bus,
293     + SYSTEMD_DBUS_NAME,
294     + SYSTEMD_DBUS_PATH,
295     + SYSTEMD_DBUS_INTERFACE,
296     + method,
297     + g_variant_new ("(b)", TRUE),
298     + NULL, 0, G_MAXINT, NULL, NULL, NULL);
299     + g_object_unref (bus);
300     +
301     + return TRUE;
302     +}
303     +
304     +gboolean systemd_proxy_restart (SystemdProxy *proxy, GError **error)
305     +{
306     + return systemd_proxy_method(proxy, "Restart", error);
307     +}
308     +
309     +gboolean systemd_proxy_shutdown (SystemdProxy *proxy, GError **error)
310     +{
311     + return systemd_proxy_method(proxy, "Shutdown", error);
312     +}
313     diff -Naur xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h xfce4-session-4.10.0-systemd/xfce4-session/xfsm-systemd.h
314     --- xfce4-session-4.10.0/xfce4-session/xfsm-systemd.h 1970-01-01 01:00:00.000000000 +0100
315     +++ xfce4-session-4.10.0-systemd/xfce4-session/xfsm-systemd.h 2012-09-07 12:00:48.530983150 +0200
316     @@ -0,0 +1,42 @@
317     +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
318     + *
319     + * Copyright (C) 2012 Christian Hesse
320     + *
321     + * Licensed under the GNU General Public License Version 2
322     + *
323     + * This program is free software; you can redistribute it and/or modify
324     + * it under the terms of the GNU General Public License as published by
325     + * the Free Software Foundation; either version 2 of the License, or
326     + * (at your option) any later version.
327     + *
328     + * This program is distributed in the hope that it will be useful,
329     + * but WITHOUT ANY WARRANTY; without even the implied warranty of
330     + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
331     + * GNU General Public License for more details.
332     + *
333     + * You should have received a copy of the GNU General Public License
334     + * along with this program; if not, write to the Free Software
335     + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
336     + */
337     +
338     +#ifndef __SYSTEMD_PROXY_H__
339     +#define __SYSTEMD_PROXY_H__
340     +
341     +#include <glib.h>
342     +
343     +G_BEGIN_DECLS
344     +
345     +typedef struct _SystemdProxy SystemdProxy;
346     +
347     +SystemdProxy *systemd_proxy_new (void);
348     +void systemd_proxy_free (SystemdProxy *proxy);
349     +gboolean systemd_proxy_can_method (SystemdProxy *proxy, gboolean *can_method, const char *method, GError **error);
350     +gboolean systemd_proxy_can_restart (SystemdProxy *proxy, gboolean *can_restart, GError **error);
351     +gboolean systemd_proxy_can_shutdown (SystemdProxy *proxy, gboolean *can_shutdown, GError **error);
352     +gboolean systemd_proxy_method (SystemdProxy *proxy, const char *method, GError **error);
353     +gboolean systemd_proxy_restart (SystemdProxy *proxy, GError **error);
354     +gboolean systemd_proxy_shutdown (SystemdProxy *proxy, GError **error);
355     +
356     +G_END_DECLS
357     +
358     +#endif /* __SYSTEMD_PROXY_H__ */