From a91eeb647138ee035444cdc3c265fa4e95898f29 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 8 Jul 2010 11:04:23 -0400 Subject: Pass GCancellable to Camel. --- mail/e-mail-backend.c | 3 +- mail/e-mail-local.c | 3 +- mail/e-mail-migrate.c | 21 ++- mail/e-mail-reader-utils.c | 2 + mail/e-mail-reader.c | 12 +- mail/e-mail-store.c | 4 +- mail/em-composer-utils.c | 38 +++-- mail/em-folder-tree.c | 34 ++-- mail/em-folder-utils.c | 45 ++++-- mail/em-format-hook.c | 4 +- mail/em-format-html-display.c | 29 ++-- mail/em-format-html-print.c | 10 +- mail/em-format-html.c | 163 +++++++++++++------ mail/em-format-html.h | 4 +- mail/em-subscribe-editor.c | 8 +- mail/em-utils.c | 34 +++- mail/em-utils.h | 2 +- mail/importers/mail-importer.c | 12 +- mail/mail-folder-cache.c | 23 ++- mail/mail-folder-cache.h | 2 +- mail/mail-mt.c | 42 +++-- mail/mail-mt.h | 8 +- mail/mail-ops.c | 357 ++++++++++++++++++++++++++--------------- mail/mail-ops.h | 53 +++--- mail/mail-send-recv.c | 106 ++++++------ mail/mail-session.c | 8 +- mail/mail-tools.c | 26 ++- mail/mail-tools.h | 16 +- mail/mail-vfolder.c | 29 +++- mail/message-list.c | 22 ++- 30 files changed, 721 insertions(+), 399 deletions(-) (limited to 'mail') diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index 3bc822cf0b..690181d87b 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -153,7 +153,8 @@ mail_backend_delete_junk (CamelStore *store, guint32 mask; guint ii; - folder = camel_store_get_junk (store, NULL); + /* FIXME camel_store_get_junk() may block. */ + folder = camel_store_get_junk (store, NULL, NULL); if (folder == NULL) return; diff --git a/mail/e-mail-local.c b/mail/e-mail-local.c index 7b825c4240..f0ad740f92 100644 --- a/mail/e-mail-local.c +++ b/mail/e-mail-local.c @@ -81,10 +81,11 @@ e_mail_local_init (const gchar *data_dir) camel_url_set_fragment (url, display_name); folder_uri = camel_url_to_string (url, 0); + /* FIXME camel_store_get_folder() may block. */ default_local_folders[ii].folder_uri = folder_uri; default_local_folders[ii].folder = camel_store_get_folder ( CAMEL_STORE (service), display_name, - CAMEL_STORE_FOLDER_CREATE, NULL); + CAMEL_STORE_FOLDER_CREATE, NULL, NULL); } camel_url_free (url); diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index 4208b380aa..360d3f6c69 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -556,9 +556,12 @@ migrate_folders (CamelStore *store, g_idle_add ((GSourceFunc) update_states_in_main_thread, info); if (is_local) - folder = camel_store_get_folder (store, fi->full_name, CAMEL_STORE_IS_MIGRATING, NULL); + folder = camel_store_get_folder ( + store, fi->full_name, + CAMEL_STORE_IS_MIGRATING, NULL, NULL); else - folder = camel_store_get_folder (store, fi->full_name, 0, NULL); + folder = camel_store_get_folder ( + store, fi->full_name, 0, NULL, NULL); if (folder != NULL) camel_folder_summary_migrate_infos (folder->summary); @@ -653,7 +656,12 @@ 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 (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, NULL); + info = camel_store_get_folder_info ( + store, NULL, + CAMEL_STORE_FOLDER_INFO_RECURSIVE | + CAMEL_STORE_FOLDER_INFO_FAST | + CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, + NULL, NULL); if (info) { struct migrate_folders_to_db_structure migrate_dbs; @@ -689,7 +697,12 @@ 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 (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, NULL); + info = camel_store_get_folder_info ( + store, NULL, + CAMEL_STORE_FOLDER_INFO_RECURSIVE | + CAMEL_STORE_FOLDER_INFO_FAST | + CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, + NULL, NULL); if (info) { struct migrate_folders_to_db_structure migrate_dbs; diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index 8317898dd6..4c320ff9f6 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -153,6 +153,7 @@ e_mail_reader_mark_as_read (EMailReader *reader, mask = CAMEL_MESSAGE_SEEN; set = CAMEL_MESSAGE_SEEN; + camel_folder_set_message_flags (folder, uid, mask, set); } @@ -180,6 +181,7 @@ e_mail_reader_mark_selected (EMailReader *reader, folder, uids->pdata[ii], mask, set); em_utils_uids_free (uids); + camel_folder_thaw (folder); return ii; diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 68cae17828..9eda80a5a5 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -1353,6 +1353,7 @@ action_mail_toggle_important_cb (GtkAction *action, flags ^= CAMEL_MESSAGE_FLAGGED; if (flags & CAMEL_MESSAGE_FLAGGED) flags &= ~CAMEL_MESSAGE_DELETED; + camel_folder_set_message_flags ( folder, uids->pdata[ii], CAMEL_MESSAGE_FLAGGED | CAMEL_MESSAGE_DELETED, flags); @@ -2233,8 +2234,10 @@ mail_reader_message_loaded_cb (CamelFolder *folder, (EEvent *) event, "message.reading", (EEventTarget *) target); + /* FIXME Need to pass a GCancellable. */ em_format_format ( - EM_FORMAT (formatter), folder, message_uid, message); + EM_FORMAT (formatter), folder, + message_uid, message, NULL); /* Reset the shell view icon. */ e_shell_event (shell, "mail-icon", (gpointer) "evolution-mail"); @@ -2355,7 +2358,9 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader) priv->retrieving_message_operation_id = op_id; } } else { - em_format_format (EM_FORMAT (formatter), NULL, NULL, NULL); + /* FIXME Need to pass a GCancellable. */ + em_format_format ( + EM_FORMAT (formatter), NULL, NULL, NULL, NULL); priv->restoring_message_selection = FALSE; } @@ -2490,7 +2495,8 @@ mail_reader_set_folder (EMailReader *reader, em_utils_folder_is_outbox (folder, folder_uri) || em_utils_folder_is_sent (folder, folder_uri)); - em_format_format (EM_FORMAT (formatter), NULL, NULL, NULL); + /* FIXME Need to pass a GCancellable. */ + em_format_format (EM_FORMAT (formatter), NULL, NULL, NULL, NULL); priv->folder_was_just_selected = (folder != NULL); diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index a8c3afe6ec..ea524ad5e2 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -86,9 +86,9 @@ 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); + store_info->vtrash = camel_store_get_trash (store, NULL, NULL); if (store->flags & CAMEL_STORE_VJUNK) - store_info->vjunk = camel_store_get_junk (store, NULL); + store_info->vjunk = camel_store_get_junk (store, NULL, NULL); return store_info; } diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 52d3c7e99a..01964d5fcd 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -229,9 +229,10 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag if (queued) { if (emcs && emcs->drafts_folder) { /* delete the old draft message */ - camel_folder_set_message_flags (emcs->drafts_folder, emcs->drafts_uid, - CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN, - CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN); + camel_folder_set_message_flags ( + emcs->drafts_folder, emcs->drafts_uid, + CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN, + CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN); g_object_unref (emcs->drafts_folder); emcs->drafts_folder = NULL; g_free (emcs->drafts_uid); @@ -240,8 +241,12 @@ composer_send_queued_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessag if (emcs && emcs->folder) { /* set any replied flags etc */ - camel_folder_set_message_flags (emcs->folder, emcs->uid, emcs->flags, emcs->set); - camel_folder_set_message_user_flag (emcs->folder, emcs->uid, "receipt-handled", TRUE); + camel_folder_set_message_flags ( + emcs->folder, emcs->uid, + emcs->flags, emcs->set); + camel_folder_set_message_user_flag ( + emcs->folder, emcs->uid, + "receipt-handled", TRUE); g_object_unref (emcs->folder); emcs->folder = NULL; g_free (emcs->uid); @@ -542,6 +547,7 @@ em_utils_composer_send_cb (EMsgComposer *composer) /* mail the message */ e_msg_composer_set_mail_sent (composer, TRUE); info = camel_message_info_new (NULL); + camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, ~0); send = g_malloc (sizeof (*send)); @@ -593,9 +599,10 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i if (emcs->drafts_folder) { /* delete the original draft message */ - camel_folder_set_message_flags (emcs->drafts_folder, emcs->drafts_uid, - CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN, - CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN); + camel_folder_set_message_flags ( + emcs->drafts_folder, emcs->drafts_uid, + CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN, + CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_SEEN); g_object_unref (emcs->drafts_folder); emcs->drafts_folder = NULL; g_free (emcs->drafts_uid); @@ -604,7 +611,9 @@ save_draft_done (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *i if (emcs->folder) { /* set the replied flags etc */ - camel_folder_set_message_flags (emcs->folder, emcs->uid, emcs->flags, emcs->set); + camel_folder_set_message_flags ( + emcs->folder, emcs->uid, + emcs->flags, emcs->set); g_object_unref (emcs->folder); emcs->folder = NULL; g_free (emcs->uid); @@ -717,7 +726,9 @@ em_utils_composer_save_draft_cb (EMsgComposer *composer) } info = camel_message_info_new (NULL); - camel_message_info_set_flags (info, CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_SEEN, ~0); + + camel_message_info_set_flags ( + info, CAMEL_MESSAGE_DRAFT | CAMEL_MESSAGE_SEEN, ~0); mail_append_mail (folder, msg, info, save_draft_done, sdi); g_object_unref (folder); @@ -1142,7 +1153,9 @@ static void real_update_forwarded_flag (gpointer uid, gpointer folder) { if (uid && folder) - camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_FORWARDED, CAMEL_MESSAGE_FORWARDED); + camel_folder_set_message_flags ( + folder, uid, CAMEL_MESSAGE_FORWARDED, + CAMEL_MESSAGE_FORWARDED); } static void @@ -1796,7 +1809,8 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message) /* Send the receipt */ info = camel_message_info_new (NULL); out_folder = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); - camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); + camel_message_info_set_flags ( + info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); mail_append_mail (out_folder, receipt, info, em_utils_receipt_done, NULL); } diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 1c0e00d508..3d1bb68265 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -201,7 +201,8 @@ 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->store, m->top, flags, &m->base.error); + m->store, m->top, flags, + m->base.cancellable, &m->base.error); /* XXX POP3 stores always return an error because they have * no folder hierarchy to scan. Clear that error so the @@ -623,8 +624,10 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, g_strfreev (strv); /* Check for duplicate folder name. */ + /* FIXME camel_store_get_folder_info() may block. */ folder_info = camel_store_get_folder_info ( - store, new_full_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL); + store, new_full_name, + CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL); if (folder_info != NULL) { e_alert_run_dialog_for_args ( parent, "mail:no-rename-folder-exists", @@ -633,9 +636,9 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, goto exit; } - /* XXX This needs to be asynchronous. */ + /* FIXME camel_store_rename_folder() may block. */ if (!camel_store_rename_folder ( - store, old_full_name, new_full_name, &local_error)) { + store, old_full_name, new_full_name, NULL, &local_error)) { e_alert_run_dialog_for_args ( parent, "mail:no-rename-folder", old_full_name, new_full_name, @@ -1528,7 +1531,8 @@ tree_drag_data_delete (GtkWidget *widget, if (is_store) goto fail; - camel_store_delete_folder (store, full_name, NULL); + /* FIXME camel_store_delete_folder() may block. */ + camel_store_delete_folder (store, full_name, NULL, NULL); fail: gtk_tree_path_free (src_path); @@ -1578,7 +1582,10 @@ tree_drag_data_get (GtkWidget *widget, break; case DND_DRAG_TYPE_TEXT_URI_LIST: /* dragging to nautilus or something, probably */ - if ((folder = camel_store_get_folder (store, full_name, 0, NULL))) { + /* FIXME camel_store_get_folder() may block. */ + if ((folder = camel_store_get_folder ( + store, full_name, 0, NULL, NULL))) { + GPtrArray *uids = camel_folder_get_uids (folder); em_utils_selection_set_urilist (selection, folder, uids); @@ -1628,7 +1635,8 @@ folder_tree_drop_folder (struct _DragDataReceivedAsync *m) d(printf(" * Drop folder '%s' onto '%s'\n", data, m->full_name)); - if (!(folder = mail_tool_uri_to_folder ((gchar *)data, 0, &m->base.error))) + if (!(folder = mail_tool_uri_to_folder ( + (gchar *)data, 0, m->base.cancellable, &m->base.error))) return; full_name = camel_folder_get_full_name (folder); @@ -1691,11 +1699,15 @@ folder_tree_drop_async__exec (struct _DragDataReceivedAsync *m) &m->base.error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Cannot drop message(s) into toplevel store")); } else if ((folder = camel_store_get_folder ( - m->store, m->full_name, 0, &m->base.error))) { + m->store, m->full_name, 0, + m->base.cancellable, &m->base.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, folder, m->move, &m->base.error); + em_utils_selection_get_uidlist ( + m->selection, folder, m->move, + m->base.cancellable, &m->base.error); m->moved = m->move && (m->base.error == NULL); break; case DND_DROP_TYPE_MESSAGE_RFC822: @@ -2798,9 +2810,11 @@ 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. */ if (store && full_name) folder = camel_store_get_folder ( - store, full_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL); + store, full_name, + CAMEL_STORE_FOLDER_INFO_FAST, NULL, NULL); g_free (full_name); diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index 5bcc0326b6..201a0b9fb0 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -105,7 +105,8 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) gint fromlen; fi = camel_store_get_folder_info ( - m->fromstore, m->frombase, flags, &m->base.error); + m->fromstore, m->frombase, flags, + m->base.cancellable, &m->base.error); if (fi == NULL) return; @@ -147,26 +148,28 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) d(printf ("this folder is selectable\n")); if (m->tostore == m->fromstore && m->delete) { camel_store_rename_folder ( - m->fromstore, info->full_name, - toname->str, &m->base.error); + m->fromstore, info->full_name, toname->str, + m->base.cancellable, &m->base.error); if (m->base.error != NULL) goto exception; /* this folder no longer exists, unsubscribe it */ if (camel_store_supports_subscriptions (m->fromstore)) - camel_store_unsubscribe_folder (m->fromstore, info->full_name, NULL); + camel_store_unsubscribe_folder ( + m->fromstore, info->full_name, NULL, NULL); deleted = 1; } else { fromfolder = camel_store_get_folder ( - m->fromstore, info->full_name, - 0, &m->base.error); + m->fromstore, info->full_name, 0, + m->base.cancellable, &m->base.error); if (fromfolder == NULL) goto exception; tofolder = camel_store_get_folder ( m->tostore, toname->str, CAMEL_STORE_FOLDER_CREATE, + m->base.cancellable, &m->base.error); if (tofolder == NULL) { g_object_unref (fromfolder); @@ -176,11 +179,15 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) uids = camel_folder_get_uids (fromfolder); camel_folder_transfer_messages_to ( fromfolder, uids, tofolder, - NULL, m->delete, &m->base.error); + NULL, m->delete, + m->base.cancellable, + &m->base.error); camel_folder_free_uids (fromfolder, uids); if (m->delete && m->base.error == NULL) - camel_folder_sync (fromfolder, TRUE, NULL); + camel_folder_sync ( + fromfolder, TRUE, + NULL, NULL); g_object_unref (fromfolder); g_object_unref (tofolder); @@ -195,7 +202,8 @@ 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 (m->tostore, toname->str, NULL); + camel_store_subscribe_folder ( + m->tostore, toname->str, NULL, NULL); info = info->next; } @@ -212,9 +220,11 @@ 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 (m->fromstore, info->full_name, NULL); + camel_store_unsubscribe_folder ( + m->fromstore, info->full_name, NULL, NULL); - camel_store_delete_folder (m->fromstore, info->full_name, NULL); + camel_store_delete_folder ( + m->fromstore, info->full_name, NULL, NULL); l = l->next; } @@ -538,9 +548,14 @@ 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 (m->store, m->parent, m->name, &m->base.error))) { + if ((m->fi = camel_store_create_folder ( + m->store, m->parent, m->name, + m->base.cancellable, &m->base.error))) { + if (camel_store_supports_subscriptions (m->store)) - camel_store_subscribe_folder (m->store, m->full_name, &m->base.error); + camel_store_subscribe_folder ( + m->store, m->full_name, + m->base.cancellable, &m->base.error); } } @@ -736,7 +751,9 @@ emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg) path = url->path + 1; if (path != NULL) - camel_store_unsubscribe_folder (store, path, &msg->base.error); + camel_store_unsubscribe_folder ( + store, path, msg->base.cancellable, + &msg->base.error); camel_url_free (url); } diff --git a/mail/em-format-hook.c b/mail/em-format-hook.c index 5bc81aa2b4..c8a8c903a1 100644 --- a/mail/em-format-hook.c +++ b/mail/em-format-hook.c @@ -67,6 +67,7 @@ emfh_format_format (EMFormat *md, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info, + GCancellable *cancellable, gboolean is_fallback) { struct _EMFormatHookItem *item = (EMFormatHookItem *)info; @@ -78,7 +79,8 @@ emfh_format_format (EMFormat *md, e_plugin_invoke (item->hook->hook.plugin, item->format, &target); } else if (info->old) { - info->old->handler (md, stream, part, info->old, FALSE); + info->old->handler ( + md, stream, part, info->old, cancellable, FALSE); } } diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index aab7ef84c2..d68b1f2508 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -108,7 +108,7 @@ static const gchar *smime_sign_colour[5] = { "", " bgcolor=\"#88bb88\"", " bgcolor=\"#bb8888\"", " bgcolor=\"#e8d122\"","" }; -static void efhd_attachment_frame (EMFormat *emf, CamelStream *stream, EMFormatPURI *puri); +static void efhd_attachment_frame (EMFormat *emf, CamelStream *stream, EMFormatPURI *puri, GCancellable *cancellable); static void efhd_message_add_bar (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info); static gboolean efhd_attachment_button (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *pobject); static gboolean efhd_attachment_optional (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject *object); @@ -384,14 +384,15 @@ efhd_format_clone (EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, - EMFormat *src) + EMFormat *src, + GCancellable *cancellable) { if (emf != src) EM_FORMAT_HTML (emf)->header_wrap_flags = 0; /* Chain up to parent's format_clone() method. */ EM_FORMAT_CLASS (parent_class)-> - format_clone (emf, folder, uid, msg, src); + format_clone (emf, folder, uid, msg, src, cancellable); } static void @@ -399,7 +400,8 @@ efhd_format_attachment (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const gchar *mime_type, - const EMFormatHandler *handle) + const EMFormatHandler *handle, + GCancellable *cancellable) { gchar *classid, *text, *html; struct _attach_puri *info; @@ -450,7 +452,8 @@ efhd_format_attachment (EMFormat *emf, EM_FORMAT_HTML_VPAD, NULL); if (handle && info->shown) - handle->handler (emf, stream, part, handle, FALSE); + handle->handler ( + emf, stream, part, handle, cancellable, FALSE); g_free (classid); } @@ -519,12 +522,13 @@ static void efhd_format_secure (EMFormat *emf, CamelStream *stream, CamelMimePart *part, - CamelCipherValidity *valid) + CamelCipherValidity *valid, + GCancellable *cancellable) { EMFormatClass *format_class; format_class = g_type_class_peek (EM_TYPE_FORMAT); - format_class->format_secure (emf, stream, part, valid); + format_class->format_secure (emf, stream, part, valid, cancellable); if (emf->valid == valid && (valid->encrypt.status != CAMEL_CIPHER_VALIDITY_ENCRYPT_NONE @@ -674,7 +678,10 @@ efhd_builtin_init (EMFormatHTMLDisplayClass *efhc) } static void -efhd_write_image (EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) +efhd_write_image (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri, + GCancellable *cancellable) { CamelDataWrapper *dw = camel_medium_get_content ((CamelMedium *)puri->part); @@ -857,13 +864,15 @@ efhd_attachment_button (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObj static void efhd_attachment_frame (EMFormat *emf, CamelStream *stream, - EMFormatPURI *puri) + EMFormatPURI *puri, + GCancellable *cancellable) { struct _attach_puri *info = (struct _attach_puri *)puri; if (info->shown) info->handle->handler ( - emf, stream, info->puri.part, info->handle, FALSE); + emf, stream, info->puri.part, + info->handle, cancellable, FALSE); camel_stream_close (stream, NULL); } diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c index f7eb288fba..f67d3c7084 100644 --- a/mail/em-format-html-print.c +++ b/mail/em-format-html-print.c @@ -223,8 +223,10 @@ emfhp_complete (EMFormatHTMLPrint *efhp) } static void -emfhp_got_message (CamelFolder *folder, const gchar *uid, - CamelMimeMessage *msg, gpointer data) +emfhp_got_message (CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *msg, + gpointer data) { EMFormatHTMLPrint *efhp = data; @@ -237,9 +239,11 @@ emfhp_got_message (CamelFolder *folder, const gchar *uid, g_signal_connect ( efhp, "complete", G_CALLBACK (emfhp_complete), efhp); + + /* FIXME Not passing a GCancellable here. */ em_format_format_clone ( (EMFormat *) efhp, folder, uid, msg, - (EMFormat *) efhp->source); + (EMFormat *) efhp->source, NULL); } void diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 327adc55e5..49a203b2eb 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -122,13 +122,24 @@ static void efh_url_requested (GtkHTML *html, const gchar *url, GtkHTMLStream *h static gboolean efh_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTML *efh); static void efh_gtkhtml_destroy (GtkHTML *html, EMFormatHTML *efh); -static void efh_format_message (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info); +static void efh_format_message (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable); -static void efh_format_secure (EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid); +static void efh_format_secure (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + CamelCipherValidity *valid, + GCancellable *cancellable); -static void efh_builtin_init (EMFormatHTMLClass *efhc); +static void efh_builtin_init (EMFormatHTMLClass *efhc); -static void efh_write_image (EMFormat *emf, CamelStream *stream, EMFormatPURI *puri); +static void efh_write_image (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri, + GCancellable *cancellable); static gpointer parent_class; static CamelDataCache *emfh_http_cache; @@ -159,7 +170,6 @@ efh_format_exec (struct _format_msg *m) EMFormat *format; struct _EMFormatHTMLJob *job; GNode *puri_level; - gint cancelled = FALSE; CamelURL *base; if (m->format->priv->web_view == NULL) @@ -194,16 +204,18 @@ efh_format_exec (struct _format_msg *m) if (handle != NULL) handle->handler ( - format, (CamelStream *) m->estream, - (CamelMimePart *) m->message, handle, FALSE); + format, CAMEL_STREAM (m->estream), + CAMEL_MIME_PART (m->message), handle, + m->base.cancellable, FALSE); mime_type = "x-evolution/message/rfc822"; handle = em_format_find_handler (format, mime_type); if (handle != NULL) handle->handler ( - format, (CamelStream *) m->estream, - (CamelMimePart *) m->message, handle, FALSE); + format, CAMEL_STREAM (m->estream), + CAMEL_MIME_PART (m->message), handle, + m->base.cancellable, FALSE); } camel_stream_flush ((CamelStream *)m->estream, NULL); @@ -218,18 +230,14 @@ efh_format_exec (struct _format_msg *m) g_mutex_unlock (m->format->priv->lock); /* This is an implicit check to see if the gtkhtml has been destroyed */ - if (!cancelled) - cancelled = m->format->priv->web_view == NULL; - - /* Now do an explicit check for user cancellation */ - if (!cancelled) - cancelled = camel_operation_cancel_check (NULL); + if (m->format->priv->web_view == NULL) + g_cancellable_cancel (m->base.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, cancelled); + job->callback (job, m->base.cancellable); format->base = base; /* clean up the job */ @@ -324,9 +332,10 @@ efh_format_timeout (struct _format_msg *m) d(printf(" ready to go, firing off format thread\n")); /* call super-class to kick it off */ + /* FIXME Not passing a GCancellable here. */ EM_FORMAT_CLASS (parent_class)->format_clone ( EM_FORMAT (efh), m->folder, m->uid, - m->message, m->format_source); + m->message, m->format_source, NULL); em_format_html_clear_pobject (m->format); /* FIXME: method off EMFormat? */ @@ -620,7 +629,8 @@ efh_format_clone (EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, - EMFormat *emfsource) + EMFormat *emfsource, + GCancellable *cancellable) { EMFormatHTML *efh = EM_FORMAT_HTML (emf); struct _format_msg *m; @@ -714,7 +724,8 @@ efh_format_attachment (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const gchar *mime_type, - const EMFormatHandler *handle) + const EMFormatHandler *handle, + GCancellable *cancellable) { gchar *text, *html; @@ -743,7 +754,7 @@ efh_format_attachment (EMFormat *emf, stream, "", NULL); if (handle && em_format_is_inline (emf, emf->part_id->str, part, handle)) - handle->handler (emf, stream, part, handle, FALSE); + handle->handler (emf, stream, part, handle, cancellable, FALSE); } static gboolean @@ -1344,7 +1355,9 @@ em_format_html_clear_pobject (EMFormatHTML *emf) } struct _EMFormatHTMLJob * -em_format_html_job_new (EMFormatHTML *emfh, void (*callback)(struct _EMFormatHTMLJob *job, gint cancelled), gpointer data) +em_format_html_job_new (EMFormatHTML *emfh, + void (*callback) (struct _EMFormatHTMLJob *job, GCancellable *cancellable), + gpointer data) { struct _EMFormatHTMLJob *job = g_malloc0 (sizeof (*job)); @@ -1368,14 +1381,20 @@ em_format_html_job_queue (EMFormatHTML *emfh, struct _EMFormatHTMLJob *job) /* ********************************************************************** */ -static void emfh_getpuri (struct _EMFormatHTMLJob *job, gint cancelled) +static void +emfh_getpuri (struct _EMFormatHTMLJob *job, + GCancellable *cancellable) { d(printf(" running getpuri task\n")); - if (!cancelled) - job->u.puri->func ((EMFormat *)job->format, job->stream, job->u.puri); + if (!g_cancellable_is_cancelled (cancellable)) + job->u.puri->func ( + EM_FORMAT (job->format), job->stream, + job->u.puri, cancellable); } -static void emfh_gethttp (struct _EMFormatHTMLJob *job, gint cancelled) +static void +emfh_gethttp (struct _EMFormatHTMLJob *job, + GCancellable *cancellable) { CamelStream *cistream = NULL, *costream = NULL, *instream = NULL; CamelURL *url; @@ -1385,7 +1404,7 @@ static void emfh_gethttp (struct _EMFormatHTMLJob *job, gint cancelled) gchar buffer[1500]; const gchar *length; - if (cancelled + if (g_cancellable_is_cancelled (cancellable) || (url = camel_url_new (job->u.uri, NULL)) == NULL) goto badurl; @@ -1418,7 +1437,7 @@ static void emfh_gethttp (struct _EMFormatHTMLJob *job, gint cancelled) camel_http_stream_set_proxy ((CamelHttpStream *)instream, proxy); g_free (proxy); } - camel_operation_start(NULL, _("Retrieving '%s'"), job->u.uri); + camel_operation_start (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); @@ -1427,7 +1446,7 @@ static void emfh_gethttp (struct _EMFormatHTMLJob *job, gint cancelled) total = atoi (length); camel_content_type_unref (content_type); } else - camel_operation_start_transient(NULL, _("Retrieving '%s'"), job->u.uri); + camel_operation_start_transient (cancellable, _("Retrieving '%s'"), job->u.uri); camel_url_free (url); @@ -1438,7 +1457,7 @@ static void emfh_gethttp (struct _EMFormatHTMLJob *job, gint cancelled) costream = camel_data_cache_add (emfh_http_cache, EMFH_HTTP_CACHE_PATH, job->u.uri, NULL); do { - if (camel_operation_cancel_check (NULL)) { + if (camel_operation_cancel_check (CAMEL_OPERATION (cancellable))) { n = -1; break; } @@ -1449,7 +1468,7 @@ static void emfh_gethttp (struct _EMFormatHTMLJob *job, gint cancelled) /* If we didn't get a valid Content-Length header, do not try to calculate percentage */ if (total != 0) { pc_complete = ((nread * 100) / total); - camel_operation_progress (NULL, pc_complete); + camel_operation_progress (cancellable, pc_complete); } d(printf(" read %d bytes\n", n)); if (costream && camel_stream_write (costream, buffer, n, NULL) == -1) { @@ -1474,7 +1493,7 @@ static void emfh_gethttp (struct _EMFormatHTMLJob *job, gint cancelled) g_object_unref (instream); done: - camel_operation_end (NULL); + camel_operation_end (cancellable); badurl: g_free (job->u.uri); } @@ -1596,13 +1615,17 @@ static const gchar *smime_sign_colour[4] = { /* TODO: this could probably be virtual on em-format-html then we only need one version of each type handler */ static void -efh_format_secure (EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid) +efh_format_secure (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + CamelCipherValidity *valid, + GCancellable *cancellable) { EMFormatClass *format_class; format_class = EM_FORMAT_CLASS (parent_class); g_return_if_fail (format_class->format_secure != NULL); - format_class->format_secure (emf, stream, part, valid); + format_class->format_secure (emf, stream, part, valid, cancellable); /* To explain, if the validity is the same, then we are the base validity and now have a combined sign/encrypt validity @@ -1663,6 +1686,7 @@ efh_text_plain (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info, + GCancellable *cancellable, gboolean is_fallback) { CamelStream *filtered_stream; @@ -1771,7 +1795,8 @@ efh_text_plain (EMFormatHTML *efh, camel_stream_write_string (stream, "\n", NULL); } else { g_string_append_printf(((EMFormat *)efh)->part_id, ".inline.%d", i); - em_format_part ((EMFormat *)efh, stream, newpart); + em_format_part ( + EM_FORMAT (efh), stream, newpart, cancellable); g_string_truncate (((EMFormat *)efh)->part_id, len); } } @@ -1820,7 +1845,10 @@ efh_text_enriched (EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, } static void -efh_write_text_html (EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) +efh_write_text_html (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri, + GCancellable *cancellable) { #if d(!)0 CamelStream *out; @@ -2019,20 +2047,25 @@ efh_message_deliverystatus (EMFormatHTML *efh, CamelStream *stream, CamelMimePar } static void -emfh_write_related (EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) +emfh_write_related (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri, + GCancellable *cancellable) { - em_format_format_content (emf, stream, puri->part); + em_format_format_content (emf, stream, puri->part, cancellable); + camel_stream_close (stream, NULL); } static void -emfh_multipart_related_check (struct _EMFormatHTMLJob *job, gint cancelled) +emfh_multipart_related_check (struct _EMFormatHTMLJob *job, + GCancellable *cancellable) { EMFormat *format; GList *link; gchar *oldpartid; - if (cancelled) + if (g_cancellable_is_cancelled (cancellable)) return; format = EM_FORMAT (job->format); @@ -2055,7 +2088,10 @@ emfh_multipart_related_check (struct _EMFormatHTMLJob *job, gint cancelled) d(printf("part '%s' '%s' used '%d'\n", puri->uri?puri->uri:"", puri->cid, puri->use_count)); if (puri->func == emfh_write_related) { g_string_printf (format->part_id, "%s", puri->part_id); - em_format_part (format, (CamelStream *)job->stream, puri->part); + /* FIXME Not passing a GCancellable here. */ + em_format_part ( + format, CAMEL_STREAM (job->stream), + puri->part, NULL); } /* else it was probably added by a previous format this loop */ } @@ -2069,7 +2105,11 @@ emfh_multipart_related_check (struct _EMFormatHTMLJob *job, gint cancelled) /* RFC 2387 */ static void -efh_multipart_related (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) +efh_multipart_related (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable) { CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content ((CamelMedium *)part); CamelMimePart *body_part, *display_part = NULL; @@ -2111,7 +2151,9 @@ efh_multipart_related (EMFormat *emf, CamelStream *stream, CamelMimePart *part, } if (display_part == NULL) { - em_format_part_as(emf, stream, part, "multipart/mixed"); + em_format_part_as ( + emf, stream, part, + "multipart/mixed", cancellable); return; } @@ -2131,12 +2173,13 @@ efh_multipart_related (EMFormat *emf, CamelStream *stream, CamelMimePart *part, } g_string_append_printf(emf->part_id, "related.%d", displayid); - em_format_part (emf, stream, display_part); + em_format_part (emf, stream, display_part, cancellable); g_string_truncate (emf->part_id, partidlen); camel_stream_flush (stream, NULL); /* queue a job to check for un-referenced parts to add as attachments */ - job = em_format_html_job_new ((EMFormatHTML *)emf, emfh_multipart_related_check, NULL); + job = em_format_html_job_new ( + EM_FORMAT_HTML (emf), emfh_multipart_related_check, NULL); job->stream = stream; g_object_ref (stream); em_format_html_job_queue ((EMFormatHTML *)emf, job); @@ -2145,7 +2188,10 @@ efh_multipart_related (EMFormat *emf, CamelStream *stream, CamelMimePart *part, } static void -efh_write_image (EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) +efh_write_image (EMFormat *emf, + CamelStream *stream, + EMFormatPURI *puri, + GCancellable *cancellable) { CamelDataWrapper *dw = camel_medium_get_content ((CamelMedium *)puri->part); @@ -2561,7 +2607,10 @@ efh_format_header (EMFormat *emf, CamelStream *stream, CamelMedium *part, struct } static void -efh_format_headers (EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) +efh_format_headers (EMFormatHTML *efh, + CamelStream *stream, + CamelMedium *part, + GCancellable *cancellable) { EMFormat *emf = (EMFormat *) efh; const gchar *charset; @@ -2771,7 +2820,9 @@ efh_format_headers (EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) camel_mime_part_set_content ((CamelMimePart *) part, (const gchar *) face_header_value, face_header_len, "image/png"); classid = g_strdup_printf("icon:///em-format-html/face/photo/header"); camel_stream_printf(stream, "", classid); - em_format_add_puri (emf, sizeof (EMFormatPURI), classid, part, efh_write_image); + em_format_add_puri ( + emf, sizeof (EMFormatPURI), + classid, part, efh_write_image); g_object_unref (part); } @@ -2794,7 +2845,9 @@ efh_format_headers (EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) } if (iconpart) { - em_format_add_puri (emf, sizeof (EMFormatPURI), classid, iconpart, efh_write_image); + em_format_add_puri ( + emf, sizeof (EMFormatPURI), + classid, iconpart, efh_write_image); g_object_unref (iconpart); } g_free (classid); @@ -2804,7 +2857,11 @@ efh_format_headers (EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) } static void -efh_format_message (EMFormat *emf, CamelStream *stream, CamelMimePart *part, const EMFormatHandler *info) +efh_format_message (EMFormat *emf, + CamelStream *stream, + CamelMimePart *part, + const EMFormatHandler *info, + GCancellable *cancellable) { const EMFormatHandler *handle; @@ -2819,14 +2876,16 @@ efh_format_message (EMFormat *emf, CamelStream *stream, CamelMimePart *part, con camel_stream_printf(stream, "
\n"); if (!efh->hide_headers) - efh_format_headers (efh, stream, (CamelMedium *)part); + efh_format_headers ( + efh, stream, CAMEL_MEDIUM (part), cancellable); handle = em_format_find_handler(emf, "x-evolution/message/post-header"); if (handle) - handle->handler (emf, stream, part, handle, FALSE); + handle->handler ( + emf, stream, part, handle, cancellable, FALSE); camel_stream_printf (stream, EM_FORMAT_HTML_VPAD); - em_format_part (emf, stream, part); + em_format_part (emf, stream, part, cancellable); if (emf->message != (CamelMimeMessage *)part) camel_stream_printf(stream, "
\n"); diff --git a/mail/em-format-html.h b/mail/em-format-html.h index 85b91f84c3..81f2fee5ca 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -115,7 +115,7 @@ struct _EMFormatHTMLJob { GNode *puri_level; CamelURL *base; - void (*callback)(EMFormatHTMLJob *job, gint cancelled); + void (*callback)(EMFormatHTMLJob *job, GCancellable *cancellable); union { gchar *uri; CamelMedium *msg; @@ -269,7 +269,7 @@ void em_format_html_remove_pobject (EMFormatHTML *efh, void em_format_html_clear_pobject (EMFormatHTML *efh); EMFormatHTMLJob * em_format_html_job_new (EMFormatHTML *efh, - void (*callback)(EMFormatHTMLJob *job, gint cancelled), + void (*callback)(EMFormatHTMLJob *job, GCancellable *cancellable), gpointer data); void em_format_html_job_queue (EMFormatHTML *efh, EMFormatHTMLJob *job); diff --git a/mail/em-subscribe-editor.c b/mail/em-subscribe-editor.c index 39ec661013..c0d1120a3e 100644 --- a/mail/em-subscribe-editor.c +++ b/mail/em-subscribe-editor.c @@ -268,11 +268,11 @@ sub_folder_exec (struct _zsubscribe_msg *m) if (m->subscribe) camel_store_subscribe_folder ( m->sub->store, m->node->info->full_name, - &m->base.error); + m->base.cancellable, &m->base.error); else camel_store_unsubscribe_folder ( m->sub->store, m->node->info->full_name, - &m->base.error); + m->base.cancellable, &m->base.error); } static void @@ -453,15 +453,13 @@ static void sub_folderinfo_exec (struct _emse_folderinfo_msg *m) { if (m->seq == m->sub->seq) { - camel_operation_register (m->base.cancel); /* get the full folder tree for search ability */ m->info = camel_store_get_folder_info ( m->sub->store, NULL, CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL | CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST | CAMEL_STORE_FOLDER_INFO_RECURSIVE, - &m->base.error); - camel_operation_unregister (); + m->base.cancellable, &m->base.error); } } diff --git a/mail/em-utils.c b/mail/em-utils.c index 17957815ad..922050212d 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -493,6 +493,7 @@ em_utils_flag_for_followup_clear (GtkWindow *parent, CamelFolder *folder, GPtrAr camel_folder_free_message_info (folder, mi); } } + camel_folder_thaw (folder); em_utils_uids_free (uids); @@ -532,6 +533,7 @@ em_utils_flag_for_followup_completed (GtkWindow *parent, CamelFolder *folder, GP camel_folder_free_message_info (folder, mi); } } + camel_folder_thaw (folder); g_free (now); @@ -558,7 +560,9 @@ em_utils_write_messages_to_stream (CamelFolder *folder, GPtrArray *uids, CamelSt CamelMimeMessage *message; gchar *from; - message = camel_folder_get_message (folder, uids->pdata[i], NULL); + /* FIXME camel_folder_get_message() may block. */ + message = camel_folder_get_message ( + folder, uids->pdata[i], NULL, NULL); if (message == NULL) { res = -1; break; @@ -607,8 +611,9 @@ em_utils_read_messages_from_stream (CamelFolder *folder, CamelStream *stream) break; } + /* FIXME camel_folder_append_message() may block. */ success = camel_folder_append_message ( - folder, msg, NULL, NULL, NULL); + folder, msg, NULL, NULL, NULL, NULL); g_object_unref (msg); if (!success) @@ -712,7 +717,9 @@ em_utils_selection_get_message (GtkSelectionData *selection_data, 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) - camel_folder_append_message (folder, msg, NULL, NULL, NULL); + /* FIXME camel_folder_append_message() may block. */ + camel_folder_append_message ( + folder, msg, NULL, NULL, NULL, NULL); g_object_unref (msg); g_object_unref (stream); } @@ -762,6 +769,7 @@ void em_utils_selection_get_uidlist (GtkSelectionData *selection_data, CamelFolder *dest, gint move, + GCancellable *cancellable, GError **error) { /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn" */ @@ -800,9 +808,13 @@ em_utils_selection_get_uidlist (GtkSelectionData *selection_data, return; } - folder = mail_tool_uri_to_folder ((gchar *) data, 0, error); + /* FIXME mail_tool_uri_to_folder() may block. */ + folder = mail_tool_uri_to_folder ( + (gchar *) data, 0, cancellable, error); if (folder) { - camel_folder_transfer_messages_to (folder, uids, dest, NULL, move, error); + /* FIXME camel_folder_transfer_messages_to() may block. */ + camel_folder_transfer_messages_to ( + folder, uids, dest, NULL, move, cancellable, error); g_object_unref (folder); } @@ -1243,7 +1255,13 @@ em_utils_get_proxy_uri (const gchar *pUri) * Return value: The html version. **/ gchar * -em_utils_message_to_html (CamelMimeMessage *message, const gchar *credits, guint32 flags, gssize *len, EMFormat *source, const gchar *append, guint32 *validity_found) +em_utils_message_to_html (CamelMimeMessage *message, + const gchar *credits, + guint32 flags, + gssize *len, + EMFormat *source, + const gchar *append, + guint32 *validity_found) { EMFormatQuote *emfq; CamelStreamMem *mem; @@ -1269,7 +1287,9 @@ em_utils_message_to_html (CamelMimeMessage *message, const gchar *credits, guint g_free (charset); } - em_format_format_clone ((EMFormat *)emfq, NULL, NULL, message, source); + /* FIXME Not passing a GCancellable here. */ + em_format_format_clone ( + EM_FORMAT (emfq), NULL, NULL, message, source, NULL); if (validity_found) *validity_found = ((EMFormat *)emfq)->validity_found; g_object_unref (emfq); diff --git a/mail/em-utils.h b/mail/em-utils.h index 7e071756a2..0e9ef9f41a 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -57,7 +57,7 @@ void em_utils_selection_get_mailbox (GtkSelectionData *data, CamelFolder *folder void em_utils_selection_get_message (GtkSelectionData *data, CamelFolder *folder); /* FIXME: be nice if these also worked on CamelFolder's, no easy way to get uri from folder yet tho */ void em_utils_selection_set_uidlist (GtkSelectionData *data, const gchar *uri, GPtrArray *uids); -void em_utils_selection_get_uidlist (GtkSelectionData *data, CamelFolder *dest, gint move, GError **error); +void em_utils_selection_get_uidlist (GtkSelectionData *data, CamelFolder *dest, gint move, GCancellable *cancellable, GError **error); void em_utils_selection_set_urilist (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids); void em_utils_selection_get_urilist (GtkSelectionData *data, CamelFolder *folder); diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c index ddc9f66300..3dac78744c 100644 --- a/mail/importers/mail-importer.c +++ b/mail/importers/mail-importer.c @@ -123,7 +123,8 @@ import_mbox_exec (struct _import_mbox_msg *m) folder = e_mail_local_get_folder (E_MAIL_FOLDER_INBOX); else folder = mail_tool_uri_to_folder ( - m->uri, CAMEL_STORE_FOLDER_CREATE, &m->base.error); + m->uri, CAMEL_STORE_FOLDER_CREATE, + m->base.cancellable, &m->base.error); if (folder == NULL) return; @@ -181,7 +182,8 @@ import_mbox_exec (struct _import_mbox_msg *m) camel_message_info_set_flags (info, flags, ~0); camel_folder_append_message ( - folder, msg, info, NULL, &m->base.error); + folder, msg, info, NULL, + m->base.cancellable, &m->base.error); camel_message_info_free (info); g_object_unref (msg); @@ -190,7 +192,8 @@ import_mbox_exec (struct _import_mbox_msg *m) camel_mime_parser_step (mp, NULL, NULL); } - camel_folder_sync (folder, FALSE, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_sync (folder, FALSE, NULL, NULL); camel_folder_thaw (folder); camel_operation_end (NULL); /* TODO: these api's are a bit weird, registering the old is the same as deregistering */ @@ -200,7 +203,8 @@ import_mbox_exec (struct _import_mbox_msg *m) g_object_unref (mp); } fail1: - camel_folder_sync (folder, FALSE, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_sync (folder, FALSE, NULL, NULL); g_object_unref (folder); } diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index d12d77ea64..00818a1ef5 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -188,11 +188,16 @@ real_flush_updates (gpointer o, gpointer event_data, gpointer data) } if (CAMEL_IS_VEE_STORE (up->store) && !up->remove) { - /* Normally the vfolder store takes care of the folder_opened event itself, - but we add folder to the noting system later, thus we do not know about - search folders to update them in a tree, thus ensure their changes will - be tracked correctly. */ - CamelFolder *folder = camel_store_get_folder (up->store, up->full_name, 0, NULL); + /* Normally the vfolder store takes care of the + * folder_opened event itself, but we add folder to + * the noting system later, thus we do not know about + * search folders to update them in a tree, thus + * ensure their changes will be tracked correctly. */ + CamelFolder *folder; + + /* FIXME camel_store_get_folder() may block. */ + folder = camel_store_get_folder ( + up->store, up->full_name, 0, NULL, NULL); if (folder) { mail_folder_cache_note_folder (self, folder); @@ -802,7 +807,8 @@ ping_store_exec (struct _ping_store_msg *m) online = TRUE; } if (online) - camel_store_noop (m->store, &m->base.error); + camel_store_noop ( + m->store, m->base.cancellable, &m->base.error); } static void @@ -1086,7 +1092,7 @@ mail_folder_cache_get_default (void) void mail_folder_cache_note_store (MailFolderCache *self, CamelStore *store, - CamelOperation *op, + GCancellable *cancellable, NoteDoneFunc done, gpointer data) { @@ -1143,7 +1149,8 @@ mail_folder_cache_note_store (MailFolderCache *self, } } else { normal_setup: - ud->id = mail_get_folderinfo (store, op, update_folders, ud); + ud->id = mail_get_folderinfo ( + store, cancellable, update_folders, ud); } g_queue_push_tail (&si->folderinfo_updates, ud); diff --git a/mail/mail-folder-cache.h b/mail/mail-folder-cache.h index 55aaeb9651..870b7fe8ae 100644 --- a/mail/mail-folder-cache.h +++ b/mail/mail-folder-cache.h @@ -83,7 +83,7 @@ MailFolderCache * mail_folder_cache_get_default (void); void mail_folder_cache_note_store (MailFolderCache *self, CamelStore *store, - CamelOperation *op, + GCancellable *cancellable, NoteDoneFunc done, gpointer data); void mail_folder_cache_note_store_remove diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 80a37c15ec..694a8f5abe 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -89,7 +89,7 @@ mail_msg_new (MailMsgInfo *info) msg->info = info; msg->ref_count = 1; msg->seq = mail_msg_seq++; - msg->cancel = camel_operation_new (); + msg->cancellable = (GCancellable *) camel_operation_new (); msg->priv = g_slice_new0 (MailMsgPrivate); msg->priv->activity = e_activity_new (); @@ -99,10 +99,10 @@ mail_msg_new (MailMsgInfo *info) e_activity_set_cancellable ( msg->priv->activity, - G_CANCELLABLE (msg->cancel)); + G_CANCELLABLE (msg->cancellable)); g_signal_connect ( - msg->cancel, "cancelled", + msg->cancellable, "cancelled", G_CALLBACK (mail_msg_cancelled), GINT_TO_POINTER (msg->seq)); @@ -157,8 +157,8 @@ mail_msg_free (MailMsg *mail_msg) g_object_unref (mail_msg->priv->activity); } - if (mail_msg->cancel != NULL) - g_object_unref (mail_msg->cancel); + if (mail_msg->cancellable != NULL) + g_object_unref (mail_msg->cancellable); if (mail_msg->error != NULL) g_error_free (mail_msg->error); @@ -255,8 +255,7 @@ mail_msg_check_error (gpointer msg) 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) - || (m->cancel && camel_operation_cancel_check (m->cancel))) + || g_error_matches (m->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID)) return; if (active_errors == NULL) @@ -295,26 +294,26 @@ mail_msg_check_error (gpointer msg) } -void mail_msg_cancel (guint msgid) +void +mail_msg_cancel (guint msgid) { - MailMsg *m; + MailMsg *msg; g_mutex_lock (mail_msg_lock); - m = g_hash_table_lookup (mail_msg_active_table, GINT_TO_POINTER (msgid)); + msg = g_hash_table_lookup ( + mail_msg_active_table, GINT_TO_POINTER (msgid)); - if (m != NULL && m->cancel != NULL && !camel_operation_cancel_check (m->cancel)) { - g_signal_handlers_block_by_func (m->cancel, mail_msg_cancelled, GINT_TO_POINTER (m->seq)); - camel_operation_cancel (m->cancel); - g_signal_handlers_unblock_by_func (m->cancel, mail_msg_cancelled, GINT_TO_POINTER (m->seq)); - } + if (msg != NULL && msg->cancellable != NULL) + camel_operation_cancel (CAMEL_OPERATION (msg->cancellable)); g_mutex_unlock (mail_msg_lock); } /* waits for a message to be finished processing (freed) the messageid is from MailMsg->seq */ -void mail_msg_wait (guint msgid) +void +mail_msg_wait (guint msgid) { MailMsg *m; @@ -473,10 +472,9 @@ mail_msg_idle_cb (void) static void mail_msg_proxy (MailMsg *msg) { - if (msg->info->desc != NULL && msg->cancel) { + if (msg->info->desc != NULL) { gchar *text = msg->info->desc (msg); - camel_operation_register (msg->cancel); - camel_operation_start (msg->cancel, "%s", text); + camel_operation_start (msg->cancellable, "%s", text); g_free (text); } @@ -489,10 +487,8 @@ mail_msg_proxy (MailMsg *msg) if (msg->info->exec != NULL) msg->info->exec (msg); - if (msg->info->desc != NULL && msg->cancel) { - camel_operation_end (msg->cancel); - camel_operation_unregister (); - } + if (msg->info->desc != NULL) + camel_operation_end (msg->cancellable); g_async_queue_push (msg_reply_queue, msg); diff --git a/mail/mail-mt.h b/mail/mail-mt.h index c27f61ce6c..e31d9e9506 100644 --- a/mail/mail-mt.h +++ b/mail/mail-mt.h @@ -38,10 +38,10 @@ typedef void (*MailMsgDispatchFunc) (gpointer msg); struct _MailMsg { MailMsgInfo *info; volatile gint ref_count; - guint seq; /* seq number for synchronisation */ - gint priority; /* priority (default = 0) */ - CamelOperation *cancel; /* a cancellation/status handle */ - GError *error; /* up to the caller to use this */ + guint seq; /* seq number for synchronisation */ + gint priority; /* priority (default = 0) */ + GCancellable *cancellable; /* a cancellation/status handle */ + GError *error; /* up to the caller to use this */ MailMsgPrivate *priv; }; diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 1303daee81..5699199666 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -69,7 +69,8 @@ struct _filter_mail_msg { struct _fetch_mail_msg { struct _filter_mail_msg fmsg; - CamelOperation *cancel; /* we have our own cancellation struct, the other should be empty */ + GCancellable *cancellable; /* we have our own cancellation + * struct, the other should be empty */ gint keep; /* keep on server? */ gchar *source_uri; @@ -116,8 +117,8 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m) folder_uids = uids = camel_folder_get_uids (folder); camel_filter_driver_filter_folder ( - m->driver, folder, m->cache, uids, - m->delete, &m->base.error); + m->driver, folder, m->cache, uids, m->delete, + m->base.cancellable, &m->base.error); camel_filter_driver_flush (m->driver, &m->base.error); if (folder_uids) @@ -125,7 +126,8 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m) /* sync our source folder */ if (!m->cache) - camel_folder_sync (folder, FALSE, &m->base.error); + camel_folder_sync ( + folder, FALSE, m->base.cancellable, &m->base.error); camel_folder_thaw (folder); if (m->destination) @@ -249,8 +251,8 @@ fetch_mail_exec (struct _fetch_mail_msg *m) struct _filter_mail_msg *fm = (struct _filter_mail_msg *)m; gint i; - if (m->cancel) - camel_operation_register (m->cancel); + 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) @@ -268,7 +270,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m) fm->driver, fm->destination); camel_filter_driver_filter_mbox ( fm->driver, path, m->source_uri, - &fm->base.error); + fm->base.cancellable, &fm->base.error); camel_folder_thaw (fm->destination); if (fm->base.error == NULL) @@ -279,7 +281,10 @@ fetch_mail_exec (struct _fetch_mail_msg *m) CamelFolder *folder; folder = fm->source_folder = - mail_tool_get_inbox (m->source_uri, &fm->base.error); + mail_tool_get_inbox ( + m->source_uri, + fm->base.cancellable, + &fm->base.error); if (folder) { /* this handles 'keep on server' stuff, if we have any new uid's to copy @@ -327,7 +332,8 @@ fetch_mail_exec (struct _fetch_mail_msg *m) if ((fm->delete || cache_uids) && fm->base.error == NULL) { /* expunge messages (downloaded so far) */ - camel_folder_sync (folder, fm->delete, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_sync (folder, fm->delete, NULL, NULL); } camel_uid_cache_destroy (cache); @@ -344,7 +350,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m) } } fail: - if (m->cancel) + if (m->cancellable) camel_operation_unregister (); /* we unref this here as it may have more work to do (syncing @@ -367,8 +373,9 @@ static void fetch_mail_free (struct _fetch_mail_msg *m) { g_free (m->source_uri); - if (m->cancel) - g_object_unref (m->cancel); + + if (m->cancellable) + g_object_unref (m->cancellable); em_filter_folder_element_free ((struct _filter_mail_msg *) m); } @@ -383,10 +390,16 @@ static MailMsgInfo fetch_mail_info = { /* ouch, a 'do everything' interface ... */ void -mail_fetch_mail (const gchar *source, gint keep, const gchar *type, CamelOperation *cancel, - CamelFilterGetFolderFunc get_folder, gpointer get_data, - CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *source, gpointer data), gpointer data) +mail_fetch_mail (const gchar *source, + gint keep, + const gchar *type, + GCancellable *cancellable, + CamelFilterGetFolderFunc get_folder, + gpointer get_data, + CamelFilterStatusFunc *status, + gpointer status_data, + void (*done)(const gchar *source, gpointer data), + gpointer data) { struct _fetch_mail_msg *m; struct _filter_mail_msg *fm; @@ -396,8 +409,8 @@ mail_fetch_mail (const gchar *source, gint keep, const gchar *type, CamelOperati m->source_uri = g_strdup (source); fm->delete = !keep; fm->cache = NULL; - if (cancel) - m->cancel = g_object_ref (cancel); + if (cancellable) + m->cancellable = g_object_ref (cancellable); m->done = done; m->data = data; @@ -457,6 +470,7 @@ mail_send_message (struct _send_queue_msg *m, const gchar *uid, const gchar *destination, CamelFilterDriver *driver, + GCancellable *cancellable, GError **error) { EAccount *account = NULL; @@ -474,7 +488,7 @@ mail_send_message (struct _send_queue_msg *m, gint i; GError *local_error = NULL; - message = camel_folder_get_message (queue, uid, error); + message = camel_folder_get_message (queue, uid, cancellable, error); if (!message) return; @@ -545,7 +559,8 @@ mail_send_message (struct _send_queue_msg *m, if (xport == NULL) goto exit; - if (!camel_transport_send_to (xport, message, from, recipients, error)) + if (!camel_transport_send_to ( + xport, message, from, recipients, cancellable, error)) goto exit; } @@ -562,9 +577,12 @@ mail_send_message (struct _send_queue_msg *m, /* TODO: don't lose errors */ uri = g_strstrip (g_strdup (header->value)); - folder = mail_tool_uri_to_folder (uri, 0, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + folder = mail_tool_uri_to_folder (uri, 0, NULL, NULL); if (folder) { - camel_folder_append_message (folder, message, info, NULL, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_append_message ( + folder, message, info, NULL, NULL, NULL); g_object_unref (folder); folder = NULL; } @@ -576,8 +594,8 @@ mail_send_message (struct _send_queue_msg *m, if (driver) { camel_filter_driver_filter_message ( - driver, message, info, NULL, - NULL, NULL, "", &local_error); + driver, message, info, NULL, NULL, + NULL, "", cancellable, &local_error); if (local_error != NULL) { if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -598,7 +616,7 @@ mail_send_message (struct _send_queue_msg *m, if (sent_folder_uri) { folder = mail_tool_uri_to_folder ( - sent_folder_uri, 0, &local_error); + sent_folder_uri, 0, cancellable, &local_error); if (folder == NULL) { g_string_append_printf ( err, _("Failed to append to %s: %s\n" @@ -613,7 +631,10 @@ mail_send_message (struct _send_queue_msg *m, g_object_ref (folder); } - if (!camel_folder_append_message (folder, message, info, NULL, &local_error)) { + if (!camel_folder_append_message ( + folder, message, info, + NULL, cancellable, &local_error)) { + CamelFolder *sent_folder; if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) @@ -637,7 +658,8 @@ mail_send_message (struct _send_queue_msg *m, g_clear_error (&local_error); camel_folder_append_message ( - folder, message, info, NULL, &local_error); + folder, message, info, + NULL, cancellable, &local_error); } if (local_error != NULL) { @@ -659,7 +681,8 @@ mail_send_message (struct _send_queue_msg *m, CAMEL_MESSAGE_SEEN, ~0); /* Sync it to disk, since if it crashes in between, * we keep sending it again on next start. */ - camel_folder_sync (queue, FALSE, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_sync (queue, FALSE, NULL, NULL); } if (err->len) { @@ -673,8 +696,9 @@ exit: if (local_error != NULL) g_propagate_error (error, local_error); + /* FIXME Not passing a GCancellable or GError here. */ if (folder) { - camel_folder_sync (folder, FALSE, NULL); + camel_folder_sync (folder, FALSE, NULL, NULL); g_object_unref (folder); } if (info) @@ -701,7 +725,7 @@ struct _send_queue_msg { gchar *destination; CamelFilterDriver *driver; - CamelOperation *cancel; + GCancellable *cancellable; /* we use camelfilterstatusfunc, even though its not the filter doing it */ CamelFilterStatusFunc *status; @@ -761,27 +785,33 @@ send_queue_exec (struct _send_queue_msg *m) return; } - if (m->cancel) - camel_operation_register (m->cancel); + if (m->cancellable) + camel_operation_register (CAMEL_OPERATION (m->cancellable)); else - camel_operation_register (m->base.cancel); + camel_operation_register (CAMEL_OPERATION (m->base.cancellable)); - if (!m->cancel) + if (!m->cancellable) camel_operation_start (NULL, _("Sending message")); - /* NB: This code somewhat abuses the 'exception' stuff. Apart from fatal problems, it is also - used as a mechanism to accumualte warning messages and present them back to the user. */ + /* NB: This code somewhat abuses the 'exception' stuff. Apart from + * fatal problems, it is also used as a mechanism to accumualte + * warning messages and present them back to the user. */ for (i = 0, j = 0; i < send_uids->len; i++) { gint pc = (100 * i) / send_uids->len; - report_status (m, CAMEL_FILTER_STATUS_START, pc, _("Sending message %d of %d"), i+1, send_uids->len); - if (!m->cancel) - camel_operation_progress (NULL, (i+1) * 100 / send_uids->len); + report_status ( + m, CAMEL_FILTER_STATUS_START, pc, + _("Sending message %d of %d"), i+1, + send_uids->len); + + if (!m->cancellable) + camel_operation_progress ( + NULL, (i+1) * 100 / send_uids->len); mail_send_message ( - m, m->queue, send_uids->pdata[i], - m->destination, m->driver, &local_error); + m, m->queue, send_uids->pdata[i], m->destination, + m->driver, m->base.cancellable, &local_error); if (local_error != NULL) { if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { /* merge exceptions into one */ @@ -833,13 +863,15 @@ send_queue_exec (struct _send_queue_msg *m) camel_folder_free_uids (m->queue, uids); g_ptr_array_free (send_uids, TRUE); + /* FIXME Not passing a GCancellable or GError here. */ if (j <= 0 && m->base.error == NULL) - camel_folder_sync (m->queue, TRUE, NULL); + camel_folder_sync (m->queue, TRUE, NULL, NULL); + /* FIXME Not passing a GCancellable or GError here. */ if (sent_folder) - camel_folder_sync (sent_folder, FALSE, NULL); + camel_folder_sync (sent_folder, FALSE, NULL, NULL); - if (!m->cancel) + if (!m->cancellable) camel_operation_end (NULL); camel_operation_unregister (); @@ -866,8 +898,8 @@ send_queue_free (struct _send_queue_msg *m) g_object_unref (m->driver); g_object_unref (m->queue); g_free (m->destination); - if (m->cancel) - g_object_unref (m->cancel); + if (m->cancellable) + g_object_unref (m->cancellable); } static MailMsgInfo send_queue_info = { @@ -880,24 +912,27 @@ static MailMsgInfo send_queue_info = { /* same interface as fetch_mail, just 'cause i'm lazy today (and we need to run it from the same spot?) */ void -mail_send_queue (CamelFolder *queue, const gchar *destination, - const gchar *type, CamelOperation *cancel, - CamelFilterGetFolderFunc get_folder, gpointer get_data, - CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *destination, gpointer data), gpointer data) +mail_send_queue (CamelFolder *queue, + const gchar *destination, + const gchar *type, + GCancellable *cancellable, + CamelFilterGetFolderFunc get_folder, + gpointer get_data, + CamelFilterStatusFunc *status, + gpointer status_data, + void (*done)(const gchar *destination, gpointer data), + gpointer data) { struct _send_queue_msg *m; m = mail_msg_new (&send_queue_info); - m->queue = queue; - g_object_ref (queue); + m->queue = g_object_ref (queue); m->destination = g_strdup (destination); - if (cancel) { - m->cancel = g_object_ref (cancel); - g_object_unref (m->base.cancel); + if (G_IS_CANCELLABLE (cancellable)) { + m->cancellable = g_object_ref (cancellable); + g_object_unref (m->base.cancellable); mail_msg_set_cancelable (m, FALSE); - - m->base.cancel = NULL; + m->base.cancellable = NULL; } m->status = status; m->status_data = status_data; @@ -933,8 +968,13 @@ append_mail_desc (struct _append_msg *m) static void append_mail_exec (struct _append_msg *m) { - camel_mime_message_set_date (m->message, CAMEL_MESSAGE_DATE_CURRENT, 0); - camel_folder_append_message (m->folder, m->message, m->info, &m->appended_uid, &m->base.error); + camel_mime_message_set_date ( + m->message, CAMEL_MESSAGE_DATE_CURRENT, 0); + + camel_folder_append_message ( + m->folder, m->message, + m->info, &m->appended_uid, + m->base.cancellable, &m->base.error); } static void @@ -1017,7 +1057,9 @@ transfer_messages_exec (struct _transfer_msg *m) { CamelFolder *dest; - dest = mail_tool_uri_to_folder (m->dest_uri, m->dest_flags, &m->base.error); + dest = mail_tool_uri_to_folder ( + m->dest_uri, m->dest_flags, + m->base.cancellable, &m->base.error); if (dest == NULL) return; @@ -1030,7 +1072,9 @@ 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, &m->base.error); + camel_folder_transfer_messages_to ( + m->source, m->uids, dest, NULL, m->delete, + m->base.cancellable, &m->base.error); /* make sure all deleted messages are marked as seen */ @@ -1038,13 +1082,16 @@ transfer_messages_exec (struct _transfer_msg *m) gint i; for (i = 0; i < m->uids->len; i++) - camel_folder_set_message_flags (m->source, m->uids->pdata[i], - CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); + camel_folder_set_message_flags ( + m->source, m->uids->pdata[i], + CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); } camel_folder_thaw (m->source); camel_folder_thaw (dest); - camel_folder_sync (dest, FALSE, NULL); + + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_sync (dest, FALSE, NULL, NULL); g_object_unref (dest); } @@ -1126,7 +1173,9 @@ 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->store, NULL, flags, &m->base.error); + m->info = camel_store_get_folder_info ( + m->store, NULL, flags, + m->base.cancellable, &m->base.error); } static void @@ -1164,15 +1213,18 @@ static MailMsgInfo get_folderinfo_info = { }; gint -mail_get_folderinfo (CamelStore *store, CamelOperation *op, gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data), gpointer data) +mail_get_folderinfo (CamelStore *store, + GCancellable *cancellable, + gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data), + gpointer data) { struct _get_folderinfo_msg *m; gint id; m = mail_msg_new (&get_folderinfo_info); - if (op) { - g_object_unref (m->base.cancel); - m->base.cancel = g_object_ref (op); + if (G_IS_CANCELLABLE (cancellable)) { + g_object_unref (m->base.cancellable); + m->base.cancellable = g_object_ref (cancellable); } m->store = store; g_object_ref (store); @@ -1270,7 +1322,8 @@ get_folder_desc (struct _get_folder_msg *m) static void get_folder_exec (struct _get_folder_msg *m) { - m->folder = mail_tool_uri_to_folder (m->uri, m->flags, &m->base.error); + m->folder = mail_tool_uri_to_folder ( + m->uri, m->flags, m->base.cancellable, &m->base.error); } static void @@ -1439,15 +1492,18 @@ static MailMsgInfo get_store_info = { }; gint -mail_get_store (const gchar *uri, CamelOperation *op, void (*done) (gchar *uri, CamelStore *store, gpointer data), gpointer data) +mail_get_store (const gchar *uri, + GCancellable *cancellable, + void (*done) (gchar *uri, CamelStore *store, gpointer data), + gpointer data) { struct _get_store_msg *m; gint id; m = mail_msg_new (&get_store_info); - if (op) { - g_object_unref (m->base.cancel); - m->base.cancel = g_object_ref (op); + if (G_IS_CANCELLABLE (cancellable)) { + g_object_unref (m->base.cancellable); + m->base.cancellable = g_object_ref (cancellable); } m->uri = g_strdup (uri); m->data = data; @@ -1476,19 +1532,24 @@ remove_folder_desc (struct _remove_folder_msg *m) } static gboolean -remove_folder_rec (CamelStore *store, CamelFolderInfo *fi, GError **error) +remove_folder_rec (CamelStore *store, + CamelFolderInfo *fi, + GCancellable *cancellable, + GError **error) { while (fi) { CamelFolder *folder; if (fi->child) { - if (!remove_folder_rec (store, fi->child, error)) + if (!remove_folder_rec ( + store, fi->child, cancellable, error)) return FALSE; } d(printf ("deleting folder '%s'\n", fi->full_name)); - folder = camel_store_get_folder (store, fi->full_name, 0, error); + folder = camel_store_get_folder ( + store, fi->full_name, 0, cancellable, error); if (folder == NULL) return FALSE; @@ -1499,20 +1560,26 @@ remove_folder_rec (CamelStore *store, CamelFolderInfo *fi, GError **error) /* Delete every message in this folder, then expunge it */ camel_folder_freeze (folder); for (i = 0; i < uids->len; i++) - camel_folder_delete_message (folder, uids->pdata[i]); + camel_folder_delete_message ( + folder, uids->pdata[i]); camel_folder_free_uids (folder, uids); - camel_folder_sync (folder, TRUE, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_sync (folder, TRUE, NULL, NULL); camel_folder_thaw (folder); } - /* if the store supports subscriptions, unsubscribe from this folder... */ + /* If the store supports subscriptions, unsubscribe + * from this folder. + * FIXME Not passing a GCancellable or GError here. */ if (camel_store_supports_subscriptions (store)) - camel_store_unsubscribe_folder (store, fi->full_name, NULL); + camel_store_unsubscribe_folder ( + store, fi->full_name, NULL, NULL); /* Then delete the folder from the store */ - if (!camel_store_delete_folder (store, fi->full_name, error)) + if (!camel_store_delete_folder ( + store, fi->full_name, cancellable, error)) return FALSE; fi = fi->next; @@ -1538,11 +1605,13 @@ 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); if (fi == NULL) return; - m->removed = remove_folder_rec (parent_store, fi, &m->base.error); + m->removed = remove_folder_rec ( + parent_store, fi, m->base.cancellable, &m->base.error); camel_store_free_folder_info (parent_store, fi); } @@ -1603,7 +1672,8 @@ sync_folder_desc (struct _sync_folder_msg *m) static void sync_folder_exec (struct _sync_folder_msg *m) { - camel_folder_sync (m->folder, FALSE, &m->base.error); + camel_folder_sync ( + m->folder, FALSE, m->base.cancellable, &m->base.error); } static void @@ -1670,7 +1740,9 @@ sync_store_desc (struct _sync_store_msg *m) static void sync_store_exec (struct _sync_store_msg *m) { - camel_store_sync (m->store, m->expunge, &m->base.error); + camel_store_sync ( + m->store, m->expunge, + m->base.cancellable, &m->base.error); } static void @@ -1720,10 +1792,8 @@ refresh_folder_desc (struct _sync_folder_msg *m) static void refresh_folder_exec (struct _sync_folder_msg *m) { - /* camel_folder_sync (m->folder, FALSE, &m->base.error); */ - - /* if (!camel_exception_is_set (&m->base.error)) */ - camel_folder_refresh_info (m->folder, &m->base.error); + camel_folder_refresh_info ( + m->folder, m->base.cancellable, &m->base.error); } /* we just use the sync stuff where we can, since it would be the same */ @@ -1760,7 +1830,8 @@ expunge_folder_desc (struct _sync_folder_msg *m) static void expunge_folder_exec (struct _sync_folder_msg *m) { - camel_folder_expunge (m->folder, &m->base.error); + camel_folder_expunge ( + m->folder, m->base.cancellable, &m->base.error); } /* we just use the sync stuff where we can, since it would be the same */ @@ -1811,16 +1882,20 @@ empty_trash_exec (struct _empty_trash_msg *m) gchar *uri; if (m->account) { - trash = mail_tool_get_trash (m->account->source->url, FALSE, &m->base.error); + trash = mail_tool_get_trash ( + m->account->source->url, FALSE, + m->base.cancellable, &m->base.error); } else { data_dir = mail_session_get_data_dir (); uri = g_strdup_printf ("mbox:%s/local", data_dir); - trash = mail_tool_get_trash (uri, TRUE, &m->base.error); + trash = mail_tool_get_trash ( + uri, TRUE, m->base.cancellable, &m->base.error); g_free (uri); } if (trash) { - camel_folder_expunge (trash, &m->base.error); + camel_folder_expunge ( + trash, m->base.cancellable, &m->base.error); g_object_unref (trash); } } @@ -1884,10 +1959,12 @@ get_message_desc (struct _get_message_msg *m) static void get_message_exec (struct _get_message_msg *m) { - if (m->base.cancel && camel_operation_cancel_check (m->base.cancel)) + if (g_cancellable_is_cancelled (m->base.cancellable)) m->message = NULL; else - m->message = camel_folder_get_message (m->folder, m->uid, &m->base.error); + m->message = camel_folder_get_message ( + m->folder, m->uid, + m->base.cancellable, &m->base.error); } static void @@ -2017,8 +2094,11 @@ get_messages_exec (struct _get_messages_msg *m) for (i=0; iuids->len; i++) { gint pc = ((i+1) * 100) / m->uids->len; - message = camel_folder_get_message (m->folder, m->uids->pdata[i], &m->base.error); - camel_operation_progress (m->base.cancel, pc); + message = camel_folder_get_message ( + m->folder, m->uids->pdata[i], + m->base.cancellable, &m->base.error); + camel_operation_progress ( + m->base.cancellable, pc); if (message == NULL) break; @@ -2157,8 +2237,11 @@ save_messages_exec (struct _save_messages_msg *m) CamelMimeMessage *message; gint pc = ((i+1) * 100) / m->uids->len; - message = camel_folder_get_message (m->folder, m->uids->pdata[i], &m->base.error); - camel_operation_progress (m->base.cancel, pc); + message = camel_folder_get_message ( + m->folder, m->uids->pdata[i], + m->base.cancellable, &m->base.error); + camel_operation_progress ( + m->base.cancellable, pc); if (message == NULL) break; @@ -2349,7 +2432,7 @@ mail_save_part (CamelMimePart *part, const gchar *path, struct _prep_offline_msg { MailMsg base; - CamelOperation *cancel; + GCancellable *cancel; gchar *uri; void (*done)(const gchar *uri, gpointer data); gpointer data; @@ -2360,26 +2443,24 @@ prep_offline_exec (struct _prep_offline_msg *m) { CamelFolder *folder; - if (m->cancel) - camel_operation_register (m->cancel); - - folder = mail_tool_uri_to_folder (m->uri, 0, &m->base.error); + folder = mail_tool_uri_to_folder ( + m->uri, 0, m->base.cancellable, &m->base.error); if (folder) { if (CAMEL_IS_DISCO_FOLDER (folder)) { - camel_disco_folder_prepare_for_offline ((CamelDiscoFolder *)folder, - "(match-all)", - &m->base.error); + camel_disco_folder_prepare_for_offline ( + CAMEL_DISCO_FOLDER (folder), + "(match-all)", m->cancel, &m->base.error); } else if (CAMEL_IS_OFFLINE_FOLDER (folder)) { - camel_offline_folder_downsync ((CamelOfflineFolder *) folder, "(match-all)", &m->base.error); + camel_offline_folder_downsync ( + 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 ... */ - camel_folder_sync (folder, FALSE, NULL); + /* FIXME Not passing a GCancellable here. */ + camel_folder_sync (folder, FALSE, NULL, NULL); g_object_unref (folder); } - - if (m->cancel) - camel_operation_unregister (); } static void @@ -2414,9 +2495,8 @@ mail_prep_offline (const gchar *uri, struct _prep_offline_msg *m; m = mail_msg_new (&prep_offline_info); - m->cancel = cancel; - if (cancel) - g_object_ref (cancel); + if (G_IS_CANCELLABLE (cancel)) + m->cancel = g_object_ref (cancel); m->uri = g_strdup (uri); m->data = data; m->done = done; @@ -2452,26 +2532,34 @@ set_offline_exec (struct _set_offline_msg *m) { 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.error); + camel_disco_store_set_status ( + CAMEL_DISCO_STORE (m->store), + CAMEL_DISCO_STORE_ONLINE, + m->base.cancellable, + &m->base.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.error); + camel_disco_store_set_status ( + CAMEL_DISCO_STORE (m->store), + CAMEL_DISCO_STORE_OFFLINE, + m->base.cancellable, + &m->base.error); 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.error); + 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.error); + camel_offline_store_set_network_state ( + CAMEL_OFFLINE_STORE (m->store), + CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL, + m->base.cancellable, + &m->base.error); return; } } @@ -2547,11 +2635,13 @@ static void prepare_offline_exec (struct _set_offline_msg *m) { if (CAMEL_IS_DISCO_STORE (m->store)) { - camel_disco_store_prepare_for_offline (CAMEL_DISCO_STORE (m->store), - &m->base.error); + camel_disco_store_prepare_for_offline ( + 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 (m->store), - &m->base.error); + camel_offline_store_prepare_for_offline ( + CAMEL_OFFLINE_STORE (m->store), + m->base.cancellable, &m->base.error); } } @@ -2637,7 +2727,8 @@ check_service_exec (struct _check_msg *m) return; } - m->authtypes = camel_service_query_auth_types (service, &m->base.error); + m->authtypes = camel_service_query_auth_types ( + service, m->base.cancellable, &m->base.error); g_object_unref (service); } diff --git a/mail/mail-ops.h b/mail/mail-ops.h index 879a62654e..06b838849b 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -71,7 +71,7 @@ gint mail_get_folder_quota (CamelFolder *folder, gpointer data, MailMsgDispatchFunc dispatch); /* and for a store */ -gint mail_get_store (const gchar *uri, CamelOperation *op, +gint mail_get_store (const gchar *uri, GCancellable *cancellable, void (*done) (gchar *uri, CamelStore *store, gpointer data), gpointer data); /* build an attachment */ @@ -99,9 +99,10 @@ void mail_empty_trash (EAccount *account, gpointer data); /* get folder info asynchronously */ -gint mail_get_folderinfo (CamelStore *store, CamelOperation *op, - gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data), - gpointer data); +gint mail_get_folderinfo (CamelStore *store, + GCancellable *cancellable, + gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data), + gpointer data); /* remove an existing folder */ void mail_remove_folder (CamelFolder *folder, @@ -124,23 +125,33 @@ gint mail_save_part (CamelMimePart *part, const gchar *path, gpointer data, gboolean readonly); /* yeah so this is messy, but it does a lot, maybe i can consolidate all user_data's to be the one */ -void mail_send_queue (CamelFolder *queue, const gchar *destination, - const gchar *type, CamelOperation *cancel, - CamelFilterGetFolderFunc get_folder, gpointer get_data, - CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *destination, gpointer data), - gpointer data); - -void mail_fetch_mail (const gchar *source, gint keep, - const gchar *type, CamelOperation *cancel, - CamelFilterGetFolderFunc get_folder, gpointer get_data, - CamelFilterStatusFunc *status, gpointer status_data, - void (*done)(const gchar *source, gpointer data), - gpointer data); - -void mail_filter_folder (CamelFolder *source_folder, GPtrArray *uids, - const gchar *type, gboolean notify, - CamelOperation *cancel); +void mail_send_queue (CamelFolder *queue, + const gchar *destination, + const gchar *type, + GCancellable *cancellable, + CamelFilterGetFolderFunc get_folder, + gpointer get_data, + CamelFilterStatusFunc *status, + gpointer status_data, + void (*done)(const gchar *destination, gpointer data), + gpointer data); + +void mail_fetch_mail (const gchar *source, + gint keep, + const gchar *type, + GCancellable *cancellable, + CamelFilterGetFolderFunc get_folder, + gpointer get_data, + CamelFilterStatusFunc *status, + gpointer status_data, + void (*done)(const gchar *source, gpointer data), + gpointer data); + +void mail_filter_folder (CamelFolder *source_folder, + GPtrArray *uids, + const gchar *type, + gboolean notify, + CamelOperation *cancel); /* 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 c7d1b3c0b4..186fc9054f 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -101,7 +101,7 @@ typedef enum { struct _send_info { send_info_t type; /* 0 = fetch, 1 = send */ - CamelOperation *cancel; + GCancellable *cancellable; gchar *uri; gboolean keep_on_server; send_state_t state; @@ -145,8 +145,8 @@ static void free_send_info (struct _send_info *info) { g_free (info->uri); - if (info->cancel) - g_object_unref (info->cancel); + if (info->cancellable) + g_object_unref (info->cancellable); if (info->timeout_id != 0) g_source_remove (info->timeout_id); g_free (info->what); @@ -181,7 +181,7 @@ static void receive_cancel (GtkButton *button, struct _send_info *info) { if (info->state == SEND_ACTIVE) { - camel_operation_cancel (info->cancel); + camel_operation_cancel (CAMEL_OPERATION (info->cancellable)); if (info->status_label) gtk_label_set_text ( GTK_LABEL (info->status_label), @@ -529,12 +529,12 @@ build_dialog (GtkWindow *parent, info->uri = g_strdup (source->url); info->keep_on_server = source->keep_on_server; - info->cancel = camel_operation_new (); + info->cancellable = (GCancellable *) camel_operation_new (); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); g_signal_connect ( - info->cancel, "status", + info->cancellable, "status", G_CALLBACK (operation_status), info); g_hash_table_insert (data->active, info->uri, info); @@ -619,12 +619,12 @@ build_dialog (GtkWindow *parent, info->uri = g_strdup (destination); info->keep_on_server = FALSE; - info->cancel = camel_operation_new (); + info->cancellable = (GCancellable *) camel_operation_new (); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add (STATUS_TIMEOUT, operation_status_timeout, info); g_signal_connect ( - info->cancel, "status", + info->cancellable, "status", G_CALLBACK (operation_status), info); g_hash_table_insert (data->active, (gpointer) SEND_URI_KEY, info); @@ -765,7 +765,7 @@ receive_done (const gchar *uri, gpointer data) mail_send_queue (local_outbox, info->uri, E_FILTER_SOURCE_OUTGOING, - info->cancel, + info->cancellable, receive_get_folder, info, receive_status, info, receive_done, info); @@ -830,7 +830,8 @@ receive_get_folder (CamelFilterDriver *d, g_object_ref (oldinfo->folder); return oldinfo->folder; } - folder = mail_tool_uri_to_folder (uri, 0, error); + /* FIXME Not passing a GCancellable here. */ + folder = mail_tool_uri_to_folder (uri, 0, NULL, error); if (!folder) return NULL; @@ -905,17 +906,20 @@ refresh_folders_exec (struct _refresh_folders_msg *m) get_folders (m->store, m->folders, m->finfo); for (i=0;ifolders->len;i++) { - folder = mail_tool_uri_to_folder (m->folders->pdata[i], 0, &local_error); + folder = mail_tool_uri_to_folder ( + m->folders->pdata[i], 0, + m->base.cancellable, &local_error); if (folder) { - camel_folder_sync (folder, FALSE, NULL); - camel_folder_refresh_info (folder, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + camel_folder_sync (folder, FALSE, NULL, NULL); + camel_folder_refresh_info (folder, NULL, NULL); g_object_unref (folder); } else if (local_error != NULL) { g_warning ("Failed to refresh folders: %s", local_error->message); g_clear_error (&local_error); } - if (camel_operation_cancel_check (m->info->cancel)) + if (g_cancellable_is_cancelled (m->info->cancellable)) break; } } @@ -979,8 +983,9 @@ receive_update_got_store (gchar *uri, CamelStore *store, gpointer data) struct _send_info *info = data; if (store) { - mail_folder_cache_note_store (mail_folder_cache_get_default (), - store, info->cancel, + mail_folder_cache_note_store ( + mail_folder_cache_get_default (), + store, info->cancellable, receive_update_got_folderinfo, info); } else { receive_done("", info); @@ -1021,24 +1026,29 @@ mail_send_receive (GtkWindow *parent) switch (info->type) { case SEND_RECEIVE: - mail_fetch_mail (info->uri, info->keep_on_server, - E_FILTER_SOURCE_INCOMING, - info->cancel, - receive_get_folder, info, - receive_status, info, - receive_done, info); + mail_fetch_mail ( + info->uri, + info->keep_on_server, + E_FILTER_SOURCE_INCOMING, + info->cancellable, + receive_get_folder, info, + receive_status, info, + receive_done, info); break; case SEND_SEND: /* todo, store the folder in info? */ - mail_send_queue (local_outbox, info->uri, - E_FILTER_SOURCE_OUTGOING, - info->cancel, - receive_get_folder, info, - receive_status, info, - receive_done, info); + mail_send_queue ( + local_outbox, info->uri, + E_FILTER_SOURCE_OUTGOING, + info->cancellable, + receive_get_folder, info, + receive_status, info, + receive_done, info); break; case SEND_UPDATE: - mail_get_store (info->uri, info->cancel, receive_update_got_store, info); + mail_get_store ( + info->uri, info->cancellable, + receive_update_got_store, info); break; default: break; @@ -1239,14 +1249,14 @@ mail_receive_uri (const gchar *uri, gboolean keep_on_server) info->status_label = NULL; info->uri = g_strdup (uri); info->keep_on_server = keep_on_server; - info->cancel = camel_operation_new (); + info->cancellable = (GCancellable *) camel_operation_new (); info->cancel_button = NULL; info->data = data; info->state = SEND_ACTIVE; info->timeout_id = 0; g_signal_connect ( - info->cancel, "status", + info->cancellable, "status", G_CALLBACK (operation_status), info); d(printf("Adding new info %p\n", info)); @@ -1255,25 +1265,29 @@ mail_receive_uri (const gchar *uri, gboolean keep_on_server) switch (info->type) { case SEND_RECEIVE: - mail_fetch_mail (info->uri, info->keep_on_server, - E_FILTER_SOURCE_INCOMING, - info->cancel, - receive_get_folder, info, - receive_status, info, - receive_done, info); + mail_fetch_mail ( + info->uri, info->keep_on_server, + E_FILTER_SOURCE_INCOMING, + info->cancellable, + receive_get_folder, info, + receive_status, info, + receive_done, info); break; case SEND_SEND: /* todo, store the folder in info? */ local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); - mail_send_queue (local_outbox, info->uri, - E_FILTER_SOURCE_OUTGOING, - info->cancel, - receive_get_folder, info, - receive_status, info, - receive_done, info); + mail_send_queue ( + local_outbox, info->uri, + E_FILTER_SOURCE_OUTGOING, + info->cancellable, + receive_get_folder, info, + receive_status, info, + receive_done, info); break; case SEND_UPDATE: - mail_get_store (info->uri, info->cancel, receive_update_got_store, info); + mail_get_store ( + info->uri, info->cancellable, + receive_update_got_store, info); break; default: g_return_if_reached (); @@ -1315,7 +1329,7 @@ mail_send (void) info->status_label = NULL; info->uri = g_strdup (transport->url); info->keep_on_server = FALSE; - info->cancel = NULL; + info->cancellable = NULL; info->cancel_button = NULL; info->data = data; info->state = SEND_ACTIVE; @@ -1329,7 +1343,7 @@ mail_send (void) local_outbox = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); mail_send_queue (local_outbox, info->uri, E_FILTER_SOURCE_OUTGOING, - info->cancel, + info->cancellable, receive_get_folder, info, receive_status, info, receive_done, info); diff --git a/mail/mail-session.c b/mail/mail-session.c index c3ba26cb10..dbe886d69a 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -478,7 +478,8 @@ get_folder (CamelFilterDriver *d, gpointer data, GError **error) { - return mail_tool_uri_to_folder (uri, 0, error); + /* FIXME Not passing a GCancellable here. */ + return mail_tool_uri_to_folder (uri, 0, NULL, error); } static void @@ -636,7 +637,7 @@ static gpointer ms_thread_msg_new (CamelSession *session, CamelSessionThreadOps msg->data = m; g_object_unref (msg->op); - msg->op = g_object_ref (m->cancel); + msg->op = g_object_ref (m->cancellable); } return msg; @@ -780,7 +781,8 @@ ms_forward_to (CamelSession *session, /* and send it */ info = camel_message_info_new (NULL); out_folder = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); - camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); + camel_message_info_set_flags ( + info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN); mail_append_mail (out_folder, forward, info, ms_forward_to_cb, NULL); return TRUE; diff --git a/mail/mail-tools.c b/mail/mail-tools.c index d717c29540..66ffdd207a 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -44,7 +44,9 @@ /* **************************************** */ CamelFolder * -mail_tool_get_inbox (const gchar *url, GError **error) +mail_tool_get_inbox (const gchar *url, + GCancellable *cancellable, + GError **error) { CamelStore *store; CamelFolder *folder; @@ -53,7 +55,7 @@ mail_tool_get_inbox (const gchar *url, GError **error) if (!store) return NULL; - folder = camel_store_get_inbox (store, error); + folder = camel_store_get_inbox (store, cancellable, error); g_object_unref (store); return folder; @@ -76,6 +78,7 @@ is_local_provider (CamelStore *store) CamelFolder * mail_tool_get_trash (const gchar *url, gint connect, + GCancellable *cancellable, GError **error) { CamelStore *store; @@ -93,7 +96,7 @@ 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, error); + trash = camel_store_get_trash (store, cancellable, error); else trash = NULL; @@ -293,7 +296,10 @@ mail_tool_make_message_attachment (CamelMimeMessage *message) } CamelFolder * -mail_tool_uri_to_folder (const gchar *uri, guint32 flags, GError **error) +mail_tool_uri_to_folder (const gchar *uri, + guint32 flags, + GCancellable *cancellable, + GError **error) { CamelURL *url; CamelStore *store = NULL; @@ -345,11 +351,14 @@ mail_tool_uri_to_folder (const gchar *uri, guint32 flags, GError **error) if (offset) { if (offset == 7) - folder = camel_store_get_trash (store, error); + folder = camel_store_get_trash ( + store, cancellable, error); else if (offset == 6) - folder = camel_store_get_junk (store, error); + folder = camel_store_get_junk ( + store, cancellable, error); } else - folder = camel_store_get_folder (store, name, flags, error); + folder = camel_store_get_folder ( + store, name, flags, cancellable, error); g_object_unref (store); } @@ -381,7 +390,8 @@ mail_tools_x_evolution_message_parse (gchar *in, guint inlen, GPtrArray **uids) if (in == NULL) return NULL; - folder = mail_tool_uri_to_folder (in, 0, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + folder = mail_tool_uri_to_folder (in, 0, NULL, NULL); if (!folder) return NULL; diff --git a/mail/mail-tools.h b/mail/mail-tools.h index 01c800fbd9..e746e9f5ec 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -27,10 +27,15 @@ #include /* Get the "inbox" for a url (uses global session) */ -CamelFolder *mail_tool_get_inbox (const gchar *url, GError **error); +CamelFolder * mail_tool_get_inbox (const gchar *url, + GCancellable *cancellable, + GError **error); /* Get the "trash" for a url (uses global session) */ -CamelFolder *mail_tool_get_trash (const gchar *url, gint connect, GError **error); +CamelFolder * mail_tool_get_trash (const gchar *url, + gint connect, + GCancellable *cancellable, + GError **error); /* Does a camel_movemail into the local movemail folder * and returns the path to the new movemail folder that was created. which shoudl be freed later */ @@ -45,8 +50,11 @@ gchar *mail_tool_generate_forward_subject (CamelMimeMessage *msg); /* Make a message into an attachment */ CamelMimePart *mail_tool_make_message_attachment (CamelMimeMessage *message); -/* Parse the ui into a real CamelFolder any way we know how. */ -CamelFolder *mail_tool_uri_to_folder (const gchar *uri, guint32 flags, GError **error); +/* Parse the URI into a real CamelFolder any way we know how. */ +CamelFolder * mail_tool_uri_to_folder (const gchar *uri, + guint32 flags, + GCancellable *cancellable, + GError **error); GHashTable *mail_lookup_url_table (CamelMimeMessage *mime_message); diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 9cb2844bff..221151c5ea 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -98,7 +98,8 @@ vfolder_setup_exec (struct _setup_msg *m) while (l && !vfolder_shutdown) { d(printf(" Adding uri: %s\n", (gchar *)l->data)); - folder = mail_tool_uri_to_folder (l->data, 0, NULL); + /* FIXME Not passing a GCancellable or GError here. */ + folder = mail_tool_uri_to_folder (l->data, 0, NULL, NULL); if (folder != NULL) list = g_list_append (list, folder); l = l->next; @@ -254,13 +255,16 @@ vfolder_adduri_exec (struct _adduri_msg *m) } if (folder == NULL) - folder = mail_tool_uri_to_folder (m->uri, 0, &m->base.error); + folder = mail_tool_uri_to_folder ( + m->uri, 0, m->base.cancellable, &m->base.error); if (folder != NULL) { l = m->folders; while (l && !vfolder_shutdown) { if (m->remove) - camel_vee_folder_remove_folder ((CamelVeeFolder *)l->data, folder); + camel_vee_folder_remove_folder ( + CAMEL_VEE_FOLDER (l->data), + folder, m->base.cancellable); else camel_vee_folder_add_folder ((CamelVeeFolder *)l->data, folder); l = l->next; @@ -829,7 +833,9 @@ rule_changed (EFilterRule *rule, CamelFolder *folder) } oldname = g_strdup (full_name); - camel_store_rename_folder (vfolder_store, oldname, rule->name, NULL); + /* FIXME Not passing a GCancellable or GError. */ + camel_store_rename_folder ( + vfolder_store, oldname, rule->name, NULL, NULL); g_free (oldname); } @@ -853,14 +859,18 @@ rule_changed (EFilterRule *rule, CamelFolder *folder) g_string_free (query, TRUE); } -static void context_rule_added (ERuleContext *ctx, EFilterRule *rule) +static void +context_rule_added (ERuleContext *ctx, + EFilterRule *rule) { CamelFolder *folder; d(printf("rule added: %s\n", rule->name)); /* this always runs quickly */ - folder = camel_store_get_folder (vfolder_store, rule->name, 0, NULL); + /* FIXME Not passing a GCancellable or GError. */ + folder = camel_store_get_folder ( + vfolder_store, rule->name, 0, NULL, NULL); if (folder) { g_signal_connect(rule, "changed", G_CALLBACK(rule_changed), folder); @@ -872,7 +882,9 @@ static void context_rule_added (ERuleContext *ctx, EFilterRule *rule) } } -static void context_rule_removed (ERuleContext *ctx, EFilterRule *rule) +static void +context_rule_removed (ERuleContext *ctx, + EFilterRule *rule) { gpointer key, folder = NULL; @@ -887,7 +899,8 @@ static void context_rule_removed (ERuleContext *ctx, EFilterRule *rule) } G_UNLOCK (vfolder); - camel_store_delete_folder (vfolder_store, rule->name, NULL); + /* FIXME Not passing a GCancellable or GError. */ + camel_store_delete_folder (vfolder_store, rule->name, NULL, NULL); /* this must be unref'd after its deleted */ if (folder) g_object_unref ((CamelFolder *) folder); diff --git a/mail/message-list.c b/mail/message-list.c index ff7350a327..c6a8092046 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -937,9 +937,12 @@ message_list_copy (MessageList *ml, gboolean cut) camel_folder_freeze (ml->folder); for (i=0;ilen;i++) - camel_folder_set_message_flags (ml->folder, uids->pdata[i], - CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED, - CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED); + camel_folder_set_message_flags ( + ml->folder, uids->pdata[i], + CAMEL_MESSAGE_SEEN | + CAMEL_MESSAGE_DELETED, + CAMEL_MESSAGE_SEEN | + CAMEL_MESSAGE_DELETED); camel_folder_thaw (ml->folder); } @@ -2108,8 +2111,9 @@ ml_selection_received (GtkWidget *widget, return; } + /* FIXME Not passing a GCancellable or GError here. */ em_utils_selection_get_uidlist ( - selection_data, ml->folder, FALSE, NULL); + selection_data, ml->folder, FALSE, NULL, NULL); } static void @@ -2176,6 +2180,7 @@ ml_drop_async_exec (struct _drop_msg *m) em_utils_selection_get_uidlist ( m->selection, m->folder, m->action == GDK_ACTION_MOVE, + m->base.cancellable, &m->base.error); break; case DND_MESSAGE_RFC822: @@ -4514,7 +4519,7 @@ regen_list_exec (struct _regen_list_msg *m) e_profile_event_emit("list.threaduids", m->folder->full_name, 0); /* camel_folder_summary_prepare_fetch_all (m->folder->summary, NULL); */ - if (!camel_operation_cancel_check (m->base.cancel)) { + if (!g_cancellable_is_cancelled (m->base.cancellable)) { /* update/build a new tree */ if (m->dotree) { ml_sort_uids_by_tree (m->ml, uids); @@ -4557,7 +4562,7 @@ regen_list_done (struct _regen_list_msg *m) if (!m->complete) return; - if (camel_operation_cancel_check (m->base.cancel)) + if (g_cancellable_is_cancelled (m->base.cancellable)) return; if (m->ml->folder != m->folder) @@ -4744,8 +4749,9 @@ mail_regen_cancel (MessageList *ml) while (l) { MailMsg *mm = l->data; - if (mm->cancel) - camel_operation_cancel (mm->cancel); + if (mm->cancellable) + camel_operation_cancel ( + CAMEL_OPERATION (mm->cancellable)); l = l->next; } -- cgit v1.2.3