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. --- .../text-highlight/e-mail-parser-text-highlight.c | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'modules/text-highlight') diff --git a/modules/text-highlight/e-mail-parser-text-highlight.c b/modules/text-highlight/e-mail-parser-text-highlight.c index 69aa1ccff2..eb56162a3d 100644 --- a/modules/text-highlight/e-mail-parser-text-highlight.c +++ b/modules/text-highlight/e-mail-parser-text-highlight.c @@ -58,21 +58,20 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED ( E_TYPE_MAIL_PARSER_EXTENSION, e_mail_parser_parser_extension_interface_init)); -static GSList * +static gboolean empe_text_highlight_parse (EMailParserExtension *extension, EMailParser *parser, CamelMimePart *part, GString *part_id, - GCancellable *cancellable) + GCancellable *cancellable, + GQueue *out_mail_parts) { - GSList *parts; - gint len; CamelContentType *ct; + gint len; /* Prevent recursion */ - if (strstr (part_id->str, ".text-highlight") != NULL) { - return NULL; - } + if (strstr (part_id->str, ".text-highlight") != NULL) + return FALSE; /* Don't parse text/html if it's not an attachment */ ct = camel_mime_part_get_content_type (part); @@ -80,9 +79,8 @@ empe_text_highlight_parse (EMailParserExtension *extension, const CamelContentDisposition *disp; disp = camel_mime_part_get_content_disposition (part); - if (!disp || (g_strcmp0 (disp->disposition, "attachment") != 0)) { - return NULL; - } + if (!disp || (g_strcmp0 (disp->disposition, "attachment") != 0)) + return FALSE; } len = part_id->len; @@ -90,12 +88,14 @@ empe_text_highlight_parse (EMailParserExtension *extension, /* All source codes and scripts are in general plain texts, * so let text/plain parser handle it. */ - parts = e_mail_parser_parse_part_as ( - parser, part, part_id, "text/plain", cancellable); + + e_mail_parser_parse_part_as ( + parser, part, part_id, "text/plain", + cancellable, out_mail_parts); g_string_truncate (part_id, len); - return parts; + return TRUE; } static const gchar ** -- cgit v1.2.3