aboutsummaryrefslogtreecommitdiffstats
path: root/em-format/e-mail-parser-message-rfc822.c
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 /em-format/e-mail-parser-message-rfc822.c
parent4611bcd7b8958c5ffadccc8b68989c839cf3f144 (diff)
downloadgsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.tar
gsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.tar.gz
gsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.tar.bz2
gsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.tar.lz
gsoc2013-evolution-3924dc759dbf38df0f9ff6941990dcf242478617.tar.xz
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 'em-format/e-mail-parser-message-rfc822.c')
-rw-r--r--em-format/e-mail-parser-message-rfc822.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/em-format/e-mail-parser-message-rfc822.c b/em-format/e-mail-parser-message-rfc822.c
index 4632c6e0eb..70bf8c89ed 100644
--- a/em-format/e-mail-parser-message-rfc822.c
+++ b/em-format/e-mail-parser-message-rfc822.c
@@ -62,14 +62,14 @@ static const gchar * parser_mime_types[] = { "message/rfc822",
"message/news",
NULL };
-static GSList *
+static gboolean
empe_msg_rfc822_parse (EMailParserExtension *extension,
EMailParser *eparser,
CamelMimePart *part,
GString *part_id,
- GCancellable *cancellable)
+ GCancellable *cancellable,
+ GQueue *out_mail_parts)
{
- GSList *parts = NULL;
EMailPart *mail_part;
gint len;
CamelMimePart *message;
@@ -81,13 +81,14 @@ empe_msg_rfc822_parse (EMailParserExtension *extension,
len = part_id->len;
g_string_append (part_id, ".rfc822");
- /* Create an empty PURI that will represent start of the RFC message */
+ /* Create an empty PURI that will represent start of the RFC message */
mail_part = e_mail_part_new (part, part_id->str);
mail_part->mime_type = g_strdup ("message/rfc822");
- parts = g_slist_append (NULL, mail_part);
+ g_queue_push_tail (out_mail_parts, mail_part);
- /* Sometime the _actual_ message is encapsulated in another CamelMimePart,
- * sometimes the CamelMimePart actually represents the RFC822 message */
+ /* Sometime the actual message is encapsulated in another
+ * CamelMimePart, sometimes the CamelMimePart itself represents
+ * the RFC822 message. */
ct = camel_mime_part_get_content_type (part);
if (camel_content_type_is (ct, "message", "rfc822")) {
new_stream = camel_stream_mem_new ();
@@ -110,28 +111,29 @@ empe_msg_rfc822_parse (EMailParserExtension *extension,
message = g_object_ref (part);
}
- parts = g_slist_concat (parts, e_mail_parser_parse_part_as (
- eparser, message, part_id,
- "application/vnd.evolution.message",
- cancellable));
+ e_mail_parser_parse_part_as (
+ eparser, message, part_id,
+ "application/vnd.evolution.message",
+ cancellable, out_mail_parts);
g_object_unref (message);
- /* Add another generic EMailPart that represents end of the RFC message.
- * The em_format_write() function will skip all parts between the ".rfc822"
- * part and ".rfc822.end" part as they will be rendered in an <iframe> */
+ /* Add another generic EMailPart that represents end of the RFC
+ * message. The em_format_write() function will skip all parts
+ * between the ".rfc822" part and ".rfc822.end" part as they will
+ * be rendered in an <iframe>. */
g_string_append (part_id, ".end");
mail_part = e_mail_part_new (message, part_id->str);
mail_part->is_hidden = TRUE;
- parts = g_slist_append (parts, mail_part);
+ g_queue_push_tail (out_mail_parts, mail_part);
+
g_string_truncate (part_id, len);
- if (e_mail_part_is_attachment (message)) {
- return e_mail_parser_wrap_as_attachment (
- eparser, message, parts, part_id, cancellable);
- }
+ if (e_mail_part_is_attachment (message))
+ e_mail_parser_wrap_as_attachment (
+ eparser, message, part_id, out_mail_parts);
- return parts;
+ return TRUE;
}
static guint32