diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-07-05 05:40:28 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-07-09 02:37:52 +0800 |
commit | 137b0743ddfbd3bbc01c9813615ede91ddd9b954 (patch) | |
tree | 1d8e09ba0239eff419d432bdd8d5b521fbb727ba /mail | |
parent | 36f1f29b9a42c56a619e031b045db5a18f2b1dd7 (diff) | |
download | gsoc2013-evolution-137b0743ddfbd3bbc01c9813615ede91ddd9b954.tar.gz gsoc2013-evolution-137b0743ddfbd3bbc01c9813615ede91ddd9b954.tar.zst gsoc2013-evolution-137b0743ddfbd3bbc01c9813615ede91ddd9b954.zip |
Migrate from CamelException to GError.
Diffstat (limited to 'mail')
34 files changed, 672 insertions, 556 deletions
diff --git a/mail/e-mail-local.c b/mail/e-mail-local.c index 002865cd33..7b825c4240 100644 --- a/mail/e-mail-local.c +++ b/mail/e-mail-local.c @@ -48,17 +48,15 @@ void e_mail_local_init (const gchar *data_dir) { static gboolean initialized = FALSE; - CamelException ex; CamelService *service; CamelURL *url; gchar *temp; gint ii; + GError *local_error = NULL; g_return_if_fail (!initialized); g_return_if_fail (data_dir != NULL); - camel_exception_init (&ex); - url = camel_url_new ("mbox:", NULL); temp = g_build_filename (data_dir, "local", NULL); camel_url_set_path (url, temp); @@ -66,10 +64,10 @@ e_mail_local_init (const gchar *data_dir) temp = camel_url_to_string (url, 0); service = camel_session_get_service ( - session, temp, CAMEL_PROVIDER_STORE, &ex); + session, temp, CAMEL_PROVIDER_STORE, &local_error); g_free (temp); - if (camel_exception_is_set (&ex)) + if (local_error != NULL) goto fail; /* Populate the rest of the default_local_folders array. */ @@ -86,9 +84,7 @@ e_mail_local_init (const gchar *data_dir) 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, &ex); - - camel_exception_clear (&ex); + CAMEL_STORE_FOLDER_CREATE, NULL); } camel_url_free (url); @@ -99,9 +95,11 @@ e_mail_local_init (const gchar *data_dir) return; fail: - g_warning ("Could not initialize local store/folder: %s", ex.desc); + g_warning ( + "Could not initialize local store/folder: %s", + local_error->message); - camel_exception_clear (&ex); + g_error_free (local_error); camel_url_free (url); } diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index 7f59d16a48..202bbaaca5 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -533,7 +533,13 @@ update_states_in_main_thread (const struct _migrate_state_info * info) } static void -migrate_folders(CamelStore *store, gboolean is_local, CamelFolderInfo *fi, const gchar *acc, CamelException *ex, gboolean *done, gint *nth_folder, gint total_folders) +migrate_folders (CamelStore *store, + gboolean is_local, + CamelFolderInfo *fi, + const gchar *acc, + gboolean *done, + gint *nth_folder, + gint total_folders) { CamelFolder *folder; @@ -550,13 +556,13 @@ migrate_folders(CamelStore *store, gboolean is_local, CamelFolderInfo *fi, const 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, ex); + folder = camel_store_get_folder (store, fi->full_name, CAMEL_STORE_IS_MIGRATING, NULL); else - folder = camel_store_get_folder (store, fi->full_name, 0, ex); + folder = camel_store_get_folder (store, fi->full_name, 0, NULL); if (folder != NULL) camel_folder_summary_migrate_infos (folder->summary); - migrate_folders(store, is_local, fi->child, acc, ex, done, nth_folder, total_folders); + migrate_folders(store, is_local, fi->child, acc, done, nth_folder, total_folders); fi = fi->next; } @@ -601,12 +607,11 @@ setup_local_store (EShellBackend *shell_backend, #ifndef G_OS_WIN32 struct migrate_folders_to_db_structure { - gchar *account_name; - CamelException ex; - CamelStore *store; - CamelFolderInfo *info; - gboolean done; - gboolean is_local_store; + gchar *account_name; + CamelStore *store; + CamelFolderInfo *info; + gboolean done; + gboolean is_local_store; }; static void @@ -614,9 +619,10 @@ migrate_folders_to_db_thread (struct migrate_folders_to_db_structure *migrate_db { gint num_of_folders = 0, nth_folder = 0; count_folders (migrate_dbs->info, &num_of_folders); - migrate_folders (migrate_dbs->store, migrate_dbs->is_local_store, migrate_dbs->info, - migrate_dbs->account_name, &(migrate_dbs->ex), &(migrate_dbs->done), - &nth_folder, num_of_folders); + migrate_folders ( + migrate_dbs->store, migrate_dbs->is_local_store, + migrate_dbs->info, migrate_dbs->account_name, + &(migrate_dbs->done), &nth_folder, num_of_folders); } static void @@ -655,7 +661,6 @@ migrate_to_db (EShellBackend *shell_backend) migrate_dbs.is_local_store = TRUE; else migrate_dbs.is_local_store = FALSE; - camel_exception_init (&migrate_dbs.ex); migrate_dbs.account_name = _("On This Computer"); migrate_dbs.info = info; migrate_dbs.store = store; @@ -681,17 +686,13 @@ migrate_to_db (EShellBackend *shell_backend) && service->url[0] && strncmp(service->url, "mbox:", 5) != 0) { - CamelException ex; - - camel_exception_init (&ex); e_mail_store_add_by_uri (service->url, name); - store = (CamelStore *) camel_session_get_service (CAMEL_SESSION (session), service->url, CAMEL_PROVIDER_STORE, &ex); - info = camel_store_get_folder_info (store, NULL, CAMEL_STORE_FOLDER_INFO_RECURSIVE|CAMEL_STORE_FOLDER_INFO_FAST|CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, &ex); + 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); if (info) { struct migrate_folders_to_db_structure migrate_dbs; - migrate_dbs.ex = ex; migrate_dbs.account_name = account->name; migrate_dbs.info = info; migrate_dbs.store = store; @@ -702,8 +703,6 @@ migrate_to_db (EShellBackend *shell_backend) g_main_context_iteration (NULL, TRUE); } else printf("%s:%s: failed to get folder infos \n", G_STRLOC, G_STRFUNC); - camel_exception_clear(&ex); - } i++; e_iterator_next (iter); diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index abfbf3b0ab..795dfcd40f 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -1789,7 +1789,7 @@ mail_reader_message_loaded_cb (CamelFolder *folder, const gchar *message_uid, CamelMimeMessage *message, gpointer user_data, - CamelException *ex) + GError **error) { EMailReader *reader = user_data; EMailReaderPrivate *priv; @@ -1874,24 +1874,19 @@ mail_reader_message_loaded_cb (CamelFolder *folder, timeout_interval, (GSourceFunc) mail_reader_message_read_cb, reader); - } else if (camel_exception_is_set (ex)) { + } else if (error != NULL && *error != NULL) { gchar *string; - if (ex->id != CAMEL_EXCEPTION_OPERATION_IN_PROGRESS) { - /* Display the error inline and clear the exception. */ - string = g_strdup_printf ( - "<h2>%s</h2><p>%s</p>", - _("Unable to retrieve message"), - ex->desc); - } else { - string = g_strdup_printf ( - _("Retrieving message '%s'"), cursor_uid); - } + /* Display the error inline and clear the exception. */ + string = g_strdup_printf ( + "<h2>%s</h2><p>%s</p>", + _("Unable to retrieve message"), + (*error)->message); e_web_view_load_string (web_view, string); g_free (string); - camel_exception_clear (ex); + g_clear_error (error); } /* We referenced this in the call to mail_get_messagex(). */ diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index 3418404e06..6fd0c7ea82 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -303,17 +303,15 @@ e_mail_store_add_by_uri (const gchar *uri, { CamelService *service; CamelProvider *provider; - CamelException ex; + GError *local_error = NULL; g_return_val_if_fail (uri != NULL, NULL); g_return_val_if_fail (display_name != NULL, NULL); - camel_exception_init (&ex); - /* Load the service, but don't connect. Check its provider, * and if this belongs in the folder tree model, add it. */ - provider = camel_provider_get (uri, &ex); + provider = camel_provider_get (uri, &local_error); if (provider == NULL) goto fail; @@ -321,7 +319,7 @@ e_mail_store_add_by_uri (const gchar *uri, return NULL; service = camel_session_get_service ( - session, uri, CAMEL_PROVIDER_STORE, &ex); + session, uri, CAMEL_PROVIDER_STORE, &local_error); if (service == NULL) goto fail; @@ -335,8 +333,8 @@ fail: /* FIXME: Show an error dialog. */ g_warning ( "Couldn't get service: %s: %s", uri, - camel_exception_get_description (&ex)); - camel_exception_clear (&ex); + local_error->message); + g_error_free (local_error); return NULL; } diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 4a41217f3d..9cc0001de9 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -913,15 +913,15 @@ traverse_parts (GSList *clues, CamelMimeMessage *message, CamelDataWrapper *cont byte_array = g_byte_array_new (); stream = camel_stream_mem_new_with_byte_array (byte_array); - camel_data_wrapper_decode_to_stream (content, stream); + camel_data_wrapper_decode_to_stream (content, stream, NULL); str = g_strndup ((gchar *) byte_array->data, byte_array->len); g_object_unref (stream); if (replace_variables (clues, message, &str)) { stream = camel_stream_mem_new_with_buffer (str, strlen (str)); - camel_stream_reset (stream); - camel_data_wrapper_construct_from_stream (content, stream); + camel_stream_reset (stream, NULL); + camel_data_wrapper_construct_from_stream (content, stream, NULL); g_object_unref (stream); } @@ -1417,13 +1417,13 @@ em_utils_redirect_message_by_uid (CamelFolder *folder, const gchar *uid) } static void -emu_handle_receipt_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, CamelException *ex) +emu_handle_receipt_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, GError **error) { if (msg) em_utils_handle_receipt(folder, uid, msg); /* we dont care really if we can't get the message */ - camel_exception_clear(ex); + g_clear_error (error); } /* Message disposition notifications, rfc 2298 */ @@ -1541,7 +1541,7 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message) /* Translators: First %s is an email address, second %s is the subject of the email, third %s is the date */ _("Your message to %s about \"%s\" on %s has been read."), self_address, message_subject, message_date); - camel_data_wrapper_construct_from_stream (receipt_text, stream); + camel_data_wrapper_construct_from_stream (receipt_text, stream, NULL); g_object_unref (stream); part = camel_mime_part_new (); @@ -1569,7 +1569,7 @@ em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message) "Original-Message-ID: %s\n" "Disposition: manual-action/MDN-sent-manually; displayed\n", ua, recipient, message_id); - camel_data_wrapper_construct_from_stream (receipt_data, stream); + camel_data_wrapper_construct_from_stream (receipt_data, stream, NULL); g_object_unref (stream); g_free (ua); diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h index 1eb0d1bd30..1a8c48038b 100644 --- a/mail/em-composer-utils.h +++ b/mail/em-composer-utils.h @@ -47,7 +47,7 @@ void em_utils_forward_messages (CamelFolder *folder, GPtrArray *uids, const gcha void em_utils_redirect_message (CamelMimeMessage *message); void em_utils_redirect_message_by_uid (CamelFolder *folder, const gchar *uid); -void em_utils_forward_message_raw (CamelFolder *folder, CamelMimeMessage *message, const gchar *address, CamelException *ex); +void em_utils_forward_message_raw (CamelFolder *folder, CamelMimeMessage *message, const gchar *address, GError **error); void em_utils_handle_receipt (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg); void em_utils_send_receipt (CamelFolder *folder, CamelMimeMessage *message); diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 37552bb555..f91bc852b5 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -206,7 +206,6 @@ account_changed_cb (EAccountList *accounts, EMFolderTreeModelStoreInfo *si; CamelProvider *provider; CamelStore *store; - CamelException ex; gchar *uri; si = g_hash_table_lookup (model->priv->account_index, account); @@ -219,22 +218,17 @@ account_changed_cb (EAccountList *accounts, if (!account->enabled ||!(uri = account->source->url)) return; - camel_exception_init (&ex); - if (!(provider = camel_provider_get(uri, &ex))) { - camel_exception_clear (&ex); + if (!(provider = camel_provider_get(uri, NULL))) return; - } /* make sure the new store belongs in the tree */ if (!(provider->flags & CAMEL_PROVIDER_IS_STORAGE)) return; store = (CamelStore *) camel_session_get_service ( - session, uri, CAMEL_PROVIDER_STORE, &ex); - if (store == NULL) { - camel_exception_clear (&ex); + session, uri, CAMEL_PROVIDER_STORE, NULL); + if (store == NULL) return; - } em_folder_tree_model_add_store (model, store, account->name); g_object_unref (store); diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index e0bace6fae..e9c39d5a0c 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -191,7 +191,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.ex); + m->fi = camel_store_get_folder_info ( + m->store, m->top, flags, &m->base.error); } static void @@ -226,7 +227,7 @@ folder_tree_get_folder_info__done (struct _EMFolderTreeGetFolderInfo *m) gtk_tree_model_get_iter (model, &root, path); /* if we had an error, then we need to re-set the load subdirs state and collapse the node */ - if (!m->fi && camel_exception_is_set(&m->base.ex)) { + if (!m->fi && m->base.error != NULL) { gtk_tree_store_set( GTK_TREE_STORE (model), &root, COL_BOOL_LOAD_SUBDIRS, TRUE, -1); @@ -440,11 +441,9 @@ folder_tree_expand_node (const gchar *key, model = gtk_tree_view_get_model (tree_view); if ((account = e_get_account_by_uid (uid)) && account->enabled) { - CamelException ex; - - camel_exception_init (&ex); - store = (CamelStore *) camel_session_get_service (session, account->source->url, CAMEL_PROVIDER_STORE, &ex); - camel_exception_clear (&ex); + store = (CamelStore *) camel_session_get_service ( + session, account->source->url, + CAMEL_PROVIDER_STORE, NULL); if (store == NULL) return; @@ -552,7 +551,6 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, const gchar *new_name) { CamelFolderInfo *folder_info; - CamelException ex; CamelStore *store; GtkTreeView *tree_view; GtkTreeModel *model; @@ -564,13 +562,12 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, gchar **strv; gpointer parent; guint index; + GError *local_error = NULL; /* XXX Consider splitting this into separate async functions: * em_folder_tree_rename_folder_async() * em_folder_tree_rename_folder_finish() */ - camel_exception_init (&ex); - parent = gtk_widget_get_toplevel (GTK_WIDGET (folder_tree)); parent = gtk_widget_is_toplevel (parent) ? parent : NULL; @@ -608,7 +605,7 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, /* Check for duplicate folder name. */ folder_info = camel_store_get_folder_info ( - store, new_full_name, CAMEL_STORE_FOLDER_INFO_FAST, &ex); + store, new_full_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL); if (folder_info != NULL) { e_alert_run_dialog_for_args ( parent, "mail:no-rename-folder-exists", @@ -618,16 +615,17 @@ folder_tree_cell_edited_cb (EMFolderTree *folder_tree, } /* XXX This needs to be asynchronous. */ - camel_store_rename_folder (store, old_full_name, new_full_name, &ex); - if (camel_exception_is_set (&ex)) { + if (!camel_store_rename_folder ( + store, old_full_name, new_full_name, &local_error)) { e_alert_run_dialog_for_args ( parent, "mail:no-rename-folder", - old_full_name, new_full_name, ex.desc, NULL); + old_full_name, new_full_name, + local_error->message, NULL); + g_clear_error (&local_error); goto exit; } exit: - camel_exception_clear (&ex); g_free (old_name); g_free (old_full_name); @@ -1471,7 +1469,6 @@ tree_drag_data_delete (GtkWidget *widget, GtkTreePath *src_path; gboolean is_store; CamelStore *store; - CamelException ex; GtkTreeIter iter; if (!priv->drag_row || (src_path = gtk_tree_row_reference_get_path (priv->drag_row))) @@ -1491,10 +1488,8 @@ tree_drag_data_delete (GtkWidget *widget, if (is_store) goto fail; - camel_exception_init(&ex); - camel_store_delete_folder(store, full_name, &ex); - if (camel_exception_is_set(&ex)) - camel_exception_clear(&ex); + camel_store_delete_folder(store, full_name, NULL); + fail: gtk_tree_path_free(src_path); g_free (full_name); @@ -1514,7 +1509,6 @@ tree_drag_data_get (GtkWidget *widget, GtkTreePath *src_path; CamelFolder *folder; CamelStore *store; - CamelException ex; GtkTreeIter iter; if (!priv->drag_row || !(src_path = gtk_tree_row_reference_get_path(priv->drag_row))) @@ -1535,8 +1529,6 @@ tree_drag_data_get (GtkWidget *widget, if (full_name == NULL) goto fail; - camel_exception_init(&ex); - switch (info) { case DND_DRAG_TYPE_FOLDER: /* dragging to a new location in the folder tree */ @@ -1544,7 +1536,7 @@ 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, &ex))) { + if ((folder = camel_store_get_folder(store, full_name, 0, NULL))) { GPtrArray *uids = camel_folder_get_uids(folder); em_utils_selection_set_urilist(selection, folder, uids); @@ -1556,8 +1548,6 @@ tree_drag_data_get (GtkWidget *widget, abort(); } - if (camel_exception_is_set(&ex)) - camel_exception_clear(&ex); fail: gtk_tree_path_free(src_path); g_free (full_name); @@ -1597,7 +1587,7 @@ 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.ex))) + if (!(folder = mail_tool_uri_to_folder((gchar *)data, 0, &m->base.error))) return; full_name = camel_folder_get_full_name (folder); @@ -1648,14 +1638,15 @@ folder_tree_drop_async__exec (struct _DragDataReceivedAsync *m) /* copy or move (aka rename) a folder */ folder_tree_drop_folder(m); } else if (m->full_name == NULL) { - camel_exception_set (&m->base.ex, CAMEL_EXCEPTION_SYSTEM, - _("Cannot drop message(s) into toplevel store")); - } else if ((folder = camel_store_get_folder (m->store, m->full_name, 0, &m->base.ex))) { + g_set_error ( + &m->base.error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Cannot drop message(s) into toplevel store")); + } else if ((folder = camel_store_get_folder (m->store, m->full_name, 0, &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.ex); - m->moved = m->move && !camel_exception_is_set(&m->base.ex); + em_utils_selection_get_uidlist(m->selection, folder, m->move, &m->base.error); + m->moved = m->move && (m->base.error == NULL); break; case DND_DROP_TYPE_MESSAGE_RFC822: /* import a message/rfc822 stream */ @@ -2348,11 +2339,9 @@ em_folder_tree_set_selected_list (EMFolderTree *folder_tree, GList *list, gboole for (;list;list = list->next) { struct _selected_uri *u = g_malloc0(sizeof(*u)); CamelURL *url; - CamelException ex = { 0 }; u->uri = g_strdup(list->data); - u->store = (CamelStore *)camel_session_get_service (session, u->uri, CAMEL_PROVIDER_STORE, &ex); - camel_exception_clear(&ex); + u->store = (CamelStore *)camel_session_get_service (session, u->uri, CAMEL_PROVIDER_STORE, NULL); url = camel_url_new(u->uri, NULL); if (u->store == NULL || url == NULL) { @@ -2704,14 +2693,11 @@ em_folder_tree_get_selected_folder (EMFolderTree *folder_tree) GtkTreeModel *model; GtkTreeIter iter; gchar *full_name = NULL; - CamelException ex; CamelStore *store = NULL; CamelFolder *folder = NULL; g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), NULL); - camel_exception_init (&ex); - tree_view = GTK_TREE_VIEW (folder_tree); selection = gtk_tree_view_get_selection (tree_view); @@ -2720,9 +2706,8 @@ em_folder_tree_get_selected_folder (EMFolderTree *folder_tree) COL_STRING_FULL_NAME, &full_name, -1); if (store && full_name) - folder = camel_store_get_folder (store, full_name, CAMEL_STORE_FOLDER_INFO_FAST, &ex); - - camel_exception_clear (&ex); + folder = camel_store_get_folder ( + store, full_name, CAMEL_STORE_FOLDER_INFO_FAST, NULL); return folder; } @@ -2735,14 +2720,11 @@ em_folder_tree_get_selected_folder_info (EMFolderTree *folder_tree) GtkTreeModel *model; GtkTreeIter iter; gchar *full_name = NULL, *name = NULL, *uri = NULL; - CamelException ex; CamelStore *store = NULL; CamelFolderInfo *fi = NULL; g_return_val_if_fail (EM_IS_FOLDER_TREE (folder_tree), NULL); - camel_exception_init (&ex); - tree_view = GTK_TREE_VIEW (folder_tree); selection = gtk_tree_view_get_selection (tree_view); diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index ab810bfa30..c7fee4b27c 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -104,7 +104,9 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) const gchar *tmp; gint fromlen; - if (!(fi = camel_store_get_folder_info (m->fromstore, m->frombase, flags, &m->base.ex))) + fi = camel_store_get_folder_info ( + m->fromstore, m->frombase, flags, &m->base.error); + if (fi == NULL) return; pending = g_list_append (pending, fi); @@ -144,8 +146,10 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) if ((info->flags & CAMEL_FOLDER_NOSELECT) == 0) { d(printf ("this folder is selectable\n")); if (m->tostore == m->fromstore && m->delete) { - camel_store_rename_folder (m->fromstore, info->full_name, toname->str, &m->base.ex); - if (camel_exception_is_set (&m->base.ex)) + camel_store_rename_folder ( + m->fromstore, info->full_name, + toname->str, &m->base.error); + if (m->base.error != NULL) goto exception; /* this folder no longer exists, unsubscribe it */ @@ -154,19 +158,28 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) deleted = 1; } else { - if (!(fromfolder = camel_store_get_folder (m->fromstore, info->full_name, 0, &m->base.ex))) + fromfolder = camel_store_get_folder ( + m->fromstore, info->full_name, + 0, &m->base.error); + if (fromfolder == NULL) goto exception; - if (!(tofolder = camel_store_get_folder (m->tostore, toname->str, CAMEL_STORE_FOLDER_CREATE, &m->base.ex))) { + tofolder = camel_store_get_folder ( + m->tostore, toname->str, + CAMEL_STORE_FOLDER_CREATE, + &m->base.error); + if (tofolder == NULL) { g_object_unref (fromfolder); goto exception; } uids = camel_folder_get_uids (fromfolder); - camel_folder_transfer_messages_to (fromfolder, uids, tofolder, NULL, m->delete, &m->base.ex); + camel_folder_transfer_messages_to ( + fromfolder, uids, tofolder, + NULL, m->delete, &m->base.error); camel_folder_free_uids (fromfolder, uids); - if (m->delete && !camel_exception_is_set (&m->base.ex)) + if (m->delete && m->base.error == NULL) camel_folder_sync(fromfolder, TRUE, NULL); g_object_unref (fromfolder); @@ -174,7 +187,7 @@ emft_copy_folders__exec (struct _EMCopyFolders *m) } } - if (camel_exception_is_set (&m->base.ex)) + if (m->base.error != NULL) goto exception; else if (m->delete && !deleted) deleting = g_list_prepend (deleting, info); @@ -265,21 +278,25 @@ emfu_copy_folder_selected (const gchar *uri, gpointer data) CamelStore *fromstore = NULL, *tostore = NULL; CamelStore *local_store; const gchar *tobase = NULL; - CamelException ex; CamelURL *url; + GError *local_error = NULL; if (uri == NULL) { g_free (cfd); return; } - camel_exception_init (&ex); - local_store = e_mail_local_get_store (); - if (!(fromstore = camel_session_get_store (session, cfd->fi->uri, &ex))) { - e_alert_run_dialog_for_args (e_shell_get_active_window (NULL), - cfd->delete?"mail:no-move-folder-notexist":"mail:no-copy-folder-notexist", cfd->fi->full_name, uri, ex.desc, NULL); + fromstore = camel_session_get_store ( + session, cfd->fi->uri, &local_error); + if (fromstore == NULL) { + e_alert_run_dialog_for_args ( + e_shell_get_active_window (NULL), + cfd->delete ? "mail:no-move-folder-notexist" : + "mail:no-copy-folder-notexist", + cfd->fi->full_name, uri, + local_error->message, NULL); goto fail; } @@ -293,9 +310,14 @@ emfu_copy_folder_selected (const gchar *uri, gpointer data) goto fail; } - if (!(tostore = camel_session_get_store (session, uri, &ex))) { - e_alert_run_dialog_for_args (e_shell_get_active_window (NULL), - cfd->delete?"mail:no-move-folder-to-notexist":"mail:no-copy-folder-to-notexist", cfd->fi->full_name, uri, ex.desc, NULL); + tostore = camel_session_get_store (session, uri, &local_error); + if (tostore == NULL) { + e_alert_run_dialog_for_args ( + e_shell_get_active_window (NULL), + cfd->delete ? "mail:no-move-folder-to-notexist" : + "mail:no-copy-folder-to-notexist", + cfd->fi->full_name, uri, + local_error->message, NULL); goto fail; } @@ -315,7 +337,9 @@ fail: g_object_unref (fromstore); if (tostore) g_object_unref (tostore); - camel_exception_clear (&ex); + + g_clear_error (&local_error); + g_free (cfd); } @@ -395,20 +419,20 @@ em_folder_utils_copy_folder (GtkWindow *parent, } static void -emfu_delete_done (CamelFolder *folder, gboolean removed, CamelException *ex, gpointer data) +emfu_delete_done (CamelFolder *folder, gboolean removed, GError **error, gpointer data) { GtkWidget *dialog = data; - if (ex && camel_exception_is_set (ex)) { + if (error != NULL && *error != NULL) { GtkWidget *w; w = e_alert_dialog_new_for_args ( e_shell_get_active_window (NULL), "mail:no-delete-folder", camel_folder_get_full_name (folder), - camel_exception_get_description (ex), NULL); + (*error)->message, NULL); em_utils_show_error_silent (w); - camel_exception_clear (ex); + g_clear_error (error); } if (dialog) @@ -514,9 +538,9 @@ 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.ex))) { + if ((m->fi = camel_store_create_folder (m->store, m->parent, m->name, &m->base.error))) { if (camel_store_supports_subscriptions (m->store)) - camel_store_subscribe_folder (m->store, m->full_name, &m->base.ex); + camel_store_subscribe_folder (m->store, m->full_name, &m->base.error); } } @@ -601,7 +625,6 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, gint response, gpointer EMFolderTreeModelStoreInfo *si; GtkTreeModel *model; const gchar *uri, *path; - CamelException ex; CamelStore *store; struct _EMCreateFolderTempData *emcftd; @@ -617,11 +640,10 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, gint response, gpointer g_print ("DEBUG: %s (%s)\n", path, uri); - camel_exception_init (&ex); - if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) { - camel_exception_clear (&ex); + store = (CamelStore *) camel_session_get_service ( + session, uri, CAMEL_PROVIDER_STORE, NULL); + if (store == NULL) return; - } model = gtk_tree_view_get_model (GTK_TREE_VIEW (emfs->emft)); si = em_folder_tree_model_lookup_store_info ( @@ -654,7 +676,6 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, gint response, gpointer } g_object_unref (store); - camel_exception_clear (&ex); } /* FIXME: these functions must be documented */ @@ -702,7 +723,7 @@ emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg) gint url_flags; store = camel_session_get_store ( - session, msg->folder_uri, &msg->base.ex); + session, msg->folder_uri, &msg->base.error); if (store == NULL) return; @@ -715,7 +736,7 @@ emfu_unsubscribe_folder__exec (struct _folder_unsub_t *msg) path = url->path + 1; if (path != NULL) - camel_store_unsubscribe_folder (store, path, &msg->base.ex); + camel_store_unsubscribe_folder (store, path, &msg->base.error); camel_url_free (url); } diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index db13260157..d49d797de4 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -426,14 +426,14 @@ efhd_format_attachment (EMFormat *emf, stream, EM_FORMAT_HTML_VPAD "<table cellspacing=0 cellpadding=0><tr><td>" "<table width=10 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td>"); + "<tr><td></td></tr></table></td>", NULL); camel_stream_printf ( stream, "<td><object classid=\"%s\"></object></td>", classid); camel_stream_write_string ( stream, "<td><table width=3 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td><td><font size=-1>"); + "<tr><td></td></tr></table></td><td><font size=-1>", NULL); /* output some info about it */ /* FIXME: should we look up mime_type from object again? */ @@ -441,13 +441,13 @@ efhd_format_attachment (EMFormat *emf, html = camel_text_to_html ( text, EM_FORMAT_HTML (emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string (stream, html); + camel_stream_write_string (stream, html, NULL); g_free (html); g_free (text); camel_stream_write_string ( stream, "</font></td></tr><tr></table>\n" - EM_FORMAT_HTML_VPAD); + EM_FORMAT_HTML_VPAD, NULL); if (handle && info->shown) handle->handler (emf, stream, part, handle, FALSE); @@ -491,7 +491,7 @@ efhd_format_optional (EMFormat *emf, camel_stream_write_string ( stream, EM_FORMAT_HTML_VPAD "<table cellspacing=0 cellpadding=0><tr><td>" - "<h3><font size=-1 color=red>"); + "<h3><font size=-1 color=red>", NULL); html = camel_text_to_html ( _("Evolution cannot render this email as it is too " @@ -499,19 +499,18 @@ efhd_format_optional (EMFormat *emf, "with an external text editor."), EM_FORMAT_HTML (emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string (stream, html); + camel_stream_write_string (stream, html, NULL); camel_stream_write_string ( - stream, "</font></h3></td></tr></table>\n"); + stream, "</font></h3></td></tr></table>\n", NULL); camel_stream_write_string ( - stream, "<table cellspacing=0 cellpadding=0><tr>"); + stream, "<table cellspacing=0 cellpadding=0><tr>", NULL); camel_stream_printf ( stream, "<td><object classid=\"%s\"></object>" "</td></tr></table>", classid); g_free(html); - camel_stream_write_string ( - stream, EM_FORMAT_HTML_VPAD); + camel_stream_write_string (stream, EM_FORMAT_HTML_VPAD, NULL); g_free (classid); } @@ -681,8 +680,8 @@ efhd_write_image(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) /* TODO: identical to efh_write_image */ d(printf("writing image '%s'\n", puri->cid)); - camel_data_wrapper_decode_to_stream(dw, stream); - camel_stream_close(stream); + camel_data_wrapper_decode_to_stream(dw, stream, NULL); + camel_stream_close(stream, NULL); } static void @@ -869,7 +868,7 @@ efhd_attachment_frame (EMFormat *emf, info->handle->handler ( emf, stream, info->puri.part, info->handle, FALSE); - camel_stream_close (stream); + camel_stream_close (stream, NULL); } static void diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 5454394e49..c63ed28085 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -204,7 +204,7 @@ efh_format_exec (struct _format_msg *m) (CamelMimePart *) m->message, handle, FALSE); } - camel_stream_flush((CamelStream *)m->estream); + camel_stream_flush((CamelStream *)m->estream, NULL); puri_level = format->pending_uri_level; base = format->base; @@ -244,8 +244,10 @@ efh_format_exec (struct _format_msg *m) /* Closing this base stream can queue more jobs, so we need to check the list again after we've finished */ d(printf("out of jobs, closing root stream\n")); - camel_stream_write_string((CamelStream *)m->estream, "</body>\n</html>\n"); - camel_stream_close((CamelStream *)m->estream); + camel_stream_write_string ( + (CamelStream *) m->estream, + "</body>\n</html>\n", NULL); + camel_stream_close((CamelStream *)m->estream, NULL); g_object_unref (m->estream); m->estream = NULL; } @@ -274,7 +276,7 @@ efh_format_free (struct _format_msg *m) d(printf("formatter freed\n")); g_object_unref(m->format); if (m->estream) { - camel_stream_close((CamelStream *)m->estream); + camel_stream_close((CamelStream *)m->estream, NULL); g_object_unref (m->estream); } if (m->folder) @@ -695,11 +697,11 @@ efh_format_source (EMFormat *emf, CAMEL_STREAM_FILTER (filtered_stream), filter); g_object_unref (filter); - camel_stream_write_string (stream, "<table><tr><td><tt>"); + camel_stream_write_string (stream, "<table><tr><td><tt>", NULL); em_format_format_text (emf, (CamelStream *) filtered_stream, dw); g_object_unref (filtered_stream); - camel_stream_write_string(stream, "</tt></td></tr></table>"); + camel_stream_write_string(stream, "</tt></td></tr></table>", NULL); } static void @@ -720,18 +722,20 @@ efh_format_attachment (EMFormat *emf, "<table width=10 cellspacing=0 cellpadding=0>" "<tr><td></td></tr></table></td>" "<td><table width=3 cellspacing=0 cellpadding=0>" - "<tr><td></td></tr></table></td><td><font size=-1>\n"); + "<tr><td></td></tr></table></td><td><font size=-1>\n", + NULL); /* output some info about it */ text = em_format_describe_part(part, mime_type); html = camel_text_to_html ( text, ((EMFormatHTML *)emf)->text_html_flags & CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS, 0); - camel_stream_write_string (stream, html); + camel_stream_write_string (stream, html, NULL); g_free (html); g_free (text); - camel_stream_write_string (stream, "</font></td></tr><tr></table>"); + camel_stream_write_string ( + stream, "</font></td></tr><tr></table>", NULL); if (handle && em_format_is_inline (emf, emf->part_id->str, part, handle)) handle->handler (emf, stream, part, handle, FALSE); @@ -1215,12 +1219,12 @@ em_format_html_file_part(EMFormatHTML *efh, const gchar *mime_type, const gchar CamelDataWrapper *dw; gchar *basename; - stream = camel_stream_fs_new_with_name(filename, O_RDONLY, 0); + stream = camel_stream_fs_new_with_name(filename, O_RDONLY, 0, NULL); if (stream == NULL) return NULL; dw = camel_data_wrapper_new(); - camel_data_wrapper_construct_from_stream(dw, stream); + camel_data_wrapper_construct_from_stream(dw, stream, NULL); g_object_unref (stream); if (mime_type) camel_data_wrapper_set_mime_type(dw, mime_type); @@ -1436,7 +1440,7 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, gint cancelled) break; } /* FIXME: progress reporting in percentage, can we get the length always? do we care? */ - n = camel_stream_read(instream, buffer, sizeof (buffer)); + n = camel_stream_read(instream, buffer, sizeof (buffer), NULL); if (n > 0) { nread += n; /* If we didn't get a valid Content-Length header, do not try to calculate percentage */ @@ -1445,18 +1449,18 @@ static void emfh_gethttp(struct _EMFormatHTMLJob *job, gint cancelled) camel_operation_progress(NULL, pc_complete); } d(printf(" read %d bytes\n", n)); - if (costream && camel_stream_write (costream, buffer, n) == -1) { + if (costream && camel_stream_write (costream, buffer, n, NULL) == -1) { n = -1; break; } - camel_stream_write(job->stream, buffer, n); + camel_stream_write(job->stream, buffer, n, NULL); } } while (n>0); /* indicates success */ if (n == 0) - camel_stream_close(job->stream); + camel_stream_close(job->stream, NULL); if (costream) { /* do not store broken files in a cache */ @@ -1709,8 +1713,9 @@ efh_text_plain (EMFormatHTML *efh, camel_stream_filter_add ( CAMEL_STREAM_FILTER (filtered_stream), CAMEL_MIME_FILTER (inline_filter)); - camel_data_wrapper_decode_to_stream (dw, (CamelStream *)filtered_stream); - camel_stream_close((CamelStream *)filtered_stream); + camel_data_wrapper_decode_to_stream ( + dw, (CamelStream *)filtered_stream, NULL); + camel_stream_close((CamelStream *)filtered_stream, NULL); g_object_unref (filtered_stream); mp = em_inline_filter_get_multipart(inline_filter); @@ -1753,11 +1758,12 @@ efh_text_plain (EMFormatHTML *efh, e_color_to_value ( &efh->priv->colors[ EM_FORMAT_HTML_COLOR_TEXT])); - camel_stream_write_string(stream, "<tt>\n" EFH_MESSAGE_START); + camel_stream_write_string ( + stream, "<tt>\n" EFH_MESSAGE_START, NULL); em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)newpart); - camel_stream_flush((CamelStream *)filtered_stream); - camel_stream_write_string(stream, "</tt>\n"); - camel_stream_write_string(stream, "</div>\n"); + camel_stream_flush((CamelStream *)filtered_stream, NULL); + camel_stream_write_string (stream, "</tt>\n", NULL); + camel_stream_write_string (stream, "</div>\n", NULL); } else { g_string_append_printf(((EMFormat *)efh)->part_id, ".inline.%d", i); em_format_part((EMFormat *)efh, stream, newpart); @@ -1777,9 +1783,11 @@ efh_text_enriched(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, E if (!strcmp(info->mime_type, "text/richtext")) { flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT; - camel_stream_write_string( stream, "\n<!-- text/richtext -->\n"); + camel_stream_write_string ( + stream, "\n<!-- text/richtext -->\n", NULL); } else { - camel_stream_write_string( stream, "\n<!-- text/enriched -->\n"); + camel_stream_write_string ( + stream, "\n<!-- text/enriched -->\n", NULL); } enriched = camel_mime_filter_enriched_new(flags); @@ -1803,7 +1811,7 @@ efh_text_enriched(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, E em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)part); g_object_unref (filtered_stream); - camel_stream_write_string(stream, "</div>"); + camel_stream_write_string (stream, "</div>", NULL); } static void @@ -1997,19 +2005,19 @@ efh_message_deliverystatus(EMFormatHTML *efh, CamelStream *stream, CamelMimePart CAMEL_STREAM_FILTER (filtered_stream), html_filter); g_object_unref (html_filter); - camel_stream_write_string(stream, "<tt>\n" EFH_MESSAGE_START); + camel_stream_write_string (stream, "<tt>\n" EFH_MESSAGE_START, NULL); em_format_format_text((EMFormat *)efh, (CamelStream *)filtered_stream, (CamelDataWrapper *)part); - camel_stream_flush((CamelStream *)filtered_stream); - camel_stream_write_string(stream, "</tt>\n"); + camel_stream_flush((CamelStream *)filtered_stream, NULL); + camel_stream_write_string (stream, "</tt>\n", NULL); - camel_stream_write_string(stream, "</div>"); + camel_stream_write_string (stream, "</div>", NULL); } static void emfh_write_related(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) { em_format_format_content(emf, stream, puri->part); - camel_stream_close(stream); + camel_stream_close(stream, NULL); } static void @@ -2120,7 +2128,7 @@ efh_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c g_string_append_printf(emf->part_id, "related.%d", displayid); em_format_part(emf, stream, display_part); g_string_truncate(emf->part_id, partidlen); - camel_stream_flush(stream); + 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); @@ -2137,8 +2145,8 @@ efh_write_image(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) CamelDataWrapper *dw = camel_medium_get_content ((CamelMedium *)puri->part); d(printf("writing image '%s'\n", puri->cid)); - camel_data_wrapper_decode_to_stream(dw, stream); - camel_stream_close(stream); + camel_data_wrapper_decode_to_stream(dw, stream, NULL); + camel_stream_close(stream, NULL); } static void diff --git a/mail/em-html-stream.c b/mail/em-html-stream.c index d86e2a3cb4..f74ba8d98b 100644 --- a/mail/em-html-stream.c +++ b/mail/em-html-stream.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <gtk/gtk.h> +#include <glib/gi18n-lib.h> #include "em-html-stream.h" #define d(x) @@ -63,19 +64,24 @@ html_stream_dispose (GObject *object) if (emhs->html_stream) { /* set 'in finalise' flag */ - camel_stream_close (CAMEL_STREAM (emhs)); + camel_stream_close (CAMEL_STREAM (emhs), NULL); } } static gssize html_stream_sync_write (CamelStream *stream, const gchar *buffer, - gsize n) + gsize n, + GError **error) { EMHTMLStream *emhs = EM_HTML_STREAM (stream); - if (emhs->html == NULL) + if (emhs->html == NULL) { + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("No HTML stream available")); return -1; + } if (emhs->html_stream == NULL) emhs->html_stream = gtk_html_begin_full ( @@ -87,12 +93,17 @@ html_stream_sync_write (CamelStream *stream, } static gint -html_stream_sync_flush (CamelStream *stream) +html_stream_sync_flush (CamelStream *stream, + GError **error) { EMHTMLStream *emhs = (EMHTMLStream *)stream; - if (emhs->html_stream == NULL) + if (emhs->html_stream == NULL) { + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("No HTML stream available")); return -1; + } gtk_html_flush (emhs->html); @@ -100,12 +111,17 @@ html_stream_sync_flush (CamelStream *stream) } static gint -html_stream_sync_close (CamelStream *stream) +html_stream_sync_close (CamelStream *stream, + GError **error) { EMHTMLStream *emhs = (EMHTMLStream *)stream; - if (emhs->html_stream == NULL) + if (emhs->html_stream == NULL) { + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("No HTML stream available")); return -1; + } gtk_html_stream_close (emhs->html_stream, GTK_HTML_STREAM_OK); html_stream_cleanup (emhs); diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c index c142ca28b1..b780256e2b 100644 --- a/mail/em-inline-filter.c +++ b/mail/em-inline-filter.c @@ -92,12 +92,12 @@ inline_filter_add_part(EMInlineFilter *emif, const gchar *data, gint len) camel_stream_filter_add (CAMEL_STREAM_FILTER (filter_stream), enc_filter); /* properly encode content */ - camel_data_wrapper_construct_from_stream (dw, filter_stream); + camel_data_wrapper_construct_from_stream (dw, filter_stream, NULL); g_object_unref (enc_filter); g_object_unref (filter_stream); } else { - camel_data_wrapper_construct_from_stream (dw, mem); + camel_data_wrapper_construct_from_stream (dw, mem, NULL); } g_object_unref (mem); diff --git a/mail/em-subscribe-editor.c b/mail/em-subscribe-editor.c index 8152974f32..ceeb770128 100644 --- a/mail/em-subscribe-editor.c +++ b/mail/em-subscribe-editor.c @@ -266,9 +266,13 @@ static void sub_folder_exec (struct _zsubscribe_msg *m) { if (m->subscribe) - camel_store_subscribe_folder (m->sub->store, m->node->info->full_name, &m->base.ex); + camel_store_subscribe_folder ( + m->sub->store, m->node->info->full_name, + &m->base.error); else - camel_store_unsubscribe_folder (m->sub->store, m->node->info->full_name, &m->base.ex); + camel_store_unsubscribe_folder ( + m->sub->store, m->node->info->full_name, + &m->base.error); } static void @@ -285,7 +289,7 @@ sub_folder_done (struct _zsubscribe_msg *m) if (m->sub->cancel) return; - if (!camel_exception_is_set(&m->base.ex)) { + if (m->base.error == NULL) { if (m->subscribe) m->node->info->flags |= CAMEL_FOLDER_SUBSCRIBED; else @@ -451,7 +455,12 @@ 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.ex); + 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.cancel); } } @@ -463,10 +472,10 @@ sub_folderinfo_done (struct _emse_folderinfo_msg *m) if (m->sub->cancel || m->seq != m->sub->seq) return; - if (camel_exception_is_set (&m->base.ex)) { - g_warning ("Error getting folder info from store: %s", - camel_exception_get_description (&m->base.ex)); - } + if (m->base.error != NULL) + g_warning ( + "Error getting folder info from store: %s", + m->base.error->message); if (m->info) { if (m->node) { diff --git a/mail/em-sync-stream.c b/mail/em-sync-stream.c index d0dd6e7853..238ccf0452 100644 --- a/mail/em-sync-stream.c +++ b/mail/em-sync-stream.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <string.h> +#include <glib/gi18n-lib.h> #include <libedataserver/e-flag.h> #include "mail-mt.h" @@ -41,6 +42,7 @@ enum _write_msg_t { struct _write_msg { EMSyncStream *emss; + GError *error; EFlag *done; enum _write_msg_t op; @@ -67,22 +69,23 @@ sync_stream_process_message (struct _write_msg *msg) if (emss->buffer != NULL && emss->buffer->len > 0) { EM_SYNC_STREAM_GET_CLASS (emss)->sync_write ( CAMEL_STREAM (emss), emss->buffer->str, - emss->buffer->len); + emss->buffer->len, &msg->error); g_string_set_size (emss->buffer, 0); } switch (msg->op) { case EMSS_WRITE: EM_SYNC_STREAM_GET_CLASS (emss)->sync_write ( - CAMEL_STREAM (emss), msg->string, msg->len); + CAMEL_STREAM (emss), msg->string, + msg->len, &msg->error); break; case EMSS_FLUSH: EM_SYNC_STREAM_GET_CLASS (emss)->sync_flush ( - CAMEL_STREAM (emss)); + CAMEL_STREAM (emss), &msg->error); break; case EMSS_CLOSE: EM_SYNC_STREAM_GET_CLASS (emss)->sync_close ( - CAMEL_STREAM (emss)); + CAMEL_STREAM (emss), &msg->error); break; } @@ -93,12 +96,16 @@ sync_stream_process_message (struct _write_msg *msg) } static void -sync_stream_sync_op (EMSyncStream *emss, enum _write_msg_t op, - const gchar *string, gsize len) +sync_stream_sync_op (EMSyncStream *emss, + enum _write_msg_t op, + const gchar *string, + gsize len, + GError **error) { struct _write_msg msg; msg.done = e_flag_new (); + msg.error = NULL; msg.emss = emss; msg.op = op; msg.string = string; @@ -113,6 +120,9 @@ sync_stream_sync_op (EMSyncStream *emss, enum _write_msg_t op, e_flag_wait (msg.done); e_flag_free (msg.done); + if (msg.error != NULL) + g_propagate_error (error, msg.error); + g_object_unref (emss); } @@ -128,57 +138,74 @@ sync_stream_finalize (GObject *object) } static gssize -sync_stream_write (CamelStream *stream, const gchar *string, gsize len) +sync_stream_write (CamelStream *stream, + const gchar *string, + gsize len, + GError **error) { EMSyncStream *emss = EM_SYNC_STREAM (stream); - if (emss->cancel) + if (emss->cancel) { + g_set_error ( + error, G_IO_ERROR, G_IO_ERROR_CANCELLED, + _("Canceled")); return -1; + } if (mail_in_main_thread ()) { - EM_SYNC_STREAM_GET_CLASS (emss)->sync_write (stream, string, len); + EM_SYNC_STREAM_GET_CLASS (emss)->sync_write (stream, string, len, error); } else if (emss->buffer != NULL) { if (len < (emss->buffer->allocated_len - emss->buffer->len)) g_string_append_len (emss->buffer, string, len); else - sync_stream_sync_op (emss, EMSS_WRITE, string, len); + sync_stream_sync_op (emss, EMSS_WRITE, string, len, error); } else { - sync_stream_sync_op(emss, EMSS_WRITE, string, len); + sync_stream_sync_op(emss, EMSS_WRITE, string, len, error); } return (gssize) len; } static gint -sync_stream_flush (CamelStream *stream) +sync_stream_flush (CamelStream *stream, + GError **error) { EMSyncStream *emss = EM_SYNC_STREAM (stream); - if (emss->cancel) + if (emss->cancel) { + g_set_error ( + error, G_IO_ERROR, G_IO_ERROR_CANCELLED, + _("Canceled")); return -1; + } if (mail_in_main_thread ()) - return EM_SYNC_STREAM_GET_CLASS (emss)->sync_flush (stream); + return EM_SYNC_STREAM_GET_CLASS (emss)->sync_flush (stream, error); else - sync_stream_sync_op (emss, EMSS_FLUSH, NULL, 0); + sync_stream_sync_op (emss, EMSS_FLUSH, NULL, 0, error); return 0; } static gint -sync_stream_close (CamelStream *stream) +sync_stream_close (CamelStream *stream, + GError **error) { EMSyncStream *emss = EM_SYNC_STREAM (stream); - if (emss->cancel) + if (emss->cancel) { + g_set_error ( + error, G_IO_ERROR, G_IO_ERROR_CANCELLED, + _("Canceled")); return -1; + } emss->idle_id = 0; if (mail_in_main_thread ()) - return EM_SYNC_STREAM_GET_CLASS (emss)->sync_close (stream); + return EM_SYNC_STREAM_GET_CLASS (emss)->sync_close (stream, error); else - sync_stream_sync_op (emss, EMSS_CLOSE, NULL, 0); + sync_stream_sync_op (emss, EMSS_CLOSE, NULL, 0, error); return 0; } diff --git a/mail/em-sync-stream.h b/mail/em-sync-stream.h index 593079021e..806d79d55a 100644 --- a/mail/em-sync-stream.h +++ b/mail/em-sync-stream.h @@ -69,9 +69,12 @@ struct _EMSyncStreamClass { gssize (*sync_write) (CamelStream *stream, const gchar *string, - gsize len); - gint (*sync_close) (CamelStream *stream); - gint (*sync_flush) (CamelStream *stream); + gsize len, + GError **error); + gint (*sync_close) (CamelStream *stream, + GError **error); + gint (*sync_flush) (CamelStream *stream, + GError **error); }; GType em_sync_stream_get_type (void); diff --git a/mail/em-utils.c b/mail/em-utils.c index 1e40087f18..aa147bf7e1 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -567,10 +567,10 @@ em_utils_write_messages_to_stream(CamelFolder *folder, GPtrArray *uids, CamelStr /* we need to flush after each stream write since we are writing to the same stream */ from = camel_mime_message_build_mbox_from(message); - if (camel_stream_write_string(stream, from) == -1 - || camel_stream_flush(stream) == -1 - || camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, (CamelStream *)filtered_stream) == -1 - || camel_stream_flush((CamelStream *)filtered_stream) == -1) + if (camel_stream_write_string(stream, from, NULL) == -1 + || camel_stream_flush(stream, NULL) == -1 + || camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, (CamelStream *)filtered_stream, NULL) == -1 + || camel_stream_flush((CamelStream *)filtered_stream, NULL) == -1) res = -1; g_free(from); @@ -590,38 +590,36 @@ em_utils_write_messages_to_stream(CamelFolder *folder, GPtrArray *uids, CamelStr static gint em_utils_read_messages_from_stream(CamelFolder *folder, CamelStream *stream) { - CamelException *ex = camel_exception_new(); CamelMimeParser *mp = camel_mime_parser_new(); - gint res = -1; + gboolean success = TRUE; camel_mime_parser_scan_from(mp, TRUE); - camel_mime_parser_init_with_stream(mp, stream); + camel_mime_parser_init_with_stream(mp, stream, NULL); while (camel_mime_parser_step(mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) { CamelMimeMessage *msg; + gboolean success; /* NB: de-from filter, once written */ msg = camel_mime_message_new(); - if (camel_mime_part_construct_from_parser((CamelMimePart *)msg, mp) == -1) { + if (camel_mime_part_construct_from_parser((CamelMimePart *)msg, mp, NULL) == -1) { g_object_unref (msg); break; } - camel_folder_append_message(folder, msg, NULL, NULL, ex); + success = camel_folder_append_message ( + folder, msg, NULL, NULL, NULL); g_object_unref (msg); - if (camel_exception_is_set (ex)) + if (!success) break; camel_mime_parser_step(mp, NULL, NULL); } g_object_unref (mp); - if (!camel_exception_is_set(ex)) - res = 0; - camel_exception_free(ex); - return res; + return success ? 0 : -1; } /** @@ -700,7 +698,6 @@ em_utils_selection_get_message (GtkSelectionData *selection_data, CamelFolder *folder) { CamelStream *stream; - CamelException *ex; CamelMimeMessage *msg; const guchar *data; gint length; @@ -711,15 +708,13 @@ em_utils_selection_get_message (GtkSelectionData *selection_data, if (data == NULL || length == -1) return; - ex = camel_exception_new(); stream = (CamelStream *) camel_stream_mem_new_with_buffer ((gchar *)data, length); msg = camel_mime_message_new(); - if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) == 0) - camel_folder_append_message(folder, msg, NULL, NULL, ex); + if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream, NULL) == 0) + camel_folder_append_message(folder, msg, NULL, NULL, NULL); g_object_unref (msg); g_object_unref (stream); - camel_exception_free(ex); } /** @@ -767,7 +762,7 @@ void em_utils_selection_get_uidlist (GtkSelectionData *selection_data, CamelFolder *dest, gint move, - CamelException *ex) + GError **error) { /* format: "uri\0uid1\0uid2\0uid3\0...\0uidn" */ gchar *inptr, *inend; @@ -805,9 +800,9 @@ em_utils_selection_get_uidlist (GtkSelectionData *selection_data, return; } - folder = mail_tool_uri_to_folder((gchar *) data, 0, ex); + folder = mail_tool_uri_to_folder((gchar *) data, 0, error); if (folder) { - camel_folder_transfer_messages_to(folder, uids, dest, NULL, move, ex); + camel_folder_transfer_messages_to(folder, uids, dest, NULL, move, error); g_object_unref (folder); } @@ -1280,9 +1275,9 @@ em_utils_message_to_html (CamelMimeMessage *message, const gchar *credits, guint g_object_unref (emfq); if (append && *append) - camel_stream_write ((CamelStream*)mem, append, strlen (append)); + camel_stream_write ((CamelStream*)mem, append, strlen (append), NULL); - camel_stream_write((CamelStream *)mem, "", 1); + camel_stream_write((CamelStream *)mem, "", 1, NULL); g_object_unref (mem); text = (gchar *)buf->data; @@ -1331,13 +1326,10 @@ em_utils_empty_trash (GtkWidget *parent) EAccountList *accounts; EAccount *account; EIterator *iter; - CamelException ex; if (!em_utils_prompt_user((GtkWindow *) parent, "/apps/evolution/mail/prompts/empty_trash", "mail:ask-empty-trash", NULL)) return; - camel_exception_init (&ex); - accounts = e_get_account_list (); iter = e_list_get_iterator ((EList *) accounts); while (e_iterator_is_valid (iter)) { @@ -1345,16 +1337,13 @@ em_utils_empty_trash (GtkWidget *parent) /* make sure this is a valid source */ if (account->enabled && account->source->url) { - provider = camel_provider_get(account->source->url, &ex); + provider = camel_provider_get(account->source->url, NULL); if (provider) { /* make sure this store is a remote store */ if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) { mail_empty_trash (account, NULL, NULL); } } - - /* clear the exception for the next round */ - camel_exception_clear (&ex); } e_iterator_next (iter); @@ -1406,22 +1395,18 @@ gchar *em_uri_from_camel(const gchar *curi) const gchar *uid, *path; gchar *euri, *tmp; CamelProvider *provider; - CamelException ex; /* Easiest solution to code that shouldnt be calling us */ if (!strncmp(curi, "email:", 6)) return g_strdup(curi); - camel_exception_init(&ex); - provider = camel_provider_get(curi, &ex); + provider = camel_provider_get(curi, NULL); if (provider == NULL) { - camel_exception_clear(&ex); d(printf("em uri from camel failed '%s'\n", curi)); return g_strdup(curi); } - curl = camel_url_new(curi, &ex); - camel_exception_clear(&ex); + curl = camel_url_new(curi, NULL); if (curl == NULL) return g_strdup(curi); @@ -1457,7 +1442,6 @@ gchar *em_uri_to_camel(const gchar *euri) EAccountService *service; CamelProvider *provider; CamelURL *eurl, *curl; - CamelException ex = CAMEL_EXCEPTION_INITIALISER; gchar *uid, *curi; if (strncmp(euri, "email:", 6) != 0) { @@ -1518,11 +1502,9 @@ gchar *em_uri_to_camel(const gchar *euri) } service = account->source; - if (!(provider = camel_provider_get (service->url, &ex))) { - camel_exception_clear (&ex); + provider = camel_provider_get (service->url, NULL); + if (provider == NULL) return g_strdup (euri); - } - camel_exception_clear (&ex); curl = camel_url_new(service->url, NULL); if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH) diff --git a/mail/em-utils.h b/mail/em-utils.h index 1fde390d72..ac1f1a0928 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, CamelException *ex); +void em_utils_selection_get_uidlist(GtkSelectionData *data, CamelFolder *dest, gint move, 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/elm-importer.c b/mail/importers/elm-importer.c index 937bfa50de..87c94ff524 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -205,7 +205,7 @@ elm_import_done(struct _elm_import_msg *m) { printf("importing complete\n"); - if (!camel_exception_is_set(&m->base.ex)) { + if (m->base.error == NULL) { GConfClient *gconf; gconf = gconf_client_get_default(); diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index dc419dc89e..8467f2c47f 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -204,7 +204,7 @@ mbox_status_timeout(gpointer data) } static void -mbox_import_done(gpointer data, CamelException *ex) +mbox_import_done(gpointer data, GError **error) { MboxImporter *importer = data; @@ -330,7 +330,7 @@ mbox_get_preview (EImport *ei, EImportTarget *target, EImportImporter *im) gchar *from; msg = camel_mime_message_new(); - if (camel_mime_part_construct_from_parser ((CamelMimePart *)msg, mp) == -1) { + if (camel_mime_part_construct_from_parser ((CamelMimePart *)msg, mp, NULL) == -1) { g_object_unref (msg); break; } diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c index 35abd8365f..7c497108b1 100644 --- a/mail/importers/mail-importer.c +++ b/mail/importers/mail-importer.c @@ -54,7 +54,7 @@ struct _import_mbox_msg { gchar *uri; CamelOperation *cancel; - void (*done)(gpointer data, CamelException *ex); + void (*done)(gpointer data, GError **error); gpointer done_data; }; @@ -122,7 +122,8 @@ import_mbox_exec (struct _import_mbox_msg *m) if (m->uri == NULL || m->uri[0] == 0) 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.ex); + folder = mail_tool_uri_to_folder ( + m->uri, CAMEL_STORE_FOLDER_CREATE, &m->base.error); if (folder == NULL) return; @@ -160,7 +161,7 @@ import_mbox_exec (struct _import_mbox_msg *m) camel_operation_progress(NULL, pc); msg = camel_mime_message_new(); - if (camel_mime_part_construct_from_parser((CamelMimePart *)msg, mp) == -1) { + if (camel_mime_part_construct_from_parser((CamelMimePart *)msg, mp, NULL) == -1) { /* set exception? */ g_object_unref (msg); break; @@ -179,11 +180,12 @@ import_mbox_exec (struct _import_mbox_msg *m) flags |= decode_status(tmp); camel_message_info_set_flags(info, flags, ~0); - camel_folder_append_message(folder, msg, info, NULL, &m->base.ex); + camel_folder_append_message ( + folder, msg, info, NULL, &m->base.error); camel_message_info_free(info); g_object_unref (msg); - if (camel_exception_is_set(&m->base.ex)) + if (m->base.error != NULL) break; camel_mime_parser_step(mp, NULL, NULL); @@ -206,7 +208,7 @@ static void import_mbox_done (struct _import_mbox_msg *m) { if (m->done) - m->done(m->done_data, &m->base.ex); + m->done(m->done_data, &m->base.error); } static void @@ -227,7 +229,7 @@ static MailMsgInfo import_mbox_info = { }; gint -mail_importer_import_mbox(const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, CamelException *), gpointer data) +mail_importer_import_mbox(const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, GError **), gpointer data) { struct _import_mbox_msg *m; gint id; diff --git a/mail/importers/mail-importer.h b/mail/importers/mail-importer.h index 15de575f8b..01a69c981d 100644 --- a/mail/importers/mail-importer.h +++ b/mail/importers/mail-importer.h @@ -46,7 +46,7 @@ EImportImporter *pine_importer_peek(void); #define MSG_FLAG_MARKED 0x0004 #define MSG_FLAG_EXPUNGED 0x0008 -gint mail_importer_import_mbox(const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, CamelException *), gpointer data); +gint mail_importer_import_mbox(const gchar *path, const gchar *folderuri, CamelOperation *cancel, void (*done)(gpointer data, GError **), gpointer data); void mail_importer_import_mbox_sync(const gchar *path, const gchar *folderuri, CamelOperation *cancel); struct _MailImporterSpecial { diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c index e6cc75e63c..354d53d377 100644 --- a/mail/importers/pine-importer.c +++ b/mail/importers/pine-importer.c @@ -247,7 +247,7 @@ pine_import_done (struct _pine_import_msg *m) { printf("importing complete\n"); - if (!camel_exception_is_set(&m->base.ex)) { + if (m->base.error == NULL) { GConfClient *gconf; gconf = gconf_client_get_default(); diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 7a8a20613d..d4c4e523f3 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -779,7 +779,7 @@ ping_store_exec (struct _ping_store_msg *m) online = TRUE; } if (online) - camel_store_noop (m->store, &m->base.ex); + camel_store_noop (m->store, &m->base.error); } static void diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 76a6ccc488..97144818d3 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -76,7 +76,6 @@ mail_msg_new (MailMsgInfo *info) msg->ref_count = 1; msg->seq = mail_msg_seq++; msg->cancel = camel_operation_new(mail_operation_status, GINT_TO_POINTER(msg->seq)); - camel_exception_init(&msg->ex); msg->priv = g_slice_new0 (MailMsgPrivate); msg->priv->cancelable = TRUE; @@ -146,7 +145,9 @@ mail_msg_free (MailMsg *mail_msg) camel_operation_unref (mail_msg->cancel); } - camel_exception_clear (&mail_msg->ex); + if (mail_msg->error != NULL) + g_error_free (mail_msg->error); + g_slice_free (MailMsgPrivate, mail_msg->priv); g_slice_free1 (mail_msg->info->size, mail_msg); } @@ -245,9 +246,9 @@ mail_msg_check_error (gpointer msg) checkmem(m->priv); #endif - if (!camel_exception_is_set(&m->ex) - || m->ex.id == CAMEL_EXCEPTION_USER_CANCEL - || m->ex.id == CAMEL_EXCEPTION_FOLDER_INVALID_UID + 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))) return; @@ -260,7 +261,7 @@ mail_msg_check_error (gpointer msg) if (g_hash_table_lookup(active_errors, m->info)) { g_message ( "Error occurred while existing dialogue active:\n%s", - camel_exception_get_description(&m->ex)); + m->error->message); return; } @@ -270,12 +271,12 @@ mail_msg_check_error (gpointer msg) && (what = m->info->desc (m))) { gd = (GtkDialog *) e_alert_dialog_new_for_args ( parent, "mail:async-error", what, - camel_exception_get_description(&m->ex), NULL); + m->error->message, NULL); g_free(what); } else gd = (GtkDialog *) e_alert_dialog_new_for_args ( parent, "mail:async-error-nodescribe", - camel_exception_get_description(&m->ex), NULL); + m->error->message, NULL); g_hash_table_insert(active_errors, m->info, gd); g_signal_connect(gd, "response", G_CALLBACK(error_response), m->info); diff --git a/mail/mail-mt.h b/mail/mail-mt.h index 261b37699f..d8b4fc70d2 100644 --- a/mail/mail-mt.h +++ b/mail/mail-mt.h @@ -41,7 +41,7 @@ struct _MailMsg { guint seq; /* seq number for synchronisation */ gint priority; /* priority (default = 0) */ CamelOperation *cancel; /* a cancellation/status handle */ - CamelException ex; /* an initialised camel exception, upto the caller to use this */ + GError *error; /* up to the caller to use this */ MailMsgPrivate *priv; }; diff --git a/mail/mail-ops.c b/mail/mail-ops.c index 52976148d6..ae2d12dfda 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -115,15 +115,17 @@ em_filter_folder_element_exec (struct _filter_mail_msg *m) else folder_uids = uids = camel_folder_get_uids (folder); - camel_filter_driver_filter_folder (m->driver, folder, m->cache, uids, m->delete, &m->base.ex); - camel_filter_driver_flush (m->driver, &m->base.ex); + camel_filter_driver_filter_folder ( + m->driver, folder, m->cache, uids, + m->delete, &m->base.error); + camel_filter_driver_flush (m->driver, &m->base.error); if (folder_uids) camel_folder_free_uids (folder, folder_uids); /* sync our source folder */ if (!m->cache) - camel_folder_sync (folder, FALSE, camel_exception_is_set (&m->base.ex) ? NULL : &m->base.ex); + camel_folder_sync (folder, FALSE, &m->base.error); camel_folder_thaw (folder); if (m->destination) @@ -260,20 +262,26 @@ fetch_mail_exec (struct _fetch_mail_msg *m) /* FIXME: this should support keep_on_server too, which would then perform a spool access thingy, right? problem is matching raw messages to uid's etc. */ if (!strncmp (m->source_uri, "mbox:", 5)) { - gchar *path = mail_tool_do_movemail (m->source_uri, &fm->base.ex); + gchar *path = mail_tool_do_movemail (m->source_uri, &fm->base.error); - if (path && !camel_exception_is_set (&fm->base.ex)) { + if (path && fm->base.error == NULL) { camel_folder_freeze (fm->destination); - camel_filter_driver_set_default_folder (fm->driver, fm->destination); - camel_filter_driver_filter_mbox (fm->driver, path, m->source_uri, &fm->base.ex); + camel_filter_driver_set_default_folder ( + fm->driver, fm->destination); + camel_filter_driver_filter_mbox ( + fm->driver, path, m->source_uri, + &fm->base.error); camel_folder_thaw (fm->destination); - if (!camel_exception_is_set (&fm->base.ex)) + if (fm->base.error == NULL) g_unlink (path); } g_free (path); } else { - CamelFolder *folder = fm->source_folder = mail_tool_get_inbox (m->source_uri, &fm->base.ex); + CamelFolder *folder; + + folder = fm->source_folder = + mail_tool_get_inbox (m->source_uri, &fm->base.error); if (folder) { /* this handles 'keep on server' stuff, if we have any new uid's to copy @@ -304,14 +312,14 @@ fetch_mail_exec (struct _fetch_mail_msg *m) em_filter_folder_element_exec (fm); /* need to uncancel so writes/etc. don't fail */ - if (fm->base.ex.id == CAMEL_EXCEPTION_USER_CANCEL) + if (g_error_matches (fm->base.error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) camel_operation_uncancel(NULL); /* save the cache of uids that we've just downloaded */ camel_uid_cache_save (cache); } - if (fm->delete && !camel_exception_is_set (&fm->base.ex)) { + if (fm->delete && fm->base.error == NULL) { /* not keep on server - just delete all the actual messages on the server */ for (i=0;i<folder_uids->len;i++) { d(printf("force delete uid '%s'\n", (gchar *)folder_uids->pdata[i])); @@ -319,7 +327,7 @@ fetch_mail_exec (struct _fetch_mail_msg *m) } } - if ((fm->delete || cache_uids) && !camel_exception_is_set (&fm->base.ex)) { + if ((fm->delete || cache_uids) && fm->base.error == NULL) { /* expunge messages (downloaded so far) */ camel_folder_sync(folder, fm->delete, NULL); } @@ -448,7 +456,12 @@ static void report_status (struct _send_queue_msg *m, enum camel_filter_status_t /* send 1 message to a specific transport */ static void -mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *uid, const gchar *destination, CamelFilterDriver *driver, CamelException *ex) +mail_send_message (struct _send_queue_msg *m, + CamelFolder *queue, + const gchar *uid, + const gchar *destination, + CamelFilterDriver *driver, + GError **error) { EAccount *account = NULL; const CamelInternetAddress *iaddr; @@ -463,8 +476,9 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u struct _camel_header_raw *xev, *header; CamelMimeMessage *message; gint i; + GError *local_error = NULL; - message = camel_folder_get_message(queue, uid, ex); + message = camel_folder_get_message(queue, uid, error); if (!message) return; @@ -529,12 +543,13 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u } if (camel_address_length(recipients) > 0) { - xport = camel_session_get_transport (session, transport_url ? transport_url : destination, ex); - if (camel_exception_is_set(ex)) + xport = camel_session_get_transport ( + session, transport_url ? transport_url : + destination, error); + if (xport == NULL) goto exit; - camel_transport_send_to(xport, message, from, recipients, ex); - if (camel_exception_is_set(ex)) + if (!camel_transport_send_to (xport, message, from, recipients, error)) goto exit; } @@ -564,30 +579,36 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u mail_tool_restore_xevolution_headers (message, xev); if (driver) { - camel_filter_driver_filter_message (driver, message, info, - NULL, NULL, NULL, "", ex); + camel_filter_driver_filter_message ( + driver, message, info, NULL, + NULL, NULL, "", &local_error); - if (camel_exception_is_set (ex)) { - if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL) + if (local_error != NULL) { + if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) goto exit; /* sending mail, filtering failed */ - g_string_append_printf (err, _("Failed to apply outgoing filters: %s"), - camel_exception_get_description (ex)); + g_string_append_printf ( + err, _("Failed to apply outgoing filters: %s"), + local_error->message); + + g_clear_error (&local_error); } } - camel_exception_clear (ex); - if (xport == NULL || !( ((CamelService *)xport)->provider->flags & CAMEL_PROVIDER_DISABLE_SENT_FOLDER)) { + GError *local_error = NULL; + if (sent_folder_uri) { - folder = mail_tool_uri_to_folder (sent_folder_uri, 0, ex); - if (camel_exception_is_set(ex)) { - g_string_append_printf (err, _("Failed to append to %s: %s\n" - "Appending to local 'Sent' folder instead."), - sent_folder_uri, camel_exception_get_description (ex)); - camel_exception_clear (ex); + folder = mail_tool_uri_to_folder ( + sent_folder_uri, 0, &local_error); + if (folder == NULL) { + g_string_append_printf ( + err, _("Failed to append to %s: %s\n" + "Appending to local 'Sent' folder instead."), + sent_folder_uri, local_error->message); + g_clear_error (&local_error); } } @@ -596,11 +617,10 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u g_object_ref (folder); } - camel_folder_append_message (folder, message, info, NULL, ex); - if (camel_exception_is_set (ex)) { + if (!camel_folder_append_message (folder, message, info, NULL, &local_error)) { CamelFolder *sent_folder; - if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL) + if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) goto exit; sent_folder = e_mail_local_get_folder (E_MAIL_FOLDER_SENT); @@ -614,38 +634,49 @@ mail_send_message (struct _send_queue_msg *m, CamelFolder *queue, const gchar *u g_string_append_printf ( err, _("Failed to append to %s: %s\n" "Appending to local 'Sent' folder instead."), - description, camel_exception_get_description (ex)); + description, local_error->message); g_object_ref (sent_folder); g_object_unref (folder); folder = sent_folder; - camel_exception_clear (ex); - camel_folder_append_message (folder, message, info, NULL, ex); + g_clear_error (&local_error); + camel_folder_append_message ( + folder, message, info, NULL, &local_error); } - if (camel_exception_is_set (ex)) { - if (camel_exception_get_id (ex) == CAMEL_EXCEPTION_USER_CANCEL) + if (local_error != NULL) { + if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) goto exit; if (err->len) g_string_append(err, "\n\n"); - g_string_append_printf (err, _("Failed to append to local 'Sent' folder: %s"), - camel_exception_get_description (ex)); + g_string_append_printf ( + err, _("Failed to append to local 'Sent' folder: %s"), + local_error->message); } } } - if (!camel_exception_is_set(ex)) { - camel_folder_set_message_flags (queue, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, ~0); - /* Sync it to disk, since if it crashes in between, we keep sending it again on next start. */ + + if (local_error == NULL) { + camel_folder_set_message_flags ( + queue, uid, CAMEL_MESSAGE_DELETED | + 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); } if (err->len) { /* set the culmulative exception report */ - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, err->str); + g_set_error ( + &local_error, CAMEL_ERROR, + CAMEL_ERROR_GENERIC, "%s", err->str); } exit: + if (local_error != NULL) + g_propagate_error (error, local_error); + if (folder) { camel_folder_sync(folder, FALSE, NULL); g_object_unref (folder); @@ -704,8 +735,8 @@ send_queue_exec (struct _send_queue_msg *m) { CamelFolder *sent_folder; GPtrArray *uids, *send_uids = NULL; - CamelException ex; gint i, j; + GError *local_error = NULL; d(printf("sending queue\n")); @@ -742,8 +773,6 @@ send_queue_exec (struct _send_queue_msg *m) if (!m->cancel) camel_operation_start (NULL, _("Sending message")); - camel_exception_init (&ex); - /* 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. */ @@ -754,21 +783,38 @@ send_queue_exec (struct _send_queue_msg *m) if (!m->cancel) camel_operation_progress (NULL, (i+1) * 100 / send_uids->len); - mail_send_message (m, m->queue, send_uids->pdata[i], m->destination, m->driver, &ex); - if (camel_exception_is_set (&ex)) { - if (ex.id != CAMEL_EXCEPTION_USER_CANCEL) { + mail_send_message ( + m, m->queue, send_uids->pdata[i], + m->destination, m->driver, &local_error); + if (local_error != NULL) { + if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { /* merge exceptions into one */ - if (camel_exception_is_set (&m->base.ex)) - camel_exception_setv (&m->base.ex, CAMEL_EXCEPTION_SYSTEM, "%s\n\n%s", m->base.ex.desc, ex.desc); - else - camel_exception_xfer (&m->base.ex, &ex); - camel_exception_clear (&ex); + if (m->base.error != NULL) { + gchar *old_message; + + old_message = g_strdup ( + m->base.error->message); + g_clear_error (&m->base.error); + g_set_error ( + &m->base.error, CAMEL_ERROR, + CAMEL_ERROR_GENERIC, + "%s\n\n%s", old_message, + local_error->message); + g_free (old_message); + + g_clear_error (&local_error); + } else { + g_propagate_error (&m->base.error, local_error); + local_error = NULL; + } /* keep track of the number of failures */ j++; } else { - /* transfer the USER_CANCEL exeption to the async op exception and then break */ - camel_exception_xfer (&m->base.ex, &ex); + /* transfer the USER_CANCEL error to the + * async op exception and then break */ + g_propagate_error (&m->base.error, local_error); + local_error = NULL; break; } } @@ -778,7 +824,7 @@ send_queue_exec (struct _send_queue_msg *m) if (j > 0) report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Failed to send %d of %d messages"), j, send_uids->len); - else if (m->base.ex.id == CAMEL_EXCEPTION_USER_CANCEL) + else if (g_error_matches (m->base.error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Canceled.")); else report_status (m, CAMEL_FILTER_STATUS_END, 100, _("Complete.")); @@ -791,15 +837,11 @@ send_queue_exec (struct _send_queue_msg *m) camel_folder_free_uids (m->queue, uids); g_ptr_array_free (send_uids, TRUE); - if (j <= 0 && !camel_exception_is_set (&m->base.ex)) { - camel_folder_sync (m->queue, TRUE, &ex); - camel_exception_clear (&ex); - } + if (j <= 0 && m->base.error == NULL) + camel_folder_sync (m->queue, TRUE, NULL); - if (sent_folder) { - camel_folder_sync (sent_folder, FALSE, &ex); - camel_exception_clear (&ex); - } + if (sent_folder) + camel_folder_sync (sent_folder, FALSE, NULL); if (!m->cancel) camel_operation_end (NULL); @@ -900,14 +942,17 @@ 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.ex); + camel_folder_append_message(m->folder, m->message, m->info, &m->appended_uid, &m->base.error); } static void append_mail_done (struct _append_msg *m) { if (m->done) - m->done(m->folder, m->message, m->info, !camel_exception_is_set(&m->base.ex), m->appended_uid, m->data); + m->done ( + m->folder, m->message, + m->info, m->base.error == NULL, + m->appended_uid, m->data); } static void @@ -980,8 +1025,8 @@ transfer_messages_exec (struct _transfer_msg *m) { CamelFolder *dest; - dest = mail_tool_uri_to_folder (m->dest_uri, m->dest_flags, &m->base.ex); - if (camel_exception_is_set (&m->base.ex)) + dest = mail_tool_uri_to_folder (m->dest_uri, m->dest_flags, &m->base.error); + if (dest == NULL) return; if (dest == m->source) { @@ -993,7 +1038,7 @@ 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.ex); + camel_folder_transfer_messages_to (m->source, m->uids, dest, NULL, m->delete, &m->base.error); /* make sure all deleted messages are marked as seen */ @@ -1015,7 +1060,7 @@ static void transfer_messages_done (struct _transfer_msg *m) { if (m->done) - m->done (!camel_exception_is_set (&m->base.ex), m->data); + m->done (m->base.error == NULL, m->data); } static void @@ -1089,18 +1134,18 @@ 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.ex); + m->info = camel_store_get_folder_info (m->store, NULL, flags, &m->base.error); } static void get_folderinfo_done (struct _get_folderinfo_msg *m) { - if (!m->info && camel_exception_is_set (&m->base.ex)) { + if (!m->info && m->base.error != NULL) { gchar *url; url = camel_service_get_url (CAMEL_SERVICE (m->store)); w(g_warning ("Error getting folder info from store at %s: %s", - url, camel_exception_get_description (&m->base.ex))); + url, m->base.error->message)); g_free (url); } @@ -1234,7 +1279,7 @@ 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.ex); + m->folder = mail_tool_uri_to_folder (m->uri, m->flags, &m->base.error); } static void @@ -1376,7 +1421,7 @@ get_store_exec (struct _get_store_msg *m) m->store = (CamelStore *) camel_session_get_service (session, m->uri, CAMEL_PROVIDER_STORE, - &m->base.ex); + &m->base.error); } static void @@ -1430,7 +1475,7 @@ struct _remove_folder_msg { CamelFolder *folder; gboolean removed; - void (*done) (CamelFolder *folder, gboolean removed, CamelException *ex, gpointer data); + void (*done) (CamelFolder *folder, gboolean removed, GError **error, gpointer data); gpointer data; }; @@ -1440,22 +1485,22 @@ remove_folder_desc (struct _remove_folder_msg *m) return g_strdup_printf (_("Removing folder '%s'"), camel_folder_get_full_name (m->folder)); } -static void -remove_folder_rec (CamelStore *store, CamelFolderInfo *fi, CamelException *ex) +static gboolean +remove_folder_rec (CamelStore *store, CamelFolderInfo *fi, GError **error) { while (fi) { CamelFolder *folder; if (fi->child) { - remove_folder_rec (store, fi->child, ex); - if (camel_exception_is_set (ex)) - return; + if (!remove_folder_rec (store, fi->child, error)) + return FALSE; } d(printf ("deleting folder '%s'\n", fi->full_name)); - if (!(folder = camel_store_get_folder (store, fi->full_name, 0, ex))) - return; + folder = camel_store_get_folder (store, fi->full_name, 0, error); + if (folder == NULL) + return FALSE; if (!CAMEL_IS_VEE_FOLDER (folder)) { GPtrArray *uids = camel_folder_get_uids (folder); @@ -1477,12 +1522,13 @@ remove_folder_rec (CamelStore *store, CamelFolderInfo *fi, CamelException *ex) camel_store_unsubscribe_folder (store, fi->full_name, NULL); /* Then delete the folder from the store */ - camel_store_delete_folder (store, fi->full_name, ex); - if (camel_exception_is_set (ex)) - return; + if (!camel_store_delete_folder (store, fi->full_name, error)) + return FALSE; fi = fi->next; } + + return TRUE; } static void @@ -1497,21 +1543,24 @@ remove_folder_exec (struct _remove_folder_msg *m) full_name = camel_folder_get_full_name (m->folder); parent_store = camel_folder_get_parent_store (m->folder); - fi = camel_store_get_folder_info (parent_store, full_name, CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, &m->base.ex); - if (camel_exception_is_set (&m->base.ex)) + fi = camel_store_get_folder_info ( + parent_store, full_name, + CAMEL_STORE_FOLDER_INFO_RECURSIVE | + CAMEL_STORE_FOLDER_INFO_FAST | + CAMEL_STORE_FOLDER_INFO_SUBSCRIBED, + &m->base.error); + if (fi == NULL) return; - remove_folder_rec (parent_store, fi, &m->base.ex); + m->removed = remove_folder_rec (parent_store, fi, &m->base.error); camel_store_free_folder_info (parent_store, fi); - - m->removed = !camel_exception_is_set (&m->base.ex); } static void remove_folder_done (struct _remove_folder_msg *m) { if (m->done) - m->done (m->folder, m->removed, &m->base.ex, m->data); + m->done (m->folder, m->removed, &m->base.error, m->data); } static void @@ -1529,7 +1578,7 @@ static MailMsgInfo remove_folder_info = { }; void -mail_remove_folder (CamelFolder *folder, void (*done) (CamelFolder *folder, gboolean removed, CamelException *ex, gpointer data), gpointer data) +mail_remove_folder (CamelFolder *folder, void (*done) (CamelFolder *folder, gboolean removed, GError **error, gpointer data), gpointer data) { struct _remove_folder_msg *m; @@ -1564,7 +1613,7 @@ 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.ex); + camel_folder_sync(m->folder, FALSE, &m->base.error); } static void @@ -1631,7 +1680,7 @@ 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.ex); + camel_store_sync(m->store, m->expunge, &m->base.error); } static void @@ -1681,10 +1730,10 @@ 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.ex); */ + /* camel_folder_sync (m->folder, FALSE, &m->base.error); */ - /* if (!camel_exception_is_set (&m->base.ex)) */ - camel_folder_refresh_info(m->folder, &m->base.ex); + /* if (!camel_exception_is_set (&m->base.error)) */ + camel_folder_refresh_info(m->folder, &m->base.error); } /* we just use the sync stuff where we can, since it would be the same */ @@ -1721,7 +1770,7 @@ 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.ex); + camel_folder_expunge(m->folder, &m->base.error); } /* we just use the sync stuff where we can, since it would be the same */ @@ -1772,16 +1821,16 @@ 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.ex); + trash = mail_tool_get_trash (m->account->source->url, FALSE, &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.ex); + trash = mail_tool_get_trash (uri, TRUE, &m->base.error); g_free (uri); } if (trash) { - camel_folder_expunge (trash, &m->base.ex); + camel_folder_expunge (trash, &m->base.error); g_object_unref (trash); } } @@ -1848,7 +1897,7 @@ get_message_exec (struct _get_message_msg *m) if (m->base.cancel && camel_operation_cancel_check (m->base.cancel)) m->message = NULL; else - m->message = camel_folder_get_message (m->folder, m->uid, &m->base.ex); + m->message = camel_folder_get_message (m->folder, m->uid, &m->base.error); } static void @@ -1899,14 +1948,14 @@ mail_get_message(CamelFolder *folder, const gchar *uid, void (*done) (CamelFolde return id; } -typedef void (*get_done)(CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, CamelException *); +typedef void (*get_done)(CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, GError **error); static void get_messagex_done (struct _get_message_msg *m) { if (m->done && !camel_operation_cancel_check (m->cancel)) { get_done done = (get_done)m->done; - done(m->folder, m->uid, m->message, m->data, &m->base.ex); + done(m->folder, m->uid, m->message, m->data, &m->base.error); } } @@ -1921,8 +1970,15 @@ static MailMsgInfo get_messagex_info = { /* This is temporary, to avoid having to rewrite everything that uses mail_get_message; it adds an exception argument to the callback */ gint -mail_get_messagex(CamelFolder *folder, const gchar *uid, void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, CamelException *), - gpointer data, MailMsgDispatchFunc dispatch) +mail_get_messagex (CamelFolder *folder, + const gchar *uid, + void (*done) (CamelFolder *folder, + const gchar *uid, + CamelMimeMessage *msg, + gpointer data, + GError **error), + gpointer data, + MailMsgDispatchFunc dispatch) { struct _get_message_msg *m; gint id; @@ -1971,7 +2027,7 @@ get_messages_exec (struct _get_messages_msg *m) for (i=0; i<m->uids->len; i++) { gint pc = ((i+1) * 100) / m->uids->len; - message = camel_folder_get_message(m->folder, m->uids->pdata[i], &m->base.ex); + message = camel_folder_get_message(m->folder, m->uids->pdata[i], &m->base.error); camel_operation_progress(m->base.cancel, pc); if (message == NULL) break; @@ -2111,7 +2167,7 @@ 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.ex); + message = camel_folder_get_message(m->folder, m->uids->pdata[i], &m->base.error); camel_operation_progress(m->base.cancel, pc); if (message == NULL) break; @@ -2120,14 +2176,21 @@ save_messages_exec (struct _save_messages_msg *m) /* we need to flush after each stream write since we are writing to the same fd */ from = camel_mime_message_build_mbox_from(message); - if (camel_stream_write_string(stream, from) == -1 - || camel_stream_flush(stream) == -1 - || camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, (CamelStream *)filtered_stream) == -1 - || camel_stream_flush((CamelStream *)filtered_stream) == -1 - || camel_stream_write_string(stream, "\n") == -1 - || camel_stream_flush(stream) == -1) { - camel_exception_setv(&m->base.ex, CAMEL_EXCEPTION_SYSTEM, - _("Error saving messages to: %s:\n %s"), m->path, g_strerror(errno)); + if (camel_stream_write_string ( + stream, from, &m->base.error) == -1 + || camel_stream_flush(stream, &m->base.error) == -1 + || camel_data_wrapper_write_to_stream ( + (CamelDataWrapper *) message, + (CamelStream *)filtered_stream, &m->base.error) == -1 + || camel_stream_flush ( + (CamelStream *)filtered_stream, &m->base.error) == -1 + || camel_stream_write_string ( + stream, "\n", &m->base.error) == -1 + || camel_stream_flush(stream, &m->base.error) == -1) { + g_prefix_error ( + &m->base.error, + _("Error saving messages to: %s:\n"), + m->path); g_free(from); g_object_unref ((CamelObject *)message); break; @@ -2216,17 +2279,21 @@ save_part_exec (struct _save_part_msg *m) if (!m->readonly) { if (!(stream = camel_stream_vfs_new_with_uri (path, CAMEL_STREAM_VFS_CREATE))) { - camel_exception_setv (&m->base.ex, CAMEL_EXCEPTION_SYSTEM, - _("Cannot create output file: %s:\n %s"), - path, g_strerror (errno)); + g_set_error ( + &m->base.error, G_FILE_ERROR, + g_file_error_from_errno (errno), + _("Cannot create output file: %s:\n %s"), + path, g_strerror (errno)); if (path != m->path) g_free (path); return; } } else if (!(stream = camel_stream_vfs_new_with_uri (path, CAMEL_STREAM_VFS_CREATE))) { - camel_exception_setv (&m->base.ex, CAMEL_EXCEPTION_SYSTEM, - _("Cannot create output file: %s:\n %s"), - path, g_strerror (errno)); + g_set_error ( + &m->base.error, G_FILE_ERROR, + g_file_error_from_errno (errno), + _("Cannot create output file: %s:\n %s"), + path, g_strerror (errno)); if (path != m->path) g_free (path); return; @@ -2237,11 +2304,10 @@ save_part_exec (struct _save_part_msg *m) content = camel_medium_get_content (CAMEL_MEDIUM (m->part)); - if (camel_data_wrapper_decode_to_stream (content, stream) == -1 - || camel_stream_flush (stream) == -1) - camel_exception_setv (&m->base.ex, CAMEL_EXCEPTION_SYSTEM, - _("Could not write data: %s"), - g_strerror (errno)); + if (camel_data_wrapper_decode_to_stream ( + content, stream, &m->base.error) == -1 + || camel_stream_flush (stream, &m->base.error) == -1) + g_prefix_error (&m->base.error, _("Could not write data: ")); g_object_unref (stream); } @@ -2250,7 +2316,7 @@ static void save_part_done (struct _save_part_msg *m) { if (m->done) - m->done (m->part, m->path, !camel_exception_is_set (&m->base.ex), m->data); + m->done (m->part, m->path, m->base.error == NULL, m->data); } static void @@ -2307,14 +2373,14 @@ prep_offline_exec (struct _prep_offline_msg *m) if (m->cancel) camel_operation_register(m->cancel); - folder = mail_tool_uri_to_folder(m->uri, 0, &m->base.ex); + folder = mail_tool_uri_to_folder(m->uri, 0, &m->base.error); if (folder) { if (CAMEL_IS_DISCO_FOLDER(folder)) { camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "(match-all)", - &m->base.ex); + &m->base.error); } else if (CAMEL_IS_OFFLINE_FOLDER (folder)) { - camel_offline_folder_downsync ((CamelOfflineFolder *) folder, "(match-all)", &m->base.ex); + camel_offline_folder_downsync ((CamelOfflineFolder *) folder, "(match-all)", &m->base.error); } /* prepare_for_offline should do this? */ /* of course it should all be atomic, but ... */ @@ -2398,31 +2464,31 @@ set_offline_exec (struct _set_offline_msg *m) if (!m->offline) { camel_disco_store_set_status (CAMEL_DISCO_STORE (m->store), CAMEL_DISCO_STORE_ONLINE, - &m->base.ex); + &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.ex); + &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.ex); + &m->base.error); return; } else { camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (m->store), CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL, - &m->base.ex); + &m->base.error); return; } } if (m->offline) camel_service_disconnect (CAMEL_SERVICE (m->store), - TRUE, &m->base.ex); + TRUE, &m->base.error); } static void @@ -2492,10 +2558,10 @@ 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.ex); + &m->base.error); } else if (CAMEL_IS_OFFLINE_STORE (m->store)) { camel_offline_store_prepare_for_offline (CAMEL_OFFLINE_STORE (m->store), - &m->base.ex); + &m->base.error); } } @@ -2575,13 +2641,13 @@ check_service_exec (struct _check_msg *m) { CamelService *service; - service = camel_session_get_service(session, m->url, m->type, &m->base.ex); + service = camel_session_get_service(session, m->url, m->type, &m->base.error); if (!service) { camel_operation_unregister(m->base.cancel); return; } - m->authtypes = camel_service_query_auth_types(service, &m->base.ex); + m->authtypes = camel_service_query_auth_types(service, &m->base.error); g_object_unref (service); } diff --git a/mail/mail-ops.h b/mail/mail-ops.h index 506de4ce80..7a3f045b63 100644 --- a/mail/mail-ops.h +++ b/mail/mail-ops.h @@ -51,7 +51,7 @@ gint mail_get_message (CamelFolder *folder, const gchar *uid, gint mail_get_messagex(CamelFolder *folder, const gchar *uid, - void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, CamelException *), + void (*done) (CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, gpointer data, GError **error), gpointer data, MailMsgDispatchFunc dispatch); /* get several messages */ @@ -105,7 +105,7 @@ gint mail_get_folderinfo (CamelStore *store, CamelOperation *op, /* remove an existing folder */ void mail_remove_folder (CamelFolder *folder, - void (*done) (CamelFolder *folder, gboolean removed, CamelException *ex, gpointer data), + void (*done) (CamelFolder *folder, gboolean removed, GError **error, gpointer data), gpointer data); /* transfer (copy/move) a folder */ diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index 149b11d4e8..651692530a 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -122,7 +122,7 @@ struct _send_info { struct _send_data *data; }; -static CamelFolder *receive_get_folder(CamelFilterDriver *d, const gchar *uri, gpointer data, CamelException *ex); +static CamelFolder *receive_get_folder(CamelFilterDriver *d, const gchar *uri, gpointer data, GError **error); static struct _send_data *send_data = NULL; static GtkWidget *send_recv_dialog = NULL; @@ -372,16 +372,13 @@ static send_info_t get_receive_type(const gchar *url) { CamelProvider *provider; - CamelException ex; /* HACK: since mbox is ALSO used for native evolution trees now, we need to fudge this to treat it as a special 'movemail' source */ if (!strncmp(url, "mbox:", 5)) return SEND_RECEIVE; - camel_exception_init (&ex); - provider = camel_provider_get(url, &ex); - camel_exception_clear (&ex); + provider = camel_provider_get(url, NULL); if (!provider) return SEND_INVALID; @@ -792,7 +789,7 @@ receive_done (const gchar *uri, gpointer data) This can also be used to hook into which folders are being updated, and occasionally let them refresh */ static CamelFolder * -receive_get_folder(CamelFilterDriver *d, const gchar *uri, gpointer data, CamelException *ex) +receive_get_folder(CamelFilterDriver *d, const gchar *uri, gpointer data, GError **error) { struct _send_info *info = data; CamelFolder *folder; @@ -806,7 +803,7 @@ receive_get_folder(CamelFilterDriver *d, const gchar *uri, gpointer data, CamelE g_object_ref (oldinfo->folder); return oldinfo->folder; } - folder = mail_tool_uri_to_folder (uri, 0, ex); + folder = mail_tool_uri_to_folder (uri, 0, error); if (!folder) return NULL; @@ -838,12 +835,8 @@ receive_get_folder(CamelFilterDriver *d, const gchar *uri, gpointer data, CamelE static void get_folders (CamelStore *store, GPtrArray *folders, CamelFolderInfo *info) { - CamelException ex; - - camel_exception_init (&ex); - while (info) { - if (camel_store_can_refresh_folder (store, info, &ex)) { + if (camel_store_can_refresh_folder (store, info, NULL)) { CamelURL *url = camel_url_new (info->uri, NULL); if (url && (!camel_url_get_param (url, "noselect") || !g_str_equal (camel_url_get_param (url, "noselect"), "yes"))) @@ -852,7 +845,6 @@ get_folders (CamelStore *store, GPtrArray *folders, CamelFolderInfo *info) if (url) camel_url_free (url); } - camel_exception_clear (&ex); get_folders (store, folders, info->child); info = info->next; @@ -879,21 +871,19 @@ refresh_folders_exec (struct _refresh_folders_msg *m) { gint i; CamelFolder *folder; - CamelException ex = CAMEL_EXCEPTION_INITIALISER; + GError *local_error = NULL; get_folders (m->store, m->folders, m->finfo); for (i=0;i<m->folders->len;i++) { - folder = mail_tool_uri_to_folder(m->folders->pdata[i], 0, &ex); + folder = mail_tool_uri_to_folder(m->folders->pdata[i], 0, &local_error); if (folder) { - camel_folder_sync (folder, FALSE, &ex); - camel_exception_clear(&ex); - camel_folder_refresh_info(folder, &ex); - camel_exception_clear(&ex); + camel_folder_sync (folder, FALSE, NULL); + camel_folder_refresh_info(folder, NULL); g_object_unref (folder); - } else if (camel_exception_is_set(&ex)) { - g_warning ("Failed to refresh folders: %s", camel_exception_get_description (&ex)); - camel_exception_clear (&ex); + } 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)) diff --git a/mail/mail-session.c b/mail/mail-session.c index 8714823f7a..e2da6389f1 100644 --- a/mail/mail-session.c +++ b/mail/mail-session.c @@ -89,16 +89,16 @@ struct _MailSessionClass { static gchar *mail_data_dir; static gchar *mail_config_dir; -static gchar *get_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *prompt, const gchar *item, guint32 flags, CamelException *ex); -static gboolean forget_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *item, CamelException *ex); +static gchar *get_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *prompt, const gchar *item, guint32 flags, GError **error); +static gboolean forget_password(CamelSession *session, CamelService *service, const gchar *domain, const gchar *item, GError **error); static gboolean alert_user(CamelSession *session, CamelSessionAlertType type, const gchar *prompt, gboolean cancel); -static CamelFilterDriver *get_filter_driver(CamelSession *session, const gchar *type, CamelException *ex); +static CamelFilterDriver *get_filter_driver(CamelSession *session, const gchar *type, GError **error); static gboolean lookup_addressbook(CamelSession *session, const gchar *name); static void ms_thread_status(CamelSession *session, CamelSessionThreadMsg *msg, const gchar *text, gint pc); static gpointer ms_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, guint size); static void ms_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *m); -static void ms_forward_to (CamelSession *session, CamelFolder *folder, CamelMimeMessage *message, const gchar *address, CamelException *ex); +static gboolean ms_forward_to (CamelSession *session, CamelFolder *folder, CamelMimeMessage *message, const gchar *address, GError **error); GType mail_session_get_type (void); @@ -175,8 +175,13 @@ make_key (CamelService *service, const gchar *item) /* ********************************************************************** */ static gchar * -get_password (CamelSession *session, CamelService *service, const gchar *domain, - const gchar *prompt, const gchar *item, guint32 flags, CamelException *ex) +get_password (CamelSession *session, + CamelService *service, + const gchar *domain, + const gchar *prompt, + const gchar *item, + guint32 flags, + GError **error) { gchar *url; gchar *ret = NULL; @@ -266,7 +271,10 @@ get_password (CamelSession *session, CamelService *service, const gchar *domain, g_free(url); if (ret == NULL) - camel_exception_set(ex, CAMEL_EXCEPTION_USER_CANCEL, _("User canceled operation.")); + g_set_error ( + error, G_IO_ERROR, + G_IO_ERROR_CANCELLED, + _("User canceled operation.")); return ret; } @@ -276,7 +284,7 @@ forget_password (CamelSession *session, CamelService *service, const gchar *domain, const gchar *item, - CamelException *ex) + GError **error) { gchar *key = make_key (service, item); @@ -466,9 +474,12 @@ alert_user(CamelSession *session, CamelSessionAlertType type, const gchar *promp } static CamelFolder * -get_folder (CamelFilterDriver *d, const gchar *uri, gpointer data, CamelException *ex) +get_folder (CamelFilterDriver *d, + const gchar *uri, + gpointer data, + GError **error) { - return mail_tool_uri_to_folder(uri, 0, ex); + return mail_tool_uri_to_folder (uri, 0, error); } static void @@ -517,7 +528,7 @@ session_system_beep (CamelFilterDriver *driver, gpointer user_data) } static CamelFilterDriver * -main_get_filter_driver (CamelSession *session, const gchar *type, CamelException *ex) +main_get_filter_driver (CamelSession *session, const gchar *type, GError **error) { CamelFilterDriver *driver; EFilterRule *rule = NULL; @@ -599,10 +610,11 @@ main_get_filter_driver (CamelSession *session, const gchar *type, CamelException } static CamelFilterDriver * -get_filter_driver (CamelSession *session, const gchar *type, CamelException *ex) +get_filter_driver (CamelSession *session, const gchar *type, GError **error) { - return (CamelFilterDriver *) mail_call_main (MAIL_CALL_p_ppp, (MailMainFunc) main_get_filter_driver, - session, type, ex); + return (CamelFilterDriver *) mail_call_main ( + MAIL_CALL_p_ppp, (MailMainFunc) main_get_filter_driver, + session, type, error); } /* TODO: This is very temporary, until we have a better way to do the progress reporting, @@ -664,8 +676,12 @@ forward_to_flush_outbox_cb (gpointer data) } static void -ms_forward_to_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo *info, - gint queued, const gchar *appended_uid, gpointer data) +ms_forward_to_cb (CamelFolder *folder, + CamelMimeMessage *msg, + CamelMessageInfo *info, + gint queued, + const gchar *appended_uid, + gpointer data) { static guint preparing_flush = 0; @@ -681,8 +697,12 @@ ms_forward_to_cb (CamelFolder *folder, CamelMimeMessage *msg, CamelMessageInfo * } } -static void -ms_forward_to (CamelSession *session, CamelFolder *folder, CamelMimeMessage *message, const gchar *address, CamelException *ex) +static gboolean +ms_forward_to (CamelSession *session, + CamelFolder *folder, + CamelMimeMessage *message, + const gchar *address, + GError **error) { EAccount *account; CamelMimeMessage *forward; @@ -693,28 +713,34 @@ ms_forward_to (CamelSession *session, CamelFolder *folder, CamelMimeMessage *mes struct _camel_header_raw *xev; gchar *subject; - g_return_if_fail (folder != NULL); - g_return_if_fail (message != NULL); - g_return_if_fail (address != NULL); + g_return_val_if_fail (folder != NULL, FALSE); + g_return_val_if_fail (message != NULL, FALSE); + g_return_val_if_fail (address != NULL, FALSE); if (!*address) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("No destination address provided, forward of the message has been cancelled.")); - return; + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("No destination address provided, forward " + "of the message has been cancelled.")); + return FALSE; } account = em_utils_guess_account_with_recipients (message, folder); if (!account) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("No account found to use, forward of the message has been cancelled.")); - return; + g_set_error ( + error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("No account found to use, forward of the " + "message has been cancelled.")); + return FALSE; } forward = camel_mime_message_new (); /* make copy of the message, because we are going to modify it */ mem = camel_stream_mem_new (); - camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, mem); - camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (mem), 0, CAMEL_STREAM_SET); - camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)forward, mem); + camel_data_wrapper_write_to_stream ((CamelDataWrapper *)message, mem, NULL); + camel_seekable_stream_seek (CAMEL_SEEKABLE_STREAM (mem), 0, CAMEL_STREAM_SET, NULL); + camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)forward, mem, NULL); g_object_unref (mem); /* clear previous recipients */ @@ -758,6 +784,8 @@ ms_forward_to (CamelSession *session, CamelFolder *folder, CamelMimeMessage *mes out_folder = e_mail_local_get_folder (E_MAIL_FOLDER_OUTBOX); 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; } gchar * diff --git a/mail/mail-tools.c b/mail/mail-tools.c index e9470c9a63..22dfb54e22 100644 --- a/mail/mail-tools.c +++ b/mail/mail-tools.c @@ -44,16 +44,16 @@ /* **************************************** */ CamelFolder * -mail_tool_get_inbox (const gchar *url, CamelException *ex) +mail_tool_get_inbox (const gchar *url, GError **error) { CamelStore *store; CamelFolder *folder; - store = camel_session_get_store (session, url, ex); + store = camel_session_get_store (session, url, error); if (!store) return NULL; - folder = camel_store_get_inbox (store, ex); + folder = camel_store_get_inbox (store, error); g_object_unref (store); return folder; @@ -74,21 +74,22 @@ is_local_provider (CamelStore *store) } CamelFolder * -mail_tool_get_trash (const gchar *url, gint connect, CamelException *ex) +mail_tool_get_trash (const gchar *url, gint connect, GError **error) { CamelStore *store; CamelFolder *trash; if (connect) - store = camel_session_get_store (session, url, ex); + store = camel_session_get_store (session, url, error); else - store = (CamelStore *) camel_session_get_service (session, url, CAMEL_PROVIDER_STORE, ex); + store = (CamelStore *) camel_session_get_service ( + session, url, CAMEL_PROVIDER_STORE, error); if (!store) return NULL; if (connect || ((CamelService *) store)->status == CAMEL_SERVICE_CONNECTED || is_local_provider (store)) - trash = camel_store_get_trash (store, ex); + trash = camel_store_get_trash (store, error); else trash = NULL; @@ -100,7 +101,7 @@ mail_tool_get_trash (const gchar *url, gint connect, CamelException *ex) #ifndef G_OS_WIN32 static gchar * -mail_tool_get_local_movemail_path (const guchar *uri, CamelException *ex) +mail_tool_get_local_movemail_path (const guchar *uri, GError **error) { guchar *safe_uri, *c; const gchar *data_dir; @@ -116,8 +117,11 @@ mail_tool_get_local_movemail_path (const guchar *uri, CamelException *ex) path = g_build_filename (data_dir, "spool", NULL); if (g_stat(path, &st) == -1 && g_mkdir_with_parents(path, 0700) == -1) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Could not create spool directory '%s': %s"), - path, g_strerror(errno)); + g_set_error ( + error, G_FILE_ERROR, + g_file_error_from_errno (errno), + _("Could not create spool directory '%s': %s"), + path, g_strerror(errno)); g_free(path); return NULL; } @@ -132,33 +136,37 @@ mail_tool_get_local_movemail_path (const guchar *uri, CamelException *ex) #endif gchar * -mail_tool_do_movemail (const gchar *source_url, CamelException *ex) +mail_tool_do_movemail (const gchar *source_url, GError **error) { #ifndef G_OS_WIN32 gchar *dest_path; struct stat sb; CamelURL *uri; + gboolean success; - uri = camel_url_new(source_url, ex); + uri = camel_url_new(source_url, error); if (uri == NULL) return NULL; if (strcmp(uri->protocol, "mbox") != 0) { /* This is really only an internal error anyway */ - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, - _("Trying to movemail a non-mbox source '%s'"), - source_url); + g_set_error ( + error, CAMEL_SERVICE_ERROR, + CAMEL_SERVICE_ERROR_URL_INVALID, + _("Trying to movemail a non-mbox source '%s'"), + source_url); camel_url_free(uri); return NULL; } /* Set up our destination. */ - dest_path = mail_tool_get_local_movemail_path ((guchar *)source_url, ex); + dest_path = mail_tool_get_local_movemail_path ( + (guchar *) source_url, error); if (dest_path == NULL) return NULL; /* Movemail from source (source_url) to dest_path */ - camel_movemail (uri->path, dest_path, ex); + success = camel_movemail (uri->path, dest_path, error); camel_url_free(uri); if (g_stat (dest_path, &sb) < 0 || sb.st_size == 0) { @@ -167,7 +175,7 @@ mail_tool_do_movemail (const gchar *source_url, CamelException *ex) return NULL; } - if (camel_exception_is_set (ex)) { + if (!success) { g_free (dest_path); return NULL; } @@ -275,7 +283,7 @@ mail_tool_make_message_attachment (CamelMimeMessage *message) } CamelFolder * -mail_tool_uri_to_folder (const gchar *uri, guint32 flags, CamelException *ex) +mail_tool_uri_to_folder (const gchar *uri, guint32 flags, GError **error) { CamelURL *url; CamelStore *store = NULL; @@ -294,19 +302,23 @@ mail_tool_uri_to_folder (const gchar *uri, guint32 flags, CamelException *ex) /* FIXME?: the filter:get_folder callback should do this itself? */ curi = em_uri_to_camel(uri); if (uri == NULL) { - camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Invalid folder: '%s'"), uri); + g_set_error ( + error, + CAMEL_ERROR, CAMEL_ERROR_GENERIC, + _("Invalid folder: '%s'"), uri); return NULL; } uri = curi; } - url = camel_url_new (uri + offset, ex); + url = camel_url_new (uri + offset, error); if (!url) { g_free(curi); return NULL; } - store = (CamelStore *)camel_session_get_service(session, uri+offset, CAMEL_PROVIDER_STORE, ex); + store = (CamelStore *) camel_session_get_service ( + session, uri + offset, CAMEL_PROVIDER_STORE, error); if (store) { const gchar *name; @@ -323,11 +335,11 @@ mail_tool_uri_to_folder (const gchar *uri, guint32 flags, CamelException *ex) if (offset) { if (offset == 7) - folder = camel_store_get_trash (store, ex); + folder = camel_store_get_trash (store, error); else if (offset == 6) - folder = camel_store_get_junk (store, ex); + folder = camel_store_get_junk (store, error); } else - folder = camel_store_get_folder (store, name, flags, ex); + folder = camel_store_get_folder (store, name, flags, error); g_object_unref (store); } diff --git a/mail/mail-tools.h b/mail/mail-tools.h index 544c3601b6..01c800fbd9 100644 --- a/mail/mail-tools.h +++ b/mail/mail-tools.h @@ -27,14 +27,14 @@ #include <camel/camel.h> /* Get the "inbox" for a url (uses global session) */ -CamelFolder *mail_tool_get_inbox (const gchar *url, CamelException *ex); +CamelFolder *mail_tool_get_inbox (const gchar *url, GError **error); /* Get the "trash" for a url (uses global session) */ -CamelFolder *mail_tool_get_trash (const gchar *url, gint connect, CamelException *ex); +CamelFolder *mail_tool_get_trash (const gchar *url, gint connect, 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 */ -gchar *mail_tool_do_movemail (const gchar *source_url, CamelException *ex); +gchar *mail_tool_do_movemail (const gchar *source_url, GError **error); struct _camel_header_raw *mail_tool_remove_xevolution_headers (CamelMimeMessage *message); void mail_tool_restore_xevolution_headers (CamelMimeMessage *message, struct _camel_header_raw *); @@ -46,7 +46,7 @@ gchar *mail_tool_generate_forward_subject (CamelMimeMessage *msg); 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, CamelException *ex); +CamelFolder *mail_tool_uri_to_folder (const gchar *uri, guint32 flags, GError **error); GHashTable *mail_lookup_url_table (CamelMimeMessage *mime_message); diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 3e9199aebe..23fd566043 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -98,13 +98,9 @@ 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, &m->base.ex); - if (folder) { - list = g_list_append(list, folder); - } else { - g_warning("Could not open vfolder source: %s", (gchar *)l->data); - camel_exception_clear(&m->base.ex); - } + folder = mail_tool_uri_to_folder (l->data, 0, NULL); + if (folder != NULL) + list = g_list_append (list, folder); l = l->next; } @@ -258,7 +254,7 @@ vfolder_adduri_exec (struct _adduri_msg *m) } if (folder == NULL) - folder = mail_tool_uri_to_folder (m->uri, 0, &m->base.ex); + folder = mail_tool_uri_to_folder (m->uri, 0, &m->base.error); if (folder != NULL) { l = m->folders; @@ -1014,7 +1010,6 @@ vfolder_load_storage(void) EFilterRule *rule; gchar *xmlfile; GConfClient *gconf; - CamelException ex; G_LOCK (vfolder_hash); @@ -1028,19 +1023,15 @@ vfolder_load_storage(void) G_UNLOCK (vfolder_hash); - camel_exception_init (&ex); - /* first, create the vfolder store, and set it up */ data_dir = mail_session_get_data_dir (); storeuri = g_strdup_printf("vfolder:%s/vfolder", data_dir); - vfolder_store = camel_session_get_store(session, storeuri, &ex); + vfolder_store = camel_session_get_store(session, storeuri, NULL); if (vfolder_store == NULL) { g_warning("Cannot open vfolder store - no vfolders available"); return; } - camel_exception_clear (&ex); - g_signal_connect ( vfolder_store, "folder-deleted", G_CALLBACK (store_folder_deleted_cb), NULL); diff --git a/mail/message-list.c b/mail/message-list.c index ecb6301773..fdf275ba6c 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -1456,14 +1456,15 @@ get_trimmed_subject (CamelMessageInfo *info) } static gpointer -ml_tree_value_at_ex (ETreeModel *etm, ETreePath path, gint col, CamelMessageInfo *msg_info, MessageList *message_list) +ml_tree_value_at_ex (ETreeModel *etm, + ETreePath path, + gint col, + CamelMessageInfo *msg_info, + MessageList *message_list) { - CamelException ex; const gchar *str; guint32 flags; - camel_exception_init (&ex); - g_return_val_if_fail (msg_info != NULL, NULL); switch (col) { @@ -1644,17 +1645,16 @@ ml_tree_value_at_ex (ETreeModel *etm, ETreePath path, gint col, CamelMessageInfo account = mail_config_get_account_by_source_url (url); if (account) { - curl = camel_url_new (url, &ex); + curl = camel_url_new (url, NULL); location = g_strconcat (account->name, ":", curl->path, NULL); } else { /* Local account */ euri = em_uri_from_camel(url); - curl = camel_url_new (euri, &ex); + curl = camel_url_new (euri, NULL); if (curl->host && !strcmp(curl->host, "local") && curl->user && !strcmp(curl->user, "local")) location = g_strconcat (_("On This Computer"), ":",curl->path, NULL); } - camel_exception_clear (&ex); camel_url_free (curl); g_free (url); g_free (euri); @@ -2160,7 +2160,10 @@ ml_drop_async_exec (struct _drop_msg *m) { switch (m->info) { case DND_X_UID_LIST: - em_utils_selection_get_uidlist(m->selection, m->folder, m->action == GDK_ACTION_MOVE, &m->base.ex); + em_utils_selection_get_uidlist ( + m->selection, m->folder, + m->action == GDK_ACTION_MOVE, + &m->base.error); break; case DND_MESSAGE_RFC822: em_utils_selection_get_message(m->selection, m->folder); @@ -2181,7 +2184,7 @@ ml_drop_async_done (struct _drop_msg *m) success = FALSE; delete = FALSE; } else { - success = !camel_exception_is_set (&m->base.ex); + success = (m->base.error == NULL); delete = success && m->move && !m->moved; } @@ -3684,15 +3687,12 @@ message_list_set_folder (MessageList *message_list, CamelFolder *folder, const g gboolean hide_deleted; GConfClient *gconf; CamelStore *folder_store; - CamelException ex; g_return_if_fail (IS_MESSAGE_LIST (message_list)); if (message_list->folder == folder) return; - camel_exception_init (&ex); - if (message_list->seen_id) { g_source_remove (message_list->seen_id); message_list->seen_id = 0; @@ -4392,7 +4392,8 @@ regen_list_exec (struct _regen_list_msg *m) } else { gboolean store_has_vjunk = folder_store_supports_vjunk_folder (m->folder); - searchuids = uids = camel_folder_search_by_expression (m->folder, expr, &m->base.ex); + searchuids = uids = camel_folder_search_by_expression ( + m->folder, expr, &m->base.error); /* If m->changes is not NULL, then it means we are called from folder_changed event, thus we will keep the selected message to be sure it doesn't disappear because it no longer belong to our search filter. */ @@ -4430,7 +4431,7 @@ regen_list_exec (struct _regen_list_msg *m) } } - if (camel_exception_is_set (&m->base.ex)) + if (m->base.error != NULL) return; e_profile_event_emit("list.threaduids", m->folder->full_name, 0); @@ -4446,17 +4447,11 @@ regen_list_exec (struct _regen_list_msg *m) else m->tree = camel_folder_thread_messages_new (m->folder, uids, m->thread_subject); } else { - CamelException ex; - camel_folder_sort_uids (m->ml->folder, uids); m->summary = g_ptr_array_new (); - camel_exception_init (&ex); - camel_folder_summary_prepare_fetch_all (m->folder->summary, &ex); - if (camel_exception_is_set (&ex)) { - g_warning ("Exception while reloading: %s\n", camel_exception_get_description (&ex)); - camel_exception_clear (&ex); - } + camel_folder_summary_prepare_fetch_all ( + m->folder->summary, NULL); for (i = 0; i < uids->len; i++) { info = camel_folder_get_message_info (m->folder, uids->pdata[i]); |