diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-03-01 04:37:11 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-03-01 04:37:11 +0800 |
commit | 6b89252b9f2d3aff1ecd2779095a8b09685385c5 (patch) | |
tree | 50103d7e3417a929f667bd27549615a99a3a93a5 | |
parent | c09b6f1f2bb87fe2a3227a4a0656c3e892f6adcb (diff) | |
download | gsoc2013-evolution-6b89252b9f2d3aff1ecd2779095a8b09685385c5.tar gsoc2013-evolution-6b89252b9f2d3aff1ecd2779095a8b09685385c5.tar.gz gsoc2013-evolution-6b89252b9f2d3aff1ecd2779095a8b09685385c5.tar.bz2 gsoc2013-evolution-6b89252b9f2d3aff1ecd2779095a8b09685385c5.tar.lz gsoc2013-evolution-6b89252b9f2d3aff1ecd2779095a8b09685385c5.tar.xz gsoc2013-evolution-6b89252b9f2d3aff1ecd2779095a8b09685385c5.tar.zst gsoc2013-evolution-6b89252b9f2d3aff1ecd2779095a8b09685385c5.zip |
Rearrange the save filter stuff so that we save raw streams for all mime
2002-02-28 Jeffrey Stedfast <fejj@ximian.com>
* camel-mime-part-utils.c
(camel_mime_part_construct_content_from_parser): Rearrange the
save filter stuff so that we save raw streams for all mime
parts. If the mime part turns out to be a multupart, then don't
bother saving the raw stream, we only need to save the raw stream
for leaf parts.
svn path=/trunk/; revision=15873
-rw-r--r-- | camel/ChangeLog | 9 | ||||
-rw-r--r-- | camel/camel-mime-part-utils.c | 67 |
2 files changed, 40 insertions, 36 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index aa26d8451c..c8e48b9653 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,12 @@ +2002-02-28 Jeffrey Stedfast <fejj@ximian.com> + + * camel-mime-part-utils.c + (camel_mime_part_construct_content_from_parser): Rearrange the + save filter stuff so that we save raw streams for all mime + parts. If the mime part turns out to be a multupart, then don't + bother saving the raw stream, we only need to save the raw stream + for leaf parts. + 2002-02-27 Jeffrey Stedfast <fejj@ximian.com> * camel-folder-summary.h: Don't #include camel-mime-filter-save.h, diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index e21152951b..3b93fab686 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -2,7 +2,8 @@ /* camel-mime-part-utils : Utility for mime parsing and so on * * Authors: Bertrand Guiheneuf <bertrand@helixcode.com> - * Michael Zucchi <notzed@ximian.com> + * Michael Zucchi <notzed@ximian.com> + * Jeffrey Stedfast <fejj@ximian.com> * * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com) * @@ -312,10 +313,24 @@ simple_data_wrapper_construct_from_parser (CamelDataWrapper *dw, CamelMimeParser void camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParser *mp) { + struct _header_content_type *content_type; CamelDataWrapper *content = NULL; + CamelMimeFilter *save_filter; + CamelStream *raw = NULL; + int saveid = -1; char *buf; int len; + content_type = camel_mime_parser_content_type (mp); + +#define SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES +#ifdef SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES + raw = camel_stream_mem_new (); + save_filter = camel_mime_filter_save_new_with_stream (raw); + saveid = camel_mime_parser_filter_add (mp, save_filter); + camel_object_unref (CAMEL_OBJECT (save_filter)); +#endif /* SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES */ + switch (camel_mime_parser_state (mp)) { case HSCAN_HEADER: d(printf("Creating body part\n")); @@ -328,53 +343,24 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse camel_mime_part_construct_from_parser ((CamelMimePart *)content, mp); break; case HSCAN_MULTIPART: { - struct _header_content_type *content_type; - CamelMimeFilter *save_filter = NULL; CamelDataWrapper *bodypart; - CamelStream *raw = NULL; - int saveid = -1; /* FIXME: we should use a came-mime-mutlipart, not jsut a camel-multipart, but who cares */ d(printf("Creating multi-part\n")); + + /* we don't need to save raw streams for multiparts */ + camel_object_unref (CAMEL_OBJECT (raw)); + camel_mime_parser_filter_remove (mp, saveid); + content = (CamelDataWrapper *)camel_multipart_new (); - - content_type = camel_mime_parser_content_type (mp); + camel_multipart_set_boundary ((CamelMultipart *)content, header_content_type_param (content_type, "boundary")); -#define SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES -#ifdef SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES - if (header_content_type_is (content_type, "multipart", "signed")) { - /* save the raw mime stream for the first mime part in the multipart/signed */ - raw = camel_stream_mem_new (); - save_filter = camel_mime_filter_save_new_with_stream (raw); - saveid = camel_mime_parser_filter_add (mp, save_filter); - camel_object_unref (CAMEL_OBJECT (save_filter)); - } -#endif /* SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES */ - while (camel_mime_parser_step (mp, &buf, &len) != HSCAN_MULTIPART_END) { camel_mime_parser_unstep (mp); bodypart = (CamelDataWrapper *)camel_mime_part_new (); camel_mime_part_construct_from_parser ((CamelMimePart *)bodypart, mp); -#ifdef SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES - if (raw) { - /* set the raw mime stream on the first part within the multipart/signed */ - CamelDataWrapper *content_object; - - content_object = camel_medium_get_content_object (CAMEL_MEDIUM (bodypart)); - if (!CAMEL_IS_MULTIPART (content_object)) { - camel_stream_reset (raw); - CAMEL_MIME_PART (bodypart)->stream = raw; - } else { - camel_object_unref (CAMEL_OBJECT (raw)); - } - camel_mime_parser_filter_remove (mp, saveid); - saveid = -1; - raw = NULL; - } -#endif /* SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES */ - camel_multipart_add_part ((CamelMultipart *)content, (CamelMimePart *)bodypart); camel_object_unref ((CamelObject *)bodypart); } @@ -395,4 +381,13 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse camel_medium_set_content_object ((CamelMedium *)dw, content); camel_object_unref ((CamelObject *)content); } + +#ifdef SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES + if (!CAMEL_IS_MULTIPART (content)) { + /* set the raw mime stream on this leaf part in case our parent is a multipart/signed */ + camel_mime_parser_filter_remove (mp, saveid); + camel_stream_reset (raw); + dw->stream = raw; + } +#endif /* SAVE_RAW_MIME_STREAM_FOR_SECURE_MIME_SIGNATURES */ } |