fix bug [14] where new mail notification worked incorrectly with IMAP accounts
authorMelvin Hadasht <melvin.hadasht@free.fr>
Mon, 13 Jan 2003 14:36:04 +0000 (14:36 +0000)
committerMelvin Hadasht <melvin.hadasht@free.fr>
Mon, 13 Jan 2003 14:36:04 +0000 (14:36 +0000)
ChangeLog.claws
configure.in
src/folderview.c
src/folderview.h
src/inc.c

index fec6a02..0c893a4 100644 (file)
@@ -1,3 +1,13 @@
+2003-01-13 [melvin]    0.8.8claws92
+
+       * src/folderview.[ch]
+               folderview_check_new(): return the number of new messages.
+       * src/inc.c
+               Should fix bug [14] where new mail notification worked 
+                       incorrectly with IMAP accounts.
+               inc_spool_account(): return number of new msgs, or -1 on error
+               inc_all_spool(): return number of new msgs
+               
 2003-01-13 [melvin]    0.8.8claws91
 
        * src/prefs_actions.c
index 69c32d8..9f073db 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=8
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws91
+EXTRA_VERSION=claws92
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 9df5ea3..3bbf251 100644 (file)
@@ -874,13 +874,14 @@ void folderview_rescan_all(void)
 }
 #endif
 
-void folderview_check_new(Folder *folder)
+gint folderview_check_new(Folder *folder)
 {
        GList *list;
        FolderItem *item;
        FolderView *folderview;
        GtkCTree *ctree;
        GtkCTreeNode *node;
+       gint new_msgs = 0;
 
        for (list = folderview_list; list != NULL; list = list->next) {
                folderview = (FolderView *)list->data;
@@ -904,6 +905,7 @@ void folderview_check_new(Folder *folder)
                                        break;
                        }
                        folderview_update_node(folderview, node);
+                       new_msgs += item->new;
                }
 
                gtk_widget_set_sensitive(folderview->ctree, TRUE);
@@ -912,6 +914,7 @@ void folderview_check_new(Folder *folder)
        }
 
        folder_write_list();
+       return new_msgs;
 }
 
 void folderview_check_new_all(void)
index 9eeebc1..3f9ddfd 100644 (file)
@@ -74,7 +74,7 @@ void folderview_update_msg_num                (FolderView     *folderview,
                                         GtkCTreeNode   *row);
 void folderview_rescan_tree            (Folder         *folder);
 void folderview_rescan_all             (void);
-void folderview_check_new              (Folder         *folder);
+gint folderview_check_new              (Folder         *folder);
 void folderview_check_new_all          (void);
 
 void folderview_new_folder             (FolderView     *folderview);
index 3d6b074..3ed19f9 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -113,8 +113,8 @@ static gint inc_spool                       (void);
 static gint get_spool                  (FolderItem     *dest,
                                         const gchar    *mbox);
 
-static void inc_spool_account(PrefsAccount *account);
-static void inc_all_spool(void);
+static gint inc_spool_account(PrefsAccount *account);
+static gint inc_all_spool(void);
 static void inc_autocheck_timer_set_interval   (guint           interval);
 static gint inc_autocheck_func                 (gpointer        data);
 
@@ -157,6 +157,7 @@ static void inc_finished(MainWindow *mainwin, gboolean new_messages)
 void inc_mail(MainWindow *mainwin, gboolean notify)
 {
        gint new_msgs = 0;
+       gint account_new_msgs = 0;
 
        if (inc_lock_count) return;
 
@@ -178,19 +179,21 @@ void inc_mail(MainWindow *mainwin, gboolean notify)
                        return;
                }
 
-               if (prefs_common.inc_local)
-                       new_msgs = inc_spool();
-
-               if (new_msgs <= 0)
-                       new_msgs = 1;
+               if (prefs_common.inc_local) {
+                       account_new_msgs = inc_spool();
+                       if (account_new_msgs > 0)
+                               new_msgs += account_new_msgs;
+               }
        } else {
                if (prefs_common.inc_local) {
-                       new_msgs = inc_spool();
-                       if (new_msgs < 0)
-                               new_msgs = 0;
+                       account_new_msgs = inc_spool();
+                       if (account_new_msgs > 0)
+                               new_msgs += account_new_msgs;
                }
                cur_account->session = STYPE_NORMAL;
-               new_msgs += inc_account_mail(cur_account, mainwin);
+               account_new_msgs = inc_account_mail(cur_account, mainwin);
+               if (account_new_msgs > 0)
+                       new_msgs += account_new_msgs;
        }
 
        inc_finished(mainwin, new_msgs > 0);
