aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-10-22 04:21:19 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-10-23 02:21:22 +0800
commitc881b5bc5e61d04b18d4ab46ad70533e7340d15b (patch)
treee70a3ed0d2f93dacfe20d856de4d29578beb2e50 /mail
parentf0714755e2fa8b06425907c2cf189abd3a1b7119 (diff)
downloadgsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar
gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar.gz
gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar.bz2
gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar.lz
gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar.xz
gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.tar.zst
gsoc2013-evolution-c881b5bc5e61d04b18d4ab46ad70533e7340d15b.zip
Simplify EActivity.
With unintrusive error dialogs gone, we can cut some unnecessary bits out of EActivity. I'm also adding a new enum property called "state", which is one of: E_ACTIVITY_RUNNING E_ACTIVITY_WAITING E_ACTIVITY_CANCELLED E_ACTIVITY_COMPLETED The state of an activity must be explicitly changed. In particular, when the user cancels an activity the state should be set only after confirming the operation has been cancelled and not when cancellation is requested (e.g. after receiving a G_IO_ERROR_CANCELLED, not when the GCancellable emits "cancelled"). EActivityBar and EActivityProxy widgets have been updated to make this distinction clearer in the UI. E_ACTIVITY_WAITING will be used when activities have to be queued and dispatched in sequence, which I haven't written yet.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-session.c30
-rw-r--r--mail/em-composer-utils.c14
-rw-r--r--mail/em-folder-tree.c32
-rw-r--r--mail/em-folder-utils.c49
-rw-r--r--mail/em-format-html.c22
-rw-r--r--mail/importers/elm-importer.c4
-rw-r--r--mail/importers/mail-importer.c22
-rw-r--r--mail/importers/pine-importer.c4
-rw-r--r--mail/mail-folder-cache.c7
-rw-r--r--mail/mail-mt.c96
-rw-r--r--mail/mail-mt.h17
-rw-r--r--mail/mail-ops.c243
-rw-r--r--mail/mail-send-recv.c8
-rw-r--r--mail/mail-vfolder.c13
-rw-r--r--mail/message-list.c31
15 files changed, 346 insertions, 246 deletions
diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c
index 23076807b3..7b726cfec5 100644
--- a/mail/e-mail-session.c
+++ b/mail/e-mail-session.c
@@ -96,7 +96,9 @@ enum {
static gchar *mail_data_dir;
static gchar *mail_config_dir;
+#if 0
static MailMsgInfo ms_thread_info_dummy = { sizeof (MailMsg) };
+#endif
G_DEFINE_TYPE (
EMailSession,
@@ -120,7 +122,9 @@ struct _user_message_msg {
guint ismain:1;
};
-static void user_message_exec (struct _user_message_msg *m);
+static void user_message_exec (struct _user_message_msg *m,
+ GCancellable *cancellable,
+ GError **error);
static void
user_message_response_free (GtkDialog *dialog,
@@ -133,8 +137,11 @@ user_message_response_free (GtkDialog *dialog,
/* check for pendings */
if (!g_queue_is_empty (&user_message_queue)) {
+ GCancellable *cancellable;
+
m = g_queue_pop_head (&user_message_queue);
- user_message_exec (m);
+ cancellable = e_activity_get_cancellable (m->base.activity);
+ user_message_exec (m, cancellable, &m->base.error);
mail_msg_unref (m);
}
}
@@ -155,7 +162,9 @@ user_message_response (GtkDialog *dialog,
}
static void
-user_message_exec (struct _user_message_msg *m)
+user_message_exec (struct _user_message_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
GtkWindow *parent;
const gchar *error_type;
@@ -716,6 +725,7 @@ mail_session_alert_user (CamelSession *session,
gboolean cancel)
{
struct _user_message_msg *m;
+ GCancellable *cancellable;
gboolean result = TRUE;
m = mail_msg_new (&user_message_info);
@@ -728,8 +738,10 @@ mail_session_alert_user (CamelSession *session,
if (cancel)
mail_msg_ref (m);
+ cancellable = e_activity_get_cancellable (m->base.activity);
+
if (m->ismain)
- user_message_exec (m);
+ user_message_exec (m, cancellable, &m->base.error);
else
mail_msg_main_loop_push (m);
@@ -788,6 +800,7 @@ mail_session_thread_msg_new (CamelSession *session,
session_class = CAMEL_SESSION_CLASS (e_mail_session_parent_class);
msg = session_class->thread_msg_new (session, ops, size);
+#if 0
/* We create a dummy mail_msg, and then copy its cancellation
* port over to ours, so we get cancellation and progress in
* common with hte existing mail code, for free. */
@@ -795,9 +808,10 @@ mail_session_thread_msg_new (CamelSession *session,
MailMsg *m = mail_msg_new (&ms_thread_info_dummy);
msg->data = m;
- g_object_unref (msg->cancellable);
- msg->cancellable = g_object_ref (m->cancellable);
+ e_activity_set_cancellable (
+ m->activity, msg->cancellable);
}
+#endif
return msg;
}
@@ -808,7 +822,9 @@ mail_session_thread_msg_free (CamelSession *session,
{
CamelSessionClass *session_class;
+#if 0
mail_msg_unref (msg->data);
+#endif
/* Chain up to parent's thread_msg_free() method. */
session_class = CAMEL_SESSION_CLASS (e_mail_session_parent_class);
@@ -821,8 +837,6 @@ mail_session_thread_status (CamelSession *session,
const gchar *text,
gint pc)
{
- /* This should never be called since we bypass it in alloc! */
- g_warn_if_reached ();
}
static gboolean
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 704bd2bd37..f084155362 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -482,6 +482,7 @@ composer_send_completed (EMailSession *session,
/* Ignore cancellations. */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
g_error_free (error);
goto exit;
}
@@ -495,7 +496,7 @@ composer_send_completed (EMailSession *session,
goto exit;
}
- e_activity_complete (context->activity);
+ e_activity_set_state (context->activity, E_ACTIVITY_COMPLETED);
/* Wait for the EActivity's completion message to
* time out and then destroy the composer window. */
@@ -625,13 +626,16 @@ composer_save_draft_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))
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ e_activity_set_state (context->activity, E_ACTIVITY_CANCELLED);
g_error_free (error);
- else if (error != NULL) {
+ } else if (error != NULL) {
g_warning ("%s", error->message);
g_error_free (error);
- }
+
+ } else
+ e_activity_set_state (context->activity, E_ACTIVITY_COMPLETED);
/* Encode the draft message we just saved into the EMsgComposer
* as X-Evolution-Draft headers. The message will be marked for
@@ -641,8 +645,6 @@ composer_save_draft_complete (EMailSession *session,
context->composer, context->folder_uri,
context->message_uid);
- e_activity_complete (context->activity);
-
async_context_free (context);
}
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 15cf4a5f35..b08da8c849 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -204,20 +204,24 @@ folder_tree_get_folder_info__desc (struct _EMFolderTreeGetFolderInfo *m)
}
static void
-folder_tree_get_folder_info__exec (struct _EMFolderTreeGetFolderInfo *m)
+folder_tree_get_folder_info__exec (struct _EMFolderTreeGetFolderInfo *m,
+ GCancellable *cancellable,
+ GError **error)
{
guint32 flags = m->flags | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+ GError *local_error = NULL;
m->fi = camel_store_get_folder_info_sync (
- m->store, m->top, flags,
- m->base.cancellable, &m->base.error);
+ m->store, m->top, flags, cancellable, &local_error);
/* XXX POP3 stores always return an error because they have
* no folder hierarchy to scan. Clear that error so the
* user doesn't see it. */
- if (g_error_matches (m->base.error,
+ if (g_error_matches (local_error,
CAMEL_STORE_ERROR, CAMEL_STORE_ERROR_NO_FOLDER))
- g_clear_error (&m->base.error);
+ g_error_free (local_error);
+ else if (local_error != NULL)
+ g_propagate_error (error, local_error);
}
static void
@@ -1741,6 +1745,7 @@ folder_tree_drop_folder (struct _DragDataReceivedAsync *m)
{
CamelFolder *folder;
CamelStore *parent_store;
+ GCancellable *cancellable;
const gchar *full_name;
const guchar *data;
@@ -1748,9 +1753,11 @@ folder_tree_drop_folder (struct _DragDataReceivedAsync *m)
d(printf(" * Drop folder '%s' onto '%s'\n", data, m->full_name));
+ cancellable = e_activity_get_cancellable (m->base.activity);
+
folder = e_mail_session_uri_to_folder_sync (
m->session, (gchar *) data, 0,
- m->base.cancellable, &m->base.error);
+ cancellable, &m->base.error);
if (folder == NULL)
return;
@@ -1801,7 +1808,9 @@ folder_tree_drop_async__desc (struct _DragDataReceivedAsync *m)
}
static void
-folder_tree_drop_async__exec (struct _DragDataReceivedAsync *m)
+folder_tree_drop_async__exec (struct _DragDataReceivedAsync *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *folder;
@@ -1811,19 +1820,18 @@ folder_tree_drop_async__exec (struct _DragDataReceivedAsync *m)
folder_tree_drop_folder (m);
} else if (m->full_name == NULL) {
g_set_error (
- &m->base.error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
+ error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
_("Cannot drop message(s) into toplevel store"));
} else if ((folder = camel_store_get_folder_sync (
- m->store, m->full_name, 0,
- m->base.cancellable, &m->base.error))) {
+ m->store, m->full_name, 0, cancellable, error))) {
switch (m->info) {
case DND_DROP_TYPE_UID_LIST:
/* import a list of uids from another evo folder */
em_utils_selection_get_uidlist (
m->selection, m->session, folder, m->move,
- m->base.cancellable, &m->base.error);
- m->moved = m->move && (m->base.error == NULL);
+ cancellable, error);
+ m->moved = m->move && (error == NULL);
break;
case DND_DROP_TYPE_MESSAGE_RFC822:
/* import a message/rfc822 stream */
diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c
index 82f3de6fcf..d457e90ecc 100644
--- a/mail/em-folder-utils.c
+++ b/mail/em-folder-utils.c
@@ -93,18 +93,23 @@ emft_copy_folders__desc (struct _EMCopyFolders *m, gint complete)
}
static void
-emft_copy_folders__exec (struct _EMCopyFolders *m)
+emft_copy_folders__exec (struct _EMCopyFolders *m,
+ GCancellable *cancellable,
+ GError **error)
{
- guint32 flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+ guint32 flags;
GList *pending = NULL, *deleting = NULL, *l;
GString *fromname, *toname;
CamelFolderInfo *fi;
const gchar *tmp;
gint fromlen;
+ flags = CAMEL_STORE_FOLDER_INFO_FAST |
+ CAMEL_STORE_FOLDER_INFO_RECURSIVE |
+ CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+
fi = camel_store_get_folder_info_sync (
- m->fromstore, m->frombase, flags,
- m->base.cancellable, &m->base.error);
+ m->fromstore, m->frombase, flags, cancellable, error);
if (fi == NULL)
return;
@@ -147,8 +152,8 @@ emft_copy_folders__exec (struct _EMCopyFolders *m)
if (m->tostore == m->fromstore && m->delete) {
camel_store_rename_folder_sync (
m->fromstore, info->full_name, toname->str,
- m->base.cancellable, &m->base.error);
- if (m->base.error != NULL)
+ cancellable, error);
+ if (error != NULL)
goto exception;
/* this folder no longer exists, unsubscribe it */
@@ -160,15 +165,14 @@ emft_copy_folders__exec (struct _EMCopyFolders *m)
} else {
fromfolder = camel_store_get_folder_sync (
m->fromstore, info->full_name, 0,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
if (fromfolder == NULL)
goto exception;
tofolder = camel_store_get_folder_sync (
m->tostore, toname->str,
CAMEL_STORE_FOLDER_CREATE,
- m->base.cancellable,
- &m->base.error);
+ cancellable, error);
if (tofolder == NULL) {
g_object_unref (fromfolder);
goto exception;
@@ -178,11 +182,10 @@ emft_copy_folders__exec (struct _EMCopyFolders *m)
camel_folder_transfer_messages_to_sync (
fromfolder, uids, tofolder,
m->delete, NULL,
- m->base.cancellable,
- &m->base.error);
+ cancellable, error);
camel_folder_free_uids (fromfolder, uids);
- if (m->delete && m->base.error == NULL)
+ if (m->delete && error == NULL)
camel_folder_synchronize_sync (
fromfolder, TRUE,
NULL, NULL);
@@ -192,7 +195,7 @@ emft_copy_folders__exec (struct _EMCopyFolders *m)
}
}
- if (m->base.error != NULL)
+ if (error != NULL)
goto exception;
else if (m->delete && !deleted)
deleting = g_list_prepend (deleting, info);
@@ -569,18 +572,17 @@ emfu_create_folder__desc (struct _EMCreateFolder *m)
}
static void
-emfu_create_folder__exec (struct _EMCreateFolder *m)
+emfu_create_folder__exec (struct _EMCreateFolder *m,
+ GCancellable *cancellable,
+ GError **error)
{
- d(printf ("creating folder parent='%s' name='%s' full_name='%s'\n", m->parent, m->name, m->full_name));
-
if ((m->fi = camel_store_create_folder_sync (
- m->store, m->parent, m->name,
- m->base.cancellable, &m->base.error))) {
+ m->store, m->parent, m->name, cancellable, error))) {
if (camel_store_supports_subscriptions (m->store))
camel_store_subscribe_folder_sync (
m->store, m->full_name,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
}
}
@@ -766,7 +768,9 @@ emfu_unsubscribe_folder__desc (struct _folder_unsub_t *msg)
}
static void
-emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg)
+emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg,
+ GCancellable *cancellable,
+ GError **error)
{
CamelStore *store;
CamelURL *url;
@@ -775,7 +779,7 @@ emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg)
store = camel_session_get_store (
CAMEL_SESSION (msg->session),
- msg->folder_uri, &msg->base.error);
+ msg->folder_uri, error);
if (store == NULL)
return;
@@ -789,8 +793,7 @@ emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg)
if (path != NULL)
camel_store_unsubscribe_folder_sync (
- store, path, msg->base.cancellable,
- &msg->base.error);
+ store, path, cancellable, error);
camel_url_free (url);
}
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 1e3c6b9abd..de8c0b5961 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -166,7 +166,9 @@ efh_format_desc (struct _format_msg *m)
}
static void
-efh_format_exec (struct _format_msg *m)
+efh_format_exec (struct _format_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
EMFormat *format;
struct _EMFormatHTMLJob *job;
@@ -195,7 +197,7 @@ efh_format_exec (struct _format_msg *m)
if (format->mode == EM_FORMAT_MODE_SOURCE) {
em_format_format_source (
format, (CamelStream *) m->estream,
- (CamelMimePart *) m->message, m->base.cancellable);
+ (CamelMimePart *) m->message, cancellable);
} else {
const EMFormatHandler *handle;
const gchar *mime_type;
@@ -207,7 +209,7 @@ efh_format_exec (struct _format_msg *m)
handle->handler (
format, CAMEL_STREAM (m->estream),
CAMEL_MIME_PART (m->message), handle,
- m->base.cancellable, FALSE);
+ cancellable, FALSE);
mime_type = "x-evolution/message/rfc822";
handle = em_format_find_handler (format, mime_type);
@@ -216,10 +218,10 @@ efh_format_exec (struct _format_msg *m)
handle->handler (
format, CAMEL_STREAM (m->estream),
CAMEL_MIME_PART (m->message), handle,
- m->base.cancellable, FALSE);
+ cancellable, FALSE);
}
- camel_stream_flush ((CamelStream *)m->estream, m->base.cancellable, NULL);
+ camel_stream_flush ((CamelStream *)m->estream, cancellable, NULL);
puri_level = format->pending_uri_level;
base = format->base;
@@ -232,13 +234,13 @@ efh_format_exec (struct _format_msg *m)
/* This is an implicit check to see if the gtkhtml has been destroyed */
if (m->format->priv->web_view == NULL)
- g_cancellable_cancel (m->base.cancellable);
+ g_cancellable_cancel (cancellable);
/* call jobs even if cancelled, so they can clean up resources */
format->pending_uri_level = job->puri_level;
if (job->base)
format->base = job->base;
- job->callback (job, m->base.cancellable);
+ job->callback (job, cancellable);
format->base = base;
/* clean up the job */
@@ -257,8 +259,8 @@ efh_format_exec (struct _format_msg *m)
d(printf("out of jobs, closing root stream\n"));
camel_stream_write_string (
(CamelStream *) m->estream,
- "</body>\n</html>\n", m->base.cancellable, NULL);
- camel_stream_close ((CamelStream *)m->estream, m->base.cancellable, NULL);
+ "</body>\n</html>\n", cancellable, NULL);
+ camel_stream_close ((CamelStream *)m->estream, cancellable, NULL);
g_object_unref (m->estream);
m->estream = NULL;
}
@@ -287,7 +289,7 @@ efh_format_free (struct _format_msg *m)
d(printf("formatter freed\n"));
g_object_unref (m->format);
if (m->estream) {
- camel_stream_close ((CamelStream *)m->estream, m->base.cancellable, NULL);
+ camel_stream_close ((CamelStream *)m->estream, NULL, NULL);
g_object_unref (m->estream);
}
if (m->folder)
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
index 18548fc21b..292d7c3ffe 100644
--- a/mail/importers/elm-importer.c
+++ b/mail/importers/elm-importer.c
@@ -184,7 +184,9 @@ static MailImporterSpecial elm_special_folders[] = {
};
static void
-elm_import_exec (struct _elm_import_msg *m)
+elm_import_exec (struct _elm_import_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
EShell *shell;
EShellBackend *shell_backend;
diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c
index b4fb3c0431..7eaed4759e 100644
--- a/mail/importers/mail-importer.c
+++ b/mail/importers/mail-importer.c
@@ -107,7 +107,9 @@ decode_mozilla_status (const gchar *tmp)
}
static void
-import_mbox_exec (struct _import_mbox_msg *m)
+import_mbox_exec (struct _import_mbox_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *folder;
CamelMimeParser *mp = NULL;
@@ -125,7 +127,7 @@ import_mbox_exec (struct _import_mbox_msg *m)
else
folder = e_mail_session_uri_to_folder_sync (
m->session, m->uri, CAMEL_STORE_FOLDER_CREATE,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
if (folder == NULL)
return;
@@ -144,7 +146,7 @@ import_mbox_exec (struct _import_mbox_msg *m)
}
camel_operation_push_message (
- m->base.cancellable, _("Importing '%s'"),
+ cancellable, _("Importing '%s'"),
camel_folder_get_full_name (folder));
camel_folder_freeze (folder);
while (camel_mime_parser_step (mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) {
@@ -155,7 +157,7 @@ import_mbox_exec (struct _import_mbox_msg *m)
if (st.st_size > 0)
pc = (gint)(100.0 * ((double)camel_mime_parser_tell (mp) / (double)st.st_size));
- camel_operation_progress (m->base.cancellable, pc);
+ camel_operation_progress (cancellable, pc);
msg = camel_mime_message_new ();
if (!camel_mime_part_construct_from_parser_sync (
@@ -180,11 +182,11 @@ import_mbox_exec (struct _import_mbox_msg *m)
camel_message_info_set_flags (info, flags, ~0);
camel_folder_append_message_sync (
folder, msg, info, NULL,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
camel_message_info_free (info);
g_object_unref (msg);
- if (m->base.error != NULL)
+ if (error != NULL)
break;
camel_mime_parser_step (mp, NULL, NULL);
@@ -192,7 +194,7 @@ import_mbox_exec (struct _import_mbox_msg *m)
/* FIXME Not passing a GCancellable or GError here. */
camel_folder_synchronize_sync (folder, FALSE, NULL, NULL);
camel_folder_thaw (folder);
- camel_operation_pop_message (m->base.cancellable);
+ camel_operation_pop_message (cancellable);
/* TODO: these api's are a bit weird, registering the old is the same as deregistering */
fail2:
g_object_unref (mp);
@@ -267,9 +269,11 @@ mail_importer_import_mbox_sync (EMailSession *session,
m->path = g_strdup (path);
m->uri = g_strdup (folderuri);
if (cancellable)
- m->cancellable = g_object_ref (cancellable);
+ e_activity_set_cancellable (m->base.activity, cancellable);
+
+ cancellable = e_activity_get_cancellable (m->base.activity);
- import_mbox_exec (m);
+ import_mbox_exec (m, cancellable, &m->base.error);
import_mbox_done (m);
mail_msg_unref (m);
}
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index 26a37b853e..e7ace0b1b5 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -230,7 +230,9 @@ static MailImporterSpecial pine_special_folders[] = {
};
static void
-pine_import_exec (struct _pine_import_msg *m)
+pine_import_exec (struct _pine_import_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
EShell *shell;
EShellBackend *shell_backend;
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 85b60ad364..8b19da4879 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -795,7 +795,9 @@ ping_store_desc (struct _ping_store_msg *m)
}
static void
-ping_store_exec (struct _ping_store_msg *m)
+ping_store_exec (struct _ping_store_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean online = FALSE;
@@ -810,8 +812,7 @@ ping_store_exec (struct _ping_store_msg *m)
online = TRUE;
}
if (online)
- camel_store_noop_sync (
- m->store, m->base.cancellable, &m->base.error);
+ camel_store_noop_sync (m->store, cancellable, error);
}
static void
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 907d57938a..8e507e46fc 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -38,11 +38,6 @@
* to rework or get rid of the functions that use this. */
const gchar *shell_builtin_backend = "mail";
-/* background operation status stuff */
-struct _MailMsgPrivate {
- EActivity *activity;
-};
-
static guint mail_msg_seq; /* sequence number of each message */
/* Table of active messages. Must hold mail_msg_lock to access. */
@@ -76,6 +71,7 @@ gpointer
mail_msg_new (MailMsgInfo *info)
{
MailMsg *msg;
+ GCancellable *cancellable;
g_mutex_lock (mail_msg_lock);
@@ -83,22 +79,20 @@ mail_msg_new (MailMsgInfo *info)
msg->info = info;
msg->ref_count = 1;
msg->seq = mail_msg_seq++;
- msg->cancellable = camel_operation_new ();
-
- msg->priv = g_slice_new0 (MailMsgPrivate);
- msg->priv->activity = e_activity_new ();
+ msg->activity = e_activity_new ();
- e_activity_set_percent (msg->priv->activity, 0.0);
+ cancellable = camel_operation_new ();
- e_activity_set_cancellable (
- msg->priv->activity,
- G_CANCELLABLE (msg->cancellable));
+ e_activity_set_percent (msg->activity, 0.0);
+ e_activity_set_cancellable (msg->activity, cancellable);
g_signal_connect (
- msg->cancellable, "cancelled",
+ cancellable, "cancelled",
G_CALLBACK (mail_msg_cancelled),
GINT_TO_POINTER (msg->seq));
+ g_object_unref (cancellable);
+
g_hash_table_insert (
mail_msg_active_table, GINT_TO_POINTER (msg->seq), msg);
@@ -145,18 +139,12 @@ mail_msg_free (MailMsg *mail_msg)
shell_backend = e_shell_get_backend_by_name (
shell, shell_builtin_backend);
- if (mail_msg->priv->activity != NULL) {
- e_activity_complete (mail_msg->priv->activity);
- g_object_unref (mail_msg->priv->activity);
- }
-
- if (mail_msg->cancellable != NULL)
- g_object_unref (mail_msg->cancellable);
+ if (mail_msg->activity != NULL)
+ g_object_unref (mail_msg->activity);
if (mail_msg->error != NULL)
g_error_free (mail_msg->error);
- g_slice_free (MailMsgPrivate, mail_msg->priv);
g_slice_free1 (mail_msg->info->size, mail_msg);
return FALSE;
@@ -226,9 +214,21 @@ mail_msg_check_error (gpointer msg)
checkmem (m->priv);
#endif
- if (m->error == NULL
- || g_error_matches (m->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)
- || g_error_matches (m->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID))
+ if (g_error_matches (m->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ e_activity_set_state (m->activity, E_ACTIVITY_CANCELLED);
+ return;
+ }
+
+ e_activity_set_state (m->activity, E_ACTIVITY_COMPLETED);
+
+ if (m->error == NULL)
+ return;
+
+ /* XXX Hmm, no explanation of why this is needed. It looks like
+ * a lame hack and will be removed at some point, if only to
+ * reintroduce whatever issue made this necessary so we can
+ * document it the source code this time. */
+ if (g_error_matches (m->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID))
return;
shell = e_shell_get_default ();
@@ -250,8 +250,7 @@ mail_msg_check_error (gpointer msg)
shell_window, shell_builtin_backend);
shell_content = e_shell_view_get_shell_content (shell_view);
- if (m->info->desc
- && (what = m->info->desc (m))) {
+ if (m->info->desc && (what = m->info->desc (m))) {
e_alert_submit (
GTK_WIDGET (shell_content),
"mail:async-error", what,
@@ -277,8 +276,13 @@ mail_msg_cancel (guint msgid)
/* Hold a reference to the GCancellable so it doesn't finalize
* itself on us between unlocking the mutex and cancelling. */
- if (msg != NULL && !g_cancellable_is_cancelled (msg->cancellable))
- cancellable = g_object_ref (msg->cancellable);
+ if (msg != NULL) {
+ cancellable = e_activity_get_cancellable (msg->activity);
+ if (g_cancellable_is_cancelled (cancellable))
+ cancellable = NULL;
+ else
+ g_object_ref (cancellable);
+ }
g_mutex_unlock (mail_msg_lock);
@@ -368,13 +372,17 @@ mail_msg_idle_cb (void)
G_UNLOCK (idle_source_id);
/* check the main loop queue */
while ((msg = g_async_queue_try_pop (main_loop_queue)) != NULL) {
+ GCancellable *cancellable;
+
+ cancellable = e_activity_get_cancellable (msg->activity);
+
g_idle_add_full (
G_PRIORITY_DEFAULT,
(GSourceFunc) mail_msg_submit,
- g_object_ref (msg->priv->activity),
+ g_object_ref (msg->activity),
(GDestroyNotify) g_object_unref);
if (msg->info->exec != NULL)
- msg->info->exec (msg);
+ msg->info->exec (msg, cancellable, &msg->error);
if (msg->info->done != NULL)
msg->info->done (msg);
mail_msg_unref (msg);
@@ -393,23 +401,27 @@ mail_msg_idle_cb (void)
static void
mail_msg_proxy (MailMsg *msg)
{
+ GCancellable *cancellable;
+
+ cancellable = e_activity_get_cancellable (msg->activity);
+
if (msg->info->desc != NULL) {
gchar *text = msg->info->desc (msg);
- camel_operation_push_message (msg->cancellable, "%s", text);
+ camel_operation_push_message (cancellable, "%s", text);
g_free (text);
}
g_idle_add_full (
G_PRIORITY_DEFAULT,
(GSourceFunc) mail_msg_submit,
- g_object_ref (msg->priv->activity),
+ g_object_ref (msg->activity),
(GDestroyNotify) g_object_unref);
if (msg->info->exec != NULL)
- msg->info->exec (msg);
+ msg->info->exec (msg, cancellable, &msg->error);
if (msg->info->desc != NULL)
- camel_operation_pop_message (msg->cancellable);
+ camel_operation_pop_message (cancellable);
g_async_queue_push (msg_reply_queue, msg);
@@ -522,7 +534,9 @@ struct _call_msg {
};
static void
-do_call (struct _call_msg *m)
+do_call (struct _call_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
gpointer p1, *p2, *p3, *p4, *p5;
gint i1;
@@ -572,6 +586,11 @@ do_call (struct _call_msg *m)
break;
}
+ e_activity_set_state (
+ m->base.activity,
+ g_cancellable_is_cancelled (cancellable) ?
+ E_ACTIVITY_CANCELLED : E_ACTIVITY_COMPLETED);
+
if (m->done != NULL)
e_flag_set (m->done);
}
@@ -587,6 +606,7 @@ static MailMsgInfo mail_call_info = {
gpointer
mail_call_main (mail_call_t type, MailMainFunc func, ...)
{
+ GCancellable *cancellable;
struct _call_msg *m;
gpointer ret;
va_list ap;
@@ -598,8 +618,10 @@ mail_call_main (mail_call_t type, MailMainFunc func, ...)
m->func = func;
G_VA_COPY (m->ap, ap);
+ cancellable = e_activity_get_cancellable (m->base.activity);
+
if (mail_in_main_thread ())
- do_call (m);
+ do_call (m, cancellable, &m->base.error);
else {
mail_msg_ref (m);
m->done = e_flag_new ();
diff --git a/mail/mail-mt.h b/mail/mail-mt.h
index 122519162b..0b595072b6 100644
--- a/mail/mail-mt.h
+++ b/mail/mail-mt.h
@@ -24,25 +24,26 @@
#define _MAIL_MT
#include <camel/camel.h>
+#include <e-util/e-activity.h>
typedef struct _MailMsg MailMsg;
typedef struct _MailMsgInfo MailMsgInfo;
-typedef struct _MailMsgPrivate MailMsgPrivate;
-typedef gchar * (*MailMsgDescFunc) (MailMsg *msg);
-typedef void (*MailMsgExecFunc) (MailMsg *msg);
-typedef void (*MailMsgDoneFunc) (MailMsg *msg);
-typedef void (*MailMsgFreeFunc) (MailMsg *msg);
-typedef void (*MailMsgDispatchFunc) (gpointer msg);
+typedef gchar * (*MailMsgDescFunc) (MailMsg *msg);
+typedef void (*MailMsgExecFunc) (MailMsg *msg,
+ GCancellable *cancellable,
+ GError **error);
+typedef void (*MailMsgDoneFunc) (MailMsg *msg);
+typedef void (*MailMsgFreeFunc) (MailMsg *msg);
+typedef void (*MailMsgDispatchFunc) (gpointer msg);
struct _MailMsg {
MailMsgInfo *info;
volatile gint ref_count;
guint seq; /* seq number for synchronisation */
gint priority; /* priority (default = 0) */
- GCancellable *cancellable; /* a cancellation/status handle */
+ EActivity *activity;
GError *error; /* up to the caller to use this */
- MailMsgPrivate *priv;
};
struct _MailMsgInfo {
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 2cdce4c598..ce219ed372 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -88,7 +88,9 @@ em_filter_folder_element_desc (struct _filter_mail_msg *m)
/* filter a folder, or a subset thereof, uses source_folder/source_uids */
/* this is shared with fetch_mail */
static void
-em_filter_folder_element_exec (struct _filter_mail_msg *m)
+em_filter_folder_element_exec (struct _filter_mail_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *folder;
GPtrArray *uids, *folder_uids = NULL;
@@ -112,8 +114,8 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m)
camel_filter_driver_filter_folder (
m->driver, folder, m->cache, uids, m->delete,
- m->base.cancellable, &m->base.error);
- camel_filter_driver_flush (m->driver, &m->base.error);
+ cancellable, error);
+ camel_filter_driver_flush (m->driver, error);
if (folder_uids)
camel_folder_free_uids (folder, folder_uids);
@@ -121,7 +123,7 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m)
/* sync our source folder */
if (!m->cache)
camel_folder_synchronize_sync (
- folder, FALSE, m->base.cancellable, &m->base.error);
+ folder, FALSE, cancellable, error);
camel_folder_thaw (folder);
if (m->destination)
@@ -225,7 +227,9 @@ fetch_mail_desc (struct _fetch_mail_msg *m)
}
static void
-fetch_mail_exec (struct _fetch_mail_msg *m)
+fetch_mail_exec (struct _fetch_mail_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
struct _filter_mail_msg *fm = (struct _filter_mail_msg *)m;
gint i;
@@ -238,18 +242,18 @@ fetch_mail_exec (struct _fetch_mail_msg *m)
/* FIXME: this should support keep_on_server too, which would then perform a spool
access thingy, right? problem is matching raw messages to uid's etc. */
if (!strncmp (m->source_uri, "mbox:", 5)) {
- gchar *path = mail_tool_do_movemail (m->source_uri, &fm->base.error);
+ gchar *path = mail_tool_do_movemail (m->source_uri, error);
- if (path && fm->base.error == NULL) {
+ if (path && error == NULL) {
camel_folder_freeze (fm->destination);
camel_filter_driver_set_default_folder (
fm->driver, fm->destination);
camel_filter_driver_filter_mbox (
fm->driver, path, m->source_uri,
- fm->base.cancellable, &fm->base.error);
+ cancellable, error);
camel_folder_thaw (fm->destination);
- if (fm->base.error == NULL)
+ if (error == NULL)
g_unlink (path);
}
g_free (path);
@@ -259,7 +263,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m)
folder = fm->source_folder =
e_mail_session_get_inbox_sync (
fm->session, m->source_uri,
- fm->base.cancellable, &fm->base.error);
+ cancellable, error);
if (folder) {
/* this handles 'keep on server' stuff, if we have any new uid's to copy
@@ -287,7 +291,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m)
camel_uid_cache_free_uids (cache_uids);
fm->cache = cache;
- em_filter_folder_element_exec (fm);
+ em_filter_folder_element_exec (fm, cancellable, error);
/* need to uncancel so writes/etc. don't fail */
if (g_cancellable_is_cancelled (m->cancellable))
@@ -297,7 +301,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m)
camel_uid_cache_save (cache);
}
- if (fm->delete && fm->base.error == NULL) {
+ if (fm->delete && error == NULL) {
/* not keep on server - just delete all the actual messages on the server */
for (i=0;i<folder_uids->len;i++) {
d(printf("force delete uid '%s'\n", (gchar *)folder_uids->pdata[i]));
@@ -305,7 +309,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m)
}
}
- if ((fm->delete || cache_uids) && fm->base.error == NULL) {
+ if ((fm->delete || cache_uids) && error == NULL) {
/* expunge messages (downloaded so far) */
/* FIXME Not passing a GCancellable or GError here. */
camel_folder_synchronize_sync (
@@ -315,7 +319,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m)
camel_uid_cache_destroy (cache);
camel_folder_free_uids (folder, folder_uids);
} else {
- em_filter_folder_element_exec (fm);
+ em_filter_folder_element_exec (fm, cancellable, error);
}
/* we unref the source folder here since we
@@ -444,7 +448,6 @@ struct _send_queue_msg {
gchar *destination;
CamelFilterDriver *driver;
- GCancellable *cancellable;
/* we use camelfilterstatusfunc, even though its not the filter doing it */
CamelFilterStatusFunc *status;
@@ -732,7 +735,9 @@ report_status (struct _send_queue_msg *m, enum camel_filter_status_t status, gin
}
static void
-send_queue_exec (struct _send_queue_msg *m)
+send_queue_exec (struct _send_queue_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *sent_folder;
GPtrArray *uids, *send_uids = NULL;
@@ -766,7 +771,7 @@ send_queue_exec (struct _send_queue_msg *m)
return;
}
- camel_operation_push_message (m->cancellable, _("Sending message"));
+ camel_operation_push_message (cancellable, _("Sending message"));
/* NB: This code somewhat abuses the 'exception' stuff. Apart from
* fatal problems, it is also used as a mechanism to accumualte
@@ -780,13 +785,12 @@ send_queue_exec (struct _send_queue_msg *m)
_("Sending message %d of %d"), i+1,
send_uids->len);
- if (!m->cancellable)
- camel_operation_progress (
- m->cancellable, (i+1) * 100 / send_uids->len);
+ camel_operation_progress (
+ cancellable, (i+1) * 100 / send_uids->len);
mail_send_message (
m, m->queue, send_uids->pdata[i], m->destination,
- m->driver, m->base.cancellable, &local_error);
+ m->driver, cancellable, &local_error);
if (local_error != NULL) {
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
/* merge exceptions into one */
@@ -846,7 +850,7 @@ send_queue_exec (struct _send_queue_msg *m)
if (sent_folder)
camel_folder_synchronize_sync (sent_folder, FALSE, NULL, NULL);
- camel_operation_pop_message (m->cancellable);
+ camel_operation_pop_message (cancellable);
}
static void
@@ -871,8 +875,6 @@ send_queue_free (struct _send_queue_msg *m)
g_object_unref (m->driver);
g_object_unref (m->queue);
g_free (m->destination);
- if (m->cancellable)
- g_object_unref (m->cancellable);
}
static MailMsgInfo send_queue_info = {
@@ -903,11 +905,8 @@ mail_send_queue (EMailSession *session,
m->session = g_object_ref (session);
m->queue = g_object_ref (queue);
m->destination = g_strdup (destination);
- if (G_IS_CANCELLABLE (cancellable)) {
- m->cancellable = g_object_ref (cancellable);
- g_object_unref (m->base.cancellable);
- m->base.cancellable = NULL;
- }
+ if (G_IS_CANCELLABLE (cancellable))
+ e_activity_set_cancellable (m->base.activity, cancellable);
m->status = status;
m->status_data = status_data;
m->done = done;
@@ -941,7 +940,9 @@ append_mail_desc (struct _append_msg *m)
}
static void
-append_mail_exec (struct _append_msg *m)
+append_mail_exec (struct _append_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
camel_mime_message_set_date (
m->message, CAMEL_MESSAGE_DATE_CURRENT, 0);
@@ -949,7 +950,7 @@ append_mail_exec (struct _append_msg *m)
camel_folder_append_message_sync (
m->folder, m->message,
m->info, &m->appended_uid,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
}
static void
@@ -1029,13 +1030,15 @@ transfer_messages_desc (struct _transfer_msg *m)
}
static void
-transfer_messages_exec (struct _transfer_msg *m)
+transfer_messages_exec (struct _transfer_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *dest;
dest = e_mail_session_uri_to_folder_sync (
m->session, m->dest_uri, m->dest_flags,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
if (dest == NULL)
return;
@@ -1050,7 +1053,7 @@ transfer_messages_exec (struct _transfer_msg *m)
camel_folder_transfer_messages_to_sync (
m->source, m->uids, dest, m->delete, NULL,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
/* make sure all deleted messages are marked as seen */
@@ -1148,13 +1151,19 @@ get_folderinfo_desc (struct _get_folderinfo_msg *m)
}
static void
-get_folderinfo_exec (struct _get_folderinfo_msg *m)
+get_folderinfo_exec (struct _get_folderinfo_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
- guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
+ guint32 flags;
+
+ flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE |
+ CAMEL_STORE_FOLDER_INFO_FAST |
+ CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
m->info = camel_store_get_folder_info_sync (
m->store, NULL, flags,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
}
static void
@@ -1201,10 +1210,8 @@ mail_get_folderinfo (CamelStore *store,
gint id;
m = mail_msg_new (&get_folderinfo_info);
- if (G_IS_CANCELLABLE (cancellable)) {
- g_object_unref (m->base.cancellable);
- m->base.cancellable = g_object_ref (cancellable);
- }
+ if (G_IS_CANCELLABLE (cancellable))
+ e_activity_set_cancellable (m->base.activity, cancellable);
m->store = store;
g_object_ref (store);
m->done = done;
@@ -1300,11 +1307,13 @@ get_folder_desc (struct _get_folder_msg *m)
}
static void
-get_folder_exec (struct _get_folder_msg *m)
+get_folder_exec (struct _get_folder_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
m->folder = e_mail_session_uri_to_folder_sync (
m->session, m->uri, m->flags,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
}
static void
@@ -1373,7 +1382,9 @@ get_quota_desc (struct _get_quota_msg *m)
}
static void
-get_quota_exec (struct _get_quota_msg *m)
+get_quota_exec (struct _get_quota_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
m->quota = camel_folder_get_quota_info (m->folder);
}
@@ -1446,13 +1457,15 @@ get_store_desc (struct _get_store_msg *m)
}
static void
-get_store_exec (struct _get_store_msg *m)
+get_store_exec (struct _get_store_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
/*camel_session_get_store connects us, which we don't want to do on startup. */
m->store = (CamelStore *) camel_session_get_service (
CAMEL_SESSION (m->session), m->uri,
- CAMEL_PROVIDER_STORE, &m->base.error);
+ CAMEL_PROVIDER_STORE, error);
}
static void
@@ -1490,10 +1503,8 @@ mail_get_store (EMailSession *session,
gint id;
m = mail_msg_new (&get_store_info);
- if (G_IS_CANCELLABLE (cancellable)) {
- g_object_unref (m->base.cancellable);
- m->base.cancellable = g_object_ref (cancellable);
- }
+ if (G_IS_CANCELLABLE (cancellable))
+ e_activity_set_cancellable (m->base.activity, cancellable);
m->session = g_object_ref (session);
m->uri = g_strdup (uri);
m->data = data;
@@ -1579,7 +1590,9 @@ remove_folder_rec (CamelStore *store,
}
static void
-remove_folder_exec (struct _remove_folder_msg *m)
+remove_folder_exec (struct _remove_folder_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolderInfo *fi;
CamelStore *parent_store;
@@ -1595,13 +1608,12 @@ remove_folder_exec (struct _remove_folder_msg *m)
CAMEL_STORE_FOLDER_INFO_RECURSIVE |
CAMEL_STORE_FOLDER_INFO_FAST |
CAMEL_STORE_FOLDER_INFO_SUBSCRIBED,
- m->base.cancellable,
- &m->base.error);
+ cancellable, error);
if (fi == NULL)
return;
m->removed = remove_folder_rec (
- parent_store, fi, m->base.cancellable, &m->base.error);
+ parent_store, fi, cancellable, error);
camel_store_free_folder_info (parent_store, fi);
}
@@ -1660,10 +1672,12 @@ sync_folder_desc (struct _sync_folder_msg *m)
}
static void
-sync_folder_exec (struct _sync_folder_msg *m)
+sync_folder_exec (struct _sync_folder_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
camel_folder_synchronize_sync (
- m->folder, FALSE, m->base.cancellable, &m->base.error);
+ m->folder, FALSE, cancellable, error);
}
static void
@@ -1728,11 +1742,13 @@ sync_store_desc (struct _sync_store_msg *m)
}
static void
-sync_store_exec (struct _sync_store_msg *m)
+sync_store_exec (struct _sync_store_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
camel_store_synchronize_sync (
m->store, m->expunge,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
}
static void
@@ -1780,10 +1796,12 @@ refresh_folder_desc (struct _sync_folder_msg *m)
}
static void
-refresh_folder_exec (struct _sync_folder_msg *m)
+refresh_folder_exec (struct _sync_folder_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
camel_folder_refresh_info_sync (
- m->folder, m->base.cancellable, &m->base.error);
+ m->folder, cancellable, error);
}
/* we just use the sync stuff where we can, since it would be the same */
@@ -1818,10 +1836,11 @@ expunge_folder_desc (struct _sync_folder_msg *m)
}
static void
-expunge_folder_exec (struct _sync_folder_msg *m)
+expunge_folder_exec (struct _sync_folder_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
- camel_folder_expunge_sync (
- m->folder, m->base.cancellable, &m->base.error);
+ camel_folder_expunge_sync (m->folder, cancellable, error);
}
/* we just use the sync stuff where we can, since it would be the same */
@@ -1866,28 +1885,28 @@ empty_trash_desc (struct _empty_trash_msg *m)
}
static void
-empty_trash_exec (struct _empty_trash_msg *m)
+empty_trash_exec (struct _empty_trash_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
- const gchar *data_dir;
CamelFolder *trash;
+ const gchar *data_dir;
gchar *uri;
if (m->account) {
trash = e_mail_session_get_trash_sync (
m->session, m->account->source->url,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
} else {
data_dir = mail_session_get_data_dir ();
uri = g_strdup_printf ("mbox:%s/local", data_dir);
trash = e_mail_session_get_trash_sync (
- m->session, uri,
- m->base.cancellable, &m->base.error);
+ m->session, uri, cancellable, error);
g_free (uri);
}
if (trash) {
- camel_folder_expunge_sync (
- trash, m->base.cancellable, &m->base.error);
+ camel_folder_expunge_sync (trash, cancellable, error);
g_object_unref (trash);
}
}
@@ -1955,14 +1974,15 @@ get_message_desc (struct _get_message_msg *m)
}
static void
-get_message_exec (struct _get_message_msg *m)
+get_message_exec (struct _get_message_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
- if (g_cancellable_is_cancelled (m->base.cancellable))
+ if (g_cancellable_is_cancelled (cancellable))
m->message = NULL;
else
m->message = camel_folder_get_message_sync (
- m->folder, m->uid,
- m->base.cancellable, &m->base.error);
+ m->folder, m->uid, cancellable, error);
}
static void
@@ -2090,7 +2110,9 @@ get_messages_desc (struct _get_messages_msg *m)
}
static void
-get_messages_exec (struct _get_messages_msg *m)
+get_messages_exec (struct _get_messages_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
gint i;
CamelMimeMessage *message;
@@ -2100,9 +2122,8 @@ get_messages_exec (struct _get_messages_msg *m)
message = camel_folder_get_message_sync (
m->folder, m->uids->pdata[i],
- m->base.cancellable, &m->base.error);
- camel_operation_progress (
- m->base.cancellable, pc);
+ cancellable, error);
+ camel_operation_progress (cancellable, pc);
if (message == NULL)
break;
@@ -2214,7 +2235,9 @@ save_prepare_part (CamelMimePart *mime_part)
}
static void
-save_messages_exec (struct _save_messages_msg *m)
+save_messages_exec (struct _save_messages_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelStream *filtered_stream;
CamelMimeFilter *from_filter;
@@ -2243,9 +2266,8 @@ save_messages_exec (struct _save_messages_msg *m)
message = camel_folder_get_message_sync (
m->folder, m->uids->pdata[i],
- m->base.cancellable, &m->base.error);
- camel_operation_progress (
- m->base.cancellable, pc);
+ cancellable, error);
+ camel_operation_progress (cancellable, pc);
if (message == NULL)
break;
@@ -2255,24 +2277,23 @@ save_messages_exec (struct _save_messages_msg *m)
from = camel_mime_message_build_mbox_from (message);
if (camel_stream_write_string (
stream, from,
- m->base.cancellable, &m->base.error) == -1
+ cancellable, error) == -1
|| camel_stream_flush (
- stream, m->base.cancellable, &m->base.error) == -1
+ stream, cancellable, error) == -1
|| camel_data_wrapper_write_to_stream_sync (
(CamelDataWrapper *) message,
(CamelStream *)filtered_stream,
- m->base.cancellable, &m->base.error) == -1
+ cancellable, error) == -1
|| camel_stream_flush (
(CamelStream *)filtered_stream,
- m->base.cancellable, &m->base.error) == -1
+ cancellable, error) == -1
|| camel_stream_write_string (
stream, "\n",
- m->base.cancellable, &m->base.error) == -1
+ cancellable, error) == -1
|| camel_stream_flush (stream,
- m->base.cancellable, &m->base.error) == -1) {
+ cancellable, error) == -1) {
g_prefix_error (
- &m->base.error,
- _("Error saving messages to: %s:\n"),
+ error, _("Error saving messages to: %s:\n"),
m->path);
g_free (from);
g_object_unref ((CamelObject *)message);
@@ -2343,22 +2364,24 @@ struct _prep_offline_msg {
};
static void
-prep_offline_exec (struct _prep_offline_msg *m)
+prep_offline_exec (struct _prep_offline_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelFolder *folder;
folder = e_mail_session_uri_to_folder_sync (
m->session, m->uri, 0,
- m->base.cancellable, &m->base.error);
+ cancellable, error);
if (folder) {
if (CAMEL_IS_DISCO_FOLDER (folder)) {
camel_disco_folder_prepare_for_offline (
CAMEL_DISCO_FOLDER (folder),
- "(match-all)", m->cancel, &m->base.error);
+ "(match-all)", m->cancel, error);
} else if (CAMEL_IS_OFFLINE_FOLDER (folder)) {
camel_offline_folder_downsync_sync (
CAMEL_OFFLINE_FOLDER (folder),
- "(match-all)", m->cancel, &m->base.error);
+ "(match-all)", m->cancel, error);
}
/* prepare_for_offline should do this? */
/* of course it should all be atomic, but ... */
@@ -2436,35 +2459,34 @@ set_offline_desc (struct _set_offline_msg *m)
}
static void
-set_offline_exec (struct _set_offline_msg *m)
+set_offline_exec (struct _set_offline_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
if (CAMEL_IS_DISCO_STORE (m->store)) {
if (!m->offline) {
camel_disco_store_set_status (
CAMEL_DISCO_STORE (m->store),
CAMEL_DISCO_STORE_ONLINE,
- m->base.cancellable,
- &m->base.error);
+ cancellable, error);
return;
} else if (camel_disco_store_can_work_offline (CAMEL_DISCO_STORE (m->store))) {
camel_disco_store_set_status (
CAMEL_DISCO_STORE (m->store),
CAMEL_DISCO_STORE_OFFLINE,
- m->base.cancellable,
- &m->base.error);
+ cancellable, error);
return;
}
} else if (CAMEL_IS_OFFLINE_STORE (m->store)) {
camel_offline_store_set_online_sync (
CAMEL_OFFLINE_STORE (m->store),
- !m->offline, m->base.cancellable,
- &m->base.error);
+ !m->offline, cancellable, error);
return;
}
if (m->offline)
camel_service_disconnect_sync (
- CAMEL_SERVICE (m->store), TRUE, &m->base.error);
+ CAMEL_SERVICE (m->store), TRUE, error);
}
static void
@@ -2530,16 +2552,18 @@ prepare_offline_desc (struct _set_offline_msg *m)
}
static void
-prepare_offline_exec (struct _set_offline_msg *m)
+prepare_offline_exec (struct _set_offline_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
if (CAMEL_IS_DISCO_STORE (m->store)) {
camel_disco_store_prepare_for_offline (
CAMEL_DISCO_STORE (m->store),
- m->base.cancellable, &m->base.error);
+ cancellable, error);
} else if (CAMEL_IS_OFFLINE_STORE (m->store)) {
camel_offline_store_prepare_for_offline_sync (
CAMEL_OFFLINE_STORE (m->store),
- m->base.cancellable, &m->base.error);
+ cancellable, error);
}
}
@@ -2616,18 +2640,19 @@ check_service_desc (struct _check_msg *m)
}
static void
-check_service_exec (struct _check_msg *m)
+check_service_exec (struct _check_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
CamelService *service;
service = camel_session_get_service (
- CAMEL_SESSION (m->session), m->url,
- m->type, &m->base.error);
+ CAMEL_SESSION (m->session), m->url, m->type, error);
if (!service)
return;
m->authtypes = camel_service_query_auth_types_sync (
- service, m->base.cancellable, &m->base.error);
+ service, cancellable, error);
g_object_unref (service);
}
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 3d303873cf..63cc28312c 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -903,10 +903,12 @@ refresh_folders_desc (struct _refresh_folders_msg *m)
}
static void
-refresh_folders_exec (struct _refresh_folders_msg *m)
+refresh_folders_exec (struct _refresh_folders_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
- gint i;
CamelFolder *folder;
+ gint i;
GError *local_error = NULL;
get_folders (m->store, m->folders, m->finfo);
@@ -915,7 +917,7 @@ refresh_folders_exec (struct _refresh_folders_msg *m)
folder = e_mail_session_uri_to_folder_sync (
m->info->session,
m->folders->pdata[i], 0,
- m->base.cancellable, &local_error);
+ cancellable, &local_error);
if (folder) {
/* FIXME Not passing a GCancellable or GError here. */
camel_folder_synchronize_sync (
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index eb447ea888..6ed6a61d90 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -88,7 +88,9 @@ vfolder_setup_desc (struct _setup_msg *m)
}
static void
-vfolder_setup_exec (struct _setup_msg *m)
+vfolder_setup_exec (struct _setup_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
GList *l, *list = NULL;
CamelFolder *folder;
@@ -243,7 +245,9 @@ vfolder_adduri_desc (struct _adduri_msg *m)
}
static void
-vfolder_adduri_exec (struct _adduri_msg *m)
+vfolder_adduri_exec (struct _adduri_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
GList *l;
CamelFolder *folder = NULL;
@@ -252,8 +256,6 @@ vfolder_adduri_exec (struct _adduri_msg *m)
if (vfolder_shutdown)
return;
- d(printf("%s uri to vfolder: %s\n", m->remove?"Removing":"Adding", m->uri));
-
folder_cache = e_mail_session_get_folder_cache (m->session);
/* we dont try lookup the cache if we are removing it, its no longer there */
@@ -266,8 +268,7 @@ vfolder_adduri_exec (struct _adduri_msg *m)
if (folder == NULL)
folder = e_mail_session_uri_to_folder_sync (
- m->session, m->uri, 0,
- m->base.cancellable, &m->base.error);
+ m->session, m->uri, 0, cancellable, error);
if (folder != NULL) {
l = m->folders;
diff --git a/mail/message-list.c b/mail/message-list.c
index 974eb1c295..68e05fc998 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -2218,7 +2218,9 @@ ml_drop_async_desc (struct _drop_msg *m)
}
static void
-ml_drop_async_exec (struct _drop_msg *m)
+ml_drop_async_exec (struct _drop_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
EMailBackend *backend;
EMailSession *session;
@@ -2231,8 +2233,7 @@ ml_drop_async_exec (struct _drop_msg *m)
em_utils_selection_get_uidlist (
m->selection, session, m->folder,
m->action == GDK_ACTION_MOVE,
- m->base.cancellable,
- &m->base.error);
+ cancellable, error);
break;
case DND_MESSAGE_RFC822:
em_utils_selection_get_message (m->selection, m->folder);
@@ -4461,7 +4462,9 @@ regen_list_desc (struct _regen_list_msg *m)
}
static void
-regen_list_exec (struct _regen_list_msg *m)
+regen_list_exec (struct _regen_list_msg *m,
+ GCancellable *cancellable,
+ GError **error)
{
GPtrArray *uids, *searchuids = NULL;
CamelMessageInfo *info;
@@ -4469,6 +4472,7 @@ regen_list_exec (struct _regen_list_msg *m)
ETree *tree;
gint i;
gchar *expr = NULL;
+ GError *local_error = NULL;
if (m->folder != m->ml->folder)
return;
@@ -4516,7 +4520,7 @@ regen_list_exec (struct _regen_list_msg *m)
gboolean store_has_vjunk = folder_store_supports_vjunk_folder (m->folder);
searchuids = uids = camel_folder_search_by_expression (
- m->folder, expr, &m->base.error);
+ m->folder, expr, &local_error);
/* If m->changes is not NULL, then it means we are called from folder_changed event,
thus we will keep the selected message to be sure it doesn't disappear because
it no longer belong to our search filter. */
@@ -4554,13 +4558,15 @@ regen_list_exec (struct _regen_list_msg *m)
}
}
- if (m->base.error != NULL)
+ if (local_error != NULL) {
+ g_propagate_error (error, local_error);
return;
+ }
e_profile_event_emit("list.threaduids", m->folder->full_name, 0);
/* camel_folder_summary_prepare_fetch_all (m->folder->summary, NULL); */
- if (!g_cancellable_is_cancelled (m->base.cancellable)) {
+ if (!g_cancellable_is_cancelled (cancellable)) {
/* update/build a new tree */
if (m->dotree) {
ml_sort_uids_by_tree (m->ml, uids);
@@ -4596,6 +4602,9 @@ static void
regen_list_done (struct _regen_list_msg *m)
{
ETree *tree;
+ GCancellable *cancellable;
+
+ cancellable = e_activity_get_cancellable (m->base.activity);
if (m->ml->priv->destroyed)
return;
@@ -4603,7 +4612,7 @@ regen_list_done (struct _regen_list_msg *m)
if (!m->complete)
return;
- if (g_cancellable_is_cancelled (m->base.cancellable))
+ if (g_cancellable_is_cancelled (cancellable))
return;
if (m->ml->folder != m->folder)
@@ -4789,10 +4798,12 @@ mail_regen_cancel (MessageList *ml)
l = ml->regen;
while (l) {
MailMsg *mm = l->data;
+ GCancellable *cancellable;
- if (mm->cancellable)
+ cancellable = e_activity_get_cancellable (mm->activity);
+ if (CAMEL_IS_OPERATION (cancellable))
camel_operation_cancel (
- CAMEL_OPERATION (mm->cancellable));
+ CAMEL_OPERATION (cancellable));
l = l->next;
}