From 035fbcd84177cf592a48e41ca0ca7689aaaa9d17 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 30 Aug 2010 14:23:33 -0400 Subject: Composer autosave cleanups. This simplifies the async autosave logic and improves error handling. Hoping this will solve bug #616987 but I've yet to reproduce it myself. --- plugins/templates/templates.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c index 04ac8a5748..483d9400eb 100644 --- a/plugins/templates/templates.c +++ b/plugins/templates/templates.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -670,14 +671,37 @@ action_template_cb (GtkAction *action, CamelMessageInfo *info; CamelMimeMessage *msg; CamelFolder *folder; + GError *error = NULL; /* Get the templates folder and all UIDs of the messages there. */ folder = e_mail_local_get_folder (E_MAIL_FOLDER_TEMPLATES); - msg = e_msg_composer_get_message_draft (composer); + msg = e_msg_composer_get_message_draft (composer, &error); + + /* Ignore cancellations. */ + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_warn_if_fail (msg == NULL); + g_error_free (error); + return; + } + + if (error != NULL) { + g_warn_if_fail (msg == NULL); + e_alert_run_dialog_for_args ( + GTK_WINDOW (composer), + "mail-composer:no-build-message", + error->message, NULL); + g_error_free (error); + return; + } + + g_return_if_fail (CAMEL_IS_MIME_MESSAGE (msg)); + info = camel_message_info_new (NULL); - /* FIXME: what's the ~0 for? :) */ + /* The last argument is a bit mask which tells the function + * which flags to modify. In this case, ~0 means all flags. + * So it clears all the flags and then sets SEEN and DRAFT. */ camel_message_info_set_flags ( info, CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DRAFT, ~0); -- cgit v1.2.3