diff -up evolution-3.8.5/mail/e-mail-backend.c.disconnect-on-network-outage evolution-3.8.5/mail/e-mail-backend.c
--- evolution-3.8.5/mail/e-mail-backend.c.disconnect-on-network-outage 2013-07-23 14:51:52.000000000 +0200
+++ evolution-3.8.5/mail/e-mail-backend.c 2014-04-07 12:47:49.658625438 +0200
@@ -128,6 +128,18 @@ mail_backend_store_operation_done_cb (Ca
}
static void
+mail_backend_set_session_offline_cb (gpointer user_data,
+ GObject *object)
+{
+ CamelSession *session = user_data;
+
+ g_return_if_fail (CAMEL_IS_SESSION (session));
+
+ camel_session_set_online (session, FALSE);
+ g_object_unref (session);
+}
+
+static void
mail_backend_prepare_for_offline_cb (EShell *shell,
EActivity *activity,
EMailBackend *backend)
@@ -138,18 +150,6 @@ mail_backend_prepare_for_offline_cb (ESh
GQueue queue = G_QUEUE_INIT;
gboolean synchronize = FALSE;
- if (e_shell_backend_is_started (E_SHELL_BACKEND (backend))) {
- if (!e_activity_get_cancellable (activity)) {
- GCancellable *cancellable;
-
- cancellable = camel_operation_new ();
- e_activity_set_cancellable (activity, cancellable);
- g_object_unref (cancellable);
- }
-
- e_shell_backend_add_activity (E_SHELL_BACKEND (backend), activity);
- }
-
window = e_shell_get_active_window (shell);
session = e_mail_backend_get_session (backend);
account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session));
@@ -163,8 +163,29 @@ mail_backend_prepare_for_offline_cb (ESh
mail_cancel_all ();
camel_session_set_network_available (
CAMEL_SESSION (session), FALSE);
+ camel_session_set_online (CAMEL_SESSION (session), FALSE);
}
+ if (e_shell_backend_is_started (E_SHELL_BACKEND (backend))) {
+ GCancellable *cancellable;
+
+ cancellable = e_activity_get_cancellable (activity);
+ if (!cancellable) {
+ cancellable = camel_operation_new ();
+ e_activity_set_cancellable (activity, cancellable);
+ g_object_unref (cancellable);
+ } else {
+ /* Maybe the cancellable just got cancelled when the above
+ mail_cancel_all() had been called, but we want it alive
+ for the following "go-offline" operation, thus reset it. */
+ g_cancellable_reset (cancellable);
+ }
+
+ e_shell_backend_add_activity (E_SHELL_BACKEND (backend), activity);
+ }
+
+ g_object_weak_ref (G_OBJECT (activity), mail_backend_set_session_offline_cb, g_object_ref (session));
+
e_mail_account_store_queue_enabled_services (account_store, &queue);
while (!g_queue_is_empty (&queue)) {
CamelService *service;