diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-09-14 05:35:52 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-09-14 05:35:52 +0800 |
commit | 05cc233af13c41610e0f9460702c6d0a955b29f4 (patch) | |
tree | ee376ba62fa9f908422d8c2d2120d58b3d1dde2d /camel/providers/imap | |
parent | 6e59bb666622d0d5c66ad44b4013658b672a3166 (diff) | |
download | gsoc2013-evolution-05cc233af13c41610e0f9460702c6d0a955b29f4.tar gsoc2013-evolution-05cc233af13c41610e0f9460702c6d0a955b29f4.tar.gz gsoc2013-evolution-05cc233af13c41610e0f9460702c6d0a955b29f4.tar.bz2 gsoc2013-evolution-05cc233af13c41610e0f9460702c6d0a955b29f4.tar.lz gsoc2013-evolution-05cc233af13c41610e0f9460702c6d0a955b29f4.tar.xz gsoc2013-evolution-05cc233af13c41610e0f9460702c6d0a955b29f4.tar.zst gsoc2013-evolution-05cc233af13c41610e0f9460702c6d0a955b29f4.zip |
Pass an exception to the cache. (imap_append_online): Same.
2001-09-13 Jeffrey Stedfast <fejj@ximian.com>
* providers/imap/camel-imap-folder.c (imap_append_offline): Pass
an exception to the cache.
(imap_append_online): Same.
(imap_append_resyncing): Here too.
(imap_copy_offline): And here.
(handle_copyuid): Pass NULL as the exception here...
(parse_fetch_response): And finally here.
* providers/imap/camel-imap-message-cache.c
(camel_imap_message_cache_insert):
(insert_setup):
(camel_imap_message_cache_insert_stream):
(camel_imap_message_cache_insert_wrapper):
(camel_imap_message_cache_copy): Take an exception argument and
set it on error.
svn path=/trunk/; revision=12813
Diffstat (limited to 'camel/providers/imap')
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 15 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-message-cache.c | 62 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-message-cache.h | 12 |
3 files changed, 56 insertions, 33 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 0e4c0dd44e..fc873f9e85 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -887,7 +887,7 @@ imap_append_offline (CamelFolder *folder, CamelMimeMessage *message, camel_imap_summary_add_offline (folder->summary, uid, message, info); CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock); camel_imap_message_cache_insert_wrapper (cache, uid, "", - CAMEL_DATA_WRAPPER (message)); + CAMEL_DATA_WRAPPER (message), ex); CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); changes = camel_folder_change_info_new (); @@ -997,8 +997,8 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message, */ CAMEL_IMAP_FOLDER_LOCK (folder, cache_lock); camel_imap_message_cache_insert_wrapper ( - CAMEL_IMAP_FOLDER (folder)->cache, - uid, "", CAMEL_DATA_WRAPPER (message)); + CAMEL_IMAP_FOLDER (folder)->cache, uid, + "", CAMEL_DATA_WRAPPER (message), ex); CAMEL_IMAP_FOLDER_UNLOCK (folder, cache_lock); g_free (uid); } @@ -1029,7 +1029,7 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message, CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); camel_imap_message_cache_copy (imap_folder->cache, olduid, - imap_folder->cache, uid); + imap_folder->cache, uid, ex); CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); camel_disco_diary_uidmap_add (CAMEL_DISCO_STORE (store)->diary, @@ -1076,7 +1076,7 @@ imap_copy_offline (CamelFolder *source, GPtrArray *uids, destuid = g_strdup_printf ("copy-%s:%s", source->full_name, uid); camel_imap_summary_add_offline (destination->summary, destuid, message, mi); - camel_imap_message_cache_copy (sc, uid, dc, destuid); + camel_imap_message_cache_copy (sc, uid, dc, destuid, ex); camel_folder_summary_info_free (source->summary, mi); camel_object_unref (CAMEL_OBJECT (message)); @@ -1133,7 +1133,8 @@ handle_copyuid (CamelImapResponse *response, CamelFolder *source, CAMEL_IMAP_FOLDER_LOCK (destination, cache_lock); for (i = 0; i < src->len; i++) { camel_imap_message_cache_copy (scache, src->pdata[i], - dcache, dest->pdata[i]); + dcache, dest->pdata[i], + NULL); } CAMEL_IMAP_FOLDER_UNLOCK (source, cache_lock); CAMEL_IMAP_FOLDER_UNLOCK (destination, cache_lock); @@ -2106,7 +2107,7 @@ parse_fetch_response (CamelImapFolder *imap_folder, char *response) CAMEL_IMAP_FOLDER_LOCK (imap_folder, cache_lock); stream = camel_imap_message_cache_insert (imap_folder->cache, uid, part_spec, - body, body_len); + body, body_len, NULL); CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); g_datalist_set_data_full (&data, "BODY_PART_STREAM", stream, (GDestroyNotify)camel_object_unref); diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c index d4f569423c..47e40a2ad1 100644 --- a/camel/providers/imap/camel-imap-message-cache.c +++ b/camel/providers/imap/camel-imap-message-cache.c @@ -225,24 +225,27 @@ stream_finalize (CamelObject *stream, gpointer event_data, gpointer user_data) static CamelStream * -insert_setup (CamelImapMessageCache *cache, const char *uid, - const char *part_spec, char **path, char **key) +insert_setup (CamelImapMessageCache *cache, const char *uid, const char *part_spec, + char **path, char **key, CamelException *ex) { CamelStream *stream; int fd; - + *path = g_strdup_printf ("%s/%s.%s", cache->path, uid, part_spec); *key = strrchr (*path, '/') + 1; stream = g_hash_table_lookup (cache->parts, *key); if (stream) camel_object_unref (CAMEL_OBJECT (stream)); - + fd = open (*path, O_RDWR | O_CREAT | O_TRUNC, 0600); if (fd == -1) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Failed to cache message %s: %s"), + uid, g_strerror (errno)); g_free (*path); return NULL; } - + return camel_stream_fs_new_with_fd (fd); } @@ -256,8 +259,8 @@ insert_abort (char *path, CamelStream *stream) } static CamelStream * -insert_finish (CamelImapMessageCache *cache, const char *uid, - char *path, char *key, CamelStream *stream) +insert_finish (CamelImapMessageCache *cache, const char *uid, char *path, + char *key, CamelStream *stream) { camel_stream_reset (stream); cache_put (cache, uid, key, stream); @@ -282,16 +285,22 @@ insert_finish (CamelImapMessageCache *cache, const char *uid, CamelStream * camel_imap_message_cache_insert (CamelImapMessageCache *cache, const char *uid, const char *part_spec, const char *data, - int len) + int len, CamelException *ex) { char *path, *key; CamelStream *stream; - - stream = insert_setup (cache, uid, part_spec, &path, &key); + + stream = insert_setup (cache, uid, part_spec, &path, &key, ex); if (!stream) return NULL; - if (camel_stream_write (stream, data, len) == -1) + + if (camel_stream_write (stream, data, len) == -1) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Failed to cache message %s: %s"), + uid, g_strerror (errno)); return insert_abort (path, stream); + } + return insert_finish (cache, uid, path, key, stream); } @@ -307,17 +316,21 @@ camel_imap_message_cache_insert (CamelImapMessageCache *cache, const char *uid, void camel_imap_message_cache_insert_stream (CamelImapMessageCache *cache, const char *uid, const char *part_spec, - CamelStream *data_stream) + CamelStream *data_stream, CamelException *ex) { char *path, *key; CamelStream *stream; - - stream = insert_setup (cache, uid, part_spec, &path, &key); + + stream = insert_setup (cache, uid, part_spec, &path, &key, ex); if (!stream) return; - if (camel_stream_write_to_stream (data_stream, stream) == -1) + + if (camel_stream_write_to_stream (data_stream, stream) == -1) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Failed to cache message %s: %s"), + uid, g_strerror (errno)); insert_abort (path, stream); - else { + } else { insert_finish (cache, uid, path, key, stream); camel_object_unref (CAMEL_OBJECT (stream)); } @@ -335,17 +348,21 @@ camel_imap_message_cache_insert_stream (CamelImapMessageCache *cache, void camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache, const char *uid, const char *part_spec, - CamelDataWrapper *wrapper) + CamelDataWrapper *wrapper, CamelException *ex) { char *path, *key; CamelStream *stream; - stream = insert_setup (cache, uid, part_spec, &path, &key); + stream = insert_setup (cache, uid, part_spec, &path, &key, ex); if (!stream) return; - if (camel_data_wrapper_write_to_stream (wrapper, stream) == -1) + + if (camel_data_wrapper_write_to_stream (wrapper, stream) == -1) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Failed to cache message %s: %s"), + uid, g_strerror (errno)); insert_abort (path, stream); - else { + } else { insert_finish (cache, uid, path, key, stream); camel_object_unref (CAMEL_OBJECT (stream)); } @@ -463,7 +480,8 @@ void camel_imap_message_cache_copy (CamelImapMessageCache *source, const char *source_uid, CamelImapMessageCache *dest, - const char *dest_uid) + const char *dest_uid, + CamelException *ex) { GPtrArray *subparts; CamelStream *stream; @@ -479,7 +497,7 @@ camel_imap_message_cache_copy (CamelImapMessageCache *source, if (!part++) continue; stream = camel_imap_message_cache_get (source, source_uid, part); - camel_imap_message_cache_insert_stream (dest, dest_uid, part, stream); + 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 6ddf7339c7..4399a5e703 100644 --- a/camel/providers/imap/camel-imap-message-cache.h +++ b/camel/providers/imap/camel-imap-message-cache.h @@ -70,15 +70,18 @@ CamelStream *camel_imap_message_cache_insert (CamelImapMessageCache *cache, const char *uid, const char *part_spec, const char *data, - int len); + int len, + CamelException *ex); void camel_imap_message_cache_insert_stream (CamelImapMessageCache *cache, const char *uid, const char *part_spec, - CamelStream *data_stream); + CamelStream *data_stream, + CamelException *ex); void camel_imap_message_cache_insert_wrapper (CamelImapMessageCache *cache, const char *uid, const char *part_spec, - CamelDataWrapper *wrapper); + CamelDataWrapper *wrapper, + CamelException *ex); CamelStream *camel_imap_message_cache_get (CamelImapMessageCache *cache, const char *uid, @@ -91,7 +94,8 @@ void camel_imap_message_cache_clear (CamelImapMessageCache *cache); void camel_imap_message_cache_copy (CamelImapMessageCache *source, const char *source_uid, CamelImapMessageCache *dest, - const char *dest_uid); + const char *dest_uid, + CamelException *ex); /* Standard Camel function */ CamelType camel_imap_message_cache_get_type (void); |