*
* 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,
* 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
#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);
SET_SENS("/Subscriptions/Unsubscribe...", item->stype == F_NORMAL && folder_item_parent(item) != NULL);
SET_SENS("/Subscriptions/Subscribe...", TRUE);
- menu_set_active(factory, "/Subscriptions/Show only subscribed folders", item->folder->account->imap_subsonly);
+ if (item->folder && item->folder->account)
+ menu_set_active(factory,
+ "/Subscriptions/Show only subscribed folders",
+ item->folder->account->imap_subsonly);
#undef SET_SENS
}
(_("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;});
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;
}
g_free(old_id);
g_free(new_id);
- folder_item_prefs_save_config(item);
+ folder_item_prefs_save_config_recursive(item);
folder_write_list();
}
if (!from_folder || from_folder->folder->klass != imap_get_class())
return;
- to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL);
+ to_folder = foldersel_folder_sel(from_folder->folder, FOLDER_SEL_MOVE, NULL, TRUE);
if (!to_folder)
return;
name = trim_string(item->name, 32);
AUTORELEASE_STR(name, {g_free(name); return;});
- message = g_strdup_printf
+ message = g_markup_printf_escaped
(_("All folders and messages under '%s' will be permanently deleted. "
"Recovery will not be possible.\n\n"
"Do you really want to delete?"), name);
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;
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)
AUTORELEASE_STR(name, {g_free(name); return;});
if (action && item->folder->account->imap_subsonly) {
- GList *child_list = imap_scan_subtree(item->folder, item, FALSE);
+ GList *child_list = NULL;
+ GList *transc_list = NULL;
+
+ message = g_markup_printf_escaped
+ (_("Do you want to search for unsubscribed subfolders of '%s'?"),
+ name);
+
+ rec_chk = gtk_check_button_new_with_label(_("Search recursively"));
+
+ g_signal_connect(G_OBJECT(rec_chk), "toggled",
+ G_CALLBACK(chk_update_val), &recurse);
+
+ avalue = alertpanel_full(_("Subscriptions"), message,
+ GTK_STOCK_CANCEL, _("+_Search"), NULL, FALSE,
+ rec_chk, ALERT_QUESTION, G_ALERTDEFAULT);
+ g_free(message);
+ if (avalue != G_ALERTALTERNATE) return;
+
+ child_list = imap_scan_subtree(item->folder, item, TRUE, recurse);
+
if (child_list) {
GList *cur;
int r = -1;
- gchar *child_folder = input_dialog_combo(_("Subscribe"),
- _("Choose a subfolder to subscribe to: "),
- _("All of them"), child_list, TRUE);
+ gchar *msg = g_strdup_printf(_("Choose a subfolder of %s to subscribe to: "),
+ item->name);
+ gchar *child_folder = NULL;
+
+ for (cur = child_list; cur; cur = cur->next) {
+ transc_list = g_list_append(transc_list,
+ imap_modified_utf7_to_utf8(cur->data, FALSE));
+ }
+
+ child_folder = input_dialog_combo(_("Subscribe"),
+ msg,
+ transc_list->next?_("All of them"):transc_list->data, transc_list);
+ g_free(msg);
if (child_folder && strcmp(child_folder, _("All of them"))) {
- r = imap_subscribe(item->folder, NULL, child_folder, TRUE);
+ gchar *transc_folder = imap_utf8_to_modified_utf7(child_folder, FALSE);
+ r = imap_subscribe(item->folder, NULL, transc_folder, TRUE);
+ g_free(transc_folder);
} else if (child_folder) {
for (cur = child_list; cur; cur = cur->next)
r = imap_subscribe(item->folder, NULL, (gchar *)cur->data, TRUE);
g_free(child_folder);
for (cur = child_list; cur; cur = cur->next)
g_free((gchar *)cur->data);
+ for (cur = transc_list; cur; cur = cur->next)
+ g_free((gchar *)cur->data);
if (r == 0)
- folderview_rescan_tree(item->folder, FALSE);
+ folderview_fast_rescan_tree(item->folder);
} else {
- alertpanel_notice(_("This folder is already subscribed to and "
- "has no subfolders. To "
- "subscribe to other folders, you must first "
- "disable \"Show subscribed folders only\".\n"
- "\n"
- "Alternatively, you can use \"Create new folder\" "
- "to subscribe to a known folder."));
+ 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;
}
- message = g_strdup_printf
+ message = g_markup_printf_escaped
(_("Do you want to %s the '%s' folder?"),
action?_("subscribe"):_("unsubscribe"), name);
G_CALLBACK(chk_update_val), &recurse);
avalue = alertpanel_full(_("Subscriptions"), message,
- GTK_STOCK_CANCEL, action?_("Subscribe"):_("Unsubscribe"), NULL, FALSE,
+ GTK_STOCK_CANCEL, action?_("+_Subscribe"):_("+_Unsubscribe"), NULL, FALSE,
rec_chk, ALERT_QUESTION, G_ALERTDEFAULT);
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));
}
if (!action && item->folder->account->imap_subsonly)
- folderview_rescan_tree(item->folder, FALSE);
+ folderview_fast_rescan_tree(item->folder);
}
static void subscribed_cb(FolderView *folderview, guint action,
if (item->folder->account->imap_subsonly == GTK_CHECK_MENU_ITEM(widget)->active)
return;
+ if (folderview->opened == folderview->selected ||
+ gtk_ctree_is_ancestor(ctree,
+ folderview->selected,
+ folderview->opened)) {
+ summary_clear_all(folderview->summaryview);
+ folderview->opened = NULL;
+ }
+
item->folder->account->imap_subsonly = GTK_CHECK_MENU_ITEM(widget)->active;
- folderview_rescan_tree(item->folder, FALSE);
+ folderview_fast_rescan_tree(item->folder);
}
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);
}