aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-part.c
diff options
context:
space:
mode:
authorNotZed <NotZed@HelixCode.com>2000-04-21 07:48:45 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-04-21 07:48:45 +0800
commit383f245d39b8b806a4b6ce4dea7b0ab7f1658450 (patch)
treeb6447bbcd6bd8c4b31582a343ce062e8d2c548c4 /camel/camel-mime-part.c
parent6b5b1f6de926a4c9dec95dbd55ae53a5b30fb6a5 (diff)
downloadgsoc2013-evolution-383f245d39b8b806a4b6ce4dea7b0ab7f1658450.tar.gz
gsoc2013-evolution-383f245d39b8b806a4b6ce4dea7b0ab7f1658450.tar.zst
gsoc2013-evolution-383f245d39b8b806a4b6ce4dea7b0ab7f1658450.zip
MERGE NEW_PARSER branch into HEAD, fixed conflicts.
2000-04-20 NotZed <NotZed@HelixCode.com> * MERGE NEW_PARSER branch into HEAD, fixed conflicts. * gmime-content-field.c (_print_parameter): Duh, removed again (@@#$@ cvs merge). * camel-mime-utils.c (header_content_type_is): Constify. (header_content_type_unref): Killed a couple warnings. * camel-folder.c (_init): Removed more log crap. * providers/Makefile.am (SUBDIRS): Removed nntp, pending fixes for summary changes. * providers/mbox/camel-mbox-folder.c (_get_message_by_number): Fixed for new summary interface. Added a warning for using this broken api. (_get_message_by_uid): Fixed for message new with session vanishing. svn path=/trunk/; revision=2531
Diffstat (limited to 'camel/camel-mime-part.c')
-rw-r--r--camel/camel-mime-part.c84
1 files changed, 50 insertions, 34 deletions
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index ca4f71dc31..67be67d248 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -39,9 +39,9 @@
#include "hash-table-utils.h"
#include "camel-stream-mem.h"
#include "camel-mime-part-utils.h"
-#include "gmime-base64.h"
#include "camel-seekable-substream.h"
-#include "camel-stream-b64.h"
+#include "camel-stream-filter.h"
+#include "camel-mime-filter-basic.h"
typedef enum {
@@ -237,13 +237,12 @@ my_finalize (GtkObject *object)
{
CamelMimePart *mime_part = CAMEL_MIME_PART (object);
-#warning do something for (mime_part->disposition) which should not be a GMimeContentField
-
g_free (mime_part->description);
g_free (mime_part->content_id);
g_free (mime_part->content_MD5);
string_list_free (mime_part->content_languages);
g_free (mime_part->filename);
+ header_disposition_unref(mime_part->disposition);
if (mime_part->header_lines) string_list_free (mime_part->header_lines);
if (mime_part->content_type) gmime_content_field_unref (mime_part->content_type);
@@ -313,15 +312,8 @@ camel_mime_part_get_description (CamelMimePart *mime_part)
static void
my_set_disposition (CamelMimePart *mime_part, const gchar *disposition)
{
-#warning Do not use MimeContentfield here !!!
-
- if (mime_part->disposition) {
- g_free (mime_part->disposition->type);
- g_free (mime_part->disposition);
- }
-
- mime_part->disposition = g_new0 (GMimeContentField,1);
- mime_part->disposition->type = g_strdup (disposition);
+ header_disposition_unref(mime_part->disposition);
+ mime_part->disposition = header_disposition_decode(disposition);
}
@@ -340,7 +332,7 @@ static const gchar *
my_get_disposition (CamelMimePart *mime_part)
{
if (!mime_part->disposition) return NULL;
- return (mime_part->disposition)->type;
+ return (mime_part->disposition)->disposition;
}
@@ -605,6 +597,7 @@ my_get_content_object (CamelMedium *medium)
CamelMimePart *mime_part = CAMEL_MIME_PART (medium);
CamelStream *stream;
CamelStream *decoded_stream;
+ CamelMimeFilter *mf = NULL;
if (!medium->content ) {
stream = mime_part->content_input_stream;
@@ -615,16 +608,23 @@ my_get_content_object (CamelMedium *medium)
case CAMEL_MIME_PART_ENCODING_DEFAULT:
case CAMEL_MIME_PART_ENCODING_7BIT:
case CAMEL_MIME_PART_ENCODING_8BIT:
+ break;
+
case CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE:
+ mf = (CamelMimeFilter *)camel_mime_filter_basic_new_type(CAMEL_MIME_FILTER_BASIC_QP_DEC);
break;
case CAMEL_MIME_PART_ENCODING_BASE64:
- decoded_stream = camel_stream_b64_new_with_input_stream (stream);
- camel_stream_b64_set_mode (CAMEL_STREAM_B64 (decoded_stream),
- CAMEL_STREAM_B64_DECODER);
+ mf = (CamelMimeFilter *)camel_mime_filter_basic_new_type(CAMEL_MIME_FILTER_BASIC_BASE64_DEC);
break;
}
+ if (mf) {
+ decoded_stream = (CamelStream *)camel_stream_filter_new_with_stream (stream);
+ camel_stream_filter_add((CamelStreamFilter *)decoded_stream, mf);
+ gtk_object_unref((GtkObject *)mf);
+ }
+
camel_mime_part_construct_content_from_stream (mime_part, decoded_stream);
}
@@ -651,8 +651,8 @@ my_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream)
{
CamelMedium *medium;
CamelStream *wrapper_stream;
- CamelStreamB64 *stream_b64;
-
+ CamelStream *stream_encode;
+ CamelMimeFilter *mf = NULL;
CamelDataWrapper *content;
g_assert (mime_part);
@@ -672,18 +672,11 @@ my_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream)
case CAMEL_MIME_PART_ENCODING_8BIT:
camel_data_wrapper_write_to_stream (content, stream);
break;
+ case CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE:
+ mf = (CamelMimeFilter *)camel_mime_filter_basic_new_type(CAMEL_MIME_FILTER_BASIC_QP_ENC);
+ break;
case CAMEL_MIME_PART_ENCODING_BASE64:
- /* encode the data wrapper output stream in base 64 ... */
- wrapper_stream = camel_data_wrapper_get_output_stream (content);
- camel_stream_reset (wrapper_stream);
- stream_b64 = CAMEL_STREAM_B64 (camel_stream_b64_new_with_input_stream (wrapper_stream));
- camel_stream_b64_set_mode (stream_b64, CAMEL_STREAM_B64_ENCODER);
-
- /* ... and write it to the output stream in a blocking way */
- camel_stream_b64_write_to_stream (stream_b64, stream);
-
- /* now free the intermediate b64 stream */
- gtk_object_unref (GTK_OBJECT (stream_b64));
+ mf = (CamelMimeFilter *)camel_mime_filter_basic_new_type(CAMEL_MIME_FILTER_BASIC_BASE64_ENC);
break;
default:
camel_data_wrapper_write_to_stream (content, stream);
@@ -691,6 +684,21 @@ my_write_content_to_stream (CamelMimePart *mime_part, CamelStream *stream)
camel_mime_part_encoding_to_string
(mime_part->encoding));
}
+
+ if (mf) {
+ /* encode the data wrapper output stream in the filtered encoding */
+ wrapper_stream = camel_data_wrapper_get_output_stream (content);
+ camel_stream_reset (wrapper_stream);
+ stream_encode = camel_stream_filter_new_with_stream (wrapper_stream);
+ camel_stream_filter_add((CamelStreamFilter *)stream_encode, mf);
+
+ /* ... and write it to the output stream in a blocking way */
+ camel_stream_write_to_stream (stream_encode, stream);
+
+ /* now free the intermediate b64 stream */
+ gtk_object_unref (GTK_OBJECT (stream_encode));
+ gtk_object_unref((GtkObject *)mf);
+ }
}
@@ -703,7 +711,18 @@ my_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
CamelMimePart *mp = CAMEL_MIME_PART (data_wrapper);
CamelMedium *medium = CAMEL_MEDIUM (data_wrapper);
- gmime_content_field_write_to_stream(mp->disposition, stream);
+ if (mp->disposition) {
+ struct _header_param *p;
+
+ camel_stream_write_strings(stream, "Content-Disposition: ", mp->disposition->disposition, NULL);
+ /* FIXME: use proper quoting rules here ... */
+ p = mp->disposition->params;
+ while (p) {
+ camel_stream_write_strings (stream, ";\n ", p->name, "= \"", p->value, "\"", NULL);
+ p = p->next;
+ }
+ camel_stream_write_string (stream, "\n");
+ }
WHPT (stream, "Content-Transfer-Encoding",
camel_mime_part_encoding_to_string (mp->encoding));
WHPT (stream, "Content-Description", mp->description);
@@ -848,9 +867,6 @@ my_get_output_stream (CamelDataWrapper *data_wrapper)
return input_stream;
case CAMEL_MIME_PART_ENCODING_BASE64:
- output_stream = camel_stream_b64_new_with_input_stream (input_stream);
- camel_stream_b64_set_mode (CAMEL_STREAM_B64 (output_stream),
- CAMEL_STREAM_B64_ENCODER);
return output_stream;
case CAMEL_MIME_PART_ENCODING_QUOTEDPRINTABLE: