diff options
author | NotZed <NotZed@HelixCode.com> | 2000-05-08 13:24:54 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-05-08 13:24:54 +0800 |
commit | b7f49ccf5755b1073d13348849cc71f67ba92a0d (patch) | |
tree | e81e979778fe6b8940a42dd8860a548da1058479 /camel/camel-stream-filter.c | |
parent | 4b0541ac3358b6f094bac4f9d1f3e415e23fd4d5 (diff) | |
download | gsoc2013-evolution-b7f49ccf5755b1073d13348849cc71f67ba92a0d.tar.gz gsoc2013-evolution-b7f49ccf5755b1073d13348849cc71f67ba92a0d.tar.zst gsoc2013-evolution-b7f49ccf5755b1073d13348849cc71f67ba92a0d.zip |
Merged NEW_SUMMARY branch back to trunk, and resolved conflicts.
2000-05-08 NotZed <NotZed@HelixCode.com>
* Merged NEW_SUMMARY branch back to trunk, and resolved conflicts.
* providers/mbox/camel-mbox-summary.c (camel_mbox_summary_update):
Return status.
* camel-stream-filter.c (do_close): We NEED a stream close.
svn path=/trunk/; revision=2906
Diffstat (limited to 'camel/camel-stream-filter.c')
-rw-r--r-- | camel/camel-stream-filter.c | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c index 500bf22846..e468435cb6 100644 --- a/camel/camel-stream-filter.c +++ b/camel/camel-stream-filter.c @@ -35,6 +35,8 @@ struct _CamelStreamFilterPrivate { char *filtered; /* the filtered data */ size_t filteredlen; + + int last_was_read; /* was the last op read or write? */ }; #define READ_PAD (64) /* bytes padded before buffer */ @@ -130,6 +132,7 @@ camel_stream_filter_init (CamelStreamFilter *obj) _PRIVATE(obj) = p = g_malloc0(sizeof(*p)); p->realbuffer = g_malloc(READ_SIZE + READ_PAD); p->buffer = p->realbuffer + READ_PAD; + p->last_was_read = TRUE; } /** @@ -216,6 +219,8 @@ static gint do_read (CamelStream *stream, gchar *buffer, gint n) int size; struct _filter *f; + p->last_was_read = TRUE; + if (p->filteredlen<=0) { int presize = READ_SIZE; @@ -253,16 +258,52 @@ static gint do_read (CamelStream *stream, gchar *buffer, gint n) return size; } -static gint do_write (CamelStream *stream, const gchar *buffer, gint n) +static gint do_write (CamelStream *stream, const gchar *buf, gint n) { - /* what semantics *should* this have?? */ - g_warning("Writing to a non-writable stream"); - return -1; + CamelStreamFilter *filter = (CamelStreamFilter *)stream; + struct _CamelStreamFilterPrivate *p = _PRIVATE(filter); + struct _filter *f; + int presize; + char *buffer = (char *)buf; + + p->last_was_read = FALSE; + + f = p->filters; + presize = 0; + while (f) { + camel_mime_filter_filter(f->filter, buffer, n, presize, &buffer, &n, &presize); + f = f->next; + } + + return camel_stream_write(filter->source, buffer, n); } static void do_flush (CamelStream *stream) { - /* NO OP */ + CamelStreamFilter *filter = (CamelStreamFilter *)stream; + struct _CamelStreamFilterPrivate *p = _PRIVATE(filter); + struct _filter *f; + char *buffer; + int len, presize; + + if (p->last_was_read) { + g_warning("Flushing a filter stream without writing to it"); + return; + } + + buffer = ""; + len = 0; + presize = 0; + f = p->filters; + while (f) { + camel_mime_filter_complete(f->filter, buffer, len, presize, &buffer, &len, &presize); + f = f->next; + } + if (camel_stream_write(filter->source, buffer, len) == -1) { + g_warning("Flushing filter failed to write, no way to signal failure ..."); + } + + return camel_stream_flush(filter->source); } static gboolean do_eos (CamelStream *stream) @@ -276,6 +317,19 @@ static gboolean do_eos (CamelStream *stream) return camel_stream_eos(filter->source); } +static void do_close (CamelStream *stream) +{ + CamelStreamFilter *filter = (CamelStreamFilter *)stream; + struct _CamelStreamFilterPrivate *p = _PRIVATE(filter); + + if (p->last_was_read == 0) { + camel_stream_flush(stream); + } + + p->filteredlen = 0; + camel_stream_close(filter->source); +} + static void do_reset (CamelStream *stream) { CamelStreamFilter *filter = (CamelStreamFilter *)stream; |