2004-05-06 16:41:59 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2012-05-27 19:31:10 +02:00
|
|
|
* Copyright (C) 1999-2012 Hiroyuki Yamamoto & the Claws Mail Team
|
2004-05-06 16:41:59 +02:00
|
|
|
*
|
|
|
|
* 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
|
2007-07-11 18:38:12 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-05-06 16:41:59 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-11 18:38:12 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2004-05-06 16:41:59 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
2012-07-07 09:09:39 +02:00
|
|
|
#include "claws-features.h"
|
2004-05-06 16:41:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
2005-02-10 13:06:07 +01:00
|
|
|
#include <glib/gi18n.h>
|
2004-05-06 16:41:59 +02:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
#include "folder.h"
|
|
|
|
#include "folderview.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "account.h"
|
|
|
|
#include "alertpanel.h"
|
|
|
|
#include "grouplistdialog.h"
|
2005-08-04 20:01:14 +02:00
|
|
|
#include "prefs_common.h"
|
|
|
|
#include "news_gtk.h"
|
2004-05-06 16:41:59 +02:00
|
|
|
#include "common/hooks.h"
|
|
|
|
#include "inc.h"
|
2006-02-24 09:25:19 +01:00
|
|
|
#include "news.h"
|
2007-07-20 20:32:01 +02:00
|
|
|
#include "statusbar.h"
|
2008-07-05 15:55:03 +02:00
|
|
|
#include "inputdialog.h"
|
2004-05-06 16:41:59 +02:00
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void subscribe_newsgroup_cb(GtkAction *action, gpointer data);
|
|
|
|
static void unsubscribe_newsgroup_cb(GtkAction *action, gpointer data);
|
|
|
|
static void rename_newsgroup_cb(GtkAction *action, gpointer data);
|
|
|
|
static void update_tree_cb(GtkAction *action, gpointer data);
|
|
|
|
static void download_cb(GtkAction *action, gpointer data);
|
|
|
|
static void sync_cb(GtkAction *action, gpointer data);
|
|
|
|
|
|
|
|
static GtkActionEntry news_popup_entries[] =
|
2004-05-06 16:41:59 +02:00
|
|
|
{
|
2008-07-30 17:59:34 +02:00
|
|
|
{"FolderViewPopup/Subscribe", NULL, N_("_Subscribe to newsgroup..."), NULL, NULL, G_CALLBACK(subscribe_newsgroup_cb) },
|
|
|
|
{"FolderViewPopup/Unsubscribe", NULL, N_("_Unsubscribe newsgroup"), NULL, NULL, G_CALLBACK(unsubscribe_newsgroup_cb) },
|
|
|
|
|
|
|
|
{"FolderViewPopup/Synchronise", NULL, N_("Synchronise"), NULL, NULL, G_CALLBACK(sync_cb) },
|
|
|
|
{"FolderViewPopup/DownloadMessages", NULL, N_("Down_load messages"), NULL, NULL, G_CALLBACK(download_cb) },
|
|
|
|
{"FolderViewPopup/RenameFolder", NULL, N_("_Rename folder..."), NULL, NULL, G_CALLBACK(rename_newsgroup_cb) },
|
|
|
|
|
|
|
|
{"FolderViewPopup/CheckNewMessages", NULL, N_("_Check for new messages"), NULL, NULL, G_CALLBACK(update_tree_cb) },
|
|
|
|
|
2004-05-06 16:41:59 +02:00
|
|
|
};
|
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item);
|
|
|
|
static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
|
|
|
static FolderViewPopup news_popup =
|
|
|
|
{
|
|
|
|
"news",
|
|
|
|
"<NewsFolder>",
|
2008-07-30 17:59:34 +02:00
|
|
|
news_popup_entries,
|
|
|
|
G_N_ELEMENTS(news_popup_entries),
|
|
|
|
NULL, 0,
|
|
|
|
NULL, 0, 0, NULL,
|
|
|
|
add_menuitems,
|
2004-05-06 16:41:59 +02:00
|
|
|
set_sensitivity
|
|
|
|
};
|
|
|
|
|
|
|
|
void news_gtk_init(void)
|
|
|
|
{
|
|
|
|
folderview_register_popup(&news_popup);
|
|
|
|
}
|
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void add_menuitems(GtkUIManager *ui_manager, FolderItem *item)
|
|
|
|
{
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Subscribe", "FolderViewPopup/Subscribe", GTK_UI_MANAGER_MENUITEM)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Unsubscribe", "FolderViewPopup/Unsubscribe", GTK_UI_MANAGER_MENUITEM)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorNews1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Synchronise", "FolderViewPopup/Synchronise", GTK_UI_MANAGER_MENUITEM)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "DownloadMessages", "FolderViewPopup/DownloadMessages", GTK_UI_MANAGER_MENUITEM)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RenameFolder", "FolderViewPopup/RenameFolder", GTK_UI_MANAGER_MENUITEM)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorNews2", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "CheckNewMessages", "FolderViewPopup/CheckNewMessages", GTK_UI_MANAGER_MENUITEM)
|
|
|
|
MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorNews3", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
|
2004-05-06 16:41:59 +02:00
|
|
|
{
|
2006-02-24 09:25:19 +01:00
|
|
|
MainWindow *mainwin = mainwindow_get_mainwindow();
|
|
|
|
|
2004-05-06 16:41:59 +02:00
|
|
|
#define SET_SENS(name, sens) \
|
2008-07-30 17:59:34 +02:00
|
|
|
cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
|
2004-05-06 16:41:59 +02:00
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
SET_SENS("FolderViewPopup/Subscribe",
|
2008-07-20 15:01:52 +02:00
|
|
|
folder_item_parent(item) == NULL
|
|
|
|
&& mainwin->lock_count == 0
|
|
|
|
&& news_folder_locked(item->folder) == 0);
|
2008-07-30 17:59:34 +02:00
|
|
|
SET_SENS("FolderViewPopup/Unsubscribe",
|
2008-07-20 15:01:52 +02:00
|
|
|
folder_item_parent(item) != NULL
|
|
|
|
&& mainwin->lock_count == 0
|
|
|
|
&& news_folder_locked(item->folder) == 0);
|
2008-07-30 17:59:34 +02:00
|
|
|
SET_SENS("FolderViewPopup/CheckNewMessages",
|
2008-07-20 15:01:52 +02:00
|
|
|
folder_item_parent(item) == NULL
|
|
|
|
&& mainwin->lock_count == 0
|
|
|
|
&& news_folder_locked(item->folder) == 0);
|
2008-07-30 17:59:34 +02:00
|
|
|
SET_SENS("FolderViewPopup/Synchronise",
|
2008-07-20 15:01:52 +02:00
|
|
|
item ? (folder_item_parent(item) != NULL
|
|
|
|
&& folder_want_synchronise(item->folder))
|
|
|
|
: FALSE);
|
2008-07-30 17:59:34 +02:00
|
|
|
SET_SENS("FolderViewPopup/DownloadMessages",
|
2008-07-20 15:01:52 +02:00
|
|
|
item ? (folder_item_parent(item) != NULL
|
|
|
|
&& !item->no_select)
|
|
|
|
: FALSE);
|
2008-07-30 17:59:34 +02:00
|
|
|
SET_SENS("FolderViewPopup/RenameFolder",
|
2008-07-20 15:01:52 +02:00
|
|
|
folder_item_parent(item) != NULL
|
|
|
|
&& mainwin->lock_count == 0
|
|
|
|
&& news_folder_locked(item->folder) == 0);
|
2004-05-06 16:41:59 +02:00
|
|
|
#undef SET_SENS
|
|
|
|
}
|
|
|
|
|
2009-11-18 21:40:19 +01:00
|
|
|
static FolderItem *news_find_child_item(FolderItem *item, const gchar *path)
|
|
|
|
{
|
|
|
|
GNode *node;
|
|
|
|
FolderItem *child;
|
|
|
|
|
|
|
|
for (node = item->node->children; node != NULL; node = node->next) {
|
|
|
|
child = FOLDER_ITEM(node->data);
|
|
|
|
if (strcmp2(child->path, path) == 0) {
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void subscribe_newsgroup_cb(GtkAction *action, gpointer data)
|
2004-05-06 16:41:59 +02:00
|
|
|
{
|
2008-07-30 17:59:34 +02:00
|
|
|
FolderView *folderview = (FolderView *)data;
|
2004-05-06 16:41:59 +02:00
|
|
|
Folder *folder;
|
|
|
|
FolderItem *item;
|
|
|
|
FolderItem *rootitem;
|
|
|
|
FolderItem *newitem;
|
|
|
|
GSList *new_subscr;
|
|
|
|
GSList *cur;
|
|
|
|
GNode *gnode;
|
2006-02-24 09:25:19 +01:00
|
|
|
MainWindow *mainwin = mainwindow_get_mainwindow();
|
|
|
|
|
2016-07-21 22:32:37 +02:00
|
|
|
if ((item = folderview_get_selected_item(folderview)) == NULL) return;
|
2006-02-24 09:25:19 +01:00
|
|
|
|
|
|
|
if (mainwin->lock_count || news_folder_locked(item->folder))
|
|
|
|
return;
|
|
|
|
|
2004-05-06 16:41:59 +02:00
|
|
|
folder = item->folder;
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(folder != NULL);
|
|
|
|
cm_return_if_fail(FOLDER_TYPE(folder) == F_NEWS);
|
|
|
|
cm_return_if_fail(folder->account != NULL);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
2016-07-21 22:32:37 +02:00
|
|
|
if ((rootitem = folder_item_parent(item)) == NULL)
|
|
|
|
rootitem = item;
|
2004-05-06 16:41:59 +02:00
|
|
|
|
|
|
|
new_subscr = grouplist_dialog(folder);
|
|
|
|
|
|
|
|
/* remove unsubscribed newsgroups */
|
|
|
|
for (gnode = folder->node->children; gnode != NULL; ) {
|
|
|
|
GNode *next = gnode->next;
|
|
|
|
|
|
|
|
item = FOLDER_ITEM(gnode->data);
|
|
|
|
if (g_slist_find_custom(new_subscr, item->path,
|
2004-10-26 12:43:50 +02:00
|
|
|
(GCompareFunc)g_ascii_strcasecmp) != NULL) {
|
2004-05-06 16:41:59 +02:00
|
|
|
gnode = next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-07-21 22:32:37 +02:00
|
|
|
if (folderview_get_opened_item(folderview) == item) {
|
2004-05-06 16:41:59 +02:00
|
|
|
summary_clear_all(folderview->summaryview);
|
2016-07-21 22:32:37 +02:00
|
|
|
folderview_close_opened(folderview, TRUE);
|
2004-05-06 16:41:59 +02:00
|
|
|
}
|
|
|
|
|
2016-07-21 22:32:37 +02:00
|
|
|
folderview_remove_item(folderview, item);
|
2004-05-06 16:41:59 +02:00
|
|
|
folder_item_remove(item);
|
|
|
|
|
|
|
|
gnode = next;
|
|
|
|
}
|
|
|
|
|
2016-07-22 20:46:54 +02:00
|
|
|
folderview_freeze(folderview);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
|
|
|
/* add subscribed newsgroups */
|
|
|
|
for (cur = new_subscr; cur != NULL; cur = cur->next) {
|
|
|
|
gchar *name = (gchar *)cur->data;
|
|
|
|
FolderUpdateData hookdata;
|
|
|
|
|
2009-11-18 21:40:19 +01:00
|
|
|
if (news_find_child_item(rootitem, name) != NULL)
|
2004-05-06 16:41:59 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
newitem = folder_item_new(folder, name, name);
|
|
|
|
folder_item_append(rootitem, newitem);
|
|
|
|
|
|
|
|
hookdata.folder = newitem->folder;
|
|
|
|
hookdata.update_flags = FOLDER_TREE_CHANGED | FOLDER_ADD_FOLDERITEM;
|
|
|
|
hookdata.item = newitem;
|
2014-05-22 22:46:07 +02:00
|
|
|
hookdata.item2 = NULL;
|
2004-05-06 16:41:59 +02:00
|
|
|
hooks_invoke(FOLDER_UPDATE_HOOKLIST, &hookdata);
|
|
|
|
}
|
|
|
|
|
2016-07-22 20:46:54 +02:00
|
|
|
folderview_thaw(folderview);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
2012-10-12 17:13:17 +02:00
|
|
|
slist_free_strings_full(new_subscr);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
|
|
|
folder_write_list();
|
|
|
|
}
|
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void unsubscribe_newsgroup_cb(GtkAction *action, gpointer data)
|
2004-05-06 16:41:59 +02:00
|
|
|
{
|
2008-07-30 17:59:34 +02:00
|
|
|
FolderView *folderview = (FolderView *)data;
|
2004-05-06 16:41:59 +02:00
|
|
|
FolderItem *item;
|
|
|
|
gchar *name;
|
|
|
|
gchar *message;
|
|
|
|
gchar *old_id;
|
|
|
|
AlertValue avalue;
|
2006-02-24 09:25:19 +01:00
|
|
|
MainWindow *mainwin = mainwindow_get_mainwindow();
|
|
|
|
|
2004-05-06 16:41:59 +02:00
|
|
|
if (!folderview->selected) return;
|
|
|
|
|
2015-10-21 20:49:03 +02:00
|
|
|
item = folderview_get_selected_item(folderview);
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(item != NULL);
|
2006-02-24 09:25:19 +01:00
|
|
|
|
|
|
|
if (mainwin->lock_count || news_folder_locked(item->folder))
|
|
|
|
return;
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(item->folder != NULL);
|
|
|
|
cm_return_if_fail(FOLDER_TYPE(item->folder) == F_NEWS);
|
|
|
|
cm_return_if_fail(item->folder->account != NULL);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
|
|
|
old_id = folder_item_get_identifier(item);
|
|
|
|
|
|
|
|
name = trim_string(item->path, 32);
|
2005-07-17 09:30:07 +02:00
|
|
|
message = g_strdup_printf(_("Really unsubscribe newsgroup '%s'?"), name);
|
2005-07-17 14:14:10 +02:00
|
|
|
avalue = alertpanel_full(_("Unsubscribe newsgroup"), message,
|
2006-01-14 12:04:52 +01:00
|
|
|
GTK_STOCK_CANCEL, _("_Unsubscribe"), NULL, FALSE,
|
2006-01-14 10:45:39 +01:00
|
|
|
NULL, ALERT_WARNING, G_ALERTDEFAULT);
|
2004-05-06 16:41:59 +02:00
|
|
|
g_free(message);
|
|
|
|
g_free(name);
|
2006-01-14 10:45:39 +01:00
|
|
|
if (avalue != G_ALERTALTERNATE) return;
|
2004-05-06 16:41:59 +02:00
|
|
|
|
2016-07-21 22:32:37 +02:00
|
|
|
if (item == folderview_get_opened_item(folderview)) {
|
2004-05-06 16:41:59 +02:00
|
|
|
summary_clear_all(folderview->summaryview);
|
2016-07-21 22:32:37 +02:00
|
|
|
folderview_close_opened(folderview, TRUE);
|
2004-05-06 16:41:59 +02:00
|
|
|
}
|
|
|
|
|
2006-03-07 10:35:31 +01:00
|
|
|
if(item->folder->klass->remove_folder(item->folder, item) < 0) {
|
|
|
|
folder_item_scan(item);
|
|
|
|
alertpanel_error(_("Can't remove the folder '%s'."), name);
|
|
|
|
g_free(old_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-06 16:41:59 +02:00
|
|
|
folder_write_list();
|
|
|
|
|
|
|
|
prefs_filtering_delete_path(old_id);
|
|
|
|
g_free(old_id);
|
|
|
|
}
|
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void rename_newsgroup_cb(GtkAction *action, gpointer data)
|
2008-07-05 15:55:03 +02:00
|
|
|
{
|
2008-07-30 17:59:34 +02:00
|
|
|
FolderView *folderview = (FolderView *)data;
|
2008-07-05 15:55:03 +02:00
|
|
|
FolderItem *item;
|
|
|
|
gchar *new_folder;
|
|
|
|
gchar *name;
|
|
|
|
gchar *message;
|
|
|
|
|
|
|
|
item = folderview_get_selected_item(folderview);
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(item != NULL);
|
|
|
|
cm_return_if_fail(item->path != NULL);
|
|
|
|
cm_return_if_fail(item->folder != NULL);
|
2008-07-05 15:55:03 +02:00
|
|
|
|
|
|
|
name = trim_string(item->name, 32);
|
|
|
|
message = g_strdup_printf(_("Input new name for '%s':"), name);
|
|
|
|
new_folder = input_dialog(_("Rename newsgroup folder"), message, item->name);
|
|
|
|
g_free(message);
|
|
|
|
g_free(name);
|
|
|
|
|
|
|
|
if (!new_folder) return;
|
|
|
|
AUTORELEASE_STR(new_folder, {g_free(new_folder); return;});
|
|
|
|
|
|
|
|
if (strchr(new_folder, G_DIR_SEPARATOR) != NULL) {
|
|
|
|
alertpanel_error(_("'%c' can't be included in folder name."),
|
|
|
|
G_DIR_SEPARATOR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-11-18 22:05:50 +01:00
|
|
|
if (folder_find_child_item_by_name(folder_item_parent(item), new_folder)) {
|
2008-07-05 15:55:03 +02:00
|
|
|
name = trim_string(new_folder, 32);
|
|
|
|
alertpanel_error(_("The folder '%s' already exists."), name);
|
|
|
|
g_free(name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (folder_item_rename(item, new_folder) < 0) {
|
|
|
|
alertpanel_error(_("The folder could not be renamed.\n"
|
|
|
|
"The new folder name is not allowed."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
folder_write_list();
|
|
|
|
}
|
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void update_tree_cb(GtkAction *action, gpointer data)
|
2004-05-06 16:41:59 +02:00
|
|
|
{
|
2008-07-30 17:59:34 +02:00
|
|
|
FolderView *folderview = (FolderView *)data;
|
2004-05-06 16:41:59 +02:00
|
|
|
FolderItem *item;
|
2006-02-24 09:25:19 +01:00
|
|
|
MainWindow *mainwin = mainwindow_get_mainwindow();
|
|
|
|
|
2004-11-12 07:41:50 +01:00
|
|
|
item = folderview_get_selected_item(folderview);
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(item != NULL);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
2006-02-24 09:25:19 +01:00
|
|
|
if (mainwin->lock_count || news_folder_locked(item->folder))
|
|
|
|
return;
|
|
|
|
|
2004-05-06 16:41:59 +02:00
|
|
|
summary_show(folderview->summaryview, NULL);
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(item->folder != NULL);
|
2004-05-06 16:41:59 +02:00
|
|
|
|
|
|
|
folderview_check_new(item->folder);
|
|
|
|
}
|
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void sync_cb(GtkAction *action, gpointer data)
|
2004-05-06 16:41:59 +02:00
|
|
|
{
|
2008-07-30 17:59:34 +02:00
|
|
|
FolderView *folderview = (FolderView *)data;
|
2004-05-06 16:41:59 +02:00
|
|
|
FolderItem *item;
|
|
|
|
|
2005-09-08 20:28:36 +02:00
|
|
|
item = folderview_get_selected_item(folderview);
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(item != NULL);
|
2005-09-08 20:28:36 +02:00
|
|
|
folder_synchronise(item->folder);
|
|
|
|
}
|
2004-05-06 16:41:59 +02:00
|
|
|
|
2007-07-20 18:20:59 +02:00
|
|
|
void news_gtk_synchronise(FolderItem *item, gint days)
|
2005-09-08 20:28:36 +02:00
|
|
|
{
|
|
|
|
MainWindow *mainwin = mainwindow_get_mainwindow();
|
|
|
|
FolderView *folderview = mainwin->folderview;
|
2007-07-20 18:20:59 +02:00
|
|
|
GSList *mlist;
|
|
|
|
GSList *cur;
|
|
|
|
gint num = 0;
|
|
|
|
gint total = 0;
|
|
|
|
time_t t = time(NULL);
|
|
|
|
|
2009-02-23 17:55:51 +01:00
|
|
|
cm_return_if_fail(item != NULL);
|
|
|
|
cm_return_if_fail(item->folder != NULL);
|
2005-08-04 20:01:14 +02:00
|
|
|
|
2006-02-24 09:25:19 +01:00
|
|
|
if (mainwin->lock_count || news_folder_locked(item->folder))
|
|
|
|
return;
|
|
|
|
|
2007-07-20 18:20:59 +02:00
|
|
|
total = item->total_msgs;
|
|
|
|
|
2004-05-06 16:41:59 +02:00
|
|
|
main_window_cursor_wait(mainwin);
|
|
|
|
inc_lock();
|
|
|
|
main_window_lock(mainwin);
|
|
|
|
gtk_widget_set_sensitive(folderview->ctree, FALSE);
|
|
|
|
main_window_progress_on(mainwin);
|
|
|
|
GTK_EVENTS_FLUSH();
|
2007-07-20 18:20:59 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
folder_item_fetch_msg_full(msginfo->folder, msginfo->msgnum, TRUE, TRUE);
|
|
|
|
statusbar_progress_all(num++,total, 100);
|
|
|
|
if (num % 100 == 0)
|
|
|
|
GTK_EVENTS_FLUSH();
|
2004-05-06 16:41:59 +02:00
|
|
|
}
|
2007-07-20 18:20:59 +02:00
|
|
|
|
|
|
|
statusbar_progress_all(0,0,0);
|
|
|
|
procmsg_msg_list_free(mlist);
|
2004-05-06 16:41:59 +02:00
|
|
|
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);
|
|
|
|
}
|
2005-09-08 20:28:36 +02:00
|
|
|
|
2008-07-30 17:59:34 +02:00
|
|
|
static void download_cb(GtkAction *action, gpointer data)
|
2005-09-08 20:28:36 +02:00
|
|
|
{
|
2008-07-30 17:59:34 +02:00
|
|
|
FolderView *folderview = (FolderView *)data;
|
2005-09-08 20:28:36 +02:00
|
|
|
FolderItem *item;
|
|
|
|
|
|
|
|
if (!folderview->selected) return;
|
|
|
|
|
2015-10-21 20:49:03 +02:00
|
|
|
item = folderview_get_selected_item(folderview);
|
2007-07-20 18:20:59 +02:00
|
|
|
news_gtk_synchronise(item, 0);
|
2005-09-08 20:28:36 +02:00
|
|
|
}
|