From 808e179d48cc2f3f7400b5007949064b147db7e4 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 22 Aug 2002 20:23:16 +0000 Subject: If current_folder is not NULL and the summary for that folder is dirty, 2002-08-22 Jeffrey Stedfast * providers/imap/camel-imap-store.c (imap_noop): If current_folder is not NULL and the summary for that folder is dirty, sync the flags rather than sending a NOOP. svn path=/trunk/; revision=17842 --- camel/providers/imap/camel-imap-store.c | 38 +++++++++++++++++++++++++++------ camel/providers/imap/camel-imap-utils.c | 2 +- 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'camel/providers/imap') diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index d269df71a5..63ca5834f7 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -1405,23 +1405,47 @@ imap_disconnect_online (CamelService *service, gboolean clean, CamelException *e return TRUE; } + +static gboolean +imap_summary_is_dirty (CamelFolderSummary *summary) +{ + CamelMessageInfo *info; + int max, i; + + max = camel_folder_summary_count (summary); + for (i = 0; i < max; i++) { + info = camel_folder_summary_index (summary, i); + if (info && (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) + return TRUE; + } + + return FALSE; +} + static void imap_noop (CamelStore *store, CamelException *ex) { CamelImapStore *imap_store = (CamelImapStore *) store; CamelDiscoStore *disco = (CamelDiscoStore *) store; CamelImapResponse *response; + CamelFolder *current_folder; - switch (camel_disco_store_status (disco)) { - case CAMEL_DISCO_STORE_ONLINE: - case CAMEL_DISCO_STORE_RESYNCING: - response = camel_imap_command (imap_store, NULL, NULL, "NOOP"); + if (camel_disco_store_status (disco) != CAMEL_DISCO_STORE_ONLINE) + return; + + CAMEL_IMAP_STORE_LOCK (imap_store, command_lock); + + current_folder = imap_store->current_folder; + if (current_folder && imap_summary_is_dirty (current_folder->summary)) { + /* let's sync the flags instead */ + camel_folder_sync (current_folder, FALSE, ex); + } else { + response = camel_imap_command (imap_store, NULL, ex, "NOOP"); if (response) camel_imap_response_free (imap_store, response); - break; - case CAMEL_DISCO_STORE_OFFLINE: - break; } + + CAMEL_IMAP_STORE_UNLOCK (imap_store, command_lock); } static guint diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c index e07d1ccac3..4f0f9f143b 100644 --- a/camel/providers/imap/camel-imap-utils.c +++ b/camel/providers/imap/camel-imap-utils.c @@ -380,7 +380,7 @@ imap_parse_list_response (CamelImapStore *store, const char *buf, int *flags, ch * can ya do when ya got the ignorance of marketing breathing * down your neck?) */ - if (is_lsub && !strcasecmp (mailbox, "INBOX")) + if (is_lsub && flags && !strcasecmp (mailbox, "INBOX")) *flags &= ~CAMEL_FOLDER_NOSELECT; *folder = mailbox; -- cgit v1.2.3