aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/e-msg-composer.c12
-rw-r--r--e-util/e-activity.c15
-rw-r--r--e-util/e-activity.h2
-rw-r--r--e-util/e-file-utils.c4
-rw-r--r--mail/e-mail-backend.c4
-rw-r--r--mail/e-mail-reader-utils.c4
-rw-r--r--mail/em-composer-utils.c38
-rw-r--r--mail/mail-mt.c4
-rw-r--r--modules/mail/e-mail-shell-view-actions.c3
-rw-r--r--modules/mail/e-mail-shell-view-private.c3
10 files changed, 39 insertions, 50 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 98d1e6f295..74a36cce44 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -3548,8 +3548,7 @@ msg_composer_send_cb (EMsgComposer *composer,
message = e_msg_composer_get_message_finish (composer, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (message == NULL);
async_context_free (context);
g_error_free (error);
@@ -3639,8 +3638,7 @@ msg_composer_save_to_drafts_cb (EMsgComposer *composer,
message = e_msg_composer_get_message_draft_finish (
composer, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (message == NULL);
async_context_free (context);
g_error_free (error);
@@ -3722,8 +3720,7 @@ msg_composer_save_to_outbox_cb (EMsgComposer *composer,
message = e_msg_composer_get_message_finish (composer, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (message == NULL);
async_context_free (context);
g_error_free (error);
@@ -3812,8 +3809,7 @@ msg_composer_print_cb (EMsgComposer *composer,
message = e_msg_composer_get_message_print_finish (
composer, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (message == NULL);
async_context_free (context);
g_error_free (error);
diff --git a/e-util/e-activity.c b/e-util/e-activity.c
index 231de505b4..2e3a078f82 100644
--- a/e-util/e-activity.c
+++ b/e-util/e-activity.c
@@ -498,3 +498,18 @@ e_activity_set_text (EActivity *activity,
g_object_notify (G_OBJECT (activity), "text");
}
+gboolean
+e_activity_handle_cancellation (EActivity *activity,
+ const GError *error)
+{
+ gboolean handled = FALSE;
+
+ g_return_val_if_fail (E_IS_ACTIVITY (activity), FALSE);
+
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ e_activity_set_state (activity, E_ACTIVITY_CANCELLED);
+ handled = TRUE;
+ }
+
+ return handled;
+}
diff --git a/e-util/e-activity.h b/e-util/e-activity.h
index 4602a5696e..3e56f992f8 100644
--- a/e-util/e-activity.h
+++ b/e-util/e-activity.h
@@ -84,6 +84,8 @@ void e_activity_set_state (EActivity *activity,
const gchar * e_activity_get_text (EActivity *activity);
void e_activity_set_text (EActivity *activity,
const gchar *text);
+gboolean e_activity_handle_cancellation (EActivity *activity,
+ const GError *error);
G_END_DECLS
diff --git a/e-util/e-file-utils.c b/e-util/e-file-utils.c
index 2d5ff30ff7..49fd4a07ee 100644
--- a/e-util/e-file-utils.c
+++ b/e-util/e-file-utils.c
@@ -85,9 +85,7 @@ file_replace_contents_cb (GFile *file,
g_file_replace_contents_finish (file, result, &new_etag, &error);
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
- else
+ if (!e_activity_handle_cancellation (context->activity, error))
e_activity_set_state (context->activity, E_ACTIVITY_COMPLETED);
if (error == NULL)
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c
index 3addb64011..eaf3bd05b1 100644
--- a/mail/e-mail-backend.c
+++ b/mail/e-mail-backend.c
@@ -446,8 +446,8 @@ mail_backend_job_finished_cb (CamelSession *session,
activity = g_hash_table_lookup (priv->jobs, cancellable);
description = e_activity_get_text (activity);
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- /* ignore cancellations */
+ if (e_activity_handle_cancellation (activity, error)) {
+ /* nothing to do */
} else if (error != NULL) {
EShell *shell;
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 81712b82f0..0311b3d429 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -369,10 +369,8 @@ mail_reader_remove_duplicates_cb (CamelFolder *folder,
duplicates = e_mail_folder_find_duplicate_messages_finish (
folder, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (duplicates == NULL);
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
async_context_free (context);
g_error_free (error);
return;
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 1431975b63..c91870ff5b 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -503,9 +503,7 @@ composer_send_completed (EMailSession *session,
e_mail_session_send_to_finish (session, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_error_free (error);
goto exit;
}
@@ -606,8 +604,7 @@ composer_save_to_drafts_complete (EMailSession *session,
e_mail_session_handle_draft_headers_finish (session, result, &error);
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_error_free (error);
} else if (error != NULL) {
@@ -645,15 +642,13 @@ composer_save_to_drafts_cleanup (CamelFolder *drafts_folder,
e_mail_folder_append_message_finish (
drafts_folder, result, &context->message_uid, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (context->message_uid == NULL);
async_context_free (context);
g_error_free (error);
return;
- }
- if (error != NULL) {
+ } else if (error != NULL) {
g_warn_if_fail (context->message_uid == NULL);
e_alert_submit (
alert_sink,
@@ -715,15 +710,13 @@ composer_save_to_drafts_got_folder (EMailSession *session,
drafts_folder = e_mail_session_uri_to_folder_finish (
session, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (drafts_folder == NULL);
async_context_free (context);
g_error_free (error);
return;
- }
- if (error != NULL) {
+ } else if (error != NULL) {
gint response;
g_warn_if_fail (drafts_folder == NULL);
@@ -807,14 +800,11 @@ composer_save_to_outbox_completed (CamelFolder *outbox_folder,
e_mail_folder_append_message_finish (
outbox_folder, result, NULL, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_error_free (error);
goto exit;
- }
- if (error != NULL) {
+ } else if (error != NULL) {
e_alert_submit (
alert_sink,
"mail-composer:append-to-outbox-error",
@@ -1265,10 +1255,8 @@ edit_messages_cb (CamelFolder *folder,
hash_table = e_mail_folder_get_multiple_messages_finish (
folder, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (hash_table == NULL);
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
async_context_free (context);
g_error_free (error);
return;
@@ -1466,11 +1454,9 @@ forward_attached_cb (CamelFolder *folder,
part = e_mail_folder_build_attachment_finish (
folder, result, &subject, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (part == NULL);
g_warn_if_fail (subject == NULL);
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
async_context_free (context);
g_error_free (error);
return;
@@ -1629,10 +1615,8 @@ forward_got_messages_cb (CamelFolder *folder,
hash_table = e_mail_folder_get_multiple_messages_finish (
folder, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (hash_table == NULL);
- e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
async_context_free (context);
g_error_free (error);
return;
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index a65f6e3c9e..53ff132545 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -208,10 +208,8 @@ mail_msg_check_error (gpointer msg)
checkmem (m->priv);
#endif
- if (g_error_matches (m->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- e_activity_set_state (m->activity, E_ACTIVITY_CANCELLED);
+ if (e_activity_handle_cancellation (m->activity, m->error))
return;
- }
e_activity_set_state (m->activity, E_ACTIVITY_COMPLETED);
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index f311246da7..80c8a92a7e 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -33,8 +33,7 @@ mail_folder_unsubscribe_done_cb (EMailSession *session,
e_mail_session_unsubscribe_folder_finish (session, result, &error);
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- e_activity_set_state (activity, E_ACTIVITY_CANCELLED);
+ if (e_activity_handle_cancellation (activity, error)) {
g_error_free (error);
} else if (error != NULL) {
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index c5f555d757..d99b643d38 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -62,8 +62,7 @@ mail_shell_view_got_folder_cb (CamelStore *store,
folder = camel_store_get_folder_finish (store, result, &error);
- /* Ignore cancellations. */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ if (e_activity_handle_cancellation (context->activity, error)) {
g_warn_if_fail (folder == NULL);
async_context_free (context);
g_error_free (error);