diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.ja | 6 | ||||
-rw-r--r-- | src/folderview.c | 41 | ||||
-rw-r--r-- | src/folderview.h | 6 | ||||
-rw-r--r-- | src/inc.c | 11 |
5 files changed, 52 insertions, 18 deletions
@@ -1,5 +1,11 @@ 2006-02-01 + * src/inc.c + src/folderview.[ch]: properly count the number of new messages on + local and remote mailboxes. + +2006-02-01 + * libsylph/imap.c: imap_cmd_gen_recv(): trim too long lines (ex. SEARCH command). diff --git a/ChangeLog.ja b/ChangeLog.ja index 5ae20e47..c5e58d08 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,11 @@ 2006-02-01 + * src/inc.c + src/folderview.[ch]: ローカルまたはリモートメールボックス上の新着 + メッセージ数を正しく数えるようにした。 + +2006-02-01 + * libsylph/imap.c: imap_cmd_gen_recv(): 長すぎる行を切り詰めるように した(ex. SEARCH コマンド)。 diff --git a/src/folderview.c b/src/folderview.c index 4778b945..1ba79a79 100644 --- a/src/folderview.c +++ b/src/folderview.c @@ -929,20 +929,21 @@ static void folderview_rescan_tree(FolderView *folderview, Folder *folder) inc_unlock(); } -void folderview_check_new(Folder *folder) +gint folderview_check_new(Folder *folder) { FolderItem *item; FolderView *folderview; GtkTreeModel *model; GtkTreeIter iter; gboolean valid; + gint prev_new, prev_unread, n_updated = 0; folderview = (FolderView *)folderview_list->data; model = GTK_TREE_MODEL(folderview->store); if (folder && !FOLDER_IS_LOCAL(folder)) { if (!main_window_toggle_online_if_offline(folderview->mainwin)) - return; + return 0; } inc_lock(); @@ -961,12 +962,18 @@ void folderview_check_new(Folder *folder) if (folder && folder != item->folder) continue; if (!folder && !FOLDER_IS_LOCAL(item->folder)) continue; + prev_new = item->new; + prev_unread = item->unread; folderview_scan_tree_func(item->folder, item, NULL); if (folder_item_scan(item) < 0) { if (folder && !FOLDER_IS_LOCAL(folder)) break; } folderview_update_row(folderview, &iter); + if (prev_unread < item->unread) + n_updated += item->unread - prev_unread; + else if (prev_new < item->new) + n_updated += item->new - prev_new; } gtk_widget_set_sensitive(folderview->treeview, TRUE); @@ -975,20 +982,23 @@ void folderview_check_new(Folder *folder) statusbar_pop_all(); folder_write_list(); + + return n_updated; } -void folderview_check_new_item(FolderItem *item) +gint folderview_check_new_item(FolderItem *item) { Folder *folder; FolderView *folderview; GtkTreeModel *model; GtkTreeIter iter; + gint prev_new, prev_unread, n_updated = 0; - g_return_if_fail(item != NULL); - g_return_if_fail(item->folder != NULL); + g_return_val_if_fail(item != NULL, 0); + g_return_val_if_fail(item->folder != NULL, 0); if (!item->path || item->no_select) - return; + return 0; folderview = (FolderView *)folderview_list->data; model = GTK_TREE_MODEL(folderview->store); @@ -997,21 +1007,27 @@ void folderview_check_new_item(FolderItem *item) if (!FOLDER_IS_LOCAL(folder)) { if (!main_window_toggle_online_if_offline(folderview->mainwin)) - return; + return 0; } if (!gtkut_tree_model_find_by_column_data (model, &iter, NULL, COL_FOLDER_ITEM, item)) - return; + return 0; inc_lock(); main_window_lock(folderview->mainwin); gtk_widget_set_sensitive(folderview->treeview, FALSE); GTK_EVENTS_FLUSH(); + prev_new = item->new; + prev_unread = item->unread; folderview_scan_tree_func(folder, item, NULL); folder_item_scan(item); folderview_update_row(folderview, &iter); + if (prev_unread < item->unread) + n_updated = item->unread - prev_unread; + else if (prev_new < item->new) + n_updated = item->new - prev_new; gtk_widget_set_sensitive(folderview->treeview, TRUE); main_window_unlock(folderview->mainwin); @@ -1019,13 +1035,16 @@ void folderview_check_new_item(FolderItem *item) statusbar_pop_all(); folder_write_list(); + + return n_updated; } -void folderview_check_new_all(void) +gint folderview_check_new_all(void) { GList *list; GtkWidget *window; FolderView *folderview; + gint n_updated = 0; folderview = (FolderView *)folderview_list->data; @@ -1038,12 +1057,14 @@ void folderview_check_new_all(void) for (; list != NULL; list = list->next) { Folder *folder = list->data; - folderview_check_new(folder); + n_updated += folderview_check_new(folder); } gtk_widget_destroy(window); main_window_unlock(folderview->mainwin); inc_unlock(); + + return n_updated; } static gboolean folderview_search_new_recursive(GtkTreeModel *model, diff --git a/src/folderview.h b/src/folderview.h index 7c283574..1ac76f95 100644 --- a/src/folderview.h +++ b/src/folderview.h @@ -94,9 +94,9 @@ gboolean folderview_append_item (FolderView *folderview, FolderItem *item, gboolean expand_parent); -void folderview_check_new (Folder *folder); -void folderview_check_new_item (FolderItem *item); -void folderview_check_new_all (void); +gint folderview_check_new (Folder *folder); +gint folderview_check_new_item (FolderItem *item); +gint folderview_check_new_all (void); void folderview_update_item (FolderItem *item, gboolean update_summary); @@ -152,7 +152,7 @@ static void inc_finished(MainWindow *mainwin, gint new_messages) debug_print("inc_finished(): %d new message(s)\n", new_messages); if (prefs_common.scan_all_after_inc) - folderview_check_new(NULL); + new_messages += folderview_check_new(NULL); if (new_messages > 0) { gchar buf[1024]; @@ -237,24 +237,25 @@ void inc_mail(MainWindow *mainwin) static gint inc_remote_account_mail(MainWindow *mainwin, PrefsAccount *account) { FolderItem *item = mainwin->summaryview->folder_item; + gint new_msgs; g_return_val_if_fail(account->folder != NULL, 0); if (account->protocol == A_IMAP4 && account->imap_check_inbox_only) { FolderItem *inbox = FOLDER(account->folder)->inbox; - folderview_check_new_item(inbox); + new_msgs = folderview_check_new_item(inbox); if (!prefs_common.scan_all_after_inc && item != NULL && inbox == item) folderview_update_item(item, TRUE); } else { - folderview_check_new(FOLDER(account->folder)); + new_msgs = folderview_check_new(FOLDER(account->folder)); if (!prefs_common.scan_all_after_inc && item != NULL && FOLDER(account->folder) == item->folder) folderview_update_item(item, TRUE); } - return 1; + return new_msgs; } static gint inc_account_mail_real(MainWindow *mainwin, PrefsAccount *account) @@ -327,7 +328,7 @@ void inc_all_account_mail(MainWindow *mainwin, gboolean autocheck) PrefsAccount *account = list->data; if ((account->protocol == A_IMAP4 || account->protocol == A_NNTP) && account->recv_at_getall) - inc_remote_account_mail(mainwin, account); + new_msgs += inc_remote_account_mail(mainwin, account); } /* check POP3 accounts */ |