gnome-session r5206 - in trunk: . gnome-session
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-session r5206 - in trunk: . gnome-session
- Date: Fri, 16 Jan 2009 20:19:34 +0000 (UTC)
Author: mccann
Date: Fri Jan 16 20:19:33 2009
New Revision: 5206
URL: http://svn.gnome.org/viewvc/gnome-session?rev=5206&view=rev
Log:
2009-01-16 William Jon McCann <jmccann redhat com>
* gnome-session/gsm-consolekit.c (gsm_consolekit_set_session_idle):
* gnome-session/gsm-consolekit.h:
* gnome-session/gsm-manager.c (on_presence_status_changed),
(gsm_manager_init):
Inform CK that session idle status has changed.
Modified:
trunk/ChangeLog
trunk/gnome-session/gsm-consolekit.c
trunk/gnome-session/gsm-consolekit.h
trunk/gnome-session/gsm-manager.c
Modified: trunk/gnome-session/gsm-consolekit.c
==============================================================================
--- trunk/gnome-session/gsm-consolekit.c (original)
+++ trunk/gnome-session/gsm-consolekit.c Fri Jan 16 20:19:33 2009
@@ -757,6 +757,69 @@
return seat_id;
}
+void
+gsm_consolekit_set_session_idle (GsmConsolekit *manager,
+ gboolean is_idle)
+{
+ gboolean res;
+ GError *error;
+ char *session_id;
+ DBusMessage *message;
+ DBusMessage *reply;
+ DBusError dbus_error;
+ DBusMessageIter iter;
+
+ error = NULL;
+
+ if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+ g_warning ("Could not connect to ConsoleKit: %s",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ session_id = NULL;
+ res = get_current_session_id (dbus_g_connection_get_connection (manager->priv->dbus_connection),
+ &session_id);
+ if (!res) {
+ goto out;
+ }
+
+
+ g_debug ("Updating ConsoleKit idle status: %d", is_idle);
+ message = dbus_message_new_method_call (CK_NAME,
+ session_id,
+ CK_SESSION_INTERFACE,
+ "SetIdleHint");
+ if (message == NULL) {
+ g_debug ("Couldn't allocate the D-Bus message");
+ return;
+ }
+
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &is_idle);
+
+ /* FIXME: use async? */
+ dbus_error_init (&dbus_error);
+ reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (manager->priv->dbus_connection),
+ message,
+ -1,
+ &dbus_error);
+ dbus_message_unref (message);
+
+ if (reply != NULL) {
+ dbus_message_unref (reply);
+ }
+
+ if (dbus_error_is_set (&dbus_error)) {
+ g_debug ("%s raised:\n %s\n\n", dbus_error.name, dbus_error.message);
+ dbus_error_free (&dbus_error);
+ }
+
+out:
+ g_free (session_id);
+}
+
static gboolean
seat_can_activate_sessions (DBusConnection *connection,
const char *seat_id)
Modified: trunk/gnome-session/gsm-consolekit.h
==============================================================================
--- trunk/gnome-session/gsm-consolekit.h (original)
+++ trunk/gnome-session/gsm-consolekit.h Fri Jan 16 20:19:33 2009
@@ -78,6 +78,9 @@
void gsm_consolekit_attempt_restart (GsmConsolekit *manager);
+void gsm_consolekit_set_session_idle (GsmConsolekit *manager,
+ gboolean is_idle);
+
GsmConsolekit *gsm_get_consolekit (void);
G_END_DECLS
Modified: trunk/gnome-session/gsm-manager.c
==============================================================================
--- trunk/gnome-session/gsm-manager.c (original)
+++ trunk/gnome-session/gsm-manager.c Fri Jan 16 20:19:33 2009
@@ -2030,6 +2030,18 @@
}
static void
+on_presence_status_changed (GsmPresence *presence,
+ guint status,
+ GsmManager *manager)
+{
+ GsmConsolekit *consolekit;
+
+ consolekit = gsm_get_consolekit ();
+ gsm_consolekit_set_session_idle (consolekit,
+ (status == GSM_PRESENCE_STATUS_IDLE));
+}
+
+static void
gsm_manager_init (GsmManager *manager)
{
@@ -2050,6 +2062,10 @@
manager->priv->apps = gsm_store_new ();
manager->priv->presence = gsm_presence_new ();
+ g_signal_connect (manager->priv->presence,
+ "status-changed",
+ G_CALLBACK (on_presence_status_changed),
+ manager);
/* GConf setup */
gconf_client_add_dir (manager->priv->gconf_client,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]