From 3924dc759dbf38df0f9ff6941990dcf242478617 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 5 Dec 2012 19:42:15 -0500 Subject: EMailParserExtension: Collect EMailParts in a GQueue. Collect EMailParts in a GQueue provided to the EMailParserExtension, and change the return type of parse() to gboolean to indicate whether the given CamelMimePart was handled (even if no parts were added to the output GQueue). This avoids the awkward corner case of a parser extension returning a linked list node with a NULL data member to indicate the CamelMimePart was handled but no EMailParts produced, and then having to watch out for that NULL data member corner case throughout the application. Also, remove the GCancellable parameter from e_mail_parser_error() and e_mail_parser_wrap_as_attachment() since neither function blocks. --- composer/e-msg-composer.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'composer') diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 4fa48a717b..5cd9a70f75 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -194,7 +194,7 @@ emcu_part_to_html (CamelSession *session, GString *part_id; EShell *shell; GtkWindow *window; - GSList *list; + GQueue queue = G_QUEUE_INIT; shell = e_shell_get_default (); window = e_shell_get_active_window (shell); @@ -207,13 +207,12 @@ emcu_part_to_html (CamelSession *session, part_id = g_string_sized_new (0); parser = e_mail_parser_new (session); - list = e_mail_parser_parse_part (parser, part, part_id, cancellable); - while (list != NULL) { - if (list->data != NULL) { - e_mail_part_list_add_part (part_list, list->data); - e_mail_part_unref (list->data); - } - list = g_slist_delete_link (list, list); + e_mail_parser_parse_part ( + parser, part, part_id, cancellable, &queue); + while (!g_queue_is_empty (&queue)) { + EMailPart *mail_part = g_queue_pop_head (&queue); + e_mail_part_list_add_part (part_list, mail_part); + e_mail_part_unref (mail_part); } g_string_free (part_id, TRUE); g_object_unref (parser); -- cgit