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. --- em-format/e-mail-parser-text-html.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'em-format/e-mail-parser-text-html.c') diff --git a/em-format/e-mail-parser-text-html.c b/em-format/e-mail-parser-text-html.c index b824931e09..a28a8ff5f0 100644 --- a/em-format/e-mail-parser-text-html.c +++ b/em-format/e-mail-parser-text-html.c @@ -57,22 +57,21 @@ G_DEFINE_TYPE_EXTENDED ( static const gchar *parser_mime_types[] = { "text/html", NULL }; -static GSList * +static gboolean empe_text_html_parse (EMailParserExtension *extension, EMailParser *parser, CamelMimePart *part, GString *part_id, - GCancellable *cancellable) + GCancellable *cancellable, + GQueue *out_mail_parts) { - EMailPart *empart; + GQueue work_queue = G_QUEUE_INIT; + EMailPart *mail_part; const gchar *location; gchar *cid = NULL; const gchar *base; gint len; - if (g_cancellable_is_cancelled (cancellable)) - return NULL; - cid = NULL; base = camel_medium_get_header (CAMEL_MEDIUM (part), "content-base"); location = camel_mime_part_get_content_location (part); @@ -93,18 +92,20 @@ empe_text_html_parse (EMailParserExtension *extension, len = part_id->len; g_string_append (part_id, ".text_html"); - empart = e_mail_part_new (part, part_id->str); - empart->mime_type = g_strdup ("text/html"); - empart->cid = cid; + mail_part = e_mail_part_new (part, part_id->str); + mail_part->mime_type = g_strdup ("text/html"); + mail_part->cid = cid; g_string_truncate (part_id, len); - if (e_mail_part_is_attachment (part)) { - return e_mail_parser_wrap_as_attachment ( - parser, part, g_slist_append (NULL, empart), - part_id, cancellable); - } + g_queue_push_head (&work_queue, mail_part); + + if (e_mail_part_is_attachment (part)) + e_mail_parser_wrap_as_attachment ( + parser, part, part_id, &work_queue); + + e_queue_transfer (&work_queue, out_mail_parts); - return g_slist_append (NULL, empart); + return TRUE; } static const gchar ** -- cgit v1.2.3