diff options
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r-- | mail/mail-ops.c | 356 |
1 files changed, 211 insertions, 145 deletions
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); } |