diff options
author | Not Zed <NotZed@Ximian.com> | 2003-08-16 04:57:30 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-08-16 04:57:30 +0800 |
commit | 87b5d92a77b11d4441b786763b5f409d903cf9c3 (patch) | |
tree | 81ea1325b20fda4a84d2815e86e684b65304053b /camel | |
parent | 405b846e5b5ab98ecb0d1a3545df3972df044730 (diff) | |
download | gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar.gz gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar.bz2 gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar.lz gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar.xz gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.tar.zst gsoc2013-evolution-87b5d92a77b11d4441b786763b5f409d903cf9c3.zip |
** 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
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 21 | ||||
-rw-r--r-- | camel/camel-data-wrapper.c | 1 | ||||
-rw-r--r-- | camel/camel-mime-message.c | 1 | ||||
-rw-r--r-- | camel/camel-mime-part-utils.c | 20 | ||||
-rw-r--r-- | camel/camel-mime-part.c | 3 | ||||
-rw-r--r-- | camel/camel-mime-part.h | 1 | ||||
-rw-r--r-- | camel/camel-multipart-signed.c | 1 | ||||
-rw-r--r-- | camel/camel-multipart.c | 1 | ||||
-rw-r--r-- | camel/tests/lib/messages.c | 66 | ||||
-rw-r--r-- | camel/tests/lib/messages.h | 2 |
10 files changed, 99 insertions, 18 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 010afb7fe2..92e759c655 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,24 @@ +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. + 2003-08-15 Jeffrey Stedfast <fejj@ximian.com> * providers/imap/camel-imap-wrapper.c (imap_wrapper_hydrate): diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c index f950c5d919..80575c96e8 100644 --- a/camel/camel-data-wrapper.c +++ b/camel/camel-data-wrapper.c @@ -177,6 +177,7 @@ decode_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) ssize_t ret; if (data_wrapper->stream == NULL) { + g_warning("data_wrapper->stream is NULL in decode_to_stream()"); return -1; } diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index ee5b7cac0e..a0700fc3a5 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -107,6 +107,7 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) /* virtual method overload */ camel_data_wrapper_class->write_to_stream = write_to_stream; + camel_data_wrapper_class->decode_to_stream = write_to_stream; camel_medium_class->add_header = add_header; camel_medium_class->set_header = set_header; 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); } diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 81036c0571..ac6e357b5b 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -164,7 +164,7 @@ camel_mime_part_init (gpointer object, gpointer klass) mime_part->content_MD5 = NULL; mime_part->content_location = NULL; mime_part->content_languages = NULL; - mime_part->encoding = CAMEL_MIME_PART_ENCODING_DEFAULT; + mime_part->encoding = CAMEL_MIME_PART_ENCODING_DEFAULT; } @@ -238,7 +238,6 @@ process_header(CamelMedium *medium, const char *header_name, const char *header_ mime_part->content_id = header_contentid_decode (header_value); break; case HEADER_ENCODING: - /* FIXME: ignore this if we are a multipart or a message/rfc822 part */ text = header_token_decode (header_value); mime_part->encoding = camel_mime_part_encoding_from_string (text); g_free (text); diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h index ac7fb403f4..ff2a311446 100644 --- a/camel/camel-mime-part.h +++ b/camel/camel-mime-part.h @@ -100,6 +100,7 @@ const GList *camel_mime_part_get_content_languages (CamelMimePart *mime_part); void camel_mime_part_set_content_type (CamelMimePart *mime_part, const char *content_type); CamelContentType *camel_mime_part_get_content_type (CamelMimePart *mime_part); +/* FIXME: move to camel-mime-utils, and rename CamelEncodingType or CamelTransferEncoding */ const char * camel_mime_part_encoding_to_string (CamelMimePartEncodingType encoding); CamelMimePartEncodingType camel_mime_part_encoding_from_string (const char *string); diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c index cc3b493e4a..5b776d7f9d 100644 --- a/camel/camel-multipart-signed.c +++ b/camel/camel-multipart-signed.c @@ -84,6 +84,7 @@ camel_multipart_signed_class_init (CamelMultipartSignedClass *camel_multipart_si /* virtual method overload */ camel_data_wrapper_class->construct_from_stream = construct_from_stream; camel_data_wrapper_class->write_to_stream = write_to_stream; + camel_data_wrapper_class->decode_to_stream = write_to_stream; camel_data_wrapper_class->set_mime_type_field = set_mime_type_field; mpclass->add_part = signed_add_part; diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index fcb500df93..0d5148e890 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -95,6 +95,7 @@ camel_multipart_class_init (CamelMultipartClass *camel_multipart_class) /* virtual method overload */ camel_data_wrapper_class->write_to_stream = write_to_stream; + camel_data_wrapper_class->decode_to_stream = write_to_stream; camel_data_wrapper_class->is_offline = is_offline; } diff --git a/camel/tests/lib/messages.c b/camel/tests/lib/messages.c index 3cf1b5fd51..5a687e8df3 100644 --- a/camel/tests/lib/messages.c +++ b/camel/tests/lib/messages.c @@ -189,27 +189,32 @@ test_message_compare (CamelMimeMessage *msg) CamelStreamMem *mem1, *mem2; mem1 = (CamelStreamMem *) camel_stream_mem_new (); - camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, (CamelStream *) mem1); + check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, (CamelStream *) mem1) != -1, "write_to_stream 1 failed"); camel_stream_reset ((CamelStream *) mem1); msg2 = camel_mime_message_new (); - camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem1); + check_msg(camel_data_wrapper_construct_from_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem1) != -1, "construct_from_stream 1 failed"); camel_stream_reset ((CamelStream *) mem1); mem2 = (CamelStreamMem *) camel_stream_mem_new (); - camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem2); + check_msg(camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg2, (CamelStream *) mem2) != -1, "write_to_stream 2 failed"); camel_stream_reset ((CamelStream *) mem2); - camel_object_unref (msg2); - if (mem1->buffer->len != mem2->buffer->len) { CamelDataWrapper *content; printf ("mem1 stream:\n%.*s\n", mem1->buffer->len, mem1->buffer->data); printf ("mem2 stream:\n%.*s\n\n", mem2->buffer->len, mem2->buffer->data); - + + printf("msg1:\n"); + test_message_dump_structure(msg); + printf("msg2:\n"); + test_message_dump_structure(msg2); + content = camel_medium_get_content_object ((CamelMedium *) msg); } + + check_unref(msg2, 1); check_msg (mem1->buffer->len == mem2->buffer->len, "mem1->buffer->len = %d, mem2->buffer->len = %d", @@ -234,3 +239,52 @@ test_message_compare_messages(CamelMimeMessage *m1, CamelMimeMessage *m2) { return 0; } + +static void +message_dump_rec(CamelMimeMessage *msg, CamelMimePart *part, int depth) +{ + CamelDataWrapper *containee; + int parts, i; + char *s; + char *mime_type; + + s = alloca(depth+1); + memset(s, ' ', depth); + s[depth] = 0; + + mime_type = camel_data_wrapper_get_mime_type((CamelDataWrapper *)part); + printf("%sPart <%s>\n", s, ((CamelObject *)part)->klass->name); + printf("%sContent-Type: %s\n", s, mime_type); + g_free(mime_type); + printf("%s encoding: %s\n", s, camel_mime_part_encoding_to_string(((CamelDataWrapper *)part)->encoding)); + printf("%s part encoding: %s\n", s, camel_mime_part_encoding_to_string(part->encoding)); + + containee = camel_medium_get_content_object (CAMEL_MEDIUM (part)); + + if (containee == NULL) + return; + + mime_type = camel_data_wrapper_get_mime_type(containee); + printf("%sContent <%s>\n", s, ((CamelObject *)containee)->klass->name); + printf ("%sContent-Type: %s\n", s, mime_type); + g_free (mime_type); + printf("%s encoding: %s\n", s, camel_mime_part_encoding_to_string(((CamelDataWrapper *)containee)->encoding)); + + /* using the object types is more accurate than using the mime/types */ + if (CAMEL_IS_MULTIPART (containee)) { + parts = camel_multipart_get_number (CAMEL_MULTIPART (containee)); + for (i = 0; i < parts; i++) { + CamelMimePart *part = camel_multipart_get_part (CAMEL_MULTIPART (containee), i); + + message_dump_rec(msg, part, depth+1); + } + } else if (CAMEL_IS_MIME_MESSAGE (containee)) { + message_dump_rec(msg, (CamelMimePart *)containee, depth+1); + } +} + +void +test_message_dump_structure(CamelMimeMessage *m) +{ + message_dump_rec(m, (CamelMimePart *)m, 0); +} diff --git a/camel/tests/lib/messages.h b/camel/tests/lib/messages.h index cdac98f30a..1f892c3cc8 100644 --- a/camel/tests/lib/messages.h +++ b/camel/tests/lib/messages.h @@ -11,3 +11,5 @@ int test_message_write_file(CamelMimeMessage *msg, const char *name); CamelMimeMessage *test_message_read_file(const char *name); int test_message_compare_content(CamelDataWrapper *dw, const char *text, int len); int test_message_compare (CamelMimeMessage *msg); + +void test_message_dump_structure(CamelMimeMessage *m); |