--- evolution-data-server-1.5.91/camel/providers/imap/camel-imap-folder.c~	2006-02-13 04:11:11.000000000 +0000
+++ evolution-data-server-1.5.91/camel/providers/imap/camel-imap-folder.c	2006-02-28 14:26:59.000000000 +0000
@@ -523,8 +523,11 @@ imap_refresh_info (CamelFolder *folder, 
 	if (!camel_imap_store_connected(imap_store, ex))
 		goto done;
 
-	if (imap_store->current_folder != folder
-	    || g_ascii_strcasecmp(folder->full_name, "INBOX") == 0) {
+	if (imap_store->current_folder != folder && (imap_store->capabilities & IMAP_CAPABILITY_STATUS)) {
+		imap_folder_refresh_status(folder, ex);
+		goto done;
+	} else if (imap_store->current_folder != folder
+		   || g_ascii_strcasecmp(folder->full_name, "INBOX") == 0) {
 		response = camel_imap_command (imap_store, folder, ex, NULL);
 		if (response) {
 			camel_imap_folder_selected (folder, response, ex);
--- evolution-data-server-1.5.91/camel/providers/imap/camel-imap-store.c~	2006-02-27 16:50:57.000000000 +0000
+++ evolution-data-server-1.5.91/camel/providers/imap/camel-imap-store.c	2006-02-28 15:11:58.000000000 +0000
@@ -1841,6 +1841,40 @@ get_folder_status (CamelImapStore *imap_
 	
 	return items;
 }
+		
+void imap_folder_refresh_status (CamelFolder *folder, CamelException *ex)
+{
+	CamelImapStore *imap_store = CAMEL_IMAP_STORE (folder->parent_store);
+	struct imap_status_item *items, *item;
+	int unread = -1, total = -1;
+	CamelStoreInfo *si;
+
+	printf("Get folder status for %s\n", folder->full_name);
+	items = item = get_folder_status (imap_store, folder->full_name, "MESSAGES UNSEEN");
+	while (item != NULL) {
+		if (!g_ascii_strcasecmp (item->name, "MESSAGES")) {
+			total = item->value;
+		} else if (!g_ascii_strcasecmp (item->name, "UNSEEN")) {
+			unread = item->value;
+		}
+		item = item->next;
+	}
+	imap_status_item_free (items);
+	printf("Got total %d unseen %d\n", total, unread);
+	si = camel_store_summary_path((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary, folder->full_name);
+	if (si) {
+		if ((total != -1 && si->total != total)
+		    || (unread != -1 && si->unread != unread)) {
+			    if (total != -1)
+				    si->total = total;
+			    if (unread != -1)
+				    si->unread = unread;
+			    printf("touch summary\n");
+			camel_store_summary_touch((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary);
+		}
+		camel_store_summary_info_free((CamelStoreSummary *)((CamelImapStore *)folder->parent_store)->summary, si);
+	}
+}
 
 static CamelFolder *
 get_folder_online (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex)
--- evolution-data-server-1.5.91/camel/providers/imap/camel-imap-store.h~	2006-02-27 16:50:56.000000000 +0000
+++ evolution-data-server-1.5.91/camel/providers/imap/camel-imap-store.h	2006-02-28 14:25:04.000000000 +0000
@@ -153,6 +153,7 @@ CamelType camel_imap_store_get_type (voi
 gboolean camel_imap_store_connected (CamelImapStore *store, CamelException *ex);
 
 ssize_t camel_imap_store_readline (CamelImapStore *store, char **dest, CamelException *ex);
+void imap_folder_refresh_status (CamelFolder *folder, CamelException *ex);
 
 #ifdef __cplusplus
 }
