2006-05-19 [colin] 2.2.0cvs39
authorColin Leroy <colin@colino.net>
Fri, 19 May 2006 17:09:06 +0000 (17:09 +0000)
committerColin Leroy <colin@colino.net>
Fri, 19 May 2006 17:09:06 +0000 (17:09 +0000)
* src/folder.c
* src/folder.h
* src/folderview.c
Try to fix bug #830 (Some unread messages
get marked read in IMAP inbox):
- Prevent scanning a folder if it's being
  opened via the GUI
- Postpone opening via the GUI of a folder
  currently scanned.

ChangeLog
PATCHSETS
configure.ac
src/folder.c
src/folder.h
src/folderview.c

index 4ec5be8d9ee29826b5ff84500b31a72687a7519b..af157d83f2153f4000a797620664cb19afcf0455 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-05-19 [colin]     2.2.0cvs39
+
+       * src/folder.c
+       * src/folder.h
+       * src/folderview.c
+               Try to fix bug #830 (Some unread messages 
+               get marked read in IMAP inbox):
+               - Prevent scanning a folder if it's being 
+                 opened via the GUI
+               - Postpone opening via the GUI of a folder
+                 currently scanned.
+
+
 2006-05-19 [wwp]       2.2.0cvs38
 
        * manual/advanced.xml
index 14e4e6a71e644d958e3476f49d273fd64ccef175..06cb67506b5c0e2baad501d34ae138d7c2f2aced 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.396.2.583 -r 1.396.2.584 ChangeLog;  ) > 2.2.0cvs36.patchset
 ( cvs diff -u -r 1.1.2.16 -r 1.1.2.17 manual/advanced.xml;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 manual/fr/advanced.xml;  cvs diff -u -r 1.1.4.16 -r 1.1.4.17 src/gtk/logwindow.c;  cvs diff -u -r 1.204.2.85 -r 1.204.2.86 src/prefs_common.c;  cvs diff -u -r 1.103.2.48 -r 1.103.2.49 src/prefs_common.h;  ) > 2.2.0cvs37.patchset
 ( cvs diff -u -r 1.1.2.17 -r 1.1.2.18 manual/advanced.xml;  ) > 2.2.0cvs38.patchset
+( cvs diff -u -r 1.213.2.92 -r 1.213.2.93 src/folder.c;  cvs diff -u -r 1.87.2.27 -r 1.87.2.28 src/folder.h;  cvs diff -u -r 1.207.2.97 -r 1.207.2.98 src/folderview.c;  ) > 2.2.0cvs39.patchset
index 98ca8f886f9e6041c2f45ab8b7fac4c56959b132..ea6280e9b6b9b63f0d546f91cbf7839b491be140 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=2
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=38
+EXTRA_VERSION=39
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 7e7ce021385782266169d53bd1f68d6c3c885817..525e61e3d39235d4410e57e419fc43ca81932722 100644 (file)
@@ -1526,6 +1526,11 @@ gint folder_item_open(FolderItem *item)
        if (item->no_select)
                return -1;
 
+       if (item->scanning) {
+               debug_print("%s is scanning... \n", item->path ? item->path : item->name);
+               return -2;
+       }
+
        item->processing_pending = TRUE;
        folder_item_process_open (item, NULL, NULL, NULL);
        
@@ -1682,11 +1687,14 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
        g_return_val_if_fail(folder != NULL, -1);
        g_return_val_if_fail(folder->klass->get_num_list != NULL, -1);
 
+       item->scanning = TRUE;
+
        debug_print("Scanning folder %s for cache changes.\n", item->path ? item->path : "(null)");
        
        /* Get list of messages for folder and cache */
        if (folder->klass->get_num_list(item->folder, item, &folder_list, &old_uids_valid) < 0) {
                debug_print("Error fetching list of message numbers\n");
+               item->scanning = FALSE;
                return(-1);
        }
 
