aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-05-29 09:18:25 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-05-29 19:09:20 +0800
commitfa39ba7c5dba1ce355fa560a1e46c542fb34a1b2 (patch)
tree812477bc2a96a5eeb02c377a5ee2d4c992696543
parentc27e3a1dd2241029b8ccb316cc5b5134f96a12a1 (diff)
downloadgsoc2013-evolution-fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2.tar
gsoc2013-evolution-fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2.tar.gz
gsoc2013-evolution-fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2.tar.bz2
gsoc2013-evolution-fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2.tar.lz
gsoc2013-evolution-fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2.tar.xz
gsoc2013-evolution-fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2.tar.zst
gsoc2013-evolution-fa39ba7c5dba1ce355fa560a1e46c542fb34a1b2.zip
EMailFormatterAttachment cleanups.
-rw-r--r--em-format/e-mail-formatter-attachment.c89
1 files changed, 35 insertions, 54 deletions
diff --git a/em-format/e-mail-formatter-attachment.c b/em-format/e-mail-formatter-attachment.c
index fb997c0230..50fbe844f3 100644
--- a/em-format/e-mail-formatter-attachment.c
+++ b/em-format/e-mail-formatter-attachment.c
@@ -120,7 +120,7 @@ emfe_attachment_format (EMailFormatterExtension *extension,
gchar *str, *text, *html;
gchar *button_id;
EAttachmentStore *store;
- EMailExtensionRegistry *reg;
+ EMailExtensionRegistry *registry;
GQueue *extensions;
EMailPartAttachment *empa;
CamelMimePart *mime_part;
@@ -176,23 +176,22 @@ emfe_attachment_format (EMailFormatterExtension *extension,
g_object_unref (attachment);
}
+ 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 *registry;
- GQueue *extensions;
- GList *iter;
-
- registry = e_mail_formatter_get_extension_registry (formatter);
+ GList *head, *link;
+ gboolean success = FALSE;
- 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 (!extensions)
return FALSE;
if (context->mode == E_MAIL_FORMATTER_MODE_PRINTING) {
@@ -229,33 +228,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);
- }
-
mime_part = e_mail_part_ref_mime_part (part);
text = e_mail_part_describe (mime_part, empa->snoop_mime_type);
flags = e_mail_formatter_get_text_format_flags (formatter);
@@ -287,13 +274,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;
@@ -306,7 +291,7 @@ emfe_attachment_format (EMailFormatterExtension *extension,
g_clear_object (&attachment_view_part);
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,
@@ -315,26 +300,22 @@ emfe_attachment_format (EMailFormatterExtension *extension,
}
} else {
+ GList *head, *link;
- for (iter = g_queue_peek_head_link (extensions); iter; iter = iter->next) {
-
- EMailFormatterExtension *ext;
+ head = g_queue_peek_head_link (extensions);
- ext = iter->data;
- if (!ext)
- continue;
-
- 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\">",
@@ -342,17 +323,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);