From 3d46fd8c99aeea34fce971f14129432ea52e8e12 Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Wed, 30 Sep 2009 11:53:03 +0000
Subject: [PATCH] Shutdown/Reboot fails when multiple users are logged in #246

---
 src/sugar/_sugarext.defs |  6 ++++++
 src/sugar/gsm-session.c  | 12 ++++++++++++
 src/sugar/gsm-session.h  |  2 ++
 3 files changed, 20 insertions(+)

diff --git a/src/sugar/_sugarext.defs b/src/sugar/_sugarext.defs
index a6befa45..e36034d7 100644
--- a/src/sugar/_sugarext.defs
+++ b/src/sugar/_sugarext.defs
@@ -345,6 +345,12 @@
   (return-type "none")
 )
 
+(define-method cancel_shutdown
+  (of-object "GsmSession")
+  (c-name "gsm_session_cancel_shutdown")
+  (return-type "none")
+)
+
 (define-method register_client
   (of-object "GsmSession")
   (c-name "gsm_session_register_client")
diff --git a/src/sugar/gsm-session.c b/src/sugar/gsm-session.c
index fd3c52f8..6430a942 100644
--- a/src/sugar/gsm-session.c
+++ b/src/sugar/gsm-session.c
@@ -344,6 +344,18 @@ session_cancel_shutdown (GsmSession *session)
     gsm_client_shutdown_cancelled (cl->data);
 }
 
+void
+gsm_session_cancel_shutdown (GsmSession *session)
+{
+  if (session == NULL || session->phase != GSM_SESSION_PHASE_SHUTDOWN)
+    {
+      g_warning ("Session is not in shutdown mode");
+      return;
+    }
+
+  session_cancel_shutdown (session);
+}
+
 static void
 initiate_shutdown (GsmSession *session)
 {
diff --git a/src/sugar/gsm-session.h b/src/sugar/gsm-session.h
index 7b23b00a..31d2762d 100644
--- a/src/sugar/gsm-session.h
+++ b/src/sugar/gsm-session.h
@@ -84,6 +84,8 @@ GsmSessionPhase  gsm_session_get_phase         (GsmSession *session);
 
 void             gsm_session_initiate_shutdown (GsmSession *session);
 
+void             gsm_session_cancel_shutdown   (GsmSession *session);
+
 char            *gsm_session_register_client   (GsmSession *session,
                                                 GsmClient  *client,
                                                 const char *previous_id);