From 55ee13ab6bf8760fb14de209d2519d6bbaf67c30 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 7 Jul 2000 22:09:57 +0000 Subject: Don't cache the exact server response, only cache the important data (aka 2000-07-07 Jeffrey Stedfast * providers/imap/camel-imap-stream.c (stream_read): Don't cache the exact server response, only cache the important data (aka the mime part). svn path=/trunk/; revision=3964 --- camel/providers/imap/camel-imap-stream.c | 34 ++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'camel') diff --git a/camel/providers/imap/camel-imap-stream.c b/camel/providers/imap/camel-imap-stream.c index 74d46eb95c..d7fb0ee75c 100644 --- a/camel/providers/imap/camel-imap-stream.c +++ b/camel/providers/imap/camel-imap-stream.c @@ -25,6 +25,7 @@ #include "camel-imap-stream.h" #include #include +#include static CamelStreamClass *parent_class = NULL; @@ -128,17 +129,19 @@ stream_read (CamelStream *stream, char *buffer, size_t n) if (!imap_stream->cache) { /* We need to send the IMAP command since this is our first fetch */ CamelFolder *folder = CAMEL_FOLDER (imap_stream->folder); - gint status; + gchar *result, *p, *q; + gint status, part_len; status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), CAMEL_FOLDER (imap_stream->folder), - &imap_stream->cache, "%s", + &result, "%s\r\n", imap_stream->command); - if (status != CAMEL_IMAP_OK) { + if (!result || status != CAMEL_IMAP_OK) { /* we got an error, dump this stuff */ - g_free (imap_stream->cache); + g_free (result); imap_stream->cache = NULL; + gtk_object_unref (GTK_OBJECT (imap_stream->folder)); return -1; } @@ -146,6 +149,29 @@ stream_read (CamelStream *stream, char *buffer, size_t n) /* we don't need the folder anymore... */ gtk_object_unref (GTK_OBJECT (imap_stream->folder)); + /* parse out the message part */ + for (p = result; *p && *p != '{' && *p != '\n'; p++); + if (*p != '{') { + g_free (result); + return -1; + } + + part_len = atoi (p + 1); + for ( ; *p && *p != '\n'; p++); + if (*p != '\n') { + g_free (result); + return -1; + } + + /* calculate the new part-length */ + for (q = p; *q && (q - p) <= part_len; q++) { + if (*q == '\n') + part_len--; + } + + imap_stream->cache = g_strndup (p, part_len); + g_free (result); + imap_stream->cache_ptr = imap_stream->cache; } -- cgit v1.2.3