diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-11-27 05:30:55 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-11-27 05:30:55 +0800 |
commit | 722899621625bafb134152534a3af08a0c9ef837 (patch) | |
tree | c86d5d549a7a3c3a47632206557c35f90541a834 /camel/camel-mime-part.c | |
parent | 6f9e5d77d970584de089538d1bd8913f03973048 (diff) | |
download | gsoc2013-evolution-722899621625bafb134152534a3af08a0c9ef837.tar.gz gsoc2013-evolution-722899621625bafb134152534a3af08a0c9ef837.tar.zst gsoc2013-evolution-722899621625bafb134152534a3af08a0c9ef837.zip |
For the uudecoding mode, garble up the "begin <mode> <filename>" line
2001-11-26 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-filter-basic.c: For the uudecoding mode, garble up
the "begin <mode> <filename>" line before decoding.
* camel-mime-part-utils.c
(simple_data_wrapper_construct_from_parser): Add a uudecoder if
the transfer encoding is x-uuencode.
* camel-mime-part.c (write_to_stream): Handle x-uuencoded content
too.
svn path=/trunk/; revision=14789
Diffstat (limited to 'camel/camel-mime-part.c')
-rw-r--r-- | camel/camel-mime-part.c | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 303fba6c7d..9a0f1b83eb 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -545,6 +545,7 @@ write_to_stream(CamelDataWrapper *data_wrapper, CamelStream *stream) { CamelMimePart *mp = CAMEL_MIME_PART(data_wrapper); CamelMedium *medium = CAMEL_MEDIUM(data_wrapper); + CamelStream *ostream = stream; CamelDataWrapper *content; int total = 0; int count; @@ -556,11 +557,11 @@ write_to_stream(CamelDataWrapper *data_wrapper, CamelStream *stream) #ifndef NO_WARNINGS #warning content-languages should be stored as a header #endif - + if (mp->headers) { struct _header_raw *h = mp->headers; char *val; - + /* fold/write the headers. But dont fold headers that are already formatted (e.g. ones with parameter-lists, that we know about, and have created) */ while (h) { @@ -581,12 +582,12 @@ write_to_stream(CamelDataWrapper *data_wrapper, CamelStream *stream) h = h->next; } } - + count = camel_stream_write(stream, "\n", 1); if (count == -1) return -1; total += count; - + content = camel_medium_get_content_object(medium); if (content) { /* I dont really like this here, but i dont know where else it might go ... */ @@ -595,15 +596,24 @@ write_to_stream(CamelDataWrapper *data_wrapper, CamelStream *stream) CamelMimeFilter *filter = NULL; CamelStreamFilter *filter_stream = NULL; CamelMimeFilter *charenc = NULL; + const char *filename; const char *charset; - - switch(mp->encoding) { + + switch (mp->encoding) { case CAMEL_MIME_PART_ENCODING_BASE64: filter = (CamelMimeFilter *)camel_mime_filter_basic_new_type(CAMEL_MIME_FILTER_BASIC_BASE64_ENC); break; case CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE: filter = (CamelMimeFilter *)camel_mime_filter_basic_new_type(CAMEL_MIME_FILTER_BASIC_QP_ENC); break; + case CAMEL_MIME_PART_ENCODING_UUENCODE: + filename = camel_mime_part_get_filename (mp); + count = camel_stream_printf (ostream, "begin 644 %s\n", filename ? filename : "untitled"); + if (count == -1) + return -1; + total += count; + filter = (CamelMimeFilter *)camel_mime_filter_basic_new_type(CAMEL_MIME_FILTER_BASIC_UU_ENC); + break; default: break; } @@ -617,33 +627,34 @@ write_to_stream(CamelDataWrapper *data_wrapper, CamelStream *stream) if (filter || charenc) { filter_stream = camel_stream_filter_new_with_stream(stream); - + /* if we have a character encoder, add that always */ if (charenc) { camel_stream_filter_add(filter_stream, charenc); camel_object_unref((CamelObject *)charenc); } - + /* we only re-do crlf on encoded blocks */ if (filter && header_content_type_is(mp->content_type, "text", "*")) { CamelMimeFilter *crlf = camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_ENCODE, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY); - + camel_stream_filter_add(filter_stream, crlf); camel_object_unref((CamelObject *)crlf); - } - + if (filter) { camel_stream_filter_add(filter_stream, filter); camel_object_unref((CamelObject *)filter); } - + stream = (CamelStream *)filter_stream; } #endif + count = camel_data_wrapper_write_to_stream(content, stream); + if (filter_stream) { camel_stream_flush((CamelStream *)filter_stream); camel_object_unref((CamelObject *)filter_stream); @@ -651,9 +662,17 @@ write_to_stream(CamelDataWrapper *data_wrapper, CamelStream *stream) if (count == -1) return -1; total += count; + + if (mp->encoding == CAMEL_MIME_PART_ENCODING_UUENCODE) { + count = camel_stream_write (ostream, "end\n", 4); + if (count == -1) + return -1; + total += count; + } } else { g_warning("No content for medium, nothing to write"); } + return total; } @@ -750,7 +769,8 @@ static const char *encodings[] = { "8bit", "base64", "quoted-printable", - "binary" + "binary", + "x-uuencode", }; const char * |