* src/folder.c
authorChristoph Hohmann <reboot@gmx.ch>
Sun, 30 Jun 2002 13:45:59 +0000 (13:45 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Sun, 30 Jun 2002 13:45:59 +0000 (13:45 +0000)
    improved folder_item_scan
    it should now always set the correct
    new, unread and total message counts

ChangeLog.claws
src/folder.c

index 197a358..1090e3d 100644 (file)
@@ -3,6 +3,10 @@
        * merge new cache branch
        * src/imap.c
            fix new cache imap copy bug
+       * src/folder.c
+           improved folder_item_scan
+           it should now always set the correct
+           new, unread and total message counts
 
 2002-06-29 [paul]      0.7.8claws35
 
index 554ac6e..047b1bc 100644 (file)
@@ -825,7 +825,8 @@ gint folder_item_scan(FolderItem *item)
        gint i;
        guint min = 0xffffffff, max = 0, cache_max = 0, maxgetcount = 0;
        FolderScanInfo *folderscaninfo;
-
+       guint newcnt = 0, unreadcnt = 0, totalcnt = 0;
+       
        g_return_val_if_fail(item != NULL, -1);
        if(item->path == NULL) return -1;
 
@@ -927,10 +928,20 @@ gint folder_item_scan(FolderItem *item)
 
                                newmsginfo = folder->fetch_msginfo(folder, item, num);
                                msgcache_add_msg(item->cache, newmsginfo);
+                               if(MSG_IS_NEW(newmsginfo->flags) && !MSG_IS_IGNORE_THREAD(newmsginfo->flags))
+                                       newcnt++;
+                               if(MSG_IS_UNREAD(newmsginfo->flags) && !MSG_IS_IGNORE_THREAD(newmsginfo->flags))
+                                       unreadcnt++;
                                procmsg_msginfo_free(newmsginfo);
 
                                debug_print(_("Updated msginfo for message %d.\n"), num);
+                       } else {
+                               if(MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
+                                       newcnt++;
+                               if(MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
+                                       unreadcnt++;
                        }
+                       totalcnt++;
                        procmsg_msginfo_free(msginfo);
                }
        }
@@ -944,11 +955,11 @@ gint folder_item_scan(FolderItem *item)
                        for(elem = newmsg_list; elem != NULL; elem = g_slist_next(elem)) {
                                msginfo = (MsgInfo *) elem->data;
                                msgcache_add_msg(item->cache, msginfo);
-                               if(MSG_IS_NEW(msginfo->flags))
-                                       item->new++;
-                               if(MSG_IS_UNREAD(msginfo->flags))
-                                       item->unread++;
-                               item->total++;
+                               if(MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
+                                       newcnt++;
+                               if(MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
+                                       unreadcnt++;
+                               totalcnt++;
                                procmsg_msginfo_free(msginfo);
                        }
                        g_slist_free(newmsg_list);
@@ -964,11 +975,11 @@ gint folder_item_scan(FolderItem *item)
                        msginfo = folder->fetch_msginfo(folder, item, num);
                        if(msginfo != NULL) {
                                msgcache_add_msg(item->cache, msginfo);
-                               if(MSG_IS_NEW(msginfo->flags))
-                                   item->new++;
-                               if(MSG_IS_UNREAD(msginfo->flags))
-                                   item->unread++;
-                               item->total++;
+                               if(MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
+                                   newcnt++;
+                               if(MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
+                                   unreadcnt++;
+                               totalcnt++;
                                procmsg_msginfo_free(msginfo);
                                debug_print(_("Added newly found message %d to cache.\n"), num);
                        }
@@ -976,6 +987,10 @@ gint folder_item_scan(FolderItem *item)
                folderview_update_item(item, FALSE);
        }
 
+       item->new = newcnt;
+       item->unread = unreadcnt;
+       item->total = totalcnt;
+       
        g_slist_free(folder_list);
        g_slist_free(cache_list);
        g_slist_free(new_list);