diff options
author | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-08-03 21:16:35 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-08-03 21:16:35 +0800 |
commit | 382308f44a4ab93659f9f54c8dac2c2cc381a471 (patch) | |
tree | 40d0f4d6d70f8ee6a8a01b7f9c6bf310732455d0 /camel | |
parent | e9c6d8921cce940e590f763a881794323a9e6703 (diff) | |
download | gsoc2013-evolution-382308f44a4ab93659f9f54c8dac2c2cc381a471.tar.gz gsoc2013-evolution-382308f44a4ab93659f9f54c8dac2c2cc381a471.tar.zst gsoc2013-evolution-382308f44a4ab93659f9f54c8dac2c2cc381a471.zip |
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
Diffstat (limited to 'camel')
-rw-r--r-- | camel/camel-mime-part.c | 14 | ||||
-rw-r--r-- | camel/camel-multipart.c | 9 | ||||
-rw-r--r-- | camel/gmime-content-field.c | 3 | ||||
-rw-r--r-- | camel/gmime-utils.c | 14 |
4 files changed, 21 insertions, 19 deletions
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"); } + diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c index 8362259ea6..20a790465c 100644 --- a/camel/camel-multipart.c +++ b/camel/camel-multipart.c @@ -389,17 +389,16 @@ _read_part (CamelStream *new_part_stream, CamelStream *stream, gchar *normal_bou CAMEL_LOG_FULL_DEBUG ("CamelMultipart:: Entering _read_part\n"); new_line = gmime_read_line_from_stream (stream); - printf ("== new line = \"%s\"\n", new_line); while (new_line && !end_of_part && !last_part) { printf ("++ new line = \"%s\"\n", new_line); end_of_part = (strcmp (new_line, normal_boundary) == 0); last_part = (strcmp (new_line, end_boundary) == 0); if (!end_of_part && !last_part) { if (first_line) { - camel_stream_write_string (new_part_stream, "\n"); first_line = FALSE; - } - camel_stream_write_strings (new_part_stream, "\n", new_line, NULL); + camel_stream_write_string (new_part_stream, new_line); + } else camel_stream_write_strings (new_part_stream, "\n", new_line, NULL); + new_line = gmime_read_line_from_stream (stream); } } @@ -425,8 +424,6 @@ _construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) real_boundary_line = g_strdup_printf ("--%s", boundary); end_boundary_line = g_strdup_printf ("--%s--", boundary); - //new_part = g_string_new (""); - /* read the prefix if any */ new_part_stream = camel_stream_mem_new (CAMEL_STREAM_MEM_RW); diff --git a/camel/gmime-content-field.c b/camel/gmime-content-field.c index b4c8496083..caa8237290 100644 --- a/camel/gmime-content-field.c +++ b/camel/gmime-content-field.c @@ -126,6 +126,7 @@ gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStre if (!content_field) return; g_assert (stream); + printf ("Content-field address = %p\n", content_field); if (content_field->type) { camel_stream_write_strings (stream, "Content-Type: ", content_field->type, NULL); if (content_field->subtype) { @@ -134,7 +135,7 @@ gmime_content_field_write_to_stream (GMimeContentField *content_field, CamelStre /* print all parameters */ g_hash_table_foreach (content_field->parameters, _print_parameter, stream); camel_stream_write_string (stream, "\n"); - } + } else CAMEL_LOG_FULL_DEBUG ("GMimeContentField::write_to_stream no mime type found\n"); } /** diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c index 7698d01039..24986d48a3 100644 --- a/camel/gmime-utils.c +++ b/camel/gmime-utils.c @@ -32,18 +32,14 @@ gmime_write_header_pair_to_stream (CamelStream *stream, const gchar* name, const { gchar *strtmp; - guint len; + CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:: Entering\n"); g_assert(name); -#warning use g_strdup_printf instead - - if (!value) return; - len = strlen (name) + strlen (value) +4; - /* 4 is for ": " and "\n\0" */ - strtmp = g_new (gchar, len); - sprintf (strtmp, "%s: %s\n", name, value); + + if (!value) return; + strtmp = g_strdup_printf ("%s: %s\n", name, value); - camel_stream_write (stream, strtmp, len); + camel_stream_write_string (stream, strtmp); CAMEL_LOG_FULL_DEBUG ( "gmime_write_header_pair_to_stream:\n writing %s\n", strtmp); g_free (strtmp); |