2007-08-11 [paul] 2.10.0cvs113
[claws.git] / src / imap_gtk.c
index fc118ed237630def33cc22a1096c4c83df3379fa..ad247b7458b32a31f8f22d07589a078adbc5b910 100644 (file)
@@ -4,7 +4,7 @@
  *
  * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -40,6 +40,7 @@
 #include "imap.h"
 #include "inc.h"
 #include "prefs_common.h"
+#include "statusbar.h"
 #include "summaryview.h"
 
 static void new_folder_cb(FolderView *folderview, guint action, GtkWidget *widget);
@@ -154,7 +155,7 @@ static void new_folder_cb(FolderView *folderview, guint action,
                (_("New folder"),
                 _("Input the name of new folder:\n"
                   "(if you want to create a folder to store subfolders\n"
-                  "and no mails, append '/' at the end of the name)"),
+                  "only and no mail, append '/' to the folder name)"),
                 _("NewFolder"));
        if (!new_folder) return;
        AUTORELEASE_STR(new_folder, {g_free(new_folder); return;});
@@ -221,7 +222,7 @@ static void rename_folder_cb(FolderView *folderview, guint action,
 
        separator = imap_get_path_separator_for_item(item);
        if (strchr(new_folder, separator) != NULL) {
-               alertpanel_error(_("`%c' can't be included in folder name."),
+               alertpanel_error(_("'%c' can't be included in folder name."),
                                 separator);
                return;
        }
@@ -359,7 +360,7 @@ static void sync_cb(FolderView *folderview, guint action,
        folder_synchronise(item->folder);
 }
 
-void imap_gtk_synchronise(FolderItem *item)
+void imap_gtk_synchronise(FolderItem *item, gint days)
 {
        MainWindow *mainwin = mainwindow_get_mainwindow();
        FolderView *folderview = mainwin->folderview;
@@ -373,20 +374,34 @@ void imap_gtk_synchronise(FolderItem *item)
        gtk_widget_set_sensitive(folderview->ctree, FALSE);
        main_window_progress_on(mainwin);
        GTK_EVENTS_FLUSH();
-       if (item->no_select == FALSE && folder_item_fetch_all_msg(item) < 0) {
-               gchar *name;
+       if (item->no_select == FALSE) {
+               GSList *mlist;
+               GSList *cur;
+               gint num = 0;
+               gint total = item->total_msgs;
+               time_t t = time(NULL);
+
+               mlist = folder_item_get_msg_list(item);
+               for (cur = mlist; cur != NULL; cur = cur->next) {
+                       MsgInfo *msginfo = (MsgInfo *)cur->data;
+                       gint age = (t - msginfo->date_t) / (60*60*24);
+                       if (days == 0 || age <= days)
+                               imap_cache_msg(msginfo->folder, msginfo->msgnum);
+                       statusbar_progress_all(num++,total, 100);
+                       if (num % 100 == 0)
+                               GTK_EVENTS_FLUSH();
+               }
 
-               name = trim_string(item->name, 32);
-               alertpanel_error(_("Error occurred while downloading messages in '%s'."), name);
-               g_free(name);
+               statusbar_progress_all(0,0,0);
+               procmsg_msg_list_free(mlist);
        }
+
        folder_set_ui_func(item->folder, NULL, NULL);
        main_window_progress_off(mainwin);
        gtk_widget_set_sensitive(folderview->ctree, TRUE);
        main_window_unlock(mainwin);
        inc_unlock();
        main_window_cursor_normal(mainwin);
-
 }
 
 static void chk_update_val(GtkWidget *widget, gpointer data)
@@ -429,10 +444,10 @@ static void subscribe_cb(FolderView *folderview, guint action,
                GList *child_list = NULL;
                
                message = g_strdup_printf
-                       (_("Do you want to look for unsubscribed subfolders of '%s'?"),
+                       (_("Do you want to search for unsubscribed subfolders of '%s'?"),
                         name);
 
-               rec_chk = gtk_check_button_new_with_label(_("Look recursively"));
+               rec_chk = gtk_check_button_new_with_label(_("Search recursively"));
 
                g_signal_connect(G_OBJECT(rec_chk), "toggled", 
                                G_CALLBACK(chk_update_val), &recurse);
@@ -465,8 +480,10 @@ static void subscribe_cb(FolderView *folderview, guint action,
                        if (r == 0)
                                folderview_fast_rescan_tree(item->folder);
                } else {
-                       alertpanel_notice(_("This folder is already subscribed to and "
-                                 "has no unsubscribed subfolders."));
+                       alertpanel_notice(_("This folder is already subscribed and "
+                                 "has no unsubscribed subfolders.\n\nIf there are new folders, "
+                                 "created and subscribed to from another client, use \"Check "
+                                 "for new folders\" at the mailbox's root folder."));
                }
                g_list_free(child_list);
                return;
@@ -486,6 +503,17 @@ static void subscribe_cb(FolderView *folderview, guint action,
        g_free(message);
        if (avalue != G_ALERTALTERNATE) return;
        
+       
+       if (!action) {
+               if (folderview->opened == folderview->selected ||
+                   gtk_ctree_is_ancestor(ctree,
+                                         folderview->selected,
+                                         folderview->opened)) {
+                       summary_clear_all(folderview->summaryview);
+                       folderview->opened = NULL;
+               }
+       }
+
        if (recurse) {
                g_node_traverse(item->node, G_PRE_ORDER,
                        G_TRAVERSE_ALL, -1, imap_gtk_subscribe_func, GINT_TO_POINTER(action));
@@ -521,5 +549,5 @@ static void download_cb(FolderView *folderview, guint action,
        if (!folderview->selected) return;
 
        item = gtk_ctree_node_get_row_data(ctree, folderview->selected);
-       imap_gtk_synchronise(item);
+       imap_gtk_synchronise(item, 0);
 }