From efb6138e6b590e843e6281ce5e1a0774a4fb1446 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 31 Mar 2005 20:00:43 +0000 Subject: [PATCH] oops, wrong branch --- camel/providers/imap4/ChangeLog | 15 +++++++ camel/providers/imap4/camel-imap4-engine.c | 4 +- camel/providers/imap4/camel-imap4-folder.c | 68 ++++++++++++++++-------------- camel/providers/imap4/camel-imap4-folder.h | 1 + 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/camel/providers/imap4/ChangeLog b/camel/providers/imap4/ChangeLog index 9981f8d..2bfcf97 100644 --- a/camel/providers/imap4/ChangeLog +++ b/camel/providers/imap4/ChangeLog @@ -1,3 +1,18 @@ +2005-03-11 Jeffrey Stedfast + + * camel-imap4-folder.c (imap4_sync): Don't try to EXPUNGE in + READ-ONLY mode. + (imap4_sync_changes): Don't check permanent_flags here. + (imap4_sync): Check permanent_flags here instead and don't bother + wasting cycles if permanent_flags is empty. + (imap4_sync): Don't attempt to EXPUNGE if the folder is READ-ONLY. + (imap4_append_message): Set an exception if the folder is + read-only and don't bother trying to append. + + * camel-imap4-engine.c (camel_imap4_engine_select_folder): Set the + READ-ONLY bit on the folder if the server says we've opened it in + READ-ONLY mode. + 2005-02-03 Jeffrey Stedfast * camel-imap4-engine.c (camel_imap4_engine_handle_untagged_1): diff --git a/camel/providers/imap4/camel-imap4-engine.c b/camel/providers/imap4/camel-imap4-engine.c index 9599b3c..0c16013 100644 --- a/camel/providers/imap4/camel-imap4-engine.c +++ b/camel/providers/imap4/camel-imap4-engine.c @@ -401,10 +401,10 @@ camel_imap4_engine_select_folder (CamelIMAP4Engine *engine, CamelFolder *folder, folder->permanent_flags = resp->v.flags; break; case CAMEL_IMAP4_RESP_CODE_READONLY: - /*folder->mode = CAMEL_FOLDER_MODE_READ_ONLY;*/ + ((CamelIMAP4Folder *) folder)->read_only = TRUE; break; case CAMEL_IMAP4_RESP_CODE_READWRITE: - /*folder->mode = CAMEL_FOLDER_MODE_READ_WRITE;*/ + ((CamelIMAP4Folder *) folder)->read_only = FALSE; break; case CAMEL_IMAP4_RESP_CODE_UIDNEXT: camel_imap4_summary_set_uidnext (folder->summary, resp->v.uidnext); diff --git a/camel/providers/imap4/camel-imap4-folder.c b/camel/providers/imap4/camel-imap4-folder.c index 9155980..b6a3ee8 100644 --- a/camel/providers/imap4/camel-imap4-folder.c +++ b/camel/providers/imap4/camel-imap4-folder.c @@ -485,9 +485,6 @@ imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex) int retval = 0; int i, j; - if (folder->permanent_flags == 0) - return 0; - on_set = g_ptr_array_new (); off_set = g_ptr_array_new (); @@ -557,39 +554,41 @@ imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); /* gather a list of changes to sync to the server */ - sync = g_ptr_array_new (); - max = camel_folder_summary_count (folder->summary); - for (i = 0; i < max; i++) { - iinfo = (CamelIMAP4MessageInfo *) (info = camel_folder_summary_index (folder->summary, i)); - if (iinfo->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) { - camel_imap4_flags_diff (&diff, iinfo->server_flags, iinfo->info.flags); - diff.changed &= folder->permanent_flags; - - /* weed out flag changes that we can't sync to the server */ - if (!diff.changed) + if (folder->permanent_flags) { + sync = g_ptr_array_new (); + max = camel_folder_summary_count (folder->summary); + for (i = 0; i < max; i++) { + iinfo = (CamelIMAP4MessageInfo *) (info = camel_folder_summary_index (folder->summary, i)); + if (iinfo->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) { + camel_imap4_flags_diff (&diff, iinfo->server_flags, iinfo->info.flags); + diff.changed &= folder->permanent_flags; + + /* weed out flag changes that we can't sync to the server */ + if (!diff.changed) + camel_message_info_free(info); + else + g_ptr_array_add (sync, info); + } else { camel_message_info_free(info); - else - g_ptr_array_add (sync, info); - } else { - camel_message_info_free(info); + } } - } - - if (sync->len > 0) { - retval = imap4_sync_changes (folder, sync, ex); - - for (i = 0; i < sync->len; i++) - camel_message_info_free(sync->pdata[i]); - - g_ptr_array_free (sync, TRUE); - if (retval == -1) - goto done; - } else { - g_ptr_array_free (sync, TRUE); + if (sync->len > 0) { + retval = imap4_sync_changes (folder, sync, ex); + + for (i = 0; i < sync->len; i++) + camel_message_info_free(sync->pdata[i]); + + g_ptr_array_free (sync, TRUE); + + if (retval == -1) + goto done; + } else { + g_ptr_array_free (sync, TRUE); + } } - if (expunge) { + if (expunge && !((CamelIMAP4Folder *) folder)->read_only) { ic = camel_imap4_engine_queue (engine, folder, "EXPUNGE\r\n"); while ((id = camel_imap4_engine_iterate (engine)) < ic->id && id != -1) ; @@ -909,6 +908,13 @@ imap4_append_message (CamelFolder *folder, CamelMimeMessage *message, if (appended_uid) *appended_uid = NULL; + if (((CamelIMAP4Folder *) folder)->read_only) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + _("Cannot append message to folder `%s': Folder is read-only"), + folder->full_name); + return; + } + if (offline->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) { camel_imap4_journal_append ((CamelIMAP4Journal *) imap4_folder->journal, message, info, appended_uid, ex); return; diff --git a/camel/providers/imap4/camel-imap4-folder.h b/camel/providers/imap4/camel-imap4-folder.h index 0edbd8d..ac0da34 100644 --- a/camel/providers/imap4/camel-imap4-folder.h +++ b/camel/providers/imap4/camel-imap4-folder.h @@ -64,6 +64,7 @@ struct _CamelIMAP4Folder { char *cachedir; char *utf7_name; + unsigned int read_only:1; unsigned int enable_mlist:1; }; -- 2.7.4