@@ -1961,6 +1969,8 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
        folder_item_update(item, update_flags);
        folder_item_update_thaw();
        
+       item->scanning = FALSE;
+
        return 0;
 }
 
@@ -2017,6 +2027,8 @@ gint folder_item_syncronize_flags(FolderItem *item)
        if (item->no_select)
                return -1;
 
+       item->scanning = TRUE;
+
        if (item->cache == NULL)
                folder_item_read_cache(item);
        
@@ -2029,6 +2041,8 @@ gint folder_item_syncronize_flags(FolderItem *item)
        
        g_slist_free(msglist);
 
+       item->scanning = FALSE;
+
        return ret;
 }
 
index 7d510e72eb1eb7afd70ebacef0a3650c8937f8c4..7ec005f23762a9777c066be484d9b05833ae662b 100644 (file)
@@ -631,6 +631,7 @@ struct _FolderItem
        /* for faster search of special parents */
        SpecialFolderItemType parent_stype;
        gboolean processing_pending;
+       gboolean scanning;
 };
 
 struct _PersistPrefs
index e1bab926f9986f0b82e7a2b68870676deb772a8f..0b8285594925c0f99e4f8acbbaf76552ddb19ddd 100644 (file)
@@ -1043,7 +1043,12 @@ gint folderview_check_new(Folder *folder)
                        if (folder && folder != item->folder) continue;
                        if (!folder && !FOLDER_IS_LOCAL(item->folder)) continue;
                        if (!item->prefs->newmailcheck) continue;
-                       
+                       if (item->processing_pending == TRUE) {
+                               debug_print("skipping %s, processing pending\n",
+                                       item->path ? item->path : item->name);
+                               continue;
+                       }
+
                        str = get_scan_str(item);
 
                        STATUSBAR_PUSH(folderview->mainwin, str);
@@ -1874,6 +1879,27 @@ static gboolean folderview_key_pressed(GtkWidget *widget, GdkEventKey *event,
        return FALSE;
 }
 
+typedef struct _PostponedSelectData
+{
+       GtkCTree *ctree;
+       GtkCTreeNode *row;
+       gint column;
+       FolderView *folderview;
+} PostponedSelectData;
+
+static gboolean postpone_select(void *data)
+{
+       PostponedSelectData *psdata = (PostponedSelectData *)data;
+       debug_print("trying again\n");
+       psdata->folderview->open_folder = TRUE;
+       main_window_cursor_normal(psdata->folderview->mainwin);
+       STATUSBAR_POP(psdata->folderview->mainwin);
+       folderview_selected(psdata->ctree, psdata->row,
+                           psdata->column, psdata->folderview);
+       g_free(psdata);
+       return FALSE;
+}
+
 static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
                                gint column, FolderView *folderview)
 {
@@ -1881,6 +1907,7 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
        gboolean opened;
        FolderItem *item;
        gchar *buf;
+       int res = 0;
 
        folderview->selected = row;
 
@@ -1951,7 +1978,8 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
 
        main_window_cursor_wait(folderview->mainwin);
 
-       if (folder_item_open(item) != 0) {
+       res = folder_item_open(item);
+       if (res == -1) {
                main_window_cursor_normal(folderview->mainwin);
                STATUSBAR_POP(folderview->mainwin);
 
@@ -1961,7 +1989,19 @@ static void folderview_selected(GtkCTree *ctree, GtkCTreeNode *row,
                can_select = TRUE;
 
                return;
-        }
+        } else if (res == -2) {
+               PostponedSelectData *data = g_new0(PostponedSelectData, 1);
+               data->ctree = ctree;
+               data->row = row;
+               data->column = column;
+               data->folderview = folderview;
+               debug_print("postponing open of %s till end of scan\n",
+                       item->path ? item->path:item->name);
+               folderview->open_folder = FALSE;
+               can_select = TRUE;
+               g_timeout_add(500, postpone_select, data);
+               return;
+       }
        
        main_window_cursor_normal(folderview->mainwin);