aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog16
-rw-r--r--camel/camel-mime-utils.c38
-rw-r--r--camel/providers/imap/camel-imap-folder.c9
-rw-r--r--camel/providers/imap/camel-imap-message-cache.c27
-rw-r--r--camel/providers/imap/camel-imap-message-cache.h4
-rw-r--r--camel/providers/imap/camel-imap-store.c2
6 files changed, 73 insertions, 23 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index f383b0dc8b..c9d13ddd20 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,17 @@
+2002-09-09 Jeffrey Stedfast <fejj@ximian.com>
+
+ Fixes bug #4224
+
+ * providers/imap/camel-imap-folder.c
+ (camel_imap_folder_fetch_data): Pass ex into
+ camel_imap_message_cache_get().
+
+ * providers/imap/camel-imap-message-cache.c
+ (camel_imap_message_cache_get): Now takes an exception and sets it
+ on fail.
+ (camel_imap_message_cache_copy): Updated to properly handle
+ cache_get error conditions.
+
2002-09-04 Dan Winship <danw@ximian.com>
* camel-mime-utils.c (header_decode_date): Use e_mktime_utc.
@@ -24,7 +38,7 @@
(get_message_simple): Set an exception if we get a construct
failure.
(imap_refresh_info): if we're refreshing inbox, force a reselect.
- this is required for at least cryus. CHECK doesnt work either :(
+ this is required for at least cyrus. CHECK doesnt work either :(
* tests/lib/folders.c (test_folder_basic): for non-local stores,
the folder will have an extra ref for selection, take this into
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index f1a3792f60..d49c41a874 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -1338,7 +1338,7 @@ header_encode_string (const unsigned char *in)
int encoding;
GString *out;
char *outstr;
-
+
g_return_val_if_fail (g_utf8_validate (in, -1, NULL), NULL);
if (in == NULL)
@@ -1350,7 +1350,7 @@ header_encode_string (const unsigned char *in)
break;
inptr++;
}
- if (*inptr == '\0')
+ if (FALSE && *inptr == '\0')
return g_strdup (in);
/* This gets each word out of the input, and checks to see what charset
@@ -1376,9 +1376,20 @@ header_encode_string (const unsigned char *in)
if (g_unichar_isspace (c) && !last_was_space) {
/* we've reached the end of a 'word' */
- if (word && !(last_was_encoded && encoding)) {
- g_string_append_len (out, start, word - start);
- start = word;
+ if (word) {
+ int len = inptr - word;
+
+ printf ("checking word '%.*s'\n", len, word);
+ if (!encoding && len > 8 && !strncmp (word, "=?", 2) && !strncmp (inptr - 2, "?=", 2)) {
+ printf ("yes...\n");
+ encoding = 1;
+ } else
+ printf ("no...\n");
+
+ if (!(last_was_encoded && encoding)) {
+ g_string_append_len (out, start, word - start);
+ start = word;
+ }
}
switch (encoding) {
@@ -1424,9 +1435,20 @@ header_encode_string (const unsigned char *in)
}
if (inptr - start) {
- if (word && !(last_was_encoded && encoding)) {
- g_string_append_len (out, start, word - start);
- start = word;
+ if (word) {
+ int len = inptr - word;
+
+ printf ("checking word '%.*s'\n", len, word);
+ if (!encoding && len > 8 && !strncmp (word, "=?", 2) && !strncmp (inptr - 3, "?=", 2)) {
+ printf ("yes...\n");
+ encoding = 1;
+ } else
+ printf ("no...\n");
+
+ if (!(last_was_encoded && encoding)) {
+ g_string_append_len (out, start, word - start);
+ start = word;
+ }
}
switch (encoding) {
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 1a2f5a79e9..0f77d80d75 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -2410,9 +2410,12 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid,
CAMEL_SERVICE_LOCK (store, connect_lock);
CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock);
- stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text);
- if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0")))
- stream = camel_imap_message_cache_get (imap_folder->cache, uid, "");
+ stream = camel_imap_message_cache_get (imap_folder->cache, uid, section_text, ex);
+ if (!stream && (!strcmp (section_text, "HEADER") || !strcmp (section_text, "0"))) {
+ camel_exception_clear (ex);
+ stream = camel_imap_message_cache_get (imap_folder->cache, uid, "", ex);
+ }
+
if (stream || cache_only) {
CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
CAMEL_SERVICE_UNLOCK (store, connect_lock);
diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c
index 0701ca45e4..559c6d2f88 100644
--- a/camel/providers/imap/camel-imap-message-cache.c
+++ b/camel/providers/imap/camel-imap-message-cache.c
@@ -384,20 +384,21 @@ camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache,
* @cache: the cache
* @uid: the UID of the data to get
* @part_spec: the part_spec of the data to get
+ * @ex: exception
*
* Return value: a CamelStream containing the cached data (which the
* caller must unref), or %NULL if that data is not cached.
**/
CamelStream *
camel_imap_message_cache_get (CamelImapMessageCache *cache, const char *uid,
- const char *part_spec)
+ const char *part_spec, CamelException *ex)
{
CamelStream *stream;
char *path, *key;
-
+
if (uid[0] == 0)
return NULL;
-
+
path = g_strdup_printf ("%s/%s.%s", cache->path, uid, part_spec);
key = strrchr (path, '/') + 1;
stream = g_hash_table_lookup (cache->parts, key);
@@ -409,8 +410,14 @@ camel_imap_message_cache_get (CamelImapMessageCache *cache, const char *uid,
}
stream = camel_stream_fs_new_with_name (path, O_RDONLY, 0);
- if (stream)
+ if (stream) {
cache_put (cache, uid, key, stream);
+ } else {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Failed to cache %s: %s"),
+ part_spec, g_strerror (errno));
+ }
+
g_free (path);
return stream;
@@ -502,17 +509,19 @@ camel_imap_message_cache_copy (CamelImapMessageCache *source,
CamelStream *stream;
char *part;
int i;
-
+
subparts = g_hash_table_lookup (source->parts, source_uid);
if (!subparts || !subparts->len)
return;
-
+
for (i = 0; i < subparts->len; i++) {
part = strchr (subparts->pdata[i], '.');
if (!part++)
continue;
- stream = camel_imap_message_cache_get (source, source_uid, part);
- camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream, ex);
- camel_object_unref (CAMEL_OBJECT (stream));
+
+ if ((stream = camel_imap_message_cache_get (source, source_uid, part, ex))) {
+ camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream, ex);
+ camel_object_unref (CAMEL_OBJECT (stream));
+ }
}
}
diff --git a/camel/providers/imap/camel-imap-message-cache.h b/camel/providers/imap/camel-imap-message-cache.h
index eb3f056b44..c79195cfa4 100644
--- a/camel/providers/imap/camel-imap-message-cache.h
+++ b/camel/providers/imap/camel-imap-message-cache.h
@@ -87,7 +87,9 @@ void camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache,
CamelStream *camel_imap_message_cache_get (CamelImapMessageCache *cache,
const char *uid,
- const char *part_spec);
+ const char *part_spec,
+ CamelException *ex);
+
void camel_imap_message_cache_remove (CamelImapMessageCache *cache,
const char *uid);
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index af4192e0c6..f095c664db 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -1223,7 +1223,7 @@ imap_connect_online (CamelService *service, CamelException *ex)
if (!store->namespace)
store->namespace = g_strdup ("");
-
+
if (!store->dir_sep) {
if (store->server_level >= IMAP_LEVEL_IMAP4REV1) {
/* This idiom means "tell me the hierarchy separator