diff options
author | Bertrand Guiheneuf <bertrand@src.gnome.org> | 2000-03-05 13:33:55 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 2000-03-05 13:33:55 +0800 |
commit | f4b7a4632573de34280e904bfb03a410a1fa1dbf (patch) | |
tree | b7b45a3424645a6836587c214dc5dfb2737239ef /camel | |
parent | 1208f96fe41fa87dfab2ee0a3b67a822380aeb27 (diff) | |
download | gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar.gz gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.tar.zst gsoc2013-evolution-f4b7a4632573de34280e904bfb03a410a1fa1dbf.zip |
Tons of fixes to fix things
svn path=/trunk/; revision=2057
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 5 | ||||
-rw-r--r-- | camel/camel-mime-part.c | 8 | ||||
-rw-r--r-- | camel/camel-seekable-substream.c | 72 | ||||
-rw-r--r-- | camel/camel-seekable-substream.h | 1 | ||||
-rw-r--r-- | camel/camel-stream-fs.c | 19 | ||||
-rw-r--r-- | camel/gmime-utils.c | 2 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-folder.c | 2 | ||||
-rw-r--r-- | camel/providers/mbox/camel-mbox-parser.c | 2 |
8 files changed, 79 insertions, 32 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 7d3a323e66..18e245364f 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,8 @@ +2000-03-05 bertrand <bertrand@helixcode.com> + + * camel-stream-fs.c (_read): + (_seek): + 2000-03-04 NotZed <NotZed@HelixCode.com> * providers/mbox/camel-mbox-search.c diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c index 460e0527d2..953ee0d077 100644 --- a/camel/camel-mime-part.c +++ b/camel/camel-mime-part.c @@ -869,10 +869,10 @@ my_set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream) /* set the input stream for the content object */ content_stream_inf_bound = camel_seekable_stream_get_current_position (seekable_stream); - mime_part->content_input_stream = - camel_seekable_substream_new_with_seekable_stream_and_bounds (seekable_stream, - content_stream_inf_bound, - -1); + printf ("Current position = %d\n", content_stream_inf_bound); + mime_part->content_input_stream = camel_seekable_substream_new_with_seekable_stream_and_bounds (seekable_stream, + content_stream_inf_bound, + -1); CAMEL_LOG_FULL_DEBUG ("CamelMimePart::set_input_stream leaving\n"); diff --git a/camel/camel-seekable-substream.c b/camel/camel-seekable-substream.c index 5e7bb72d21..df09e81ba5 100644 --- a/camel/camel-seekable-substream.c +++ b/camel/camel-seekable-substream.c @@ -172,12 +172,16 @@ _set_bounds (CamelSeekableSubstream *seekable_substream, guint32 inf_bound, gint seekable_substream->cur_pos = 0; + seekable_substream->eos = FALSE; - CAMEL_LOG_FULL_DEBUG ("In CamelSeekableSubstream::_set_bounds, " + CAMEL_LOG_FULL_DEBUG ("In CamelSeekableSubstream::_set_bounds (%p), " "setting inf bound to %lu, " - "sup bound to %lld, current position to %lu from %lu\n", + "sup bound to %lld, current position to %lu from %lu\n" + "Parent stream = %p\n", + seekable_substream, seekable_substream->inf_bound, seekable_substream->sup_bound, - seekable_substream->cur_pos, inf_bound); + seekable_substream->cur_pos, inf_bound, + seekable_substream->parent_stream); CAMEL_LOG_FULL_DEBUG ("CamelSeekableSubstream::_set_bounds Leaving\n"); } @@ -272,6 +276,7 @@ _read (CamelStream *stream, gchar *buffer, gint n) g_assert (stream); g_assert (seekable_substream->parent_stream); + g_assert (n); /* @@ -286,6 +291,9 @@ _read (CamelStream *stream, gchar *buffer, gint n) and is incompatible with buffering. */ + printf ("in CamelSeekable::read stream=(%p) cur position : %d\n", seekable_stream, seekable_stream->cur_pos); + + parent_stream_current_position = camel_seekable_stream_get_current_position (seekable_substream->parent_stream); @@ -293,14 +301,6 @@ _read (CamelStream *stream, gchar *buffer, gint n) position_in_parent = seekable_stream->cur_pos + seekable_substream->inf_bound; - /* go to our position in the parent stream */ - if (parent_stream_current_position != position_in_parent) - camel_seekable_stream_seek (seekable_substream->parent_stream, - position_in_parent, - CAMEL_STREAM_SET); - - - /* compute how much byte should be read */ if (seekable_substream->sup_bound != -1) nb_to_read = @@ -308,6 +308,33 @@ _read (CamelStream *stream, gchar *buffer, gint n) else nb_to_read = n; + if (!nb_to_read) { + seekable_substream->eos = TRUE; + return 0; + } + + /* go to our position in the parent stream */ + if (parent_stream_current_position != position_in_parent) { + printf ("In SeekableSubstream(%p)::read, the position has to be changed\n", stream); + printf ("--- parent_stream_current_position=%d, position_in_parent=%d\n", parent_stream_current_position, position_in_parent); + printf ("--- seekable_substream->inf_bound=%d\n", seekable_substream->inf_bound); + printf ("--- seekable_substream->sup_bound=%d\n", seekable_substream->sup_bound); + printf ("--- seekable_substream->parent_stream=%p\n", seekable_substream->parent_stream); + camel_seekable_stream_seek (seekable_substream->parent_stream, + position_in_parent, + CAMEL_STREAM_SET); + } + + /* check if we were able to set the position in the parent */ + parent_stream_current_position = + camel_seekable_stream_get_current_position (seekable_substream->parent_stream); + + if (parent_stream_current_position != position_in_parent) { + printf ("Unable to set the position in the parent\n"); + seekable_substream->eos = TRUE; + return 0; + } + /* Read the data */ if (nb_to_read >0 ) @@ -402,14 +429,23 @@ _eos (CamelStream *stream) gboolean eos; g_assert (stream); - - if (seekable_substream->sup_bound != -1) { - substream_len = seekable_substream->sup_bound - seekable_substream->inf_bound; - eos = ( seekable_stream->cur_pos >= substream_len); - } else { + + printf ("** %% ** (%p)\n", stream); + if (seekable_substream->eos) + eos = TRUE; + else { + + /* first check that the parent stream is ok */ eos = camel_stream_eos (CAMEL_STREAM (seekable_substream->parent_stream)); + if ((!eos) && (seekable_substream->sup_bound != -1)) { + substream_len = seekable_substream->sup_bound - seekable_substream->inf_bound; + eos = ( seekable_stream->cur_pos >= substream_len); + } } - + + if (eos) + printf (" EOS\n"); + return eos; } @@ -442,6 +478,8 @@ _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy) substream_len = seekable_substream->sup_bound - seekable_substream->inf_bound; + seekable_substream->eos = FALSE; + switch (policy) { case CAMEL_STREAM_SET: diff --git a/camel/camel-seekable-substream.h b/camel/camel-seekable-substream.h index d3a177f915..a80b1b8484 100644 --- a/camel/camel-seekable-substream.h +++ b/camel/camel-seekable-substream.h @@ -57,6 +57,7 @@ struct _CamelSeekableSubstream guint32 inf_bound; /* first valid position */ gint64 sup_bound; /* first invalid position */ gboolean open; + gboolean eos; }; diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index 46ccfe6e8f..16c5da2ba6 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -169,11 +169,12 @@ _set_bounds (CamelStreamFs *stream_fs, guint32 inf_bound, guint32 sup_bound) /* go to the first position */ lseek (stream_fs->fd, inf_bound, SEEK_SET); - CAMEL_SEEKABLE_STREAM (stream_fs)->cur_pos = inf_bound; + CAMEL_SEEKABLE_STREAM (stream_fs)->cur_pos = 0; - CAMEL_LOG_FULL_DEBUG ("In CamelStreamFs::_set_bounds, " + CAMEL_LOG_FULL_DEBUG ("In CamelStreamFs::_set_bounds (%p), " "setting inf bound to %u, " "sup bound to %ld, current postion to %u from %u\n", + stream_fs, stream_fs->inf_bound, stream_fs->sup_bound, CAMEL_SEEKABLE_STREAM (stream_fs)->cur_pos, inf_bound); @@ -344,11 +345,13 @@ static gint _read (CamelStream *stream, gchar *buffer, gint n) { CamelStreamFs *stream_fs = CAMEL_STREAM_FS (stream); - gint v; + gint v = 0; gint nb_to_read; + g_assert (n); + if (stream_fs->sup_bound != -1) - nb_to_read = MIN (stream_fs->sup_bound - CAMEL_SEEKABLE_STREAM (stream)->cur_pos, n); + nb_to_read = MIN (stream_fs->sup_bound - CAMEL_SEEKABLE_STREAM (stream)->cur_pos - stream_fs->inf_bound , n); else nb_to_read = n; @@ -496,10 +499,10 @@ _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy) break; case CAMEL_STREAM_CUR: - if ((stream_fs->sup_bound != -1) && ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + offset) > stream_fs->sup_bound)) { + if ((stream_fs->sup_bound != -1) && ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + stream_fs->inf_bound + offset) > stream_fs->sup_bound)) { real_offset = stream_fs->sup_bound; whence = SEEK_SET; - } else if ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + offset) < stream_fs->inf_bound) { + } else if ((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + stream_fs->inf_bound + offset) < stream_fs->inf_bound) { real_offset = stream_fs->inf_bound; whence = SEEK_SET; } else @@ -528,10 +531,10 @@ _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy) printf ("***** Seeking : real_offset=%d, whence=%d\n", real_offset, whence); return_position = lseek (stream_fs->fd, real_offset, whence) - stream_fs->inf_bound; - if (CAMEL_SEEKABLE_STREAM (stream)->cur_pos != return_position) + if (((CAMEL_SEEKABLE_STREAM (stream)->cur_pos + stream_fs->inf_bound) != return_position) && stream_fs->eof) stream_fs->eof = FALSE; - CAMEL_SEEKABLE_STREAM (stream)->cur_pos = return_position; + CAMEL_SEEKABLE_STREAM (stream)->cur_pos = return_position - stream_fs->inf_bound; return return_position; diff --git a/camel/gmime-utils.c b/camel/gmime-utils.c index 01d35772ed..69534ebdc0 100644 --- a/camel/gmime-utils.c +++ b/camel/gmime-utils.c @@ -271,7 +271,7 @@ gmime_read_line_from_stream (CamelStream *stream) new_line = g_string_new (""); do { nb_char_read = camel_stream_read (stream, &next_char, 1); - + printf ("Nb char read: %d\n", nb_char_read); if (nb_char_read>0) { switch (next_char) { diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c index cc3839abb6..34d3a5783a 100644 --- a/camel/providers/mbox/camel-mbox-folder.c +++ b/camel/providers/mbox/camel-mbox-folder.c @@ -1022,7 +1022,7 @@ _get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex) CamelMimeMessage *message = NULL; CamelStore *parent_store; - CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::get_uid_list\n"); + CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxFolder::get_message_by_uid\n"); searched_uid = strtoul(uid, (char **)NULL, 10); diff --git a/camel/providers/mbox/camel-mbox-parser.c b/camel/providers/mbox/camel-mbox-parser.c index d730c07aa6..b17c5c1e95 100644 --- a/camel/providers/mbox/camel-mbox-parser.c +++ b/camel/providers/mbox/camel-mbox-parser.c @@ -380,7 +380,7 @@ new_message_detected (CamelMboxPreParser *parser) /* if we were filling a message information save it in the message information array */ - + CAMEL_LOG_FULL_DEBUG (" Message position : %d\n", parser->real_position); if (parser->is_pending_message) { parser->current_message_info.size = parser->real_position - parser->current_message_info.message_position; |