2007-09-22 [colin] 3.0.1cvs22
authorColin Leroy <colin@colino.net>
Sat, 22 Sep 2007 12:00:27 +0000 (12:00 +0000)
committerColin Leroy <colin@colino.net>
Sat, 22 Sep 2007 12:00:27 +0000 (12:00 +0000)
* src/folder.c
* src/folder.h
* src/prefs_folder_item.c
Add a button to allow users to drop local caches.

ChangeLog
PATCHSETS
configure.ac
src/folder.c
src/folder.h
src/prefs_folder_item.c

index 0efdf05cf1808be75bf562c28cabd3ea07abf2d1..b4f4a014a06e7030645e28756a2411fb06ff1c42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-22 [colin]     3.0.1cvs22
+
+       * src/folder.c
+       * src/folder.h
+       * src/prefs_folder_item.c
+               Add a button to allow users to drop local caches.
+
 2007-09-21 [colin]     3.0.1cvs21
 
        * src/summaryview.c
index 32dd856115fa3e952560b772c8e2fe1a7d9b3854..ea6495ad69a6d7fbff82f45577aad43568823f14 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.105.2.110 -r 1.105.2.111 src/prefs_account.c;  cvs diff -u -r 1.52.2.48 -r 1.52.2.49 src/prefs_folder_item.c;  cvs diff -u -r 1.1.2.23 -r 1.1.2.24 src/prefs_quote.c;  cvs diff -u -r 1.8.2.23 -r 1.8.2.24 src/quote_fmt.c;  ) > 3.0.1cvs19.patchset
 ( cvs diff -u -r 1.12.2.42 -r 1.12.2.43 src/gtk/prefswindow.c;  ) > 3.0.1cvs20.patchset
 ( cvs diff -u -r 1.395.2.326 -r 1.395.2.327 src/summaryview.c;  ) > 3.0.1cvs21.patchset
+( cvs diff -u -r 1.213.2.161 -r 1.213.2.162 src/folder.c;  cvs diff -u -r 1.87.2.47 -r 1.87.2.48 src/folder.h;  cvs diff -u -r 1.52.2.49 -r 1.52.2.50 src/prefs_folder_item.c;  ) > 3.0.1cvs22.patchset
index d39c04b7884730167cc71fdfc9441d5090a913dd..78336968753923adfca16db2cd3baa46d4fc7692 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=21
+EXTRA_VERSION=22
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 02c5afb36e0ac6f86d68ea82491b12c1d85a079a..013dfb3ec5d1c28a3f8d0a260f0547f522333b8b 100644 (file)
@@ -2447,6 +2447,7 @@ static void folder_item_read_cache(FolderItem *item)
                                        unreadmarkedcnt++;
                                if (MSG_IS_MARKED(msginfo->flags))
                                        markedcnt++;
+                               procmsg_msginfo_unset_flags(msginfo, MSG_FULLY_CACHED, 0);
                        }
                        item->new_msgs = newcnt;
                        item->unread_msgs = unreadcnt;
@@ -2833,6 +2834,9 @@ static void copy_msginfo_flags(MsgInfo *source, MsgInfo *dest)
        if (procmsg_msg_has_flagged_parent(dest, MSG_IGNORE_THREAD))
                perm_flags |= MSG_IGNORE_THREAD;
 
+       /* unset FULLY_CACHED flags */
+       perm_flags &= ~MSG_FULLY_CACHED;
+
        if (procmsg_msg_has_flagged_parent(dest, MSG_WATCH_THREAD))
                perm_flags |= MSG_WATCH_THREAD;
 
@@ -3598,6 +3602,30 @@ gboolean folder_item_is_msg_changed(FolderItem *item, MsgInfo *msginfo)
        return folder->klass->is_msg_changed(folder, item, msginfo);
 }
 