@@ -243,8 +246,7 @@ static gint inc_account_mail(PrefsAccount *account, MainWindow *mainwin)
        switch (account->protocol) {
        case A_IMAP4:
        case A_NNTP:
-               folderview_check_new(FOLDER(account->folder));
-               return 1;
+               return folderview_check_new(FOLDER(account->folder));
 
        case A_POP3:
        case A_APOP:
@@ -270,8 +272,7 @@ static gint inc_account_mail(PrefsAccount *account, MainWindow *mainwin)
                return inc_start(inc_dialog);
 
        case A_LOCAL:
-               inc_spool_account(account);
-               return 1;
+               return inc_spool_account(account);
 
        default:
                break;
@@ -284,6 +285,7 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
        GList *list, *queue_list = NULL;
        IncProgressDialog *inc_dialog;
        gint new_msgs = 0;
+       gint account_new_msgs = 0;
        
        if (prefs_common.work_offline)
                if (alertpanel(_("Offline warning"), 
@@ -297,9 +299,9 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
        main_window_lock(mainwin);
 
        if (prefs_common.inc_local) {
-               new_msgs = inc_spool();
-               if (new_msgs < 0)
-                       new_msgs = 0;
+               account_new_msgs = inc_spool();
+               if (account_new_msgs > 0)
+                       new_msgs += account_new_msgs;   
        }
 
        list = account_get_list();
@@ -312,7 +314,9 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
        }
 
        /* check local folders */
-       inc_all_spool();
+       account_new_msgs = inc_all_spool();
+       if (account_new_msgs > 0)
+               new_msgs += account_new_msgs;
 
        /* check IMAP4 folders */
        for (; list != NULL; list = list->next) {
@@ -321,7 +325,7 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
                     account->protocol == A_NNTP) && account->recv_at_getall) {
                        FolderItem *item = mainwin->summaryview->folder_item;
 
-                       folderview_check_new(FOLDER(account->folder));
+                       new_msgs += folderview_check_new(FOLDER(account->folder));
                }
        }
 
@@ -363,8 +367,7 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean notify)
        toolbar_main_set_sensitive(mainwin);
        main_window_set_menu_sensitive(mainwin);
 
-       new_msgs += inc_start(inc_dialog);
-
+       new_msgs = inc_start(inc_dialog);
        inc_finished(mainwin, new_msgs > 0);
        main_window_unlock(mainwin);
        inc_notify_cmd(new_msgs, notify);
@@ -1097,7 +1100,7 @@ static gint inc_spool(void)
        return msgs;
 }
 
-static void inc_spool_account(PrefsAccount *account)
+static gint inc_spool_account(PrefsAccount *account)
 {
        FolderItem *inbox;
 
@@ -1108,23 +1111,30 @@ static void inc_spool_account(PrefsAccount *account)
        } else
                inbox = folder_get_default_inbox();
 
-       get_spool(inbox, account->local_mbox);
+       return get_spool(inbox, account->local_mbox);
 }
 
-static void inc_all_spool(void)
+static gint inc_all_spool(void)
 {
        GList *list = NULL;
+       gint new_msgs = 0;
+       gint account_new_msgs = 0;
 
        list = account_get_list();
-       if (!list) return;
+       if (!list) return 0;
 
        for (; list != NULL; list = list->next) {
                PrefsAccount *account = list->data;
 
                if ((account->protocol == A_LOCAL) &&
-                   (account->recv_at_getall))
-                       inc_spool_account(account);
+                   (account->recv_at_getall)) {
+                       account_new_msgs = inc_spool_account(account);
+                       if (account_new_msgs > 0)
+                               new_msgs += account_new_msgs;
+               }
        }
+
+       return new_msgs;
 }
 
 static gint get_spool(FolderItem *dest, const gchar *mbox)