[gnome-control-center] Add optional systemd support



commit b294b10324a5444fa110f6d66ed35353eba9b954
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 13 13:16:41 2012 -0500

    Add optional systemd support
    
    When configured with --enable-systemd, this patch makes
    the user panel use systemd for session tracking instead
    of ConsoleKit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=666573

 configure.ac                   |   14 +++++++++++++-
 panels/user-accounts/um-user.c |   17 +++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6696050..2ea7631 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,17 @@ CPPFLAGS=$savecppflags
 
 AC_CHECK_LIB(m, floor)
 
+AC_ARG_ENABLE([systemd],
+              AS_HELP_STRING([--enable-systemd], [Use systemd]),
+              [with_systemd=$enableval],
+              [with_systemd=no])
+if test "$with_systemd" = "yes" ; then
+  SYSTEMD=libsystemd-login
+  AC_DEFINE(HAVE_SYSTEMD, 1, [Define to 1 if systemd is available])
+else
+  SYSTEMD=
+fi
+
 dnl ==============================================
 dnl Check that we meet the  dependencies
 dnl ==============================================
@@ -118,7 +129,8 @@ PKG_CHECK_MODULES(USER_ACCOUNTS_PANEL, $COMMON_MODULES dbus-glib-1
                   polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
                   gnome-desktop-3.0
                   clutter-gst-1.0
-                  gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
+                  gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION
+                  $SYSTEMD)
 PKG_CHECK_MODULES(WACOM_PANEL, $COMMON_MODULES
                   gnome-settings-daemon >= $GSD_REQUIRED_VERSION
                   xi >= 1.2 x11 libwacom)
diff --git a/panels/user-accounts/um-user.c b/panels/user-accounts/um-user.c
index f480108..64e7872 100644
--- a/panels/user-accounts/um-user.c
+++ b/panels/user-accounts/um-user.c
@@ -1028,6 +1028,22 @@ um_user_set_password (UmUser      *user,
         }
 }
 
+#ifdef HAVE_SYSTEMD
+
+#include <systemd/sd-login.h>
+
+gboolean
+um_user_is_logged_in (UmUser *user)
+{
+  int n_sessions;
+
+  n_sessions = sd_uid_get_sessions (um_user_get_uid (user), 0, NULL) > 0;
+
+  return n_sessions > 0;
+}
+
+#else
+
 gboolean
 um_user_is_logged_in (UmUser *user)
 {
@@ -1065,6 +1081,7 @@ um_user_is_logged_in (UmUser *user)
         return n_sessions > 0;
 }
 
+#endif
 
 void
 um_user_set_automatic_login (UmUser   *user,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]