diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-06-22 07:53:41 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-06-22 07:53:41 +0000 |
commit | e666e7b500acb716cbc6464c3c8f80015275185c (patch) | |
tree | 39d3710f5279c27afe3a1eaf2da6118f13cb0390 /src | |
parent | e9fb73aab838eee5889b99dbd76d134ec015759c (diff) |
disabled strict checking of caches by stat() and improved the performance.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@360 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r-- | src/mh.c | 27 | ||||
-rw-r--r-- | src/prefs_common.c | 86 | ||||
-rw-r--r-- | src/prefs_common.h | 6 | ||||
-rw-r--r-- | src/procmsg.h | 4 |
4 files changed, 92 insertions, 31 deletions
@@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2003 Hiroyuki Yamamoto + * Copyright (C) 1999-2005 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,6 +42,7 @@ #include "procmsg.h" #include "procheader.h" #include "utils.h" +#include "prefs_common.h" static void mh_folder_init (Folder *folder, const gchar *name, @@ -210,9 +211,10 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item, item->cache_dirty = TRUE; } } else if (use_cache) { - GSList *newlist; + GSList *newlist, *cur, *next; - mlist = procmsg_read_cache(item, TRUE); + mlist = procmsg_read_cache + (item, prefs_common.strict_cache_check); msg_table = procmsg_msg_hash_table_create(mlist); newlist = mh_get_uncached_msgs(msg_table, item); if (newlist) @@ -220,6 +222,21 @@ static GSList *mh_get_msg_list(Folder *folder, FolderItem *item, if (msg_table) g_hash_table_destroy(msg_table); + if (!prefs_common.strict_cache_check) { + /* remove nonexistent messages */ + for (cur = mlist; cur != NULL; cur = next) { + MsgInfo *msginfo = (MsgInfo *)cur->data; + next = cur->next; + if (!MSG_IS_CACHED(msginfo->flags)) { + debug_print("removing nonexistent message %d from cache\n", msginfo->msgnum); + mlist = g_slist_remove(mlist, msginfo); + procmsg_msginfo_free(msginfo); + item->cache_dirty = TRUE; + item->mark_dirty = TRUE; + } + } + } + mlist = g_slist_concat(mlist, newlist); } else { mlist = mh_get_uncached_msgs(NULL, item); @@ -987,7 +1004,9 @@ static GSList *mh_get_uncached_msgs(GHashTable *msg_table, FolderItem *item) msginfo = g_hash_table_lookup (msg_table, GUINT_TO_POINTER(num)); - if (!msginfo) { + if (msginfo) { + MSG_SET_TMP_FLAGS(msginfo->flags, MSG_CACHED); + } else { /* not found in the cache (uncached message) */ msginfo = mh_parse_msg(d->d_name, item); if (!msginfo) continue; diff --git a/src/prefs_common.c b/src/prefs_common.c index 8bc87d2d..132e151e 100644 --- a/src/prefs_common.c +++ b/src/prefs_common.c @@ -196,10 +196,13 @@ static struct Other { GtkWidget *checkbtn_cleanonexit; GtkWidget *checkbtn_askonclean; GtkWidget *checkbtn_warnqueued; +} other; +static struct Advanced { + GtkWidget *checkbtn_strict_cache_check; GtkWidget *spinbtn_iotimeout; GtkObject *spinbtn_iotimeout_adj; -} other; +} advanced; static struct MessageColorButtons { GtkWidget *quote_level1_btn; @@ -693,13 +696,17 @@ static PrefParam param[] = { P_BOOL, &other.checkbtn_warnqueued, prefs_set_data_from_toggle, prefs_set_toggle}, - {"io_timeout_secs", "60", &prefs_common.io_timeout_secs, - P_INT, &other.spinbtn_iotimeout, - prefs_set_data_from_spinbtn, prefs_set_spinbtn}, - {"logwindow_line_limit", "1000", &prefs_common.logwin_line_limit, P_INT, NULL, NULL, NULL}, + /* Advanced */ + {"strict_cache_check", "FALSE", &prefs_common.strict_cache_check, + P_BOOL, &advanced.checkbtn_strict_cache_check, + prefs_set_data_from_toggle, prefs_set_toggle}, + {"io_timeout_secs", "60", &prefs_common.io_timeout_secs, + P_INT, &advanced.spinbtn_iotimeout, + prefs_set_data_from_spinbtn, prefs_set_spinbtn}, + {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL} }; @@ -719,6 +726,7 @@ static void prefs_privacy_create (void); #endif static void prefs_interface_create (void); static void prefs_other_create (void); +static void prefs_advanced_create (void); static void date_format_ok_btn_clicked (GtkButton *button, GtkWidget **widget); @@ -947,6 +955,8 @@ static void prefs_common_create(void) SET_NOTEBOOK_LABEL(dialog.notebook, _("Interface"), page++); prefs_other_create(); SET_NOTEBOOK_LABEL(dialog.notebook, _("Other"), page++); + prefs_advanced_create(); + SET_NOTEBOOK_LABEL(dialog.notebook, _("Advanced"), page++); gtk_widget_show_all(dialog.window); } @@ -2306,10 +2316,6 @@ static void prefs_other_create(void) GtkWidget *checkbtn_askonclean; GtkWidget *checkbtn_warnqueued; - GtkWidget *label_iotimeout; - GtkWidget *spinbtn_iotimeout; - GtkObject *spinbtn_iotimeout_adj; - vbox1 = gtk_vbox_new (FALSE, VSPACING); gtk_widget_show (vbox1); gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1); @@ -2414,6 +2420,50 @@ static void prefs_other_create(void) PACK_CHECK_BUTTON (vbox_exit, checkbtn_warnqueued, _("Warn if there are queued messages")); + other.uri_combo = uri_combo; + other.uri_entry = uri_entry; + other.printcmd_entry = printcmd_entry; + + other.exteditor_combo = exteditor_combo; + other.exteditor_entry = exteditor_entry; + + other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick; + + other.checkbtn_confonexit = checkbtn_confonexit; + other.checkbtn_cleanonexit = checkbtn_cleanonexit; + other.checkbtn_askonclean = checkbtn_askonclean; + other.checkbtn_warnqueued = checkbtn_warnqueued; +} + +static void prefs_advanced_create(void) +{ + GtkWidget *vbox1; + + GtkWidget *vbox2; + GtkWidget *checkbtn_strict_cache_check; + GtkWidget *label; + + GtkWidget *hbox1; + GtkWidget *label_iotimeout; + GtkWidget *spinbtn_iotimeout; + GtkObject *spinbtn_iotimeout_adj; + + vbox1 = gtk_vbox_new (FALSE, VSPACING); + gtk_widget_show (vbox1); + gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1); + gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER); + + vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW); + gtk_widget_show (vbox2); + gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0); + + PACK_CHECK_BUTTON (vbox2, checkbtn_strict_cache_check, + _("Enable strict checking of the integrity of summary caches")); + PACK_SMALL_LABEL + (vbox2, label, + _("Enable this if the contents of folders have the possibility of modification by other applications.\n" + "This option will degrade the performance of displaying summary.")); + hbox1 = gtk_hbox_new (FALSE, 8); gtk_widget_show (hbox1); gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0); @@ -2435,22 +2485,10 @@ static void prefs_other_create(void) gtk_widget_show (label_iotimeout); gtk_box_pack_start (GTK_BOX (hbox1), label_iotimeout, FALSE, FALSE, 0); - other.uri_combo = uri_combo; - other.uri_entry = uri_entry; - other.printcmd_entry = printcmd_entry; - - other.exteditor_combo = exteditor_combo; - other.exteditor_entry = exteditor_entry; - - other.checkbtn_addaddrbyclick = checkbtn_addaddrbyclick; - - other.checkbtn_confonexit = checkbtn_confonexit; - other.checkbtn_cleanonexit = checkbtn_cleanonexit; - other.checkbtn_askonclean = checkbtn_askonclean; - other.checkbtn_warnqueued = checkbtn_warnqueued; + advanced.checkbtn_strict_cache_check = checkbtn_strict_cache_check; - other.spinbtn_iotimeout = spinbtn_iotimeout; - other.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj; + advanced.spinbtn_iotimeout = spinbtn_iotimeout; + advanced.spinbtn_iotimeout_adj = spinbtn_iotimeout_adj; } static void date_format_ok_btn_clicked(GtkButton *button, GtkWidget **widget) diff --git a/src/prefs_common.h b/src/prefs_common.h index 266d4a6e..190d1036 100644 --- a/src/prefs_common.h +++ b/src/prefs_common.h @@ -230,10 +230,12 @@ struct _PrefsCommon gboolean ask_on_clean; gboolean warn_queued_on_exit; - gint io_timeout_secs; - gint logwin_line_limit; + /* Advanced */ + gboolean strict_cache_check; + gint io_timeout_secs; + /* Filtering */ GSList *fltlist; GSList *junk_fltlist; diff --git a/src/procmsg.h b/src/procmsg.h index f5bcc710..a6fd1dfe 100644 --- a/src/procmsg.h +++ b/src/procmsg.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2004 Hiroyuki Yamamoto + * Copyright (C) 1999-2005 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,6 +89,7 @@ typedef guint32 MsgPermFlags; #define MSG_IMAP (1U << 19) #define MSG_NEWS (1U << 20) #define MSG_SIGNED (1U << 21) +#define MSG_CACHED (1U << 28) #define MSG_MIME (1U << 29) #define MSG_INVALID (1U << 30) #define MSG_RECEIVED (1U << 31) @@ -129,6 +130,7 @@ typedef guint32 MsgTmpFlags; #define MSG_IS_IMAP(msg) (((msg).tmp_flags & MSG_IMAP) != 0) #define MSG_IS_NEWS(msg) (((msg).tmp_flags & MSG_NEWS) != 0) #define MSG_IS_SIGNED(msg) (((msg).tmp_flags & MSG_SIGNED) != 0) +#define MSG_IS_CACHED(msg) (((msg).tmp_flags & MSG_CACHED) != 0) #define MSG_IS_MIME(msg) (((msg).tmp_flags & MSG_MIME) != 0) #define MSG_IS_INVALID(msg) (((msg).tmp_flags & MSG_INVALID) != 0) #define MSG_IS_RECEIVED(msg) (((msg).tmp_flags & MSG_RECEIVED) != 0) |