aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-04-29 23:57:11 +0800
committerDan Winship <danw@src.gnome.org>2000-04-29 23:57:11 +0800
commit18903e6b226aa9f18e1fd25450b2b463dd2a4801 (patch)
treefa0d21c0756de5c6decca25d8608516fba59bd16
parent4e9fab3ba3a1b55ef924ae4332bf43e7fc3d12ba (diff)
downloadgsoc2013-evolution-18903e6b226aa9f18e1fd25450b2b463dd2a4801.tar.gz
gsoc2013-evolution-18903e6b226aa9f18e1fd25450b2b463dd2a4801.tar.zst
gsoc2013-evolution-18903e6b226aa9f18e1fd25450b2b463dd2a4801.zip
camel_mime_parser_tell() returns an offset from where it started parsing,
* camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): camel_mime_parser_tell() returns an offset from where it started parsing, not necessarily from the start of data. Since we're parsing a bounded seekable_stream, we need to add the stream's starting bound to camel_mime_parser_tell's return value to create the substream in the right place. * camel-seekable-substream.c (camel_seekable_substream_new_with_seekable_stream_and_bounds): say CAMEL_STREAM_UNBOUND rather than -1 in doc. * camel-seekable-stream.c (camel_seekable_stream_seek): Add more info to docs. svn path=/trunk/; revision=2680
-rw-r--r--camel/ChangeLog17
-rw-r--r--camel/camel-mime-part-utils.c33
-rw-r--r--camel/camel-seekable-stream.c13
-rw-r--r--camel/camel-seekable-substream.c5
4 files changed, 53 insertions, 15 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 67ca228842..d0fd6e08f7 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,20 @@
+2000-04-29 Dan Winship <danw@helixcode.com>
+
+ * camel-mime-part-utils.c
+ (simple_data_wrapper_construct_from_parser):
+ camel_mime_parser_tell() returns an offset from where it started
+ parsing, not necessarily from the start of data. Since we're
+ parsing a bounded seekable_stream, we need to add the stream's
+ starting bound to camel_mime_parser_tell's return value to
+ create the substream in the right place.
+
+ * camel-seekable-substream.c
+ (camel_seekable_substream_new_with_seekable_stream_and_bounds):
+ say CAMEL_STREAM_UNBOUND rather than -1 in doc.
+
+ * camel-seekable-stream.c (camel_seekable_stream_seek): Add more
+ info to docs.
+
2000-04-28 Dan Winship <danw@helixcode.com>
* camel-mime-parser.c (folder_scan_header): fix a bug that would
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 22df4fd610..83433c06ba 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -47,8 +47,9 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
off_t start, end;
CamelMimeFilter *fdec = NULL, *fch = NULL;
struct _header_content_type *ct;
- int decid=-1, chrid=-1, cache=FALSE;
+ int decid=-1, chrid=-1, cache=TRUE;
CamelStream *source;
+ CamelSeekableStream *seekable_source;
char *encoding;
d(printf("constructing data-wrapper\n"));
@@ -59,10 +60,13 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
/* if we can't seek, dont have a stream/etc, then we must cache it */
source = camel_mime_parser_stream(mp);
- gtk_object_ref((GtkObject *)source);
- if (source == NULL
- || !CAMEL_IS_SEEKABLE_STREAM(source))
- cache = TRUE;
+ if (source) {
+ gtk_object_ref((GtkObject *)source);
+ if (CAMEL_IS_SEEKABLE_STREAM (source)) {
+ seekable_source = CAMEL_SEEKABLE_STREAM (source);
+ cache = FALSE;
+ }
+ }
/* first, work out conversion, if any, required, we dont care about what we dont know about */
encoding = header_content_encoding_decode(camel_mime_parser_header(mp, "content-transfer-encoding", NULL));
@@ -99,7 +103,10 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
buffer = g_byte_array_new();
- start = camel_mime_parser_tell(mp);
+ if (!cache) {
+ start = camel_mime_parser_tell(mp) +
+ seekable_source->bound_start;
+ }
while ( camel_mime_parser_step(mp, &buf, &len) != HSCAN_BODY_END ) {
if (buffer) {
if (buffer->len > 20480 && !cache) {
@@ -122,15 +129,16 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
mem = camel_stream_mem_new_with_byte_array(buffer);
camel_data_wrapper_set_output_stream (dw, mem);
} else {
- CamelSeekableSubstream *sub;
+ CamelStream *sub;
CamelStreamFilter *filter;
d(printf("Big message part, left on disk ...\n"));
- end = camel_mime_parser_tell(mp);
- sub = (CamelSeekableSubstream *)camel_seekable_substream_new_with_seekable_stream_and_bounds ((CamelSeekableStream *)source, start, end);
+ end = camel_mime_parser_tell(mp) +
+ seekable_source->bound_start;
+ sub = camel_seekable_substream_new_with_seekable_stream_and_bounds (seekable_source, start, end);
if (fdec || fch) {
- filter = camel_stream_filter_new_with_stream((CamelStream *)sub);
+ filter = camel_stream_filter_new_with_stream(sub);
if (fdec) {
camel_mime_filter_reset(fdec);
camel_stream_filter_add(filter, fdec);
@@ -141,7 +149,7 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
}
camel_data_wrapper_set_output_stream (dw, (CamelStream *)filter);
} else {
- camel_data_wrapper_set_output_stream (dw, (CamelStream *)sub);
+ camel_data_wrapper_set_output_stream (dw, sub);
}
}
@@ -152,7 +160,8 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
gtk_object_unref((GtkObject *)fdec);
if (fch)
gtk_object_unref((GtkObject *)fch);
- gtk_object_unref((GtkObject *)source);
+ if (source)
+ gtk_object_unref((GtkObject *)source);
}
diff --git a/camel/camel-seekable-stream.c b/camel/camel-seekable-stream.c
index 27eba97d26..6d51c6c554 100644
--- a/camel/camel-seekable-stream.c
+++ b/camel/camel-seekable-stream.c
@@ -106,7 +106,18 @@ seek (CamelSeekableStream *stream,
* @offset: offset value
* @policy: what to do with the offset
*
- *
+ * Seek to the specified position in @stream.
+ *
+ * If @policy is CAMEL_STREAM_SET, seeks to @offset.
+ *
+ * If @policy is CAMEL_STREAM_CUR, seeks to the current position plus
+ * @offset.
+ *
+ * If @policy is CAMEL_STREAM_END, seeks to the end of the stream plus
+ * @offset.
+ *
+ * Regardless of @policy, the stream's final position will be clamped
+ * to the range specified by its lower and upper bounds.
*
* Return value: new position, -1 if operation failed.
**/
diff --git a/camel/camel-seekable-substream.c b/camel/camel-seekable-substream.c
index 55c44514b7..5b01495be1 100644
--- a/camel/camel-seekable-substream.c
+++ b/camel/camel-seekable-substream.c
@@ -125,8 +125,9 @@ init_with_seekable_stream_and_bounds (CamelSeekableSubstream *seekable_substream
* @sup_bound: an upper bound
*
* Creates a new CamelSeekableSubstream that references the portion
- * of @parent_stream from @inf_bound to @sup_bound. (If @sup_bound is -1,
- * it references to the end of stream, even if the stream grows.)
+ * of @parent_stream from @inf_bound to @sup_bound. (If @sup_bound is
+ * #CAMEL_STREAM_UNBOUND, it references to the end of stream, even if
+ * the stream grows.)
*
* While the substream is open, the caller cannot assume anything about
* the current position of @parent_stream. After the substream has been