From cd7969810436f5f4074736e72e6f68fac9469074 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Thu, 29 Jan 2004 09:45:59 +0000 Subject: Fixes a bug i can't find right now 2004-01-29 Not Zed * em-format-html-display.c (efhd_attachment_button): check the snooped type for the icon/etc. (efhd_format_attachment): save the snooped type in the attach_puri. * em-format-html.c (efh_text_plain): If we had a snooped type, use that as the base type, rather than octet-stream, which will cause an attachment in attachment loop. * em-format.c (em_format_part_as): save the current snooped mime type in a stack if we had any. svn path=/trunk/; revision=24515 --- mail/ChangeLog | 14 ++++++++++++++ mail/em-format-html-display.c | 10 ++++++++-- mail/em-format-html.c | 12 +++++++++++- mail/em-format.c | 7 ++++++- mail/em-format.h | 2 ++ 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 1151a322d7..adb87f4d10 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,17 @@ +2004-01-29 Not Zed + + * em-format-html-display.c (efhd_attachment_button): check the + snooped type for the icon/etc. + (efhd_format_attachment): save the snooped type in the + attach_puri. + + * em-format-html.c (efh_text_plain): If we had a snooped type, use + that as the base type, rather than octet-stream, which will cause + an attachment in attachment loop. + + * em-format.c (em_format_part_as): save the current snooped mime + type in a stack if we had any. + 2004-01-29 Not Zed ** See bug #53320 and probably others diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index d904bf33a6..64fefde3fe 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -116,6 +116,8 @@ struct _attach_puri { const EMFormatHandler *handle; + const char *snoop_mime_type; + /* for the > and V buttons */ GtkWidget *forward, *down; /* currently no way to correlate this data to the frame :( */ @@ -1320,8 +1322,11 @@ efhd_attachment_button(EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObje gtk_container_add((GtkContainer *)button, hbox); gtk_box_pack_start((GtkBox *)mainbox, button, TRUE, TRUE, 0); - /* FIXME: loses any snoop info */ - simple_type = camel_content_type_simple (((CamelDataWrapper *)pobject->part)->mime_type); + /* Check for snooped type to get the right icon/processing */ + if (info->snoop_mime_type) + simple_type = g_strdup(info->snoop_mime_type); + else + simple_type = camel_content_type_simple (((CamelDataWrapper *)pobject->part)->mime_type); camel_strdown(simple_type); /* FIXME: offline parts, just get icon */ @@ -1547,6 +1552,7 @@ efhd_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, em_format_html_add_pobject((EMFormatHTML *)emf, sizeof(EMFormatHTMLPObject), classid, part, efhd_attachment_button); info->handle = handle; info->shown = em_format_is_inline(emf, info->puri.part) && handle != NULL; + info->snoop_mime_type = emf->snoop_mime_type; camel_stream_write_string(stream, "
\n" diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 441dc854e8..a619040ef0 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -701,11 +701,20 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo if (mp == NULL) { EMInlineFilter *inline_filter; CamelStream *null; + CamelContentType *ct; + + /* if we had to snoop the part type to get here, then + * use that as the base type, yuck */ + if (((EMFormat *)efh)->snoop_mime_type == NULL + || (ct = camel_content_type_decode(((EMFormat *)efh)->snoop_mime_type)) == NULL) { + ct = dw->mime_type; + camel_content_type_ref(ct); + } null = camel_stream_null_new(); filtered_stream = camel_stream_filter_new_with_stream(null); camel_object_unref(null); - inline_filter = em_inline_filter_new(camel_mime_part_get_encoding(part), dw->mime_type); + inline_filter = em_inline_filter_new(camel_mime_part_get_encoding(part), ct); camel_stream_filter_add(filtered_stream, (CamelMimeFilter *)inline_filter); camel_data_wrapper_write_to_stream(dw, (CamelStream *)filtered_stream); camel_stream_close((CamelStream *)filtered_stream); @@ -713,6 +722,7 @@ efh_text_plain(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFo mp = em_inline_filter_get_multipart(inline_filter); g_hash_table_insert(efh->priv->text_inline_parts, part, mp); camel_object_unref(inline_filter); + camel_content_type_unref(ct); } filtered_stream = camel_stream_filter_new_with_stream(stream); diff --git a/mail/em-format.c b/mail/em-format.c index ef6678dfb3..7eb8794827 100644 --- a/mail/em-format.c +++ b/mail/em-format.c @@ -477,10 +477,13 @@ void em_format_part_as(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const char *mime_type) { const EMFormatHandler *handle = NULL; + const char *snoop_save = emf->snoop_mime_type; + + emf->snoop_mime_type = NULL; if (mime_type != NULL) { if (g_ascii_strcasecmp(mime_type, "application/octet-stream") == 0) - mime_type = emf_snoop_part(part); + emf->snoop_mime_type = mime_type = emf_snoop_part(part); handle = em_format_find_handler(emf, mime_type); if (handle == NULL) @@ -490,6 +493,7 @@ em_format_part_as(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const && !em_format_is_attachment(emf, part)) { d(printf("running handler for type '%s'\n", mime_type)); handle->handler(emf, stream, part, handle); + emf->snoop_mime_type = snoop_save; return; } d(printf("this type is an attachment? '%s'\n", mime_type)); @@ -498,6 +502,7 @@ em_format_part_as(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const } ((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_attachment(emf, stream, part, mime_type, handle); + emf->snoop_mime_type = snoop_save; } void diff --git a/mail/em-format.h b/mail/em-format.h index 5d41ae0020..a5fd08f55c 100644 --- a/mail/em-format.h +++ b/mail/em-format.h @@ -112,6 +112,8 @@ struct _EMFormat { struct _CamelSession *session; /* session, used for authentication when required */ struct _CamelURL *base; /* current location (base url) */ + const char *snoop_mime_type; /* if we snooped an application/octet-stream type, what we snooped */ + /* for forcing inlining */ GHashTable *inline_table; -- cgit v1.2.3