diff options
author | Bastien Nocera <hadess@hadess.net> | 2012-10-22 10:35:29 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2012-10-22 10:35:29 +0200 |
commit | a1ab95fae75dd61fd50165b4d8a08b5588245273 (patch) | |
tree | 9601dc7fa1a6e1f1609bbfdf6565a406bc2d0af6 /gnome-settings-daemon | |
parent | 078a6f2e72f03fc7ca244d1c666032ef1e6814e4 (diff) | |
download | gnome-settings-daemon-a1ab95fae75dd61fd50165b4d8a08b5588245273.tar.gz |
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.
Diffstat (limited to 'gnome-settings-daemon')
-rw-r--r-- | gnome-settings-daemon/gnome-settings-session.c | 187 |
1 files changed, 4 insertions, 183 deletions
diff --git a/gnome-settings-daemon/gnome-settings-session.c b/gnome-settings-daemon/gnome-settings-session.c index 4ba48691..5a96e443 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); } |