aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-06-21 10:09:48 +0800
committerDan Winship <danw@src.gnome.org>2000-06-21 10:09:48 +0800
commit4f20138bfc192d2feff2e913fbc0ff87ca6bd19c (patch)
tree76c0972dee1278911723b296a1870e9a3922768f
parented11b82023a5501fb05837f63cceff18698691a5 (diff)
downloadgsoc2013-evolution-4f20138bfc192d2feff2e913fbc0ff87ca6bd19c.tar
gsoc2013-evolution-4f20138bfc192d2feff2e913fbc0ff87ca6bd19c.tar.gz
gsoc2013-evolution-4f20138bfc192d2feff2e913fbc0ff87ca6bd19c.tar.bz2
gsoc2013-evolution-4f20138bfc192d2feff2e913fbc0ff87ca6bd19c.tar.lz
gsoc2013-evolution-4f20138bfc192d2feff2e913fbc0ff87ca6bd19c.tar.xz
gsoc2013-evolution-4f20138bfc192d2feff2e913fbc0ff87ca6bd19c.tar.zst
gsoc2013-evolution-4f20138bfc192d2feff2e913fbc0ff87ca6bd19c.zip
flush the filter stream before unreffing it, so it will
* camel-mime-part.c (write_to_stream): flush the filter stream before unreffing it, so it will camel_mime_filter_complete. * camel-stream-filter.c (camel_stream_filter_class_init): Fix a braino so camel_stream_flush works here. * camel-stream-mem.c (stream_seek): Fix a bug that resulted in large attachments being silently dropped. * providers/pop3/camel-pop3-store.c (camel_pop3_command_get_additional_data): Don't use g_strjoinv here, since it is O(n^2) on the length of the output string, and we can do O(n). * camel-mime-part-utils.c (simple_data_wrapper_construct_from_parser): add a CRLF decoder after the QP/B64 decoder if it's text. svn path=/trunk/; revision=3658
-rw-r--r--camel/ChangeLog20
-rw-r--r--camel/camel-mime-part-utils.c22
-rw-r--r--camel/camel-mime-part.c4
-rw-r--r--camel/camel-stream-filter.c2
-rw-r--r--camel/camel-stream-mem.c4
-rw-r--r--camel/providers/pop3/camel-pop3-store.c28
6 files changed, 60 insertions, 20 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 6b4a0ef95e..c35d9ddcad 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,23 @@
+2000-06-20 Dan Winship <danw@helixcode.com>
+
+ * camel-mime-part.c (write_to_stream): flush the filter stream
+ before unreffing it, so it will camel_mime_filter_complete.
+
+ * camel-stream-filter.c (camel_stream_filter_class_init): Fix a
+ braino so camel_stream_flush works here.
+
+ * camel-stream-mem.c (stream_seek): Fix a bug that resulted in
+ large attachments being silently dropped.
+
+ * providers/pop3/camel-pop3-store.c
+ (camel_pop3_command_get_additional_data): Don't use g_strjoinv
+ here, since it is O(n^2) on the length of the output string, and
+ we can do O(n).
+
+ * camel-mime-part-utils.c
+ (simple_data_wrapper_construct_from_parser): add a CRLF decoder
+ after the QP/B64 decoder if it's text.
+
2000-06-20 Jeffrey Stedfast <fejj@helixcode.com>
* providers/imap/camel-imap-folder.c (imap_get_summary): Only
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index d82f65c90d..656520030c 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -33,6 +33,7 @@
#include "camel-stream-mem.h"
#include "camel-mime-filter-basic.h"
#include "camel-mime-filter-charset.h"
+#include "camel-mime-filter-crlf.h"
#define d(x)
@@ -44,9 +45,9 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
char *buf;
int len;
off_t start, end; /* ignore the start may be used unitialised warning */
- CamelMimeFilter *fdec = NULL, *fch = NULL;
+ CamelMimeFilter *fdec = NULL, *fcrlf = NULL, *fch = NULL;
struct _header_content_type *ct;
- int decid=-1, chrid=-1, cache=TRUE;
+ int decid=-1, crlfid=-1, chrid=-1, cache=TRUE;
CamelStream *source;
CamelSeekableStream *seekable_source; /* and ignore the warning about this one too. */
char *encoding;
@@ -82,10 +83,18 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
g_free(encoding);
}
- /* if we're doing text, then see if we have to convert it to UTF8 as well */
+ /* If we're doing text, we also need to do CRLF->LF and may have to convert it to UTF8 as well. */
ct = camel_mime_parser_content_type(mp);
if (header_content_type_is(ct, "text", "*")) {
const char *charset = header_content_type_param(ct, "charset");
+
+ if (fdec) {
+ d(printf("Adding CRLF conversion filter\n"));
+ fcrlf = (CamelMimeFilter *)camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_DECODE,
+ CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
+ crlfid = camel_mime_parser_filter_add(mp, fcrlf);
+ }
+
if (charset!=NULL
&& !(strcasecmp(charset, "us-ascii")==0
|| strcasecmp(charset, "iso-8859-1")==0)) {
@@ -141,6 +150,10 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
camel_mime_filter_reset(fdec);
camel_stream_filter_add(filter, fdec);
}
+ if (fcrlf) {
+ camel_mime_filter_reset(fcrlf);
+ camel_stream_filter_add(filter, fcrlf);
+ }
if (fch) {
camel_mime_filter_reset(fch);
camel_stream_filter_add(filter, fch);
@@ -154,10 +167,13 @@ simple_data_wrapper_construct_from_parser(CamelDataWrapper *dw, CamelMimeParser
}
camel_mime_parser_filter_remove(mp, decid);
+ camel_mime_parser_filter_remove(mp, crlfid);
camel_mime_parser_filter_remove(mp, chrid);
if (fdec)
gtk_object_unref((GtkObject *)fdec);
+ if (fcrlf)
+ gtk_object_unref((GtkObject *)fcrlf);
if (fch)
gtk_object_unref((GtkObject *)fch);
if (source)
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 14b8106314..ab4c44b82f 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -542,8 +542,10 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
#endif
count = camel_data_wrapper_write_to_stream (content, stream);
- if (filter_stream)
+ if (filter_stream) {
+ camel_stream_flush((CamelStream *)filter_stream);
gtk_object_unref((GtkObject *)filter_stream);
+ }
if (count == -1)
return -1;
total += count;
diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c
index 547796c660..9051bdb64f 100644
--- a/camel/camel-stream-filter.c
+++ b/camel/camel-stream-filter.c
@@ -120,7 +120,7 @@ camel_stream_filter_class_init (CamelStreamFilterClass *klass)
camel_stream_class->read = do_read;
camel_stream_class->write = do_write;
camel_stream_class->flush = do_flush;
- camel_stream_class->flush = do_close;
+ camel_stream_class->close = do_close;
camel_stream_class->eos = do_eos;
camel_stream_class->reset = do_reset;
diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c
index 2d5c84a113..722b49f3f8 100644
--- a/camel/camel-stream-mem.c
+++ b/camel/camel-stream-mem.c
@@ -233,9 +233,9 @@ stream_seek (CamelSeekableStream *stream, off_t offset,
break;
}
- if (stream->bound_end == CAMEL_STREAM_UNBOUND)
+ if (stream->bound_end != CAMEL_STREAM_UNBOUND)
position = MIN (position, stream->bound_end);
- if (stream->bound_start == CAMEL_STREAM_UNBOUND)
+ if (stream->bound_start != CAMEL_STREAM_UNBOUND)
position = MAX (position, 0);
else
position = MAX (position, stream->bound_start);
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index b465faa499..ea4db42097 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -642,8 +642,8 @@ camel_pop3_command_get_additional_data (CamelPop3Store *store,
{
CamelStreamBuffer *stream = CAMEL_STREAM_BUFFER (store->istream);
GPtrArray *data;
- char *buf;
- int i, status = CAMEL_POP3_OK;
+ char *buf, *p;
+ int i, len = 0, status = CAMEL_POP3_OK;
data = g_ptr_array_new ();
while (1) {
@@ -655,24 +655,26 @@ camel_pop3_command_get_additional_data (CamelPop3Store *store,
if (!strcmp (buf, "."))
break;
- if (*buf == '.')
- memmove (buf, buf + 1, strlen (buf));
- g_ptr_array_add (data, buf);
+ p = (*buf == '.') ? buf + 1 : buf;
+ g_ptr_array_add (data, p);
+ len += strlen (p) + 1;
}
g_free (buf);
if (status == CAMEL_POP3_OK) {
- /* Append an empty string to the end of the array
- * so when we g_strjoinv it, we get a "\n" after
- * the last real line.
- */
- g_ptr_array_add (data, "");
- g_ptr_array_add (data, NULL);
- buf = g_strjoinv ("\n", (char **)data->pdata);
+ buf = g_malloc (len + 1);
+
+ for (i = 0, p = buf; i < data->len; i++) {
+ len = strlen (data->pdata[i]);
+ memcpy (p, data->pdata[i], len);
+ p += len;
+ *p++ = '\n';
+ }
+ *p = '\0';
} else
buf = NULL;
- for (i = 0; i < data->len - 2; i++)
+ for (i = 0; i < data->len; i++)
g_free (data->pdata[i]);
g_ptr_array_free (data, TRUE);