aboutsummaryrefslogtreecommitdiffstats
path: root/modules/text-highlight
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-12-06 08:42:15 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-12-08 03:01:04 +0800
commit3924dc759dbf38df0f9ff6941990dcf242478617 (patch)
treeaa00cb03ef21e3b11759dd9f094c9c2563d05956 /modules/text-highlight
parent4611bcd7b8958c5ffadccc8b68989c839cf3f144 (diff)
downloadgsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.tar.gz
gsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.tar.zst
gsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.zip
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.
Diffstat (limited to 'modules/text-highlight')
-rw-r--r--modules/text-highlight/e-mail-parser-text-highlight.c26
1 files changed, 13 insertions, 13 deletions
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 **