[Xfce4-commits] [apps/xfce4-screensaver] 01/03: Add support for elogind (bug #15243)

noreply at xfce.org noreply at xfce.org
Wed Jun 5 11:32:52 CEST 2019


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-screensaver.

commit 7faa39544c7fbafb39daa55382d30be31a1a6950
Author: Michał Górny <mgorny at gentoo.org>
Date:   Sat Mar 23 08:03:56 2019 +0100

    Add support for elogind (bug #15243)
    
    Add support for elogind, the split-off implementation of systemd-logind
    for non-systemd systems.  It is mostly API-compatible, with the notable
    exception of renaming the library, so I've managed to keep changes
    to the minimum.  I've replaced 'systemd' and 'SYSTEMD_LOGIND' with plain
    'logind' to avoid the confusion that they are only used by systemd
    branches of the code.
    
    Signed-off-by: Michał Górny <mgorny at gentoo.org>
    Signed-off-by: Sean Davis <smd.seandavis at gmail.com>
---
 Makefile.am            |  1 +
 configure.ac           | 32 +++++++++++++++++++++++++
 src/Makefile.am        |  2 ++
 src/gs-listener-dbus.c | 63 ++++++++++++++++++++++++++------------------------
 4 files changed, 68 insertions(+), 30 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b88bf8c..94f4989 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,6 +6,7 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 NULL =
 
 DISTCHECK_CONFIGURE_FLAGS = \
+	--without-elogind \
 	--without-systemd
 
 SUBDIRS =			\
diff --git a/configure.ac b/configure.ac
index 6c412b0..9517de4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -985,6 +985,37 @@ AC_SUBST(SYSTEMD_CFLAGS)
 AC_SUBST(SYSTEMD_LIBS)
 
 dnl ---------------------------------------------------------------------------
+dnl elogind
+dnl ---------------------------------------------------------------------------
+
+AC_ARG_WITH(elogind,
+            AS_HELP_STRING([--with-elogind],
+            [Add elogind support]),
+            [with_elogind=$withval], [with_elogind=auto])
+
+PKG_CHECK_MODULES(ELOGIND, [libelogind], [have_elogind=yes], [have_elogind=no])
+
+if test "x$with_elogind" = "xauto" ; then
+        if test x$have_elogind = xno ; then
+                use_elogind=no
+        else
+                use_elogind=yes
+        fi
+else
+	use_elogind=$with_elogind
+fi
+
+if test "x$use_elogind" = "xyes"; then
+        if test "x$have_elogind" = "xno"; then
+                AC_MSG_ERROR([Elogind support explicitly required, but elogind not found])
+        fi
+
+        AC_DEFINE(WITH_ELOGIND, 1, [elogind support])
+fi
+AC_SUBST(ELOGIND_CFLAGS)
+AC_SUBST(ELOGIND_LIBS)
+
+dnl ---------------------------------------------------------------------------
 dnl libxfcekbd
 dnl ---------------------------------------------------------------------------
 
@@ -1175,6 +1206,7 @@ echo "
         Screen locking enabled:   ${enable_locking}
         Show keyboard indicator:  ${with_kbd_layout_indicator}
         systemd support:          ${use_systemd}
+        elogind support:          ${use_elogind}
         ConsoleKit support:       ${use_console_kit}
         PAM support:              ${have_pam}
         PAM auth type:            ${PAM_AUTH_TYPE}
diff --git a/src/Makefile.am b/src/Makefile.am
index 8d69b5c..31068e3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,6 +32,7 @@ AM_CPPFLAGS =							\
 	$(LIBXFCEKBDUI_CFLAGS)					\
 	$(LIBXKLAVIER_CFLAGS)				\
 	$(SYSTEMD_CFLAGS)					\
+	$(ELOGIND_CFLAGS)					\
 	$(NULL)
 
 bin_PROGRAMS = \
@@ -248,6 +249,7 @@ xfce4_screensaver_LDADD =		\
 	$(XFCE_SCREENSAVER_LIBS)	\
 	$(SAVER_LIBS)			\
 	$(SYSTEMD_LIBS)			\
+	$(ELOGIND_LIBS)			\
 	$(NULL)
 
 xfce4_screensaver_LDFLAGS = -export-dynamic
diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
index 80e4f79..389f67f 100644
--- a/src/gs-listener-dbus.c
+++ b/src/gs-listener-dbus.c
@@ -38,6 +38,9 @@
 #ifdef WITH_SYSTEMD
 #include <systemd/sd-login.h>
 #endif
+#ifdef WITH_ELOGIND
+#include <elogind/sd-login.h>
+#endif
 
 #include "gs-listener-dbus.h"
 #include "gs-marshal.h"
@@ -61,12 +64,12 @@ static DBusHandlerResult gs_listener_message_handler    (DBusConnection  *connec
 #define HAL_DEVICE_INTERFACE "org.freedesktop.Hal.Device"
 
 /* systemd logind */
-#define SYSTEMD_LOGIND_SERVICE   "org.freedesktop.login1"
-#define SYSTEMD_LOGIND_PATH      "/org/freedesktop/login1"
-#define SYSTEMD_LOGIND_INTERFACE "org.freedesktop.login1.Manager"
+#define LOGIND_SERVICE   "org.freedesktop.login1"
+#define LOGIND_PATH      "/org/freedesktop/login1"
+#define LOGIND_INTERFACE "org.freedesktop.login1.Manager"
 
-#define SYSTEMD_LOGIND_SESSION_INTERFACE "org.freedesktop.login1.Session"
-#define SYSTEMD_LOGIND_SESSION_PATH      "/org/freedesktop/login1/session"
+#define LOGIND_SESSION_INTERFACE "org.freedesktop.login1.Session"
+#define LOGIND_SESSION_PATH      "/org/freedesktop/login1/session"
 
 /* consolekit */
 #define CK_NAME              "org.freedesktop.ConsoleKit"
@@ -91,8 +94,8 @@ struct GSListenerPrivate {
     time_t          session_idle_start;
     char           *session_id;
 
-#ifdef WITH_SYSTEMD
-    gboolean have_systemd;
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
+    gboolean have_logind;
 #endif
 
     guint32         ck_throttle_cookie;
@@ -1368,7 +1371,7 @@ _listener_message_path_is_our_session (GSListener  *listener,
     return FALSE;
 }
 
-#ifdef WITH_SYSTEMD
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
 static gboolean
 properties_changed_match (DBusMessage *message,
                           const char  *property) {
@@ -1455,23 +1458,23 @@ listener_dbus_handle_system_message (DBusConnection *connection,
               dbus_message_get_destination (message));
 #endif
 
-#ifdef WITH_SYSTEMD
-    if (listener->priv->have_systemd) {
-        if (dbus_message_is_signal (message, SYSTEMD_LOGIND_SESSION_INTERFACE, "Unlock")) {
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
+    if (listener->priv->have_logind) {
+        if (dbus_message_is_signal (message, LOGIND_SESSION_INTERFACE, "Unlock")) {
             if (_listener_message_path_is_our_session (listener, message)) {
                 gs_debug ("Systemd requested session unlock");
                 gs_listener_set_active (listener, FALSE);
             }
 
             return DBUS_HANDLER_RESULT_HANDLED;
-        } else if (dbus_message_is_signal (message, SYSTEMD_LOGIND_SESSION_INTERFACE, "Lock")) {
+        } else if (dbus_message_is_signal (message, LOGIND_SESSION_INTERFACE, "Lock")) {
             if (_listener_message_path_is_our_session (listener, message)) {
                 gs_debug ("Systemd requested session lock");
                 g_signal_emit (listener, signals[LOCK], 0);
             }
 
             return DBUS_HANDLER_RESULT_HANDLED;
-        } else if (dbus_message_is_signal (message, SYSTEMD_LOGIND_INTERFACE, "PrepareForSleep")) {
+        } else if (dbus_message_is_signal (message, LOGIND_INTERFACE, "PrepareForSleep")) {
             gboolean  active = 0;
             DBusError error;
 
@@ -2034,29 +2037,29 @@ gs_listener_acquire (GSListener  *listener,
                                     listener_dbus_system_filter_function,
                                     listener,
                                     NULL);
-#ifdef WITH_SYSTEMD
-        if (listener->priv->have_systemd) {
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
+        if (listener->priv->have_logind) {
             dbus_bus_add_match (listener->priv->system_connection,
                                 "type='signal'"
-                                ",sender='"SYSTEMD_LOGIND_SERVICE"'"
-                                ",interface='"SYSTEMD_LOGIND_SESSION_INTERFACE"'"
+                                ",sender='"LOGIND_SERVICE"'"
+                                ",interface='"LOGIND_SESSION_INTERFACE"'"
                                 ",member='Unlock'",
                                 NULL);
             dbus_bus_add_match (listener->priv->system_connection,
                                 "type='signal'"
-                                ",sender='"SYSTEMD_LOGIND_SERVICE"'"
-                                ",interface='"SYSTEMD_LOGIND_SESSION_INTERFACE"'"
+                                ",sender='"LOGIND_SERVICE"'"
+                                ",interface='"LOGIND_SESSION_INTERFACE"'"
                                 ",member='Lock'",
                                 NULL);
             dbus_bus_add_match (listener->priv->system_connection,
                                 "type='signal'"
-                                ",sender='"SYSTEMD_LOGIND_SERVICE"'"
-                                ",interface='"SYSTEMD_LOGIND_INTERFACE"'"
+                                ",sender='"LOGIND_SERVICE"'"
+                                ",interface='"LOGIND_INTERFACE"'"
                                 ",member='PrepareForSleep'",
                                 NULL);
             dbus_bus_add_match (listener->priv->system_connection,
                                 "type='signal'"
-                                ",sender='"SYSTEMD_LOGIND_SERVICE"'"
+                                ",sender='"LOGIND_SERVICE"'"
                                 ",interface='"DBUS_INTERFACE_PROPERTIES"'"
                                 ",member='PropertiesChanged'",
                                 NULL);
@@ -2109,14 +2112,14 @@ query_session_id (GSListener *listener) {
 
     dbus_error_init (&error);
 
-#ifdef WITH_SYSTEMD
-    if (listener->priv->have_systemd) {
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
+    if (listener->priv->have_logind) {
         dbus_uint32_t pid = getpid();
 
-        message = dbus_message_new_method_call (SYSTEMD_LOGIND_SERVICE,
-                                                SYSTEMD_LOGIND_PATH,
-                            SYSTEMD_LOGIND_INTERFACE,
-                            "GetSessionByPID");
+        message = dbus_message_new_method_call (LOGIND_SERVICE,
+                                                LOGIND_PATH,
+                                                LOGIND_INTERFACE,
+                                                "GetSessionByPID");
         if (message == NULL) {
             gs_debug ("Couldn't allocate the dbus message");
             return NULL;
@@ -2191,9 +2194,9 @@ static void
 gs_listener_init (GSListener *listener) {
     listener->priv = gs_listener_get_instance_private (listener);
 
-#ifdef WITH_SYSTEMD
+#if defined(WITH_SYSTEMD) || defined(WITH_ELOGIND)
     /* check if logind is running */
-    listener->priv->have_systemd = (access("/run/systemd/seats/", F_OK) >= 0);
+    listener->priv->have_logind = (access("/run/systemd/seats/", F_OK) >= 0);
 #endif
 
     gs_listener_dbus_init (listener);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list