Index: gsm-manager.c
===================================================================
--- gsm-manager.c	(révision 5324)
+++ gsm-manager.c	(copie de travail)
@@ -137,6 +137,8 @@ static void     gsm_manager_class_init
 static void     gsm_manager_init        (GsmManager      *manager);
 static void     gsm_manager_finalize    (GObject         *object);
 
+static gboolean auto_save_is_enabled (GsmManager *manager);
+
 static gpointer manager_object = NULL;
 
 G_DEFINE_TYPE (GsmManager, gsm_manager, G_TYPE_OBJECT)
@@ -548,6 +550,9 @@ do_phase_end_session (GsmManager *manage
         if (manager->priv->forceful_logout) {
                 data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL;
         }
+	if (auto_save_is_enabled (manager)) {
+                data.flags |= GSM_CLIENT_END_SESSION_FLAG_SAVE;
+	}
 
         if (manager->priv->phase_timeout_id > 0) {
                 g_source_remove (manager->priv->phase_timeout_id);
@@ -677,6 +682,11 @@ inhibitor_is_jit (gpointer      key,
 static void
 cancel_end_session (GsmManager *manager)
 {
+        /* just ignore if received outside of shutdown */
+        if (manager->priv->phase != GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                return;
+        }
+
         /* switch back to running phase */
 
         /* clear all JIT inhibitors */
@@ -691,6 +701,9 @@ cancel_end_session (GsmManager *manager)
         gsm_manager_set_phase (manager, GSM_MANAGER_PHASE_RUNNING);
         manager->priv->forceful_logout = FALSE;
 
+        gtk_widget_destroy (GTK_WIDGET (manager->priv->inhibit_dialog));
+        manager->priv->inhibit_dialog = NULL;
+
         start_phase (manager);
 }
 
@@ -981,6 +994,9 @@ do_phase_query_end_session (GsmManager *
         if (manager->priv->forceful_logout) {
                 data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL;
         }
+	if (auto_save_is_enabled (manager)) {
+                data.flags |= GSM_CLIENT_END_SESSION_FLAG_SAVE;
+	}
 
         debug_clients (manager);
         g_debug ("GsmManager: sending query-end-session to clients forceful:%d", manager->priv->forceful_logout);
@@ -1533,7 +1549,7 @@ on_xsmp_client_register_request (GsmXSMP
 }
 
 static gboolean
-auto_save_is_enabled(GsmManager *manager)
+auto_save_is_enabled (GsmManager *manager)
 {
         GError   *error;
         gboolean  auto_save;
@@ -1593,6 +1609,7 @@ out:
 static void
 on_client_end_session_response (GsmClient  *client,
                                 gboolean    is_ok,
+                                gboolean    cancel,
                                 const char *reason,
                                 GsmManager *manager)
 {
@@ -1601,6 +1618,11 @@ on_client_end_session_response (GsmClien
                 return;
         }
 
+	if (cancel) {
+		cancel_end_session (manager);
+		return;
+	}
+
         g_debug ("GsmManager: Response from end session request: is-ok=%d reason=%s", is_ok, reason);
 
         manager->priv->query_clients = g_slist_remove (manager->priv->query_clients, client);
Index: gsm-client.c
===================================================================
--- gsm-client.c	(révision 5324)
+++ gsm-client.c	(copie de travail)
@@ -324,9 +324,9 @@ gsm_client_class_init (GsmClientClass *k
                               G_SIGNAL_RUN_LAST,
                               G_STRUCT_OFFSET (GsmClientClass, end_session_response),
                               NULL, NULL,
-                              gsm_marshal_VOID__BOOLEAN_STRING,
+                              gsm_marshal_VOID__BOOLEAN_BOOLEAN_STRING,
                               G_TYPE_NONE,
-                              2, G_TYPE_BOOLEAN, G_TYPE_STRING);
+                              3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING);
 
         g_object_class_install_property (object_class,
                                          PROP_STARTUP_ID,
@@ -522,7 +522,9 @@ gsm_client_save (GsmClient *client,
 void
 gdm_client_end_session_response (GsmClient  *client,
                                  gboolean    is_ok,
+                                 gboolean    cancel,
                                  const char *reason)
 {
-        g_signal_emit (client, signals[END_SESSION_RESPONSE], 0, is_ok, reason);
+        g_signal_emit (client, signals[END_SESSION_RESPONSE], 0,
+                       is_ok, cancel, reason);
 }
Index: gsm-marshal.list
===================================================================
--- gsm-marshal.list	(révision 5324)
+++ gsm-marshal.list	(copie de travail)
@@ -1,2 +1,2 @@
 BOOLEAN:POINTER
-VOID:BOOLEAN,STRING
+VOID:BOOLEAN,BOOLEAN,STRING
Index: gsm-client.h
===================================================================
--- gsm-client.h	(révision 5324)
+++ gsm-client.h	(copie de travail)
@@ -55,7 +55,8 @@ typedef enum {
 } GsmClientRestartStyle;
 
 typedef enum {
-        GSM_CLIENT_END_SESSION_FLAG_FORCEFUL = 1 << 0
+        GSM_CLIENT_END_SESSION_FLAG_FORCEFUL = 1 << 0,
+        GSM_CLIENT_END_SESSION_FLAG_SAVE     = 1 << 1
 } GsmClientEndSessionFlag;
 
 struct _GsmClient
@@ -72,6 +73,7 @@ struct _GsmClientClass
         void         (*disconnected)               (GsmClient  *client);
         void         (*end_session_response)       (GsmClient  *client,
                                                     gboolean    ok,
+                                                    gboolean    cancel,
                                                     const char *reason);
 
         /* virtual methods */
@@ -158,6 +160,7 @@ gboolean              gsm_client_get_uni
 
 void                  gdm_client_end_session_response       (GsmClient  *client,
                                                              gboolean    is_ok,
+                                                             gboolean    cancel,
                                                              const char *reason);
 
 G_END_DECLS
Index: gsm-xsmp-client.c
===================================================================
--- gsm-xsmp-client.c	(révision 5324)
+++ gsm-xsmp-client.c	(copie de travail)
@@ -480,6 +480,7 @@ xsmp_save_yourself_phase2 (GsmClient *cl
 
         SmsSaveYourselfPhase2 (xsmp->priv->conn);
 }
+#endif
 
 static void
 xsmp_interact (GsmClient *client)
@@ -490,7 +491,6 @@ xsmp_interact (GsmClient *client)
 
         SmsInteract (xsmp->priv->conn);
 }
-#endif
 
 static gboolean
 xsmp_cancel_end_session (GsmClient *client,
@@ -509,6 +509,11 @@ xsmp_cancel_end_session (GsmClient *clie
         }
 
         SmsShutdownCancelled (xsmp->priv->conn);
+
+        /* reset the state */
+        xsmp->priv->current_save_yourself = -1;
+        xsmp->priv->next_save_yourself = -1;
+
         return TRUE;
 }
 
@@ -690,6 +695,7 @@ xsmp_query_end_session (GsmClient *clien
                         GError   **error)
 {
         gboolean forceful;
+        int      save_type;
 
         if (GSM_XSMP_CLIENT (client)->priv->conn == NULL) {
                 g_set_error (error,
@@ -700,7 +706,14 @@ xsmp_query_end_session (GsmClient *clien
         }
 
         forceful = (flags & GSM_CLIENT_END_SESSION_FLAG_FORCEFUL);
-        do_save_yourself (GSM_XSMP_CLIENT (client), SmSaveGlobal, forceful);
+
+        if (flags & GSM_CLIENT_END_SESSION_FLAG_SAVE) {
+                save_type = SmSaveBoth;
+        } else {
+                save_type = SmSaveGlobal;
+        }
+
+        do_save_yourself (GSM_XSMP_CLIENT (client), save_type, forceful);
         return TRUE;
 }
 
@@ -710,6 +723,7 @@ xsmp_end_session (GsmClient *client,
                   GError   **error)
 {
         gboolean forceful;
+        int      save_type;
 
         if (GSM_XSMP_CLIENT (client)->priv->conn == NULL) {
                 g_set_error (error,
@@ -720,7 +734,13 @@ xsmp_end_session (GsmClient *client,
         }
 
         forceful = (flags & GSM_CLIENT_END_SESSION_FLAG_FORCEFUL);
-        do_save_yourself (GSM_XSMP_CLIENT (client), SmSaveGlobal, forceful);
+        if (flags & GSM_CLIENT_END_SESSION_FLAG_SAVE) {
+                save_type = SmSaveBoth;
+        } else {
+                save_type = SmSaveGlobal;
+        }
+
+        do_save_yourself (GSM_XSMP_CLIENT (client), save_type, forceful);
         return TRUE;
 }
 
@@ -1125,7 +1145,7 @@ save_yourself_phase2_request_callback (S
         /* this is a valid response to SaveYourself and therefore
            may be a response to a QES or ES */
         gdm_client_end_session_response (GSM_CLIENT (client),
-                                         TRUE,
+                                         TRUE, FALSE,
                                          NULL);
 
         /* FIXME: change priority so this client runs at the end? */
@@ -1137,17 +1157,20 @@ interact_request_callback (SmsConn   con
                            int       dialog_type)
 {
         GsmXSMPClient *client = manager_data;
+#if 0
         gboolean       res;
         GError        *error;
+#endif
 
         g_debug ("GsmXSMPClient: Client '%s' received InteractRequest(%s)",
                  client->priv->description,
                  dialog_type == SmDialogNormal ? "Dialog" : "Errors");
 
         gdm_client_end_session_response (GSM_CLIENT (client),
-                                         FALSE,
+                                         FALSE, FALSE,
                                          _("This program is blocking log out."));
 
+#if 0
         /* Can't just call back with Interact because session client
            grabs the keyboard!  So, we try to get it to release
            grabs by telling it we've cancelled the shutdown.
@@ -1159,6 +1182,8 @@ interact_request_callback (SmsConn   con
                 g_warning ("Unable to cancel end session: %s", error->message);
                 g_error_free (error);
         }
+#endif
+        xsmp_interact (GSM_CLIENT (client));
 }
 
 static void
@@ -1173,7 +1198,7 @@ interact_done_callback (SmsConn   conn,
                  cancel_shutdown ? "True" : "False");
 
         gdm_client_end_session_response (GSM_CLIENT (client),
-                                         TRUE,
+                                         TRUE, cancel_shutdown,
                                          NULL);
 }
 
@@ -1195,15 +1220,12 @@ save_yourself_done_callback (SmsConn   c
                 client->priv->current_save_yourself = -1;
         }
 
-        /* If success is false then the application still has
-           unsafe data.  We may also have tricked it into sending
-           us this message when we faked the ShutdownCancel to
-           break its grabs. */
-        if (success) {
-                gdm_client_end_session_response (GSM_CLIENT (client),
-                                                 TRUE,
-                                                 NULL);
-        }
+        /* If success is false then the application couldn't save data. Nothing
+         * the session manager can do about, though. FIXME: we could display a
+         * dialog about this, I guess. */
+        gdm_client_end_session_response (GSM_CLIENT (client),
+                                         TRUE, FALSE,
+                                         NULL);
 
         if (client->priv->next_save_yourself) {
                 int save_type = client->priv->next_save_yourself;
Index: gsm-inhibit-dialog.c
===================================================================
--- gsm-inhibit-dialog.c	(révision 5324)
+++ gsm-inhibit-dialog.c	(copie de travail)
@@ -52,7 +52,7 @@
 #define GLADE_XML_FILE "gsm-inhibit-dialog.glade"
 
 #ifndef DEFAULT_ICON_SIZE
-#define DEFAULT_ICON_SIZE 64
+#define DEFAULT_ICON_SIZE 32
 #endif
 
 #ifndef DEFAULT_SNAPSHOT_SIZE
Index: main.c
===================================================================
--- main.c	(révision 5324)
+++ main.c	(copie de travail)
@@ -57,7 +57,7 @@
 
 static gboolean failsafe = FALSE;
 static gboolean show_version = FALSE;
-static gboolean debug = FALSE;
+static gboolean debug = TRUE;
 
 static void
 on_bus_name_lost (DBusGProxy *bus_proxy,
Index: gsm-dbus-client.c
===================================================================
--- gsm-dbus-client.c	(révision 5324)
+++ gsm-dbus-client.c	(copie de travail)
@@ -189,7 +189,8 @@ handle_end_session_response (GsmDBusClie
                 g_error ("No memory");
         }
 
-        gdm_client_end_session_response (GSM_CLIENT (client), is_ok, reason);
+        gdm_client_end_session_response (GSM_CLIENT (client),
+                                         is_ok, FALSE, reason);
 
 
         if (! dbus_connection_send (client->priv->connection, reply, NULL)) {
