From 382308f44a4ab93659f9f54c8dac2c2cc381a471 Mon Sep 17 00:00:00 2001 From: Bertrand Guiheneuf Date: Tue, 3 Aug 1999 13:16:35 +0000 Subject: There is a probleme here. We can not allow mime part content-type field * camel/camel-mime-part.c (_set_content_object): There is a probleme here. We can not allow mime part content-type field and content_object mime-type to be different. I thus chosed to set mime part object content field to be freed (if necessary) and set to be a pointer to content_object mime type field. (_construct_from_stream): set content_object mime type to be the same as mime_part's one. This is necessary because we use _set_content_type. This two things are a bit hackish ansd may need to be redesigned. svn path=/trunk/; revision=1071 --- camel/camel-mime-part.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'camel/camel-mime-part.c') diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index bdb36f6748..39cdbe5cba 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -535,6 +535,8 @@ camel_mime_part_get_content_object(CamelMimePart *mime_part) static void _set_content_object(CamelMimePart *mime_part, CamelDataWrapper *content) { + GMimeContentField *object_content_field; + CAMEL_LOG_FULL_DEBUG ("Entering CamelMimePart::set_content_object\n"); if (mime_part->content) { CAMEL_LOG_FULL_DEBUG ("CamelMimePart::set_content_object unreferencing old content object\n"); @@ -542,8 +544,10 @@ _set_content_object(CamelMimePart *mime_part, CamelDataWrapper *content) } gtk_object_ref (GTK_OBJECT (content)); mime_part->content = content; - if (mime_part->content_type) gmime_content_field_free (mime_part->content_type); - mime_part->content_type = camel_data_wrapper_get_mime_type_field (content); + object_content_field = camel_data_wrapper_get_mime_type_field (content); + if (mime_part->content_type && (mime_part->content_type != object_content_field)) + gmime_content_field_free (mime_part->content_type); + mime_part->content_type = object_content_field; CAMEL_LOG_FULL_DEBUG ("Leaving CamelMimePart::set_content_object\n"); } @@ -620,7 +624,7 @@ _write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) write_header_table_to_stream (stream, mp->headers); CAMEL_LOG_FULL_DEBUG ( "CamelMimePart::write_to_stream writing content-type\n"); - gmime_content_field_write_to_stream(mp->content_type, stream); + gmime_content_field_write_to_stream (mp->content_type, stream); camel_stream_write_string(stream,"\n"); _write_content_to_stream (mp, stream); @@ -753,6 +757,7 @@ _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream parsing content\n"); content_type = camel_mime_part_get_content_type (mime_part); mime_type = gmime_content_field_get_mime_type (content_type); + printf ("Content-Type address = %p\n", content_type); if (!mime_type) { CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream content type field not found " "using default \"text/plain\"\n"); @@ -760,9 +765,11 @@ _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) camel_mime_part_set_content_type (mime_part, mime_type); } content_object_type = data_wrapper_repository_get_data_wrapper_type (mime_type); + CAMEL_LOG_FULL_DEBUG ("CamelMimePart::construct_from_stream content type object type used: %s\n", gtk_type_name (content_object_type)); g_free (mime_type); content_object = CAMEL_DATA_WRAPPER (gtk_type_new (content_object_type)); + camel_data_wrapper_set_mime_type_field (content_object, camel_mime_part_get_content_type (mime_part)); camel_mime_part_set_content_object (mime_part, content_object); camel_data_wrapper_construct_from_stream (content_object, stream); @@ -810,3 +817,4 @@ camel_mime_part_set_text (CamelMimePart *camel_mime_part, gchar *text) CAMEL_LOG_FULL_DEBUG ("CamelMimePart:: Leaving camel_mime_part_set_text\n"); } + -- cgit v1.2.3