diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-09-21 11:13:43 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-09-28 23:35:55 +0800 |
commit | 31b57ed0383b2ea225195d4b72a872f7f2d93163 (patch) | |
tree | 2d70adcce04ed1ed5111c06cd7ad93266419b0e0 /mail | |
parent | a91eeb647138ee035444cdc3c265fa4e95898f29 (diff) | |
download | gsoc2013-evolution-31b57ed0383b2ea225195d4b72a872f7f2d93163.tar.gz gsoc2013-evolution-31b57ed0383b2ea225195d4b72a872f7f2d93163.tar.zst gsoc2013-evolution-31b57ed0383b2ea225195d4b72a872f7f2d93163.zip |
Adapt to Camel API changes.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-backend.c | 4 | ||||
-rw-r--r-- | mail/e-mail-local.c | 2 | ||||
-rw-r--r-- | mail/e-mail-migrate.c | 8 | ||||
-rw-r--r-- | mail/e-mail-store.c | 8 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 22 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 22 | ||||
-rw-r--r-- | mail/em-folder-utils.c | 28 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 53 | ||||
-rw-r--r-- | mail/em-format-html.c | 253 | ||||
-rw-r--r-- | mail/em-format-html.h | 3 | ||||
-rw-r--r-- | mail/em-html-stream.c | 2 | ||||
-rw-r--r-- | mail/em-inline-filter.c | 6 | ||||
-rw-r--r-- | mail/em-subscribe-editor.c | 6 | ||||
-rw-r--r-- | mail/em-sync-stream.c | 3 | ||||
-rw-r--r-- | mail/em-utils.c | 44 | ||||
-rw-r--r-- | mail/importers/evolution-mbox-importer.c | 4 | ||||
-rw-r--r-- | mail/importers/mail-importer.c | 35 | ||||
-rw-r--r-- | mail/mail-folder-cache.c | 14 | ||||
-rw-r--r-- | mail/mail-mt.c | 16 | ||||
-rw-r--r-- | mail/mail-ops.c | 172 | ||||
-rw-r--r-- | mail/mail-ops.h | 3 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 5 | ||||
-rw-r--r-- | mail/mail-session.c | 8 | ||||
-rw-r--r-- | mail/mail-tools.c | 11 | ||||
-rw-r--r-- | mail/mail-vfolder.c | 10 |
25 files changed, 396 insertions, 346 deletions
diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index 690181d87b..8012cc79af 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -153,8 +153,8 @@ mail_backend_delete_junk (CamelStore *store, guint32 mask; guint ii; - /* FIXME camel_store_get_junk() may block. */ - folder = camel_store_get_junk (store, NULL, NULL); + /* FIXME camel_store_get_junk_folder_sync() may block. */ + folder = camel_store_get_junk_folder_sync (store, NULL, NULL); if (folder == NULL) return; diff --git a/mail/e-mail-local.c b/mail/e-mail-local.c index f0ad740f92..861ac8fe35 100644 --- a/mail/e-mail-local.c +++ b/mail/e-mail-local.c @@ -83,7 +83,7 @@ e_mail_local_init (const gchar *data_dir) /* FIXME camel_store_get_folder() may block. */ default_local_folders[ii].folder_uri = folder_uri; - default_local_folders[ii].folder = camel_store_get_folder ( + default_local_folders[ii].folder = camel_store_get_folder_sync ( CAMEL_STORE (service), display_name, CAMEL_STORE_FOLDER_CREATE, NULL, NULL); } diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index 360d3f6c69..f5481bc68a 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -556,11 +556,11 @@ migrate_folders (CamelStore *store, g_idle_add ((GSourceFunc) update_states_in_main_thread, info); if (is_local) - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( store, fi->full_name, CAMEL_STORE_IS_MIGRATING, NULL, NULL); else - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( store, fi->full_name, 0, NULL, NULL); if (folder != NULL) @@ -656,7 +656,7 @@ migrate_to_db (EShellBackend *shell_backend) em_migrate_set_progress ( (double)i/(len+1)); store = setup_local_store (shell_backend, session); - info = camel_store_get_folder_info ( + info = camel_store_get_folder_info_sync ( store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST | @@ -697,7 +697,7 @@ migrate_to_db (EShellBackend *shell_backend) e_mail_store_add_by_uri (service->url, name); store = (CamelStore *) camel_session_get_service (CAMEL_SESSION (session), service->url, CAMEL_PROVIDER_STORE, NULL); - info = camel_store_get_folder_info ( + info = camel_store_get_folder_info_sync ( store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST | diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index ea524ad5e2..d27c01a298 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -86,9 +86,11 @@ store_info_new (CamelStore *store, /* If these are vfolders then they need to be opened now, * otherwise they won't keep track of all folders. */ if (store->flags & CAMEL_STORE_VTRASH) - store_info->vtrash = camel_store_get_trash (store, NULL, NULL); + store_info->vtrash = + camel_store_get_trash_folder_sync (store, NULL, NULL); if (store->flags & CAMEL_STORE_VJUNK) - store_info->vjunk = camel_store_get_junk (store, NULL, NULL); + store_info->vjunk = + camel_store_get_junk_folder_sync (store, NULL, NULL); return store_info; } @@ -343,7 +345,7 @@ fail: static void mail_store_remove_cb (CamelStore *store) { - camel_service_disconnect (CAMEL_SERVICE (store), TRUE, NULL); + camel_service_disconnect_sync (CAMEL_SERVICE (store), TRUE, NULL); g_object_unref (store); } diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 01964d5fcd..b65237b288 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -473,7 +473,7 @@ composer_get_message (EMsgComposer *composer, gboolean save_html_object_data) /* actually get the message now, this will sign/encrypt etc */ message = e_msg_composer_get_message ( - composer, save_html_object_data, &error); + composer, save_html_object_data, NULL, &error); /* Ignore cancellations. */ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { @@ -670,7 +670,7 @@ em_utils_composer_save_draft_cb (EMsgComposer *composer) local_drafts_folder_uri = e_mail_local_get_folder_uri (E_MAIL_FOLDER_DRAFTS); - msg = e_msg_composer_get_message_draft (composer, &error); + msg = e_msg_composer_get_message_draft (composer, NULL, &error); /* Ignore cancellations. */ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { @@ -742,7 +742,7 @@ em_utils_composer_print_cb (EMsgComposer *composer, CamelMimeMessage *message; EMFormatHTMLPrint *efhp; - message = e_msg_composer_get_message_print (composer, 1); + message = e_msg_composer_get_message_print (composer, 1, NULL); efhp = em_format_html_print_new (NULL, action); em_format_html_print_raw_message (efhp, message); @@ -966,7 +966,8 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont byte_array = g_byte_array_new (); stream = camel_stream_mem_new_with_byte_array (byte_array); - camel_data_wrapper_decode_to_stream (content, stream, NULL); + camel_data_wrapper_decode_to_stream_sync ( + content, stream, NULL, NULL); str = g_strndup ((gchar *) byte_array->data, byte_array->len); g_object_unref (stream); @@ -974,7 +975,8 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont if (replace_variables (clues, message, &str)) { stream = camel_stream_mem_new_with_buffer (str, strlen (str)); camel_stream_reset (stream, NULL); - camel_data_wrapper_construct_from_stream (content, stream, NULL); + camel_data_wrapper_construct_from_stream_sync ( + content, stream, NULL, NULL); g_object_unref (stream); } @@ -1008,7 +1010,7 @@ edit_message (EShell *shell, g_slist_free (clue_list); } - composer = e_msg_composer_new_with_message (shell, message); + composer = e_msg_composer_new_with_message (shell, message, NULL); if (em_utils_folder_is_drafts (drafts, NULL)) { struct emcs_t *emcs; @@ -1548,7 +1550,7 @@ redirect_get_composer (EShell *shell, account = em_utils_guess_account_with_recipients (message, NULL); composer = e_msg_composer_new_redirect ( - shell, message, account ? account->name : NULL); + shell, message, account ? account->name : NULL, NULL); return composer; } @@ -1741,7 +1743,8 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message) /* Translators: First %s is an email address, second %s is the subject of the email, third %s is the date */ _("Your message to %s about \"%s\" on %s has been read."), self_address, message_subject, message_date); - camel_data_wrapper_construct_from_stream (receipt_text, stream, NULL); + camel_data_wrapper_construct_from_stream_sync ( + receipt_text, stream, NULL, NULL); g_object_unref (stream); part = camel_mime_part_new (); @@ -1769,7 +1772,8 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message) "Original-Message-ID: %s\n" "Disposition: manual-action/MDN-sent-manually; displayed\n", ua, recipient, message_id); - camel_data_wrapper_construct_from_stream (receipt_data, stream, NULL); + camel_data_wrapper_construct_from_stream_sync ( + receipt_data, stream, NULL, NULL); g_object_unref (stream); g_free (ua); diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 3d1bb68265..512aa9b026 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -200,7 +200,7 @@ folder_tree_get_folder_info__exec (struct _EMFolderTreeGetFolderInfo *m) { guint32 flags = m->flags | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED; - m->fi = camel_store_get_folder_info ( + m->fi = camel_store_get_folder_info_sync ( m->store, m->top, flags, m->base.cancellable, &m->base.error); @@ -625,7 +625,7 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, /* Check for duplicate folder name. */ /* FIXME camel_store_get_folder_info() may block. */ - folder_info = camel_store_get_folder_info ( + folder_info = camel_store_get_folder_info_sync ( store, new_full_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL); if (folder_info != NULL) { @@ -636,8 +636,8 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, goto exit; } - /* FIXME camel_store_rename_folder() may block. */ - if (!camel_store_rename_folder ( + /* FIXME camel_store_rename_folder_sync() may block. */ + if (!camel_store_rename_folder_sync ( store, old_full_name, new_full_name, NULL, &local_error)) { e_alert_run_dialog_for_args ( parent, "mail:no-rename-folder", @@ -1531,8 +1531,8 @@ tree_drag_data_delete (GtkWidget *widget, if (is_store) goto fail; - /* FIXME camel_store_delete_folder() may block. */ - camel_store_delete_folder (store, full_name, NULL, NULL); + /* FIXME camel_store_delete_folder_sync() may block. */ + camel_store_delete_folder_sync (store, full_name, NULL, NULL); fail: gtk_tree_path_free (src_path); @@ -1582,8 +1582,8 @@ tree_drag_data_get (GtkWidget *widget, break; case DND_DRAG_TYPE_TEXT_URI_LIST: /* dragging to nautilus or something, probably */ - /* FIXME camel_store_get_folder() may block. */ - if ((folder = camel_store_get_folder ( + /* FIXME camel_store_get_folder_sync() may block. */ + if ((folder = camel_store_get_folder_sync ( store, full_name, 0, NULL, NULL))) { GPtrArray *uids = camel_folder_get_uids (folder); @@ -1698,7 +1698,7 @@ folder_tree_drop_async__exec (struct _DragDataReceivedAsync *m) g_set_error ( &m->base.error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Cannot drop message(s) into toplevel store")); - } else if ((folder = camel_store_get_folder ( + } else if ((folder = camel_store_get_folder_sync ( m->store, m->full_name, 0, m->base.cancellable, &m->base.error))) { @@ -2810,9 +2810,9 @@ em_folder_tree_get_selected_folder (EMFolderTree *folder_tree) gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, COL_STRING_FULL_NAME, &full_name, -1); - /* FIXME camel_store_get_folder() may block. */ + /* FIXME camel_store_get_folder_sync() may block. */ if (store && full_name) - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( store, full_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL); diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index 201a0b9fb0..dbd673c4cb 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -104,7 +104,7 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) const gchar *tmp; gint fromlen; - fi = camel_store_get_folder_info ( + fi = camel_store_get_folder_info_sync ( m->fromstore, m->frombase, flags, m->base.cancellable, &m->base.error); if (fi == NULL) @@ -147,7 +147,7 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) if ((info->flags & CAMEL_FOLDER_NOSELECT) == 0) { d(printf ("this folder is selectable\n")); if (m->tostore == m->fromstore && m->delete) { - camel_store_rename_folder ( + camel_store_rename_folder_sync ( m->fromstore, info->full_name, toname->str, m->base.cancellable, &m->base.error); if (m->base.error != NULL) @@ -155,18 +155,18 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) /* this folder no longer exists, unsubscribe it */ if (camel_store_supports_subscriptions (m->fromstore)) - camel_store_unsubscribe_folder ( + camel_store_unsubscribe_folder_sync ( m->fromstore, info->full_name, NULL, NULL); deleted = 1; } else { - fromfolder = camel_store_get_folder ( + fromfolder = camel_store_get_folder_sync ( m->fromstore, info->full_name, 0, m->base.cancellable, &m->base.error); if (fromfolder == NULL) goto exception; - tofolder = camel_store_get_folder ( + tofolder = camel_store_get_folder_sync ( m->tostore, toname->str, CAMEL_STORE_FOLDER_CREATE, m->base.cancellable, @@ -177,15 +177,15 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) } uids = camel_folder_get_uids (fromfolder); - camel_folder_transfer_messages_to ( + camel_folder_transfer_messages_to_sync ( fromfolder, uids, tofolder, - NULL, m->delete, + m->delete, NULL, m->base.cancellable, &m->base.error); camel_folder_free_uids (fromfolder, uids); if (m->delete && m->base.error == NULL) - camel_folder_sync ( + camel_folder_synchronize_sync ( fromfolder, TRUE, NULL, NULL); @@ -202,7 +202,7 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) /* subscribe to the new folder if appropriate */ if (camel_store_supports_subscriptions (m->tostore) && !camel_store_folder_is_subscribed (m->tostore, toname->str)) - camel_store_subscribe_folder ( + camel_store_subscribe_folder_sync ( m->tostore, toname->str, NULL, NULL); info = info->next; @@ -220,10 +220,10 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) since otherwise the users sees a failed operation with no error message or even any warnings */ if (camel_store_supports_subscriptions (m->fromstore)) - camel_store_unsubscribe_folder ( + camel_store_unsubscribe_folder_sync ( m->fromstore, info->full_name, NULL, NULL); - camel_store_delete_folder ( + camel_store_delete_folder_sync ( m->fromstore, info->full_name, NULL, NULL); l = l->next; } @@ -548,12 +548,12 @@ emfu_create_folder__exec (struct _EMCreateFolder *m) { 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 ( + if ((m->fi = camel_store_create_folder_sync ( m->store, m->parent, m->name, m->base.cancellable, &m->base.error))) { if (camel_store_supports_subscriptions (m->store)) - camel_store_subscribe_folder ( + camel_store_subscribe_folder_sync ( m->store, m->full_name, m->base.cancellable, &m->base.error); } @@ -751,7 +751,7 @@ emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg) path = url->path + 1; if (path != NULL) - camel_store_unsubscribe_folder ( + camel_store_unsubscribe_folder_sync ( store, path, msg->base.cancellable, &msg->base.error); diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index d68b1f2508..3776d944ad 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -146,7 +146,12 @@ struct _attach_puri { camel_cipher_validity_encrypt_t encrypt; }; -static void efhd_message_prefix (EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info); +static void efhd_message_prefix (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable, + gboolean is_fallback); static void efhd_builtin_init (EMFormatHTMLDisplayClass *efhc); @@ -428,14 +433,16 @@ efhd_format_attachment (EMFormat *emf, stream, EM_FORMAT_HTML_VPAD "<table cellspacing=0 cellpadding=0><tr><td>" "<table width=10 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td>", NULL); + "<tr><td></td></tr></table></td>", + cancellable, NULL); camel_stream_printf ( stream, "<td><object classid=\"%s\"></object></td>", classid); camel_stream_write_string ( stream, "<td><table width=3 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td><td><font size=-1>", NULL); + "<tr><td></td></tr></table></td><td><font size=-1>", + cancellable, NULL); /* output some info about it */ /* FIXME: should we look up mime_type from object again? */ @@ -443,13 +450,13 @@ efhd_format_attachment (EMFormat *emf, html = camel_text_to_html ( text, EM_FORMAT_HTML (emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string (stream, html, NULL); + camel_stream_write_string (stream, html, cancellable, NULL); g_free (html); g_free (text); camel_stream_write_string ( stream, "</font></td></tr><tr></table>\n" - EM_FORMAT_HTML_VPAD, NULL); + EM_FORMAT_HTML_VPAD, cancellable, NULL); if (handle && info->shown) handle->handler ( @@ -462,7 +469,8 @@ static void efhd_format_optional (EMFormat *emf, CamelStream *fstream, CamelMimePart *part, - CamelStream *mstream) + CamelStream *mstream, + GCancellable *cancellable) { gchar *classid, *html; struct _attach_puri *info; @@ -494,7 +502,7 @@ efhd_format_optional (EMFormat *emf, camel_stream_write_string ( stream, EM_FORMAT_HTML_VPAD "<table cellspacing=0 cellpadding=0><tr><td>" - "<h3><font size=-1 color=red>", NULL); + "<h3><font size=-1 color=red>", cancellable, NULL); html = camel_text_to_html ( _("Evolution cannot render this email as it is too " @@ -502,18 +510,21 @@ efhd_format_optional (EMFormat *emf, "with an external text editor."), EM_FORMAT_HTML (emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string (stream, html, NULL); + camel_stream_write_string (stream, html, cancellable, NULL); camel_stream_write_string ( - stream, "</font></h3></td></tr></table>\n", NULL); + stream, "</font></h3></td></tr></table>\n", + cancellable, NULL); camel_stream_write_string ( - stream, "<table cellspacing=0 cellpadding=0><tr>", NULL); + stream, "<table cellspacing=0 cellpadding=0><tr>", + cancellable, NULL); camel_stream_printf ( stream, "<td><object classid=\"%s\"></object>" "</td></tr></table>", classid); g_free (html); - camel_stream_write_string (stream, EM_FORMAT_HTML_VPAD, NULL); + camel_stream_write_string ( + stream, EM_FORMAT_HTML_VPAD, cancellable, NULL); g_free (classid); } @@ -664,7 +675,7 @@ em_format_html_display_new (void) /* ********************************************************************** */ static EMFormatHandler type_builtin_table[] = { - { (gchar *) "x-evolution/message/prefix", (EMFormatFunc)efhd_message_prefix }, + { (gchar *) "x-evolution/message/prefix", efhd_message_prefix }, { (gchar *) "x-evolution/message/post-header", (EMFormatFunc)efhd_message_add_bar } }; @@ -687,12 +698,18 @@ efhd_write_image (EMFormat *emf, /* TODO: identical to efh_write_image */ d(printf("writing image '%s'\n", puri->cid)); - camel_data_wrapper_decode_to_stream (dw, stream, NULL); - camel_stream_close (stream, NULL); + camel_data_wrapper_decode_to_stream_sync ( + dw, stream, cancellable, NULL); + camel_stream_close (stream, cancellable, NULL); } static void -efhd_message_prefix (EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +efhd_message_prefix (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable, + gboolean is_fallback) { const gchar *flag, *comp, *due; time_t date; @@ -711,7 +728,9 @@ efhd_message_prefix (EMFormat *emf, CamelStream *stream, CamelMimePart *part, EM if (iconpath) { CamelMimePart *iconpart; - iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png", iconpath); + iconpart = em_format_html_file_part ( + (EMFormatHTML *)emf, "image/png", + iconpath, cancellable); g_free (iconpath); if (iconpart) { gchar *classid; @@ -874,7 +893,7 @@ efhd_attachment_frame (EMFormat *emf, emf, stream, info->puri.part, info->handle, cancellable, FALSE); - camel_stream_close (stream, NULL); + camel_stream_close (stream, cancellable, NULL); } static void diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 49a203b2eb..42edac30d4 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -126,7 +126,8 @@ static void efh_format_message (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info, - GCancellable *cancellable); + GCancellable *cancellable, + gboolean is_fallback); static void efh_format_secure (EMFormat *emf, CamelStream *stream, @@ -194,7 +195,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); + (CamelMimePart *) m->message, m->base.cancellable); } else { const EMFormatHandler *handle; const gchar *mime_type; @@ -218,7 +219,7 @@ efh_format_exec (struct _format_msg *m) m->base.cancellable, FALSE); } - camel_stream_flush ((CamelStream *)m->estream, NULL); + camel_stream_flush ((CamelStream *)m->estream, m->base.cancellable, NULL); puri_level = format->pending_uri_level; base = format->base; @@ -256,8 +257,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", NULL); - camel_stream_close ((CamelStream *)m->estream, NULL); + "</body>\n</html>\n", m->base.cancellable, NULL); + camel_stream_close ((CamelStream *)m->estream, m->base.cancellable, NULL); g_object_unref (m->estream); m->estream = NULL; } @@ -286,7 +287,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, NULL); + camel_stream_close ((CamelStream *)m->estream, m->base.cancellable, NULL); g_object_unref (m->estream); } if (m->folder) @@ -696,7 +697,8 @@ efh_format_error (EMFormat *emf, static void efh_format_source (EMFormat *emf, CamelStream *stream, - CamelMimePart *part) + CamelMimePart *part, + GCancellable *cancellable) { CamelStream *filtered_stream; CamelMimeFilter *filter; @@ -712,11 +714,11 @@ efh_format_source (EMFormat *emf, CAMEL_STREAM_FILTER (filtered_stream), filter); g_object_unref (filter); - camel_stream_write_string (stream, "<table><tr><td><tt>", NULL); - em_format_format_text (emf, (CamelStream *) filtered_stream, dw); + camel_stream_write_string (stream, "<table><tr><td><tt>", cancellable, NULL); + em_format_format_text (emf, (CamelStream *) filtered_stream, dw, cancellable); g_object_unref (filtered_stream); - camel_stream_write_string(stream, "</tt></td></tr></table>", NULL); + camel_stream_write_string(stream, "</tt></td></tr></table>", cancellable, NULL); } static void @@ -739,19 +741,19 @@ efh_format_attachment (EMFormat *emf, "<tr><td></td></tr></table></td>" "<td><table width=3 cellspacing=0 cellpadding=0>" "<tr><td></td></tr></table></td><td><font size=-1>\n", - NULL); + cancellable, NULL); /* output some info about it */ text = em_format_describe_part (part, mime_type); html = camel_text_to_html ( text, ((EMFormatHTML *)emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string (stream, html, NULL); + camel_stream_write_string (stream, html, cancellable, NULL); g_free (html); g_free (text); camel_stream_write_string ( - stream, "</font></td></tr><tr></table>", NULL); + stream, "</font></td></tr><tr></table>", cancellable, NULL); if (handle && em_format_is_inline (emf, emf->part_id->str, part, handle)) handle->handler (emf, stream, part, handle, cancellable, FALSE); @@ -1226,7 +1228,10 @@ em_format_html_set_show_real_date (EMFormatHTML *efh, } CamelMimePart * -em_format_html_file_part (EMFormatHTML *efh, const gchar *mime_type, const gchar *filename) +em_format_html_file_part (EMFormatHTML *efh, + const gchar *mime_type, + const gchar *filename, + GCancellable *cancellable) { CamelMimePart *part; CamelStream *stream; @@ -1238,7 +1243,8 @@ em_format_html_file_part (EMFormatHTML *efh, const gchar *mime_type, const gchar return NULL; dw = camel_data_wrapper_new (); - camel_data_wrapper_construct_from_stream (dw, stream, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, stream, cancellable, NULL); g_object_unref (stream); if (mime_type) camel_data_wrapper_set_mime_type (dw, mime_type); @@ -1437,7 +1443,8 @@ emfh_gethttp (struct _EMFormatHTMLJob *job, camel_http_stream_set_proxy ((CamelHttpStream *)instream, proxy); g_free (proxy); } - camel_operation_start (cancellable, _("Retrieving '%s'"), job->u.uri); + camel_operation_push_message ( + cancellable, _("Retrieving '%s'"), job->u.uri); tmp_stream = (CamelHttpStream *)instream; content_type = camel_http_stream_get_content_type (tmp_stream); length = camel_header_raw_find(&tmp_stream->headers, "Content-Length", NULL); @@ -1446,7 +1453,8 @@ emfh_gethttp (struct _EMFormatHTMLJob *job, total = atoi (length); camel_content_type_unref (content_type); } else - camel_operation_start_transient (cancellable, _("Retrieving '%s'"), job->u.uri); + camel_operation_push_message ( + cancellable, _("Retrieving '%s'"), job->u.uri); camel_url_free (url); @@ -1462,7 +1470,7 @@ emfh_gethttp (struct _EMFormatHTMLJob *job, break; } /* FIXME: progress reporting in percentage, can we get the length always? do we care? */ - n = camel_stream_read (instream, buffer, sizeof (buffer), NULL); + n = camel_stream_read (instream, buffer, sizeof (buffer), cancellable, NULL); if (n > 0) { nread += n; /* If we didn't get a valid Content-Length header, do not try to calculate percentage */ @@ -1471,18 +1479,18 @@ emfh_gethttp (struct _EMFormatHTMLJob *job, camel_operation_progress (cancellable, pc_complete); } d(printf(" read %d bytes\n", n)); - if (costream && camel_stream_write (costream, buffer, n, NULL) == -1) { + if (costream && camel_stream_write (costream, buffer, n, cancellable, NULL) == -1) { n = -1; break; } - camel_stream_write (job->stream, buffer, n, NULL); + camel_stream_write (job->stream, buffer, n, cancellable, NULL); } } while (n>0); /* indicates success */ if (n == 0) - camel_stream_close (job->stream, NULL); + camel_stream_close (job->stream, cancellable, NULL); if (costream) { /* do not store broken files in a cache */ @@ -1493,7 +1501,7 @@ emfh_gethttp (struct _EMFormatHTMLJob *job, g_object_unref (instream); done: - camel_operation_end (cancellable); + camel_operation_pop_message (cancellable); badurl: g_free (job->u.uri); } @@ -1649,7 +1657,7 @@ efh_format_secure (EMFormat *emf, else icon = smime_encrypt_table[valid->encrypt.status].icon; iconpath = e_icon_factory_get_icon_filename (icon, GTK_ICON_SIZE_DIALOG); - iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png", iconpath); + iconpart = em_format_html_file_part((EMFormatHTML *)emf, "image/png", iconpath, cancellable); if (iconpart) { (void)em_format_add_puri (emf, sizeof (EMFormatPURI), classid, iconpart, efh_write_image); g_object_unref (iconpart); @@ -1682,13 +1690,14 @@ efh_format_secure (EMFormat *emf, } static void -efh_text_plain (EMFormatHTML *efh, +efh_text_plain (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info, GCancellable *cancellable, gboolean is_fallback) { + EMFormatHTML *efh = EM_FORMAT_HTML (emf); CamelStream *filtered_stream; CamelMimeFilter *html_filter; CamelMultipart *mp; @@ -1721,7 +1730,10 @@ efh_text_plain (EMFormatHTML *efh, filters a bit. Perhaps the superclass should just deal with html anyway and be done with it ... */ - efhc = g_hash_table_lookup (efh->priv->text_inline_parts, ((EMFormat *)efh)->part_id->str); + efhc = g_hash_table_lookup ( + efh->priv->text_inline_parts, + emf->part_id->str); + if (efhc == NULL || (mp = efhc->textmp) == NULL) { EMInlineFilter *inline_filter; CamelStream *null; @@ -1729,8 +1741,8 @@ efh_text_plain (EMFormatHTML *efh, /* if we had to snoop the part type to get here, then * use that as the base type, yuck */ - if (((EMFormat *)efh)->snoop_mime_type == NULL - || (ct = camel_content_type_decode (((EMFormat *)efh)->snoop_mime_type)) == NULL) { + if (emf->snoop_mime_type == NULL + || (ct = camel_content_type_decode (emf->snoop_mime_type)) == NULL) { ct = dw->mime_type; camel_content_type_ref (ct); } @@ -1742,14 +1754,14 @@ efh_text_plain (EMFormatHTML *efh, camel_stream_filter_add ( CAMEL_STREAM_FILTER (filtered_stream), CAMEL_MIME_FILTER (inline_filter)); - camel_data_wrapper_decode_to_stream ( - dw, (CamelStream *)filtered_stream, NULL); - camel_stream_close ((CamelStream *)filtered_stream, NULL); + camel_data_wrapper_decode_to_stream_sync ( + dw, (CamelStream *)filtered_stream, cancellable, NULL); + camel_stream_close ((CamelStream *)filtered_stream, cancellable, NULL); g_object_unref (filtered_stream); mp = em_inline_filter_get_multipart (inline_filter); if (efhc == NULL) - efhc = efh_insert_cache (efh, ((EMFormat *)efh)->part_id->str); + efhc = efh_insert_cache (efh, emf->part_id->str); efhc->textmp = mp; g_object_unref (inline_filter); @@ -1766,7 +1778,7 @@ efh_text_plain (EMFormatHTML *efh, /* We handle our made-up multipart here, so we don't recursively call ourselves */ - len = ((EMFormat *)efh)->part_id->len; + len = emf->part_id->len; count = camel_multipart_get_number (mp); for (i=0;i<count;i++) { CamelMimePart *newpart = camel_multipart_get_part (mp, i); @@ -1788,16 +1800,19 @@ efh_text_plain (EMFormatHTML *efh, &efh->priv->colors[ EM_FORMAT_HTML_COLOR_TEXT])); camel_stream_write_string ( - stream, "<tt>\n" EFH_MESSAGE_START, NULL); - em_format_format_text ((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)newpart); - camel_stream_flush ((CamelStream *)filtered_stream, NULL); - camel_stream_write_string (stream, "</tt>\n", NULL); - camel_stream_write_string (stream, "</div>\n", NULL); + stream, "<tt>\n" EFH_MESSAGE_START, cancellable, NULL); + em_format_format_text ( + emf, filtered_stream, + (CamelDataWrapper *) newpart, + cancellable); + camel_stream_flush ((CamelStream *)filtered_stream, cancellable, NULL); + camel_stream_write_string (stream, "</tt>\n", cancellable, NULL); + camel_stream_write_string (stream, "</div>\n", cancellable, NULL); } else { - g_string_append_printf(((EMFormat *)efh)->part_id, ".inline.%d", i); + g_string_append_printf (emf->part_id, ".inline.%d", i); em_format_part ( - EM_FORMAT (efh), stream, newpart, cancellable); - g_string_truncate (((EMFormat *)efh)->part_id, len); + emf, stream, newpart, cancellable); + g_string_truncate (emf->part_id, len); } } @@ -1805,8 +1820,14 @@ efh_text_plain (EMFormatHTML *efh, } static void -efh_text_enriched (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +efh_text_enriched (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable, + gboolean is_fallback) { + EMFormatHTML *efh = EM_FORMAT_HTML (emf); CamelStream *filtered_stream; CamelMimeFilter *enriched; guint32 flags = 0; @@ -1814,10 +1835,12 @@ efh_text_enriched (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, if (!strcmp(info->mime_type, "text/richtext")) { flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT; camel_stream_write_string ( - stream, "\n<!-- text/richtext -->\n", NULL); + stream, "\n<!-- text/richtext -->\n", + cancellable, NULL); } else { camel_stream_write_string ( - stream, "\n<!-- text/enriched -->\n", NULL); + stream, "\n<!-- text/enriched -->\n", + cancellable, NULL); } enriched = camel_mime_filter_enriched_new (flags); @@ -1838,10 +1861,12 @@ efh_text_enriched (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, &efh->priv->colors[ EM_FORMAT_HTML_COLOR_TEXT])); - em_format_format_text ((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)part); + em_format_format_text ( + emf, (CamelStream *) filtered_stream, + (CamelDataWrapper *)part, cancellable); g_object_unref (filtered_stream); - camel_stream_write_string (stream, "</div>", NULL); + camel_stream_write_string (stream, "</div>", cancellable, NULL); } static void @@ -1863,12 +1888,19 @@ efh_write_text_html (EMFormat *emf, camel_data_wrapper_write_to_stream (dw, out); g_object_unref (out); #endif - em_format_format_text (emf, stream, (CamelDataWrapper *)puri->part); + em_format_format_text ( + emf, stream, (CamelDataWrapper *)puri->part, cancellable); } static void -efh_text_html (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +efh_text_html (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable, + gboolean is_fallback) { + EMFormatHTML *efh = EM_FORMAT_HTML (emf); const gchar *location; gchar *cid = NULL; @@ -1892,15 +1924,15 @@ efh_text_html (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo shouldn't blindly inherit the container's location. */ location = camel_mime_part_get_content_location (part); if (location == NULL) { - if (((EMFormat *)efh)->base) - cid = camel_url_to_string (((EMFormat *)efh)->base, 0); + if (emf->base) + cid = camel_url_to_string (emf->base, 0); else - cid = g_strdup (((EMFormat *)efh)->part_id->str); + cid = g_strdup (emf->part_id->str); } else { - if (strchr (location, ':') == NULL && ((EMFormat *)efh)->base != NULL) { + if (strchr (location, ':') == NULL && emf->base != NULL) { CamelURL *uri; - uri = camel_url_new_with_base (((EMFormat *)efh)->base, location); + uri = camel_url_new_with_base (emf->base, location); cid = camel_url_to_string (uri, 0); camel_url_free (uri); } else { @@ -1908,7 +1940,9 @@ efh_text_html (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo } } - em_format_add_puri ((EMFormat *)efh, sizeof (EMFormatPURI), cid, part, efh_write_text_html); + em_format_add_puri ( + emf, sizeof (EMFormatPURI), cid, + part, efh_write_text_html); d(printf("adding iframe, location %s\n", cid)); camel_stream_printf (stream, "<iframe src=\"%s\" frameborder=0 scrolling=no>could not get %s</iframe>\n" @@ -1919,7 +1953,12 @@ efh_text_html (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo /* This is a lot of code for something useless ... */ static void -efh_message_external (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +efh_message_external (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable, + gboolean is_fallback) { CamelContentType *type; const gchar *access_type; @@ -2013,8 +2052,14 @@ fail: } static void -efh_message_deliverystatus (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +efh_message_deliverystatus (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable, + gboolean is_fallback) { + EMFormatHTML *efh = EM_FORMAT_HTML (emf); CamelStream *filtered_stream; CamelMimeFilter *html_filter; guint32 rgb = 0x737373; @@ -2038,12 +2083,14 @@ efh_message_deliverystatus (EMFormatHTML *efh, CamelStream *stream, CamelMimePar CAMEL_STREAM_FILTER (filtered_stream), html_filter); g_object_unref (html_filter); - camel_stream_write_string (stream, "<tt>\n" EFH_MESSAGE_START, NULL); - em_format_format_text ((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)part); - camel_stream_flush ((CamelStream *)filtered_stream, NULL); - camel_stream_write_string (stream, "</tt>\n", NULL); + camel_stream_write_string (stream, "<tt>\n" EFH_MESSAGE_START, cancellable, NULL); + em_format_format_text ( + emf, filtered_stream, + (CamelDataWrapper *)part, cancellable); + camel_stream_flush (filtered_stream, cancellable, NULL); + camel_stream_write_string (stream, "</tt>\n", cancellable, NULL); - camel_stream_write_string (stream, "</div>", NULL); + camel_stream_write_string (stream, "</div>", cancellable, NULL); } static void @@ -2054,7 +2101,7 @@ emfh_write_related (EMFormat *emf, { em_format_format_content (emf, stream, puri->part, cancellable); - camel_stream_close (stream, NULL); + camel_stream_close (stream, cancellable, NULL); } static void @@ -2109,7 +2156,8 @@ efh_multipart_related (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info, - GCancellable *cancellable) + GCancellable *cancellable, + gboolean is_fallback) { CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content ((CamelMedium *)part); CamelMimePart *body_part, *display_part = NULL; @@ -2121,7 +2169,7 @@ efh_multipart_related (EMFormat *emf, struct _EMFormatHTMLJob *job; if (!CAMEL_IS_MULTIPART (mp)) { - em_format_format_source (emf, stream, part); + em_format_format_source (emf, stream, part, cancellable); return; } @@ -2175,7 +2223,7 @@ efh_multipart_related (EMFormat *emf, g_string_append_printf(emf->part_id, "related.%d", displayid); em_format_part (emf, stream, display_part, cancellable); g_string_truncate (emf->part_id, partidlen); - camel_stream_flush (stream, NULL); + camel_stream_flush (stream, cancellable, NULL); /* queue a job to check for un-referenced parts to add as attachments */ job = em_format_html_job_new ( @@ -2196,55 +2244,62 @@ efh_write_image (EMFormat *emf, CamelDataWrapper *dw = camel_medium_get_content ((CamelMedium *)puri->part); d(printf("writing image '%s'\n", puri->cid)); - camel_data_wrapper_decode_to_stream (dw, stream, NULL); - camel_stream_close (stream, NULL); + camel_data_wrapper_decode_to_stream_sync ( + dw, stream, cancellable, NULL); + camel_stream_close (stream, cancellable, NULL); } static void -efh_image (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info) +efh_image (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable, + gboolean is_fallback) { EMFormatPURI *puri; - puri = em_format_add_puri ((EMFormat *)efh, sizeof (EMFormatPURI), NULL, part, efh_write_image); - d(printf("adding image '%s'\n", puri->cid)); - camel_stream_printf(stream, "<img hspace=10 vspace=10 src=\"%s\">", puri->cid); + puri = em_format_add_puri ( + emf, sizeof (EMFormatPURI), NULL, part, efh_write_image); + camel_stream_printf ( + stream, "<img hspace=10 vspace=10 src=\"%s\">", puri->cid); } static EMFormatHandler type_builtin_table[] = { - { (gchar *) "image/gif", (EMFormatFunc)efh_image }, - { (gchar *) "image/jpeg", (EMFormatFunc)efh_image }, - { (gchar *) "image/png", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-png", (EMFormatFunc)efh_image }, - { (gchar *) "image/tiff", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-bmp", (EMFormatFunc)efh_image }, - { (gchar *) "image/bmp", (EMFormatFunc)efh_image }, - { (gchar *) "image/svg", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-cmu-raster", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-ico", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-portable-anymap", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-portable-bitmap", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-portable-graymap", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-portable-pixmap", (EMFormatFunc)efh_image }, - { (gchar *) "image/x-xpixmap", (EMFormatFunc)efh_image }, - { (gchar *) "text/enriched", (EMFormatFunc)efh_text_enriched }, - { (gchar *) "text/plain", (EMFormatFunc)efh_text_plain }, - { (gchar *) "text/html", (EMFormatFunc)efh_text_html }, - { (gchar *) "text/richtext", (EMFormatFunc)efh_text_enriched }, - { (gchar *) "text/*", (EMFormatFunc)efh_text_plain }, - { (gchar *) "message/external-body", (EMFormatFunc)efh_message_external }, - { (gchar *) "message/delivery-status", (EMFormatFunc)efh_message_deliverystatus }, - { (gchar *) "multipart/related", (EMFormatFunc)efh_multipart_related }, + { (gchar *) "image/gif", efh_image }, + { (gchar *) "image/jpeg", efh_image }, + { (gchar *) "image/png", efh_image }, + { (gchar *) "image/x-png", efh_image }, + { (gchar *) "image/tiff", efh_image }, + { (gchar *) "image/x-bmp", efh_image }, + { (gchar *) "image/bmp", efh_image }, + { (gchar *) "image/svg", efh_image }, + { (gchar *) "image/x-cmu-raster", efh_image }, + { (gchar *) "image/x-ico", efh_image }, + { (gchar *) "image/x-portable-anymap", efh_image }, + { (gchar *) "image/x-portable-bitmap", efh_image }, + { (gchar *) "image/x-portable-graymap", efh_image }, + { (gchar *) "image/x-portable-pixmap", efh_image }, + { (gchar *) "image/x-xpixmap", efh_image }, + { (gchar *) "text/enriched", efh_text_enriched }, + { (gchar *) "text/plain", efh_text_plain }, + { (gchar *) "text/html", efh_text_html }, + { (gchar *) "text/richtext", efh_text_enriched }, + { (gchar *) "text/*", efh_text_plain }, + { (gchar *) "message/external-body", efh_message_external }, + { (gchar *) "message/delivery-status", efh_message_deliverystatus }, + { (gchar *) "multipart/related", efh_multipart_related }, /* This is where one adds those busted, non-registered types, that some idiot mailer writers out there decide to pull out of their proverbials at random. */ - { (gchar *) "image/jpg", (EMFormatFunc)efh_image }, - { (gchar *) "image/pjpeg", (EMFormatFunc)efh_image }, + { (gchar *) "image/jpg", efh_image }, + { (gchar *) "image/pjpeg", efh_image }, /* special internal types */ - { (gchar *) "x-evolution/message/rfc822", (EMFormatFunc)efh_format_message } + { (gchar *) "x-evolution/message/rfc822", efh_format_message } }; static void @@ -2840,7 +2895,8 @@ efh_format_headers (EMFormatHTML *efh, if (icon_info != NULL) { iconpart = em_format_html_file_part ( (EMFormatHTML *) emf, "image/png", - gtk_icon_info_get_filename (icon_info)); + gtk_icon_info_get_filename (icon_info), + cancellable); gtk_icon_info_free (icon_info); } @@ -2861,7 +2917,8 @@ efh_format_message (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info, - GCancellable *cancellable) + GCancellable *cancellable, + gboolean is_fallback) { const EMFormatHandler *handle; diff --git a/mail/em-format-html.h b/mail/em-format-html.h index 81f2fee5ca..bdfa62dfb9 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -248,7 +248,8 @@ void em_format_html_set_show_sender_photo /* retrieves a pseudo-part icon wrapper for a file */ CamelMimePart * em_format_html_file_part (EMFormatHTML *efh, const gchar *mime_type, - const gchar *filename); + const gchar *filename, + GCancellable *cancellable); /* for implementers */ EMFormatHTMLPObject * diff --git a/mail/em-html-stream.c b/mail/em-html-stream.c index f74ba8d98b..87e2296c03 100644 --- a/mail/em-html-stream.c +++ b/mail/em-html-stream.c @@ -64,7 +64,7 @@ html_stream_dispose (GObject *object) if (emhs->html_stream) { /* set 'in finalise' flag */ - camel_stream_close (CAMEL_STREAM (emhs), NULL); + camel_stream_close (CAMEL_STREAM (emhs), NULL, NULL); } } diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c index 11a4b32764..c1376fc18f 100644 --- a/mail/em-inline-filter.c +++ b/mail/em-inline-filter.c @@ -92,12 +92,14 @@ inline_filter_add_part (EMInlineFilter *emif, const gchar *data, gint len) camel_stream_filter_add (CAMEL_STREAM_FILTER (filter_stream), enc_filter); /* properly encode content */ - camel_data_wrapper_construct_from_stream (dw, filter_stream, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, filter_stream, NULL, NULL); g_object_unref (enc_filter); g_object_unref (filter_stream); } else { - camel_data_wrapper_construct_from_stream (dw, mem, NULL); + camel_data_wrapper_construct_from_stream_sync ( + dw, mem, NULL, NULL); } g_object_unref (mem); diff --git a/mail/em-subscribe-editor.c b/mail/em-subscribe-editor.c index c0d1120a3e..b942e35a4b 100644 --- a/mail/em-subscribe-editor.c +++ b/mail/em-subscribe-editor.c @@ -266,11 +266,11 @@ static void sub_folder_exec (struct _zsubscribe_msg *m) { if (m->subscribe) - camel_store_subscribe_folder ( + camel_store_subscribe_folder_sync ( m->sub->store, m->node->info->full_name, m->base.cancellable, &m->base.error); else - camel_store_unsubscribe_folder ( + camel_store_unsubscribe_folder_sync ( m->sub->store, m->node->info->full_name, m->base.cancellable, &m->base.error); } @@ -454,7 +454,7 @@ sub_folderinfo_exec (struct _emse_folderinfo_msg *m) { if (m->seq == m->sub->seq) { /* get the full folder tree for search ability */ - m->info = camel_store_get_folder_info ( + m->info = camel_store_get_folder_info_sync ( m->sub->store, NULL, CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL | CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST | diff --git a/mail/em-sync-stream.c b/mail/em-sync-stream.c index bb5a21808e..9c52cd703b 100644 --- a/mail/em-sync-stream.c +++ b/mail/em-sync-stream.c @@ -141,6 +141,7 @@ static gssize sync_stream_write (CamelStream *stream, const gchar *string, gsize len, + GCancellable *cancellable, GError **error) { EMSyncStream *emss = EM_SYNC_STREAM (stream); @@ -168,6 +169,7 @@ sync_stream_write (CamelStream *stream, static gint sync_stream_flush (CamelStream *stream, + GCancellable *cancellable, GError **error) { EMSyncStream *emss = EM_SYNC_STREAM (stream); @@ -189,6 +191,7 @@ sync_stream_flush (CamelStream *stream, static gint sync_stream_close (CamelStream *stream, + GCancellable *cancellable, GError **error) { EMSyncStream *emss = EM_SYNC_STREAM (stream); diff --git a/mail/em-utils.c b/mail/em-utils.c index 922050212d..cf00c73a28 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -560,8 +560,8 @@ em_utils_write_messages_to_stream (CamelFolder *folder, GPtrArray *uids, CamelSt CamelMimeMessage *message; gchar *from; - /* FIXME camel_folder_get_message() may block. */ - message = camel_folder_get_message ( + /* FIXME camel_folder_get_message_sync() may block. */ + message = camel_folder_get_message_sync ( folder, uids->pdata[i], NULL, NULL); if (message == NULL) { res = -1; @@ -571,10 +571,10 @@ em_utils_write_messages_to_stream (CamelFolder *folder, GPtrArray *uids, CamelSt /* we need to flush after each stream write since we are writing to the same stream */ from = camel_mime_message_build_mbox_from (message); - if (camel_stream_write_string (stream, from, NULL) == -1 - || camel_stream_flush (stream, NULL) == -1 - || camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, (CamelStream *)filtered_stream, NULL) == -1 - || camel_stream_flush ((CamelStream *)filtered_stream, NULL) == -1) + if (camel_stream_write_string (stream, from, NULL, NULL) == -1 + || camel_stream_flush (stream, NULL, NULL) == -1 + || camel_data_wrapper_write_to_stream_sync ((CamelDataWrapper *)message, (CamelStream *)filtered_stream, NULL, NULL) == -1 + || camel_stream_flush ((CamelStream *)filtered_stream, NULL, NULL) == -1) res = -1; g_free (from); @@ -606,13 +606,14 @@ em_utils_read_messages_from_stream (CamelFolder *folder, CamelStream *stream) /* NB: de-from filter, once written */ msg = camel_mime_message_new (); - if (camel_mime_part_construct_from_parser ((CamelMimePart *)msg, mp, NULL) == -1) { + if (!camel_mime_part_construct_from_parser_sync ( + (CamelMimePart *)msg, mp, NULL, NULL)) { g_object_unref (msg); break; } - /* FIXME camel_folder_append_message() may block. */ - success = camel_folder_append_message ( + /* FIXME camel_folder_append_message_sync() may block. */ + success = camel_folder_append_message_sync ( folder, msg, NULL, NULL, NULL, NULL); g_object_unref (msg); @@ -716,9 +717,10 @@ em_utils_selection_get_message (GtkSelectionData *selection_data, stream = (CamelStream *) camel_stream_mem_new_with_buffer ((gchar *)data, length); msg = camel_mime_message_new (); - if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)msg, stream, NULL) == 0) - /* FIXME camel_folder_append_message() may block. */ - camel_folder_append_message ( + if (camel_data_wrapper_construct_from_stream_sync ( + (CamelDataWrapper *)msg, stream, NULL, NULL)) + /* FIXME camel_folder_append_message_sync() may block. */ + camel_folder_append_message_sync ( folder, msg, NULL, NULL, NULL, NULL); g_object_unref (msg); g_object_unref (stream); @@ -812,9 +814,9 @@ em_utils_selection_get_uidlist (GtkSelectionData *selection_data, folder = mail_tool_uri_to_folder ( (gchar *) data, 0, cancellable, error); if (folder) { - /* FIXME camel_folder_transfer_messages_to() may block. */ - camel_folder_transfer_messages_to ( - folder, uids, dest, NULL, move, cancellable, error); + /* FIXME camel_folder_transfer_messages_to_sync() may block. */ + camel_folder_transfer_messages_to_sync ( + folder, uids, dest, move, NULL, cancellable, error); g_object_unref (folder); } @@ -1264,15 +1266,15 @@ em_utils_message_to_html (CamelMimeMessage *message, guint32 *validity_found) { EMFormatQuote *emfq; - CamelStreamMem *mem; + CamelStream *mem; GByteArray *buf; gchar *text; buf = g_byte_array_new (); - mem = (CamelStreamMem *) camel_stream_mem_new (); - camel_stream_mem_set_byte_array (mem, buf); + mem = camel_stream_mem_new (); + camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (mem), buf); - emfq = em_format_quote_new (credits, (CamelStream *)mem, flags); + emfq = em_format_quote_new (credits, mem, flags); ((EMFormat *) emfq)->composer = TRUE; if (!source) { @@ -1295,9 +1297,9 @@ em_utils_message_to_html (CamelMimeMessage *message, g_object_unref (emfq); if (append && *append) - camel_stream_write ((CamelStream*)mem, append, strlen (append), NULL); + camel_stream_write_string (mem, append, NULL, NULL); - camel_stream_write((CamelStream *)mem, "", 1, NULL); + camel_stream_write(mem, "", 1, NULL, NULL); g_object_unref (mem); text = (gchar *)buf->data; diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index 51d8796648..a929b6b06d 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -332,8 +332,8 @@ mbox_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im) gchar *from; msg = camel_mime_message_new (); - if (camel_mime_part_construct_from_parser ( - (CamelMimePart *)msg, mp, NULL) == -1) { + if (!camel_mime_part_construct_from_parser_sync ( + (CamelMimePart *)msg, mp, NULL, NULL)) { g_object_unref (msg); break; } diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c index 3dac78744c..b70b6b0c0c 100644 --- a/mail/importers/mail-importer.c +++ b/mail/importers/mail-importer.c @@ -130,8 +130,6 @@ import_mbox_exec (struct _import_mbox_msg *m) return; if (S_ISREG (st.st_mode)) { - CamelOperation *oldcancel = NULL; - fd = g_open (m->path, O_RDONLY|O_BINARY, 0); if (fd == -1) { g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno)); @@ -144,11 +142,8 @@ import_mbox_exec (struct _import_mbox_msg *m) goto fail2; } - if (m->cancel) - oldcancel = camel_operation_register (m->cancel); - - camel_operation_start ( - NULL, _("Importing '%s'"), + camel_operation_push_message ( + m->base.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) { @@ -159,10 +154,11 @@ 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 (NULL, pc); + camel_operation_progress (m->base.cancellable, pc); msg = camel_mime_message_new (); - if (camel_mime_part_construct_from_parser ((CamelMimePart *)msg, mp, NULL) == -1) { + if (!camel_mime_part_construct_from_parser_sync ( + (CamelMimePart *)msg, mp, NULL, NULL)) { /* set exception? */ g_object_unref (msg); break; @@ -181,7 +177,7 @@ import_mbox_exec (struct _import_mbox_msg *m) flags |= decode_status (tmp); camel_message_info_set_flags (info, flags, ~0); - camel_folder_append_message ( + camel_folder_append_message_sync ( folder, msg, info, NULL, m->base.cancellable, &m->base.error); camel_message_info_free (info); @@ -193,18 +189,16 @@ import_mbox_exec (struct _import_mbox_msg *m) camel_mime_parser_step (mp, NULL, NULL); } /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_sync (folder, FALSE, NULL, NULL); + camel_folder_synchronize_sync (folder, FALSE, NULL, NULL); camel_folder_thaw (folder); - camel_operation_end (NULL); + camel_operation_pop_message (m->base.cancellable); /* TODO: these api's are a bit weird, registering the old is the same as deregistering */ - if (m->cancel) - camel_operation_register (oldcancel); fail2: g_object_unref (mp); } fail1: /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_sync (folder, FALSE, NULL, NULL); + camel_folder_synchronize_sync (folder, FALSE, NULL, NULL); g_object_unref (folder); } @@ -292,7 +286,7 @@ import_folders_rec (struct _import_folders_data *m, const gchar *filepath, const data_dir = mail_session_get_data_dir (); utf8_filename = g_filename_to_utf8 (filepath, -1, NULL, NULL, NULL); - camel_operation_start(NULL, _("Scanning %s"), utf8_filename); + camel_operation_push_message (NULL, _("Scanning %s"), utf8_filename); g_free (utf8_filename); while ( (d=g_dir_read_name (dir))) { @@ -350,7 +344,7 @@ import_folders_rec (struct _import_folders_data *m, const gchar *filepath, const } g_dir_close (dir); - camel_operation_end (NULL); + camel_operation_pop_message (NULL); } /** @@ -372,17 +366,10 @@ void mail_importer_import_folders_sync (const gchar *filepath, MailImporterSpecial special_folders[], gint flags, CamelOperation *cancel) { struct _import_folders_data m; - CamelOperation *oldcancel = NULL; m.special_folders = special_folders; m.elmfmt = (flags & MAIL_IMPORTER_MOZFMT) == 0; m.cancel = cancel; - if (cancel) - oldcancel = camel_operation_register (cancel); - import_folders_rec (&m, filepath, NULL); - - if (cancel) - camel_operation_register (oldcancel); } diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 00818a1ef5..78cd647283 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -195,8 +195,8 @@ real_flush_updates (gpointer o, gpointer event_data, gpointer data) * ensure their changes will be tracked correctly. */ CamelFolder *folder; - /* FIXME camel_store_get_folder() may block. */ - folder = camel_store_get_folder ( + /* FIXME camel_store_get_folder_sync() may block. */ + folder = camel_store_get_folder_sync ( up->store, up->full_name, 0, NULL, NULL); if (folder) { @@ -802,12 +802,12 @@ ping_store_exec (struct _ping_store_msg *m) CAMEL_DISCO_STORE (m->store)) !=CAMEL_DISCO_STORE_OFFLINE) online = TRUE; else if (CAMEL_IS_OFFLINE_STORE (m->store) && - CAMEL_OFFLINE_STORE (m->store)->state != - CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) + camel_offline_store_get_online ( + CAMEL_OFFLINE_STORE (m->store))) online = TRUE; } if (online) - camel_store_noop ( + camel_store_noop_sync ( m->store, m->base.cancellable, &m->base.error); } @@ -1140,8 +1140,8 @@ mail_folder_cache_note_store (MailFolderCache *self, } } else if (CAMEL_IS_OFFLINE_STORE (store)) { if (camel_session_get_online (session) && - CAMEL_OFFLINE_STORE (store)->state == - CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { + !camel_offline_store_get_online ( + CAMEL_OFFLINE_STORE (store))) { /* Note: we use the 'id' here, even though its not the right id, its still ok */ ud->id = mail_store_set_offline (store, FALSE, store_online_cb, ud); } else { diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 694a8f5abe..87f6b251bf 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -298,16 +298,24 @@ void mail_msg_cancel (guint msgid) { MailMsg *msg; + GCancellable *cancellable = NULL; g_mutex_lock (mail_msg_lock); msg = g_hash_table_lookup ( mail_msg_active_table, GINT_TO_POINTER (msgid)); - if (msg != NULL && msg->cancellable != NULL) - camel_operation_cancel (CAMEL_OPERATION (msg->cancellable)); + /* 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); g_mutex_unlock (mail_msg_lock); + + if (cancellable != NULL) { + camel_operation_cancel (CAMEL_OPERATION (cancellable)); + g_object_unref (cancellable); + } } /* waits for a message to be finished processing (freed) @@ -474,7 +482,7 @@ mail_msg_proxy (MailMsg *msg) { if (msg->info->desc != NULL) { gchar *text = msg->info->desc (msg); - camel_operation_start (msg->cancellable, "%s", text); + camel_operation_push_message (msg->cancellable, "%s", text); g_free (text); } @@ -488,7 +496,7 @@ mail_msg_proxy (MailMsg *msg) msg->info->exec (msg); if (msg->info->desc != NULL) - camel_operation_end (msg->cancellable); + camel_operation_pop_message (msg->cancellable); g_async_queue_push (msg_reply_queue, msg); diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 5699199666..89b83ec426 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -59,7 +59,6 @@ struct _filter_mail_msg { CamelFolder *source_folder; /* where they come from */ GPtrArray *source_uids; /* uids to copy, or NULL == copy all */ CamelUIDCache *cache; /* UID cache if we are to cache the uids, NULL otherwise */ - CamelOperation *cancel; CamelFilterDriver *driver; gint delete; /* delete messages after filtering them? */ CamelFolder *destination; /* default destination for any messages, NULL for none */ @@ -93,16 +92,10 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m) CamelFolder *folder; GPtrArray *uids, *folder_uids = NULL; - if (m->cancel) - camel_operation_register (m->cancel); - folder = m->source_folder; - if (folder == NULL || camel_folder_get_message_count (folder) == 0) { - if (m->cancel) - camel_operation_unregister (); + if (folder == NULL || camel_folder_get_message_count (folder) == 0) return; - } if (m->destination) { camel_folder_freeze (m->destination); @@ -126,7 +119,7 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m) /* sync our source folder */ if (!m->cache) - camel_folder_sync ( + camel_folder_synchronize_sync ( folder, FALSE, m->base.cancellable, &m->base.error); camel_folder_thaw (folder); @@ -137,9 +130,6 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m) see also fetch_mail_fetch () below */ g_object_unref (m->driver); m->driver = NULL; - - if (m->cancel) - camel_operation_unregister (); } static void @@ -156,9 +146,6 @@ em_filter_folder_element_free (struct _filter_mail_msg *m) if (m->source_uids) em_utils_uids_free (m->source_uids); - if (m->cancel) - g_object_unref (m->cancel); - if (m->destination) g_object_unref (m->destination); @@ -178,8 +165,7 @@ static MailMsgInfo em_filter_folder_element_info = { void mail_filter_folder (CamelFolder *source_folder, GPtrArray *uids, - const gchar *type, gboolean notify, - CamelOperation *cancel) + const gchar *type, gboolean notify) { struct _filter_mail_msg *m; @@ -189,8 +175,6 @@ mail_filter_folder (CamelFolder *source_folder, GPtrArray *uids, m->source_uids = uids; m->cache = NULL; m->delete = FALSE; - if (cancel) - m->cancel = g_object_ref (cancel); m->driver = camel_session_get_filter_driver (session, type, NULL); @@ -207,13 +191,13 @@ mail_filter_folder (CamelFolder *source_folder, GPtrArray *uids, void mail_filter_on_demand (CamelFolder *folder, GPtrArray *uids) { - mail_filter_folder (folder, uids, E_FILTER_SOURCE_DEMAND, FALSE, NULL); + mail_filter_folder (folder, uids, E_FILTER_SOURCE_DEMAND, FALSE); } void mail_filter_junk (CamelFolder *folder, GPtrArray *uids) { - mail_filter_folder (folder, uids, E_FILTER_SOURCE_JUNKTEST, FALSE, NULL); + mail_filter_folder (folder, uids, E_FILTER_SOURCE_JUNKTEST, FALSE); } /* ********************************************************************** */ @@ -251,9 +235,6 @@ fetch_mail_exec (struct _fetch_mail_msg *m) struct _filter_mail_msg *fm = (struct _filter_mail_msg *)m; gint i; - if (m->cancellable) - camel_operation_register (CAMEL_OPERATION (m->cancellable)); - fm->destination = e_mail_local_get_folder (E_MAIL_FOLDER_LOCAL_INBOX); if (fm->destination == NULL) goto fail; @@ -315,8 +296,8 @@ fetch_mail_exec (struct _fetch_mail_msg *m) em_filter_folder_element_exec (fm); /* need to uncancel so writes/etc. don't fail */ - if (g_error_matches (fm->base.error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - camel_operation_uncancel (NULL); + if (g_cancellable_is_cancelled (m->cancellable)) + g_cancellable_reset (m->cancellable); /* save the cache of uids that we've just downloaded */ camel_uid_cache_save (cache); @@ -333,7 +314,8 @@ fetch_mail_exec (struct _fetch_mail_msg *m) if ((fm->delete || cache_uids) && fm->base.error == NULL) { /* expunge messages (downloaded so far) */ /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_sync (folder, fm->delete, NULL, NULL); + camel_folder_synchronize_sync ( + folder, fm->delete, NULL, NULL); } camel_uid_cache_destroy (cache); @@ -350,9 +332,6 @@ fetch_mail_exec (struct _fetch_mail_msg *m) } } fail: - if (m->cancellable) - camel_operation_unregister (); - /* we unref this here as it may have more work to do (syncing folders and whatnot) before we are really done */ /* should this be cancellable too? (i.e. above unregister above) */ @@ -488,7 +467,8 @@ mail_send_message (struct _send_queue_msg *m, gint i; GError *local_error = NULL; - message = camel_folder_get_message (queue, uid, cancellable, error); + message = camel_folder_get_message_sync ( + queue, uid, cancellable, error); if (!message) return; @@ -559,7 +539,7 @@ mail_send_message (struct _send_queue_msg *m, if (xport == NULL) goto exit; - if (!camel_transport_send_to ( + if (!camel_transport_send_to_sync ( xport, message, from, recipients, cancellable, error)) goto exit; } @@ -581,7 +561,7 @@ mail_send_message (struct _send_queue_msg *m, folder = mail_tool_uri_to_folder (uri, 0, NULL, NULL); if (folder) { /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_append_message ( + camel_folder_append_message_sync ( folder, message, info, NULL, NULL, NULL); g_object_unref (folder); folder = NULL; @@ -631,7 +611,7 @@ mail_send_message (struct _send_queue_msg *m, g_object_ref (folder); } - if (!camel_folder_append_message ( + if (!camel_folder_append_message_sync ( folder, message, info, NULL, cancellable, &local_error)) { @@ -657,7 +637,7 @@ mail_send_message (struct _send_queue_msg *m, folder = sent_folder; g_clear_error (&local_error); - camel_folder_append_message ( + camel_folder_append_message_sync ( folder, message, info, NULL, cancellable, &local_error); } @@ -682,7 +662,7 @@ mail_send_message (struct _send_queue_msg *m, /* Sync it to disk, since if it crashes in between, * we keep sending it again on next start. */ /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_sync (queue, FALSE, NULL, NULL); + camel_folder_synchronize_sync (queue, FALSE, NULL, NULL); } if (err->len) { @@ -698,7 +678,7 @@ exit: /* FIXME Not passing a GCancellable or GError here. */ if (folder) { - camel_folder_sync (folder, FALSE, NULL, NULL); + camel_folder_synchronize_sync (folder, FALSE, NULL, NULL); g_object_unref (folder); } if (info) @@ -785,13 +765,7 @@ send_queue_exec (struct _send_queue_msg *m) return; } - if (m->cancellable) - camel_operation_register (CAMEL_OPERATION (m->cancellable)); - else - camel_operation_register (CAMEL_OPERATION (m->base.cancellable)); - - if (!m->cancellable) - camel_operation_start (NULL, _("Sending message")); + camel_operation_push_message (m->cancellable, _("Sending message")); /* NB: This code somewhat abuses the 'exception' stuff. Apart from * fatal problems, it is also used as a mechanism to accumualte @@ -807,7 +781,7 @@ send_queue_exec (struct _send_queue_msg *m) if (!m->cancellable) camel_operation_progress ( - NULL, (i+1) * 100 / send_uids->len); + m->cancellable, (i+1) * 100 / send_uids->len); mail_send_message ( m, m->queue, send_uids->pdata[i], m->destination, @@ -865,17 +839,13 @@ send_queue_exec (struct _send_queue_msg *m) /* FIXME Not passing a GCancellable or GError here. */ if (j <= 0 && m->base.error == NULL) - camel_folder_sync (m->queue, TRUE, NULL, NULL); + camel_folder_synchronize_sync (m->queue, TRUE, NULL, NULL); /* FIXME Not passing a GCancellable or GError here. */ if (sent_folder) - camel_folder_sync (sent_folder, FALSE, NULL, NULL); - - if (!m->cancellable) - camel_operation_end (NULL); - - camel_operation_unregister (); + camel_folder_synchronize_sync (sent_folder, FALSE, NULL, NULL); + camel_operation_pop_message (m->cancellable); } static void @@ -971,7 +941,7 @@ append_mail_exec (struct _append_msg *m) camel_mime_message_set_date ( m->message, CAMEL_MESSAGE_DATE_CURRENT, 0); - camel_folder_append_message ( + camel_folder_append_message_sync ( m->folder, m->message, m->info, &m->appended_uid, m->base.cancellable, &m->base.error); @@ -1072,8 +1042,8 @@ transfer_messages_exec (struct _transfer_msg *m) camel_folder_freeze (m->source); camel_folder_freeze (dest); - camel_folder_transfer_messages_to ( - m->source, m->uids, dest, NULL, m->delete, + camel_folder_transfer_messages_to_sync ( + m->source, m->uids, dest, m->delete, NULL, m->base.cancellable, &m->base.error); /* make sure all deleted messages are marked as seen */ @@ -1091,7 +1061,7 @@ transfer_messages_exec (struct _transfer_msg *m) camel_folder_thaw (dest); /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_sync (dest, FALSE, NULL, NULL); + camel_folder_synchronize_sync (dest, FALSE, NULL, NULL); g_object_unref (dest); } @@ -1173,7 +1143,7 @@ get_folderinfo_exec (struct _get_folderinfo_msg *m) { guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED; - m->info = camel_store_get_folder_info ( + m->info = camel_store_get_folder_info_sync ( m->store, NULL, flags, m->base.cancellable, &m->base.error); } @@ -1548,7 +1518,7 @@ remove_folder_rec (CamelStore *store, d(printf ("deleting folder '%s'\n", fi->full_name)); - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( store, fi->full_name, 0, cancellable, error); if (folder == NULL) return FALSE; @@ -1566,7 +1536,7 @@ remove_folder_rec (CamelStore *store, camel_folder_free_uids (folder, uids); /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_sync (folder, TRUE, NULL, NULL); + camel_folder_synchronize_sync (folder, TRUE, NULL, NULL); camel_folder_thaw (folder); } @@ -1574,11 +1544,11 @@ remove_folder_rec (CamelStore *store, * from this folder. * FIXME Not passing a GCancellable or GError here. */ if (camel_store_supports_subscriptions (store)) - camel_store_unsubscribe_folder ( + camel_store_unsubscribe_folder_sync ( store, fi->full_name, NULL, NULL); /* Then delete the folder from the store */ - if (!camel_store_delete_folder ( + if (!camel_store_delete_folder_sync ( store, fi->full_name, cancellable, error)) return FALSE; @@ -1600,7 +1570,7 @@ remove_folder_exec (struct _remove_folder_msg *m) full_name = camel_folder_get_full_name (m->folder); parent_store = camel_folder_get_parent_store (m->folder); - fi = camel_store_get_folder_info ( + fi = camel_store_get_folder_info_sync ( parent_store, full_name, CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST | @@ -1672,7 +1642,7 @@ sync_folder_desc (struct _sync_folder_msg *m) static void sync_folder_exec (struct _sync_folder_msg *m) { - camel_folder_sync ( + camel_folder_synchronize_sync ( m->folder, FALSE, m->base.cancellable, &m->base.error); } @@ -1740,7 +1710,7 @@ sync_store_desc (struct _sync_store_msg *m) static void sync_store_exec (struct _sync_store_msg *m) { - camel_store_sync ( + camel_store_synchronize_sync ( m->store, m->expunge, m->base.cancellable, &m->base.error); } @@ -1792,7 +1762,7 @@ refresh_folder_desc (struct _sync_folder_msg *m) static void refresh_folder_exec (struct _sync_folder_msg *m) { - camel_folder_refresh_info ( + camel_folder_refresh_info_sync ( m->folder, m->base.cancellable, &m->base.error); } @@ -1830,7 +1800,7 @@ expunge_folder_desc (struct _sync_folder_msg *m) static void expunge_folder_exec (struct _sync_folder_msg *m) { - camel_folder_expunge ( + camel_folder_expunge_sync ( m->folder, m->base.cancellable, &m->base.error); } @@ -1894,7 +1864,7 @@ empty_trash_exec (struct _empty_trash_msg *m) } if (trash) { - camel_folder_expunge ( + camel_folder_expunge_sync ( trash, m->base.cancellable, &m->base.error); g_object_unref (trash); } @@ -1962,7 +1932,7 @@ get_message_exec (struct _get_message_msg *m) if (g_cancellable_is_cancelled (m->base.cancellable)) m->message = NULL; else - m->message = camel_folder_get_message ( + m->message = camel_folder_get_message_sync ( m->folder, m->uid, m->base.cancellable, &m->base.error); } @@ -2094,7 +2064,7 @@ get_messages_exec (struct _get_messages_msg *m) for (i=0; i<m->uids->len; i++) { gint pc = ((i+1) * 100) / m->uids->len; - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( m->folder, m->uids->pdata[i], m->base.cancellable, &m->base.error); camel_operation_progress ( @@ -2237,7 +2207,7 @@ save_messages_exec (struct _save_messages_msg *m) CamelMimeMessage *message; gint pc = ((i+1) * 100) / m->uids->len; - message = camel_folder_get_message ( + message = camel_folder_get_message_sync ( m->folder, m->uids->pdata[i], m->base.cancellable, &m->base.error); camel_operation_progress ( @@ -2250,16 +2220,22 @@ save_messages_exec (struct _save_messages_msg *m) /* we need to flush after each stream write since we are writing to the same fd */ from = camel_mime_message_build_mbox_from (message); if (camel_stream_write_string ( - stream, from, &m->base.error) == -1 - || camel_stream_flush (stream, &m->base.error) == -1 - || camel_data_wrapper_write_to_stream ( + stream, from, + m->base.cancellable, &m->base.error) == -1 + || camel_stream_flush ( + stream, m->base.cancellable, &m->base.error) == -1 + || camel_data_wrapper_write_to_stream_sync ( (CamelDataWrapper *) message, - (CamelStream *)filtered_stream, &m->base.error) == -1 + (CamelStream *)filtered_stream, + m->base.cancellable, &m->base.error) == -1 || camel_stream_flush ( - (CamelStream *)filtered_stream, &m->base.error) == -1 + (CamelStream *)filtered_stream, + m->base.cancellable, &m->base.error) == -1 || camel_stream_write_string ( - stream, "\n", &m->base.error) == -1 - || camel_stream_flush (stream, &m->base.error) == -1) { + stream, "\n", + m->base.cancellable, &m->base.error) == -1 + || camel_stream_flush (stream, + m->base.cancellable, &m->base.error) == -1) { g_prefix_error ( &m->base.error, _("Error saving messages to: %s:\n"), @@ -2377,9 +2353,9 @@ save_part_exec (struct _save_part_msg *m) content = camel_medium_get_content (CAMEL_MEDIUM (m->part)); - if (camel_data_wrapper_decode_to_stream ( - content, stream, &m->base.error) == -1 - || camel_stream_flush (stream, &m->base.error) == -1) + if (camel_data_wrapper_decode_to_stream_sync ( + content, stream, m->base.cancellable, &m->base.error) == -1 + || camel_stream_flush (stream, m->base.cancellable, &m->base.error) == -1) g_prefix_error (&m->base.error, _("Could not write data: ")); g_object_unref (stream); @@ -2451,14 +2427,14 @@ prep_offline_exec (struct _prep_offline_msg *m) CAMEL_DISCO_FOLDER (folder), "(match-all)", m->cancel, &m->base.error); } else if (CAMEL_IS_OFFLINE_FOLDER (folder)) { - camel_offline_folder_downsync ( + camel_offline_folder_downsync_sync ( CAMEL_OFFLINE_FOLDER (folder), "(match-all)", m->cancel, &m->base.error); } /* prepare_for_offline should do this? */ /* of course it should all be atomic, but ... */ /* FIXME Not passing a GCancellable here. */ - camel_folder_sync (folder, FALSE, NULL, NULL); + camel_folder_synchronize_sync (folder, FALSE, NULL, NULL); g_object_unref (folder); } } @@ -2547,26 +2523,16 @@ set_offline_exec (struct _set_offline_msg *m) return; } } else if (CAMEL_IS_OFFLINE_STORE (m->store)) { - if (!m->offline) { - camel_offline_store_set_network_state ( - CAMEL_OFFLINE_STORE (m->store), - CAMEL_OFFLINE_STORE_NETWORK_AVAIL, - m->base.cancellable, - &m->base.error); - return; - } else { - camel_offline_store_set_network_state ( - CAMEL_OFFLINE_STORE (m->store), - CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL, - m->base.cancellable, - &m->base.error); - return; - } + camel_offline_store_set_online_sync ( + CAMEL_OFFLINE_STORE (m->store), + !m->offline, m->base.cancellable, + &m->base.error); + return; } if (m->offline) - camel_service_disconnect (CAMEL_SERVICE (m->store), - TRUE, &m->base.error); + camel_service_disconnect_sync ( + CAMEL_SERVICE (m->store), TRUE, &m->base.error); } static void @@ -2639,7 +2605,7 @@ prepare_offline_exec (struct _set_offline_msg *m) CAMEL_DISCO_STORE (m->store), m->base.cancellable, &m->base.error); } else if (CAMEL_IS_OFFLINE_STORE (m->store)) { - camel_offline_store_prepare_for_offline ( + camel_offline_store_prepare_for_offline_sync ( CAMEL_OFFLINE_STORE (m->store), m->base.cancellable, &m->base.error); } @@ -2722,12 +2688,10 @@ check_service_exec (struct _check_msg *m) CamelService *service; service = camel_session_get_service (session, m->url, m->type, &m->base.error); - if (!service) { - camel_operation_unregister (); + if (!service) return; - } - m->authtypes = camel_service_query_auth_types ( + m->authtypes = camel_service_query_auth_types_sync ( service, m->base.cancellable, &m->base.error); g_object_unref (service); } diff --git a/mail/mail-ops.h b/mail/mail-ops.h index 06b838849b..a0af5ff097 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -150,8 +150,7 @@ void mail_fetch_mail (const gchar *source, void mail_filter_folder (CamelFolder *source_folder, GPtrArray *uids, const gchar *type, - gboolean notify, - CamelOperation *cancel); + gboolean notify); /* convenience functions for above */ void mail_filter_on_demand (CamelFolder *folder, GPtrArray *uids); diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index 186fc9054f..3dcba97c71 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -911,8 +911,9 @@ refresh_folders_exec (struct _refresh_folders_msg *m) m->base.cancellable, &local_error); if (folder) { /* FIXME Not passing a GCancellable or GError here. */ - camel_folder_sync (folder, FALSE, NULL, NULL); - camel_folder_refresh_info (folder, NULL, NULL); + camel_folder_synchronize_sync ( + folder, FALSE, NULL, NULL); + camel_folder_refresh_info_sync (folder, NULL, NULL); g_object_unref (folder); } else if (local_error != NULL) { g_warning ("Failed to refresh folders: %s", local_error->message); diff --git a/mail/mail-session.c b/mail/mail-session.c index dbe886d69a..31b11ea260 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -636,8 +636,8 @@ static gpointer ms_thread_msg_new (CamelSession *session, CamelSessionThreadOps MailMsg *m = mail_msg_new (&ms_thread_info_dummy); msg->data = m; - g_object_unref (msg->op); - msg->op = g_object_ref (m->cancellable); + g_object_unref (msg->cancellable); + msg->cancellable = g_object_ref (m->cancellable); } return msg; @@ -737,9 +737,9 @@ ms_forward_to (CamelSession *session, /* make copy of the message, because we are going to modify it */ mem = camel_stream_mem_new (); - camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, mem, NULL); + camel_data_wrapper_write_to_stream_sync ((CamelDataWrapper *)message, mem, NULL, NULL); camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (mem), 0, CAMEL_STREAM_SET, NULL); - camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)forward, mem, NULL); + camel_data_wrapper_construct_from_stream_sync ((CamelDataWrapper *)forward, mem, NULL, NULL); g_object_unref (mem); /* clear previous recipients */ diff --git a/mail/mail-tools.c b/mail/mail-tools.c index 66ffdd207a..3804321740 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -55,7 +55,7 @@ mail_tool_get_inbox (const gchar *url, if (!store) return NULL; - folder = camel_store_get_inbox (store, cancellable, error); + folder = camel_store_get_inbox_folder_sync (store, cancellable, error); g_object_unref (store); return folder; @@ -96,7 +96,8 @@ mail_tool_get_trash (const gchar *url, if (connect || (CAMEL_SERVICE (store)->status == CAMEL_SERVICE_CONNECTED || is_local_provider (store))) - trash = camel_store_get_trash (store, cancellable, error); + trash = camel_store_get_trash_folder_sync ( + store, cancellable, error); else trash = NULL; @@ -351,13 +352,13 @@ mail_tool_uri_to_folder (const gchar *uri, if (offset) { if (offset == 7) - folder = camel_store_get_trash ( + folder = camel_store_get_trash_folder_sync ( store, cancellable, error); else if (offset == 6) - folder = camel_store_get_junk ( + folder = camel_store_get_junk_folder_sync ( store, cancellable, error); } else - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( store, name, flags, cancellable, error); g_object_unref (store); } diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 221151c5ea..cb47af8efb 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -263,8 +263,7 @@ vfolder_adduri_exec (struct _adduri_msg *m) while (l && !vfolder_shutdown) { if (m->remove) camel_vee_folder_remove_folder ( - CAMEL_VEE_FOLDER (l->data), - folder, m->base.cancellable); + CAMEL_VEE_FOLDER (l->data), folder); else camel_vee_folder_add_folder ((CamelVeeFolder *)l->data, folder); l = l->next; @@ -834,7 +833,7 @@ rule_changed (EFilterRule *rule, CamelFolder *folder) oldname = g_strdup (full_name); /* FIXME Not passing a GCancellable or GError. */ - camel_store_rename_folder ( + camel_store_rename_folder_sync ( vfolder_store, oldname, rule->name, NULL, NULL); g_free (oldname); } @@ -869,7 +868,7 @@ context_rule_added (ERuleContext *ctx, /* this always runs quickly */ /* FIXME Not passing a GCancellable or GError. */ - folder = camel_store_get_folder ( + folder = camel_store_get_folder_sync ( vfolder_store, rule->name, 0, NULL, NULL); if (folder) { g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder); @@ -900,7 +899,8 @@ context_rule_removed (ERuleContext *ctx, G_UNLOCK (vfolder); /* FIXME Not passing a GCancellable or GError. */ - camel_store_delete_folder (vfolder_store, rule->name, NULL, NULL); + camel_store_delete_folder_sync ( + vfolder_store, rule->name, NULL, NULL); /* this must be unref'd after its deleted */ if (folder) g_object_unref ((CamelFolder *) folder); |