[gnome-settings-daemon] main: Require logind for session tracking



commit a1ab95fae75dd61fd50165b4d8a08b5588245273
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Oct 22 10:35:29 2012 +0200

    main: Require logind for session tracking
    
    Instead of offering both ConsoleKit and logind support.
    
    We already require logind being available for inhibition and
    suspend/hibernation in the power plugin, so requiring logind
    for session tracking doesn't add any new dependencies.

 configure.ac                                   |   22 +---
 gnome-settings-daemon/gnome-settings-session.c |  187 +-----------------------
 2 files changed, 5 insertions(+), 204 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 815750b..f453430 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,7 @@ PKG_CHECK_MODULES(SETTINGS_DAEMON,
         gmodule-2.0
         gthread-2.0
 	gsettings-desktop-schemas >= 3.5.90
+	libsystemd-login
 )
 
 PKG_CHECK_MODULES(SETTINGS_PLUGIN,
@@ -339,27 +340,6 @@ fi
 AC_SUBST(NSS_DATABASE)
 
 
-dnl ==============================================
-dnl systemd check
-dnl ==============================================
-
-AC_ARG_ENABLE([systemd],
-              AS_HELP_STRING([--enable-systemd], [Use systemd for session tracking]),
-              [with_systemd=$enableval],
-              [with_systemd=no])
-if test "$with_systemd" = "yes" ; then
-  PKG_CHECK_MODULES(SYSTEMD, [libsystemd-login])
-  AC_DEFINE(HAVE_SYSTEMD, 1, [Define if systemd is used for session tracking])
-  SESSION_TRACKING=systemd
-else
-  SESSION_TRACKING=ConsoleKit
-fi
-
-AC_SUBST(SYSTEMD_CFLAGS)
-AC_SUBST(SYSTEMD_LIBS)
-
-AM_CONDITIONAL(WITH_SYSTEMD, [test "$with_systemd" = "yes"], [Using systemd])
-
 # ---------------------------------------------------------------------------
 # CUPS
 # ---------------------------------------------------------------------------
diff --git a/gnome-settings-daemon/gnome-settings-session.c b/gnome-settings-daemon/gnome-settings-session.c
index 4ba4869..5a96e44 100644
--- a/gnome-settings-daemon/gnome-settings-session.c
+++ b/gnome-settings-daemon/gnome-settings-session.c
@@ -26,12 +26,10 @@
 #include <stdio.h>
 #include <glib.h>
 #include <gio/gio.h>
+#include <systemd/sd-login.h>
 
 #include "gnome-settings-session.h"
 
-#ifdef HAVE_SYSTEMD
-#include <systemd/sd-login.h>
-
 typedef struct
 {
   GSource source;
@@ -111,31 +109,15 @@ sd_source_new (void)
   return source;
 }
 
-#endif
-
-static void     gnome_settings_session_finalize	(GObject		*object);
+static void gnome_settings_session_finalize (GObject *object);
 
 #define GNOME_SETTINGS_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNOME_TYPE_SETTINGS_SESSION, GnomeSettingsSessionPrivate))
 
-#define CONSOLEKIT_NAME			"org.freedesktop.ConsoleKit"
-#define CONSOLEKIT_PATH			"/org/freedesktop/ConsoleKit"
-#define CONSOLEKIT_INTERFACE		"org.freedesktop.ConsoleKit"
-
-#define CONSOLEKIT_MANAGER_PATH	 	"/org/freedesktop/ConsoleKit/Manager"
-#define CONSOLEKIT_MANAGER_INTERFACE    "org.freedesktop.ConsoleKit.Manager"
-#define CONSOLEKIT_SEAT_INTERFACE       "org.freedesktop.ConsoleKit.Seat"
-#define CONSOLEKIT_SESSION_INTERFACE    "org.freedesktop.ConsoleKit.Session"
-
 struct GnomeSettingsSessionPrivate
 {
-#ifdef HAVE_SYSTEMD
         GSource                   *sd_source;
-#else
-	GDBusProxy		*proxy_session;
-	GCancellable		*cancellable;
-#endif
-	gchar			*session_id;
-	GnomeSettingsSessionState state;
+	gchar                     *session_id;
+	GnomeSettingsSessionState  state;
 };
 
 enum {
@@ -223,8 +205,6 @@ gnome_settings_session_class_init (GnomeSettingsSessionClass *klass)
 							    G_PARAM_READABLE));
 }
 
-#ifdef HAVE_SYSTEMD
-
 static gboolean
 sessions_changed (gpointer user_data)
 {
@@ -237,148 +217,11 @@ sessions_changed (gpointer user_data)
         return TRUE;
 }
 
