diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-12-06 08:42:15 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-12-08 03:01:04 +0800 |
commit | 3924dc759dbf38df0f9ff6941990dcf242478617 (patch) | |
tree | aa00cb03ef21e3b11759dd9f094c9c2563d05956 /composer | |
parent | 4611bcd7b8958c5ffadccc8b68989c839cf3f144 (diff) | |
download | gsoc2013-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 'composer')
-rw-r--r-- | composer/e-msg-composer.c | 15 |
1 files changed, 7 insertions, 8 deletions
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); |