* src/folderview.c
authorMelvin Hadasht <melvin.hadasht@free.fr>
Tue, 14 Jan 2003 15:34:44 +0000 (15:34 +0000)
committerMelvin Hadasht <melvin.hadasht@free.fr>
Tue, 14 Jan 2003 15:34:44 +0000 (15:34 +0000)
folderview_check_new(): return the number of new messages
since last check.
* src/inc.c
inc_account_mail(): Disable counting of new messages for IMAP
and NNTP until bug [19] and [14] are fixed.

ChangeLog.claws
configure.in
src/folderview.c
src/inc.c

index 7ac1618..6ed4429 100644 (file)
@@ -1,3 +1,12 @@
+2003-01-14 [melvin]    0.8.8claws97
+
+       * src/folderview.c
+               folderview_check_new(): return the number of new messages 
+                       since last check.
+       * src/inc.c
+               inc_account_mail(): Disable counting of new messages for IMAP
+                       and NNTP until bug [19] and [14] are fixed.
+
 2003-01-14 [paul]      0.8.8claws96
 
        * sync with 0.8.8cvs6
index c73ac7e..cf7fe4e 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws96
+EXTRA_VERSION=claws97
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 2eb832e..634e39c 100644 (file)
@@ -874,6 +874,11 @@ void folderview_rescan_all(void)
 }
 #endif
 
+/** folderview_check_new()
+ *  Count the number of new messages since last check. 
+ *  \param folder the folder to check for new messages
+ *  \return the number of new messages since last check
+ */
 gint folderview_check_new(Folder *folder)
 {
        GList *list;
@@ -882,6 +887,8 @@ gint folderview_check_new(Folder *folder)
        GtkCTree *ctree;
        GtkCTreeNode *node;
        gint new_msgs = 0;
+       gint former_new_msgs = 0;
+       gint former_new = 0;
 
        for (list = folderview_list; list != NULL; list = list->next) {
                folderview = (FolderView *)list->data;
@@ -900,12 +907,14 @@ gint folderview_check_new(Folder *folder)
                        if (!folder && !FOLDER_IS_LOCAL(item->folder)) continue;
 
                        folderview_scan_tree_func(item->folder, item, NULL);
+                       former_new = item->new;
                        if (folder_item_scan(item) < 0) {
                                if (folder && !FOLDER_IS_LOCAL(folder))
                                        break;
                        }
                        folderview_update_node(folderview, node);
                        new_msgs += item->new;
+                       former_new_msgs += former_new;
                }
 
                gtk_widget_set_sensitive(folderview->ctree, TRUE);
@@ -914,6 +923,12 @@ gint folderview_check_new(Folder *folder)
        }
 
        folder_write_list();
+       /* Number of new messages since last check is the just the difference 
+        * between former_new_msgs and new_msgs. If new_msgs is less than
+        * former_new_msgs, that would mean another session accessed the folder
+        * and the result is not well defined.
+        */
+       new_msgs = (former_new_msgs < new_msgs ? new_msgs - former_new_msgs : 0);
        return new_msgs;
 }
 
index 69bb654..8c62a1e 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -246,8 +246,13 @@ static gint inc_account_mail(PrefsAccount *account, MainWindow *mainwin)
        switch (account->protocol) {
        case A_IMAP4:
        case A_NNTP:
-               return folderview_check_new(FOLDER(account->folder));
-
+               /* Melvin: bug [14]
+                * FIXME: it should return foldeview_check_new() value.
+                * TODO: do it when bug [19] is fixed (IMAP folder sets 
+                * an incorrect new message count)
+                */
+               folderview_check_new(FOLDER(account->folder));
+               return 0;
        case A_POP3:
        case A_APOP:
                session = inc_session_new(account);