From 87b5d92a77b11d4441b786763b5f409d903cf9c3 Mon Sep 17 00:00:00 2001
From: Not Zed <NotZed@Ximian.com>
Date: Fri, 15 Aug 2003 20:57:30 +0000
Subject: ** See bug #47634.

2003-08-15  Not Zed  <NotZed@Ximian.com>

        ** See bug #47634.

        * tests/lib/messages.c (test_message_compare): check
        write_to_stream returns.
        (message_dump_rec): helper to dump message structure.

        * camel-mime-part-utils.c
        (simple_data_wrapper_construct_from_parser): dont set content
        encoding here.
        (camel_mime_part_construct_content_from_parser): set it here
        instead, on every part.  basically same as setting the
        mime_type_field always.

        * camel-multipart-signed.c (camel_multipart_signed_class_init):
        * camel-mime-message.c (camel_mime_message_class_init):
        * camel-multipart.c (camel_multipart_class_init): override
        decode_to_stream to always do the same as write_to_stream, since
        we can never be encoded.

svn path=/trunk/; revision=22252
---
 camel/camel-mime-part-utils.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'camel/camel-mime-part-utils.c')

diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 92769b3083..0f80507fd7 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -57,16 +57,13 @@
 static void
 simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser *mp)
 {
-	char *encoding, *buf;
+	char *buf;
 	GByteArray *buffer;
 	CamelStream *mem;
 	size_t len;
 	
 	d(printf ("simple_data_wrapper_construct_from_parser()\n"));
 	
-	/* first, work out conversion, if any, required, we dont care about what we dont know about */
-	encoding = header_content_encoding_decode (camel_mime_parser_header (mp, "Content-Transfer-Encoding", NULL));
-	
 	/* read in the entire content */
 	buffer = g_byte_array_new ();
 	while (camel_mime_parser_step (mp, &buf, &len) != HSCAN_BODY_END) {
@@ -79,11 +76,6 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser
 	mem = camel_stream_mem_new_with_byte_array (buffer);
 	camel_data_wrapper_construct_from_stream (dw, mem);
 	camel_object_unref (mem);
-	
-	if (encoding) {
-		dw->encoding = camel_mime_part_encoding_from_string (encoding);
-		g_free (encoding);
-	}
 }
 
 /* This replaces the data wrapper repository ... and/or could be replaced by it? */
@@ -92,8 +84,11 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse
 {
 	CamelDataWrapper *content = NULL;
 	CamelContentType *ct;
-	
+	char *encoding;
+
 	ct = camel_mime_parser_content_type (mp);
+
+	encoding = header_content_encoding_decode (camel_mime_parser_header (mp, "Content-Transfer-Encoding", NULL));
 	
 	switch (camel_mime_parser_state (mp)) {
 	case HSCAN_HEADER:
@@ -129,9 +124,14 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse
 	}
 	
 	if (content) {
+		if (encoding)
+			content->encoding = camel_mime_part_encoding_from_string (encoding);
+
 		/* would you believe you have to set this BEFORE you set the content object???  oh my god !!!! */
 		camel_data_wrapper_set_mime_type_field (content, camel_mime_part_get_content_type (dw));
 		camel_medium_set_content_object ((CamelMedium *)dw, content);
 		camel_object_unref (content);
 	}
+
+	g_free (encoding);
 }
-- 
cgit v1.2.3