aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-part-utils.c
diff options
context:
space:
mode:
authorbertrand <Bertrand.Guiheneuf@aful.org>1999-08-26 23:29:40 +0800
committerBertrand Guiheneuf <bertrand@src.gnome.org>1999-08-26 23:29:40 +0800
commite826255bf13255f2b5c626192de4fd10a3885b6f (patch)
tree7280cb551648d126c30162f28779503a9b1b6eeb /camel/camel-mime-part-utils.c
parent2a912b33018b0389672d9a4f09496b6a57071388 (diff)
downloadgsoc2013-evolution-e826255bf13255f2b5c626192de4fd10a3885b6f.tar.gz
gsoc2013-evolution-e826255bf13255f2b5c626192de4fd10a3885b6f.tar.zst
gsoc2013-evolution-e826255bf13255f2b5c626192de4fd10a3885b6f.zip
contruct the content from the buffer before calling CamelMedium
1999-08-26 bertrand <Bertrand.Guiheneuf@aful.org> * camel/camel-mime-part.c (_get_content_object): contruct the content from the buffer before calling CamelMedium implementation. (_construct_from_stream): Do not construct the content by default, just store the content bytes in a temporary buffer. Content will be constructed only at caller request (when calling CamelMedium::get_content_object) Providers with better access to the messages (mbox/MH ...) will have to provider lighter implementation, that is shall not read content at all unless the caller asks for it (again with get_content). * camel/camel-mime-part-utils.c: new file, groups mime-part related utils. Meant to be used by providers subclassing MimeMessage. (camel_mime_part_construct_headers_from_stream): (camel_mime_part_construct_content_from_stream): no more useless temporary hash table. * camel/camel-mime-part.c (_construct_from_stream): calls mime-part-utils functions now. * camel/gmime-utils.c (_store_header_pair_from_string): do not use hash table to store header, use an array instead. svn path=/trunk/; revision=1145
Diffstat (limited to 'camel/camel-mime-part-utils.c')
-rw-r--r--camel/camel-mime-part-utils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 9914964a52..59ae49e595 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -132,3 +132,34 @@ camel_mime_part_construct_content_from_stream (CamelMimePart *mime_part,
+void
+camel_mime_part_store_stream_in_buffer (CamelMimePart *mime_part,
+ CamelStream *stream)
+{
+ gint nb_bytes_read_total = 0;
+ gint nb_bytes_read_chunk;
+ GByteArray *buffer;
+#define STREAM_READ_CHUNK_SZ 100
+
+ if (mime_part->temp_message_buffer == NULL)
+ mime_part->temp_message_buffer = g_byte_array_new ();
+
+ buffer = mime_part->temp_message_buffer;
+
+ g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_chunk = camel_stream_read (stream,
+ buffer->data + nb_bytes_read_total,
+ STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_total += nb_bytes_read_chunk;
+
+ while (nb_bytes_read_chunk) {
+ g_byte_array_set_size (buffer, nb_bytes_read_total + STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_chunk = camel_stream_read (stream,
+ buffer->data + nb_bytes_read_total,
+ STREAM_READ_CHUNK_SZ);
+ nb_bytes_read_total += nb_bytes_read_chunk;
+ }
+
+ g_byte_array_set_size (buffer, nb_bytes_read_total);
+
+}