aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2014-04-03 18:54:54 +0800
committerMilan Crha <mcrha@redhat.com>2014-04-03 18:54:54 +0800
commite888740b06b4363068dc15f00e34e1570f792133 (patch)
tree39b13654511eea59231400eb618c8132c61056bf /mail
parentd55def09ad8e6c5293f254d019ce1b8bf2e1988d (diff)
downloadgsoc2013-evolution-e888740b06b4363068dc15f00e34e1570f792133.tar
gsoc2013-evolution-e888740b06b4363068dc15f00e34e1570f792133.tar.gz
gsoc2013-evolution-e888740b06b4363068dc15f00e34e1570f792133.tar.bz2
gsoc2013-evolution-e888740b06b4363068dc15f00e34e1570f792133.tar.lz
gsoc2013-evolution-e888740b06b4363068dc15f00e34e1570f792133.tar.xz
gsoc2013-evolution-e888740b06b4363068dc15f00e34e1570f792133.tar.zst
gsoc2013-evolution-e888740b06b4363068dc15f00e34e1570f792133.zip
Cancel pending mail operations when going offline or on quit
This used to be done in mail_cancel_all(), but since commit 8ae3cc32830179e09 the function is gone and the mail operations are not cancelled, which prevents the application to go offline or to quit in a timely manner, because it's waiting for a finish of possibly expensive operations.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-backend.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 4d80c6371a..d3113ba8cc 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -199,12 +199,15 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
session = e_mail_backend_get_session (backend);
account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session));
- if (!e_shell_get_network_available (shell))
+ if (!e_shell_get_network_available (shell)) {
camel_session_set_online (CAMEL_SESSION (session), FALSE);
+ camel_operation_cancel_all ();
+ }
if (e_shell_backend_is_started (shell_backend)) {
gboolean ask_to_synchronize;
gboolean synchronize = FALSE;
+ GCancellable *cancellable;
ask_to_synchronize =
e_shell_get_network_available (shell) &&
@@ -220,12 +223,16 @@ mail_backend_prepare_for_offline_cb (EShell *shell,
camel_session_set_online (CAMEL_SESSION (session), FALSE);
}
- if (!e_activity_get_cancellable (activity)) {
- 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
+ camel_operation_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 (shell_backend, activity);
@@ -368,6 +375,7 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
EMailSession *session;
ESourceRegistry *registry;
GList *list, *link;
+ GCancellable *cancellable;
gboolean delete_junk;
gboolean empty_trash;
@@ -379,8 +387,17 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
camel_application_is_exiting = TRUE;
+ camel_operation_cancel_all ();
mail_vfolder_shutdown ();
+ cancellable = e_activity_get_cancellable (activity);
+ if (cancellable) {
+ /* Maybe the cancellable just got cancelled when the above
+ camel_operation_cancel_all() had been called, but we want
+ it alive for the following operations, thus reset it. */
+ g_cancellable_reset (cancellable);
+ }
+
list = camel_session_list_services (CAMEL_SESSION (session));
if (delete_junk) {
@@ -417,9 +434,6 @@ mail_backend_prepare_for_quit_cb (EShell *shell,
/* local trash requires special handling,
* due to POP3's "delete-expunged" option */
CamelFolder *local_trash;
- GCancellable *cancellable;
-
- cancellable = e_activity_get_cancellable (activity);
/* This should be lightning-fast since
* it's just the local trash folder. */