diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-05-29 09:18:25 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-05-29 19:45:50 +0800 |
commit | 767fc1d01b6e7526146e1fd134140994fd9d43b5 (patch) | |
tree | 99f1b87be484366fe418919cb5ebcc82be33daa8 /em-format | |
parent | e339ec69c87e8753eb8ceeb5901740220d1696ab (diff) | |
download | gsoc2013-evolution-767fc1d01b6e7526146e1fd134140994fd9d43b5.tar gsoc2013-evolution-767fc1d01b6e7526146e1fd134140994fd9d43b5.tar.gz gsoc2013-evolution-767fc1d01b6e7526146e1fd134140994fd9d43b5.tar.bz2 gsoc2013-evolution-767fc1d01b6e7526146e1fd134140994fd9d43b5.tar.lz gsoc2013-evolution-767fc1d01b6e7526146e1fd134140994fd9d43b5.tar.xz gsoc2013-evolution-767fc1d01b6e7526146e1fd134140994fd9d43b5.tar.zst gsoc2013-evolution-767fc1d01b6e7526146e1fd134140994fd9d43b5.zip |
EMailFormatterAttachment cleanups.
(cherry picked from commit fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2)
Conflicts:
em-format/e-mail-formatter-attachment.c
Diffstat (limited to 'em-format')
-rw-r--r-- | em-format/e-mail-formatter-attachment.c | 95 |
1 files changed, 38 insertions, 57 deletions
diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c index d84c6b75a3..7b98cf212d 100644 --- a/em-format/e-mail-formatter-attachment.c +++ b/em-format/e-mail-formatter-attachment.c @@ -113,7 +113,7 @@ emfe_attachment_format (EMailFormatterExtension *extension, gchar *str, *text, *html; gchar *button_id; EAttachmentStore *store; - EMailExtensionRegistry *reg; + EMailExtensionRegistry *registry; GQueue *extensions; EMailPartAttachment *empa; CamelMimeFilterToHTMLFlags flags; @@ -156,23 +156,22 @@ emfe_attachment_format (EMailFormatterExtension *extension, } } - /* If the attachment is requested as RAW, then call the handler directly - * and do not append any other code. */ + registry = e_mail_formatter_get_extension_registry (formatter); + + extensions = e_mail_extension_registry_get_for_mime_type ( + registry, empa->snoop_mime_type); + if (extensions == NULL) + extensions = e_mail_extension_registry_get_fallback ( + registry, empa->snoop_mime_type); + + /* If the attachment is requested as RAW, then call the + * handler directly and do not append any other code. */ if ((context->mode == E_MAIL_FORMATTER_MODE_RAW) || (context->mode == E_MAIL_FORMATTER_MODE_PRINTING)) { - EMailExtensionRegistry *reg; - GQueue *extensions; - GList *iter; - reg = e_mail_formatter_get_extension_registry (formatter); - - extensions = e_mail_extension_registry_get_for_mime_type ( - reg, empa->snoop_mime_type); - if (!extensions) { - extensions = e_mail_extension_registry_get_fallback ( - reg, empa->snoop_mime_type); - } + GList *head, *link; + gboolean success = FALSE; - if (!extensions) + if (extensions == NULL) return FALSE; if (context->mode == E_MAIL_FORMATTER_MODE_PRINTING) { @@ -206,33 +205,21 @@ emfe_attachment_format (EMailFormatterExtension *extension, g_object_unref (file_info); } - for (iter = g_queue_peek_head_link (extensions); iter; iter = iter->next) { - - EMailFormatterExtension *ext; - ext = iter->data; - if (!ext) - continue; + head = g_queue_peek_head_link (extensions); - if (e_mail_formatter_extension_format (ext, formatter, - context, part, stream, cancellable)) { - return TRUE; - } + for (link = head; link != NULL; link = g_list_next (link)) { + success = e_mail_formatter_extension_format ( + E_MAIL_FORMATTER_EXTENSION (link->data), + formatter, context, part, stream, cancellable); + if (success) + break; } - return FALSE; + return success; } /* E_MAIL_FORMATTER_MODE_NORMAL: */ - reg = e_mail_formatter_get_extension_registry (formatter); - extensions = e_mail_extension_registry_get_for_mime_type ( - reg, empa->snoop_mime_type); - - if (!extensions) { - extensions = e_mail_extension_registry_get_fallback ( - reg, empa->snoop_mime_type); - } - text = e_mail_part_describe (part->part, empa->snoop_mime_type); flags = e_mail_formatter_get_text_format_flags (formatter); html = camel_text_to_html ( @@ -262,13 +249,11 @@ emfe_attachment_format (EMailFormatterExtension *extension, g_free (str); g_free (html); - if (extensions) { - GList *iter; + if (extensions != NULL) { CamelStream *content_stream; - gboolean ok; + gboolean success = FALSE; content_stream = camel_stream_mem_new (); - ok = FALSE; if (empa->attachment_view_part_id != NULL) { EMailPart *attachment_view_part; @@ -283,7 +268,7 @@ emfe_attachment_format (EMailFormatterExtension *extension, } if (attachment_view_part != NULL) { - ok = e_mail_formatter_format_as ( + success = e_mail_formatter_format_as ( formatter, context, attachment_view_part, content_stream, NULL, @@ -292,26 +277,22 @@ emfe_attachment_format (EMailFormatterExtension *extension, } } else { + GList *head, *link; - for (iter = g_queue_peek_head_link (extensions); iter; iter = iter->next) { - - EMailFormatterExtension *ext; - - ext = iter->data; - if (!ext) - continue; + head = g_queue_peek_head_link (extensions); - if (e_mail_formatter_extension_format ( - ext, formatter, context, - part, content_stream, - cancellable)) { - ok = TRUE; + for (link = head; link != NULL; link = g_list_next (link)) { + success = e_mail_formatter_extension_format ( + E_MAIL_FORMATTER_EXTENSION (link->data), + formatter, context, + part, content_stream, + cancellable); + if (success) break; - } } } - if (ok) { + if (success) { str = g_strdup_printf ( "<tr><td colspan=\"2\">" "<div class=\"attachment-wrapper\" id=\"%s\">", @@ -319,17 +300,17 @@ emfe_attachment_format (EMailFormatterExtension *extension, camel_stream_write_string ( stream, str, cancellable, NULL); - g_free (str); g_seekable_seek ( G_SEEKABLE (content_stream), 0, G_SEEK_SET, cancellable, NULL); camel_stream_write_to_stream ( - content_stream, stream, - cancellable, NULL); + content_stream, stream, cancellable, NULL); camel_stream_write_string ( stream, "</div></td></tr>", cancellable, NULL); + + g_free (str); } g_object_unref (content_stream); |