-#else /* HAVE_SYSTEMD */
-
-static void
-gnome_settings_session_proxy_signal_cb (GDBusProxy *proxy,
-					const gchar *sender_name,
-					const gchar *signal_name,
-					GVariant *parameters,
-					GnomeSettingsSession *session)
-{
-	gboolean active;
-	if (g_strcmp0 (signal_name, "ActiveChanged") == 0) {
-		g_variant_get (parameters, "(b)", &active);
-		g_debug ("emitting active: %i", active);
-		gnome_settings_session_set_state (session, active);
-	}
-}
-
-static void
-is_active_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-	gboolean active = FALSE;
-	GError *error = NULL;
-	GVariant *result;
-	GnomeSettingsSession *session = GNOME_SETTINGS_SESSION (user_data);
-
-	/* is our session active */
-	result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
-					   res,
-					   &error);
-	if (result == NULL) {
-		g_warning ("IsActive failed: %s", error->message);
-		g_error_free (error);
-		return;
-	}
-	g_variant_get (result, "(b)", &active);
-	gnome_settings_session_set_state (session, active);
-
-	/* watch for changes */
-	g_signal_connect (session->priv->proxy_session, "g-signal",
-			  G_CALLBACK (gnome_settings_session_proxy_signal_cb),
-			  session);
-
-	g_variant_unref (result);
-}
-
-static void
-got_session_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-	GError *error = NULL;
-	GnomeSettingsSession *session = GNOME_SETTINGS_SESSION (user_data);
-
-	/* connect to session */
-	session->priv->proxy_session = g_dbus_proxy_new_for_bus_finish (res,
-									&error);
-	if (session->priv->proxy_session == NULL) {
-		g_warning ("cannot connect to %s: %s",
-			   session->priv->session_id,
-			   error->message);
-		g_error_free (error);
-		return;
-	}
-
-	/* is our session active */
-	g_dbus_proxy_call (session->priv->proxy_session,
-			   "IsActive",
-			   NULL,
-			   G_DBUS_CALL_FLAGS_NONE,
-			   -1,
-			   session->priv->cancellable,
-			   is_active_cb,
-			   session);
-}
-
-static void
-got_session_path_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-	GVariant *result;
-	GError *error = NULL;
-	GnomeSettingsSession *session = GNOME_SETTINGS_SESSION (user_data);
-
-	result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
-					   res,
-					   &error);
-	if (result == NULL) {
-		g_warning ("Failed to get session for pid: %s",
-			   error->message);
-		g_error_free (error);
-		return;
-	}
-
-	g_variant_get (result, "(o)", &session->priv->session_id);
-	g_debug ("ConsoleKit session ID: %s", session->priv->session_id);
-
-	/* connect to session */
-	g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
-				  G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
-				  NULL,
-				  CONSOLEKIT_NAME,
-				  session->priv->session_id,
-				  CONSOLEKIT_SESSION_INTERFACE,
-				  session->priv->cancellable,
-				  got_session_proxy_cb,
-				  session);
-	g_variant_unref (result);
-}
-
-static void
-got_manager_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
-{
-	GDBusProxy *proxy_manager;
-	GError *error = NULL;
-	guint32 pid;
-	GnomeSettingsSession *session = GNOME_SETTINGS_SESSION (user_data);
-
-	proxy_manager = g_dbus_proxy_new_for_bus_finish (res, &error);
-	if (proxy_manager == NULL) {
-		g_warning ("cannot connect to ConsoleKit: %s",
-			   error->message);
-		g_error_free (error);
-		return;
-	}
-
-	/* get the session we are running in */
-	pid = getpid ();
-	g_dbus_proxy_call (proxy_manager,
-			   "GetSessionForUnixProcess",
-			   g_variant_new ("(u)", pid),
-			   G_DBUS_CALL_FLAGS_NONE,
-			   -1, session->priv->cancellable,
-			   got_session_path_cb,
-			   session);
-	g_object_unref (proxy_manager);
-}
-
-#endif /* HAVE_SYSTEMD */
-
 static void
 gnome_settings_session_init (GnomeSettingsSession *session)
 {
 	session->priv = GNOME_SETTINGS_SESSION_GET_PRIVATE (session);
 
-#ifdef HAVE_SYSTEMD
         sd_pid_get_session (getpid(), &session->priv->session_id);
 
         session->priv->sd_source = sd_source_new ();
@@ -386,20 +229,6 @@ gnome_settings_session_init (GnomeSettingsSession *session)
         g_source_attach (session->priv->sd_source, NULL);
 
         sessions_changed (session);
-#else
-	session->priv->cancellable = g_cancellable_new ();
-
-	/* connect to ConsoleKit */
-	g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
-				  G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
-				  NULL,
-				  CONSOLEKIT_NAME,
-				  CONSOLEKIT_MANAGER_PATH,
-				  CONSOLEKIT_MANAGER_INTERFACE,
-				  session->priv->cancellable,
-				  got_manager_proxy_cb,
-				  session);
-#endif
 }
 
 static void
@@ -411,18 +240,10 @@ gnome_settings_session_finalize (GObject *object)
 
         g_free (session->priv->session_id);
 
-#ifdef HAVE_SYSTEMD
         if (session->priv->sd_source != NULL) {
                 g_source_destroy (session->priv->sd_source);
                 g_source_unref (session->priv->sd_source);
         }
-#else
-	g_cancellable_cancel (session->priv->cancellable);
-
-	if (session->priv->proxy_session != NULL)
-		g_object_unref (session->priv->proxy_session);
-	g_object_unref (session->priv->cancellable);
-#endif
 
 	G_OBJECT_CLASS (gnome_settings_session_parent_class)->finalize (object);
 }



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