+void folder_item_discard_cache(FolderItem *item)
+{
+       gchar *dir;
+       gchar *cache;
+
+       if (!item)
+               return;
+
+       if (item->cache) {
+               msgcache_destroy(item->cache);
+               item->cache = NULL;
+       }
+       dir = folder_item_get_path(item);
+       if (is_dir_exist(dir))
+               remove_all_numbered_files(dir);
+       g_free(dir);
+       
+       cache = folder_item_get_cache_file(item);
+       if (is_file_exist(cache))
+               g_unlink(cache);
+       g_free(cache);
+       
+}
+
 static gchar *folder_item_get_cache_file(FolderItem *item)
 {
        gchar *path;
index 075e9e2ed55dc484eb632e9f2264fbb9f03ee9ab..1bc3219cc6a51ec4c33bc90cdc62c445d016e9a4 100644 (file)
@@ -866,4 +866,5 @@ gboolean folder_get_sort_type               (Folder         *folder,
                                         FolderSortKey  *sort_key,
                                         FolderSortType *sort_type);
 void folder_item_synchronise           (FolderItem *item);
+void folder_item_discard_cache         (FolderItem *item);
 #endif /* __FOLDER_H__ */
index a5a4b94cc4d07c975e18adda3560c441bb0c1f43..6aecc3bb40b6cb42a63e651f57a69b7ecc30fe65 100644 (file)
@@ -30,6 +30,7 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include "folder.h"
+#include "alertpanel.h"
 #include "prefs_folder_item.h"
 #include "folderview.h"
 #include "folder.h"
@@ -171,6 +172,7 @@ static gboolean templates_save_recurse_func(GNode *node, gpointer data);
 static gint prefs_folder_item_chmod_mode               (gchar *folder_chmod);
 
 static void folder_color_set_dialog(GtkWidget *widget, gpointer data);
+static void clean_cache_cb(GtkWidget *widget, gpointer data);
 static void folder_regexp_test_cb(GtkWidget *widget, gpointer data);
 static void folder_regexp_set_subject_example_cb(GtkWidget *widget, gpointer data);
 
@@ -192,7 +194,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        GtkListStore *folder_type_menu;
        GtkWidget *folder_type;
        GtkTreeIter iter;
-       GtkWidget *dummy_checkbtn;
+       GtkWidget *dummy_checkbtn, *clean_cache_btn;
        SpecialFolderItemType type;
        
        GtkWidget *no_save_warning = NULL;
@@ -228,7 +230,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        page->item         = item;
 
        /* Table */
-       table = gtk_table_new(9, 4, FALSE);
+       table = gtk_table_new(10, 4, FALSE);
        gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER);
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 4);
@@ -501,6 +503,14 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox);
        SET_TOGGLE_SENSITIVITY (checkbtn_offlinesync, hbox2);
        
+       clean_cache_btn = gtk_button_new_with_label(_("Discard folder cache"));
+       gtk_widget_show (clean_cache_btn);
+       gtk_table_attach(GTK_TABLE(table), clean_cache_btn, 0, 1,
+                        rowcount, rowcount+1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+       g_signal_connect(G_OBJECT(clean_cache_btn), "clicked",
+                        G_CALLBACK(clean_cache_cb),
+                        page);
+
        gtk_widget_show_all(table);
 
        if (item->folder && (item->folder->klass->type != F_IMAP && 
@@ -517,6 +527,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
                gtk_widget_hide(GTK_WIDGET(hbox));
                gtk_widget_hide(GTK_WIDGET(hbox2));
                gtk_widget_hide(GTK_WIDGET(offlinesync_rec_checkbtn));
+               gtk_widget_hide(GTK_WIDGET(clean_cache_btn));
        
        }
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_offlinesync),
@@ -1361,6 +1372,33 @@ static void folder_color_set_dialog(GtkWidget *widget, gpointer data)
        page->folder_color = rgbcolor;
 }
 
+static void clean_cache_cb(GtkWidget *widget, gpointer data)
+{
+       FolderItemGeneralPage *page = (FolderItemGeneralPage *) data;
+       FolderItem *item = page->item;
+       gboolean was_open = FALSE;
+       FolderView *folderview = NULL;
+
+       if (alertpanel_full(_("Discard cache"), 
+                           _("Do you really want to discard the local cached "
+                             "data for this folder?"),
+                                GTK_STOCK_CANCEL, _("+Discard"), NULL, FALSE,
+                                NULL, ALERT_WARNING, G_ALERTDEFAULT)
+               != G_ALERTALTERNATE)
+               return;
+       
+       if (mainwindow_get_mainwindow())
+               folderview = mainwindow_get_mainwindow()->folderview;
+
+       if (folderview && item->opened) {
+               folderview_close_opened(folderview);
+               was_open = TRUE;
+       }
+       folder_item_discard_cache(item);
+       if (was_open)
+               folderview_select(folderview,item);
+}
+
 static regex_t *summary_compile_simplify_regexp(gchar *simplify_subject_regexp)
 {
        int err;