/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2020 the Claws Mail team and 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
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
*/
#ifdef HAVE_CONFIG_H
#include "main.h"
#include "msgcache.h"
#include "privacy.h"
+#include "prefs_common.h"
+#include "prefs_migration.h"
+#include "file-utils.h"
/* Dependecies to be removed ?! */
-#include "prefs_common.h"
#include "prefs_account.h"
/* Define possible missing constants for Windows. */
if (folder) {
folder_add(folder);
folder_unloaded_list = g_slist_remove(folder_unloaded_list, node);
+ xml_free_tree(node);
}
cur = NULL;
continue;
return NULL;
}
item->folder = folder;
- folder->node = item->node = g_node_new(item);
+ folder->node = item->node;
folder->data = NULL;
return folder;
item->no_sub = FALSE;
item->no_select = FALSE;
item->collapsed = FALSE;
- item->thread_collapsed = FALSE;
- item->threaded = TRUE;
+ item->thread_collapsed = prefs_common.folder_default_thread_collapsed;
+ item->threaded = prefs_common.folder_default_thread;
+ item->hide_read_threads = prefs_common.folder_default_hide_read_threads;
+ item->hide_read_msgs = prefs_common.folder_default_hide_read_msgs;
+ item->hide_del_msgs = prefs_common.folder_default_hide_del_msgs;
item->ret_rcpt = FALSE;
item->opened = FALSE;
item->node = g_node_new(item);
item->last_seen = 0;
}
}
+ /* options without meaning in drafts */
+ if (item->stype == F_DRAFT)
+ item->hide_read_msgs =
+ item->hide_del_msgs =
+ item->hide_read_threads = FALSE;
}
XMLTag *folder_item_get_xml(Folder *folder, FolderItem *item)
GNode *node, *cur;
XMLNode *xmlnode;
gchar *path;
+ GList *list;
+ gint config_version = -1;
path = folder_get_list_path();
if (!is_file_exist(path)) return -1;
if (!node) return -1;
xmlnode = node->data;
- if (strcmp2(xmlnode->tag->tag, "folderlist") != 0) {
+ if (g_strcmp0(xmlnode->tag->tag, "folderlist") != 0) {
g_warning("wrong folder list");
xml_free_tree(node);
return -1;
cur = cur->next;
}
+ for (list = xmlnode->tag->attr; list != NULL; list = list->next) {
+ XMLAttr *attr = list->data;
+
+ if (!attr || !attr->name || !attr->value) continue;
+ if (!strcmp(attr->name, "config_version")) {
+ config_version = atoi(attr->value);
+ debug_print("Found folderlist config_version %d\n", config_version);
+ }
+ }
+
xml_free_tree(node);
+
+ if (prefs_update_config_version_folderlist(config_version) < 0) {
+ debug_print("Folderlist configuration file version upgrade failed\n");
+ return -2;
+ }
+
if (folder_list || folder_unloaded_list)
return 0;
else
return;
}
tag = xml_tag_new("folderlist");
+ xml_tag_add_attr(tag, xml_attr_new_int("config_version",
+ CLAWS_CONFIG_VERSION));
xmlnode = xml_node_new(tag, NULL);
for (list = folder_list; list != NULL; list = list->next) {
folder = list->data;
if (folder->klass == klass &&
- strcmp2(name, folder->name) == 0)
+ g_strcmp0(name, folder->name) == 0)
return folder;
}
for (node = item->node->children; node != NULL; node = node->next) {
child = FOLDER_ITEM(node->data);
- if (strcmp2(child->name, name) == 0) {
+ if (g_strcmp0(child->name, name) == 0) {
return child;
}
}
switch (item->stype) {
case F_INBOX:
- name = g_strdup(!strcmp2(item->name, INBOX_DIR) ? _("Inbox") :
+ name = g_strdup(!g_strcmp0(item->name, INBOX_DIR) ? _("Inbox") :
item->name);
break;
case F_OUTBOX:
- name = g_strdup(!strcmp2(item->name, OUTBOX_DIR) ? _("Sent") :
+ name = g_strdup(!g_strcmp0(item->name, OUTBOX_DIR) ? _("Sent") :
item->name);
break;
case F_QUEUE:
- name = g_strdup(!strcmp2(item->name, QUEUE_DIR) ? _("Queue") :
+ name = g_strdup(!g_strcmp0(item->name, QUEUE_DIR) ? _("Queue") :
item->name);
break;
case F_TRASH:
- name = g_strdup(!strcmp2(item->name, TRASH_DIR) ? _("Trash") :
+ name = g_strdup(!g_strcmp0(item->name, TRASH_DIR) ? _("Trash") :
item->name);
break;
case F_DRAFT:
- name = g_strdup(!strcmp2(item->name, DRAFT_DIR) ? _("Drafts") :
+ name = g_strdup(!g_strcmp0(item->name, DRAFT_DIR) ? _("Drafts") :
item->name);
break;
default:
name = g_strconcat(item->name, " (", item->folder->klass->uistr, ")", NULL);
} else {
if (FOLDER_CLASS(item->folder) == news_get_class() &&
- item->path && !strcmp2(item->name, item->path))
+ item->path && !g_strcmp0(item->name, item->path))
name = get_abbrev_newsgroup_name
(item->path,
prefs_common.ng_abbrev_len);
cache_list_last = g_slist_last(cache_list);
cache_max_num = ((MsgInfo *)cache_list_last->data)->msgnum;
} else {
- cache_cur_num = G_MAXINT;
+ cache_cur_num = G_MAXUINT;
cache_max_num = 0;
}
if (folder_list_cur != NULL) {
GSList *folder_list_last;
- folder_cur_num = GPOINTER_TO_INT(folder_list_cur->data);
+ folder_cur_num = GPOINTER_TO_UINT(folder_list_cur->data);
folder_list_last = g_slist_last(folder_list);
- folder_max_num = GPOINTER_TO_INT(folder_list_last->data);
+ folder_max_num = GPOINTER_TO_UINT(folder_list_last->data);
} else {
- folder_cur_num = G_MAXINT;
+ folder_cur_num = G_MAXUINT;
folder_max_num = 0;
}
- while ((cache_cur_num != G_MAXINT) || (folder_cur_num != G_MAXINT)) {
+ while ((cache_cur_num != G_MAXUINT) || (folder_cur_num != G_MAXUINT)) {
/*
* Message only exists in the folder
* Remember message for fetching
}
if (add) {
- new_list = g_slist_prepend(new_list, GINT_TO_POINTER(folder_cur_num));
- debug_print("Remembered message %d for fetching\n", folder_cur_num);
+ new_list = g_slist_prepend(new_list, GUINT_TO_POINTER(folder_cur_num));
+ debug_print("Remembered message %u for fetching\n", folder_cur_num);
}
/* Move to next folder number */
folder_list_cur = folder_list_cur->next;
if (folder_list_cur != NULL)
- folder_cur_num = GPOINTER_TO_INT(folder_list_cur->data);
+ folder_cur_num = GPOINTER_TO_UINT(folder_list_cur->data);
else
- folder_cur_num = G_MAXINT;
+ folder_cur_num = G_MAXUINT;
continue;
}
*/
if (cache_cur_num < folder_cur_num) {
msgcache_remove_msg(item->cache, cache_cur_num);
- debug_print("Removed message %d from cache.\n", cache_cur_num);
+ debug_print("Removed message %u from cache.\n", cache_cur_num);
/* Move to next cache number */
if (cache_list_cur)
if (cache_list_cur != NULL)
cache_cur_num = ((MsgInfo *)cache_list_cur->data)->msgnum;
else
- cache_cur_num = G_MAXINT;
+ cache_cur_num = G_MAXUINT;
update_flags |= F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT;
new_list = g_slist_prepend(new_list, GINT_TO_POINTER(msginfo->msgnum));
procmsg_msginfo_free(&msginfo);
- debug_print("Remembering message %d to update...\n", folder_cur_num);
+ debug_print("Remembering message %u to update...\n", folder_cur_num);
} else if (msginfo) {
exists_list = g_slist_prepend(exists_list, msginfo);
if (cache_list_cur != NULL)
cache_cur_num = ((MsgInfo *)cache_list_cur->data)->msgnum;
else
- cache_cur_num = G_MAXINT;
+ cache_cur_num = G_MAXUINT;
if (folder_list_cur != NULL)
- folder_cur_num = GPOINTER_TO_INT(folder_list_cur->data);
+ folder_cur_num = GPOINTER_TO_UINT(folder_list_cur->data);
else
- folder_cur_num = G_MAXINT;
+ folder_cur_num = G_MAXUINT;
continue;
}
if (newmsg_list != NULL) {
GSList *elem, *to_filter = NULL;
gboolean do_filter = (filtering == TRUE) &&
- (item->stype == F_INBOX) &&
- (item->folder->account != NULL) &&
- (item->folder->account->filter_on_recv);
-
+ (item->folder->account != NULL) &&
+ (item->folder->account->filter_on_recv) &&
+ ((item->stype == F_INBOX) ||
+ ((item->stype == F_NORMAL) &&
+ (FOLDER_TYPE(item->folder) == F_NEWS)));
+
for (elem = newmsg_list; elem != NULL; elem = g_slist_next(elem)) {
MsgInfo *msginfo = (MsgInfo *) elem->data;
gint msgnum = 0;
gchar buf[BUFFSIZE];
- if ((fp = g_fopen(file, "rb")) == NULL)
+ if ((fp = claws_fopen(file, "rb")) == NULL)
return 0;
if ((folder_has_parent_of_type(dest, F_QUEUE)) ||
(folder_has_parent_of_type(dest, F_DRAFT)))
- while (fgets(buf, sizeof(buf), fp) != NULL) {
+ while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
/* new way */
if ((!strncmp(buf, "X-Claws-End-Special-Headers: 1",
strlen("X-Claws-End-Special-Headers:"))) ||
g_free(hentry[0].body);
hentry[0].body = NULL;
- fclose(fp);
+ claws_fclose(fp);
return msgnum;
}
}
tmp = folder_item_parent(tmp);
}
-
+
+ /* both dst and src can be root folders */
src_identifier = folder_item_get_identifier(src);
+ if (src_identifier == NULL && src->folder && folder_item_parent(src) == NULL) {
+ src_identifier = folder_get_identifier(src->folder);
+ }
+
dst_identifier = folder_item_get_identifier(dest);
-
if(dst_identifier == NULL && dest->folder && folder_item_parent(dest) == NULL) {
- /* dest can be a root folder */
dst_identifier = folder_get_identifier(dest->folder);
}
+
if (src_identifier == NULL || dst_identifier == NULL) {
debug_print("Can't get identifiers\n");
return F_MOVE_FAILED;
for (; cur; cur = cur->next) {
Compose *compose = NULL;
FolderItem *queue = dest;
- int val = 0;
+ ComposeQueueResult val = COMPOSE_QUEUE_SUCCESS;
msginfo = (MsgInfo *)cur->data;
compose = compose_reedit(msginfo, TRUE);
}
val = compose_queue(compose, NULL, &queue, NULL,
FALSE);
- if (val < 0) {
+ if (val != COMPOSE_QUEUE_SUCCESS) {
queue_err = TRUE;
} else if (remove_source) {
folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
}
- if (val == 0)
+ if (val == COMPOSE_QUEUE_SUCCESS)
compose_close(compose);
}
return queue_err ? -1:0;
item->folder->klass->remove_msg(item->folder,
msginfo->folder,
msginfo->msgnum);
- if (!item->folder->account || item->folder->account->imap_use_trash) {
- remove_msginfo_from_cache(item, msginfo);
- }
+ remove_msginfo_from_cache(item, msginfo);
}
}
}
}
ret = folder->klass->remove_msg(folder, item, num);
- if (!item->folder->account || item->folder->account->imap_use_trash) {
- if (msginfo != NULL) {
- if (ret == 0)
- remove_msginfo_from_cache(item, msginfo);
- procmsg_msginfo_free(&msginfo);
- }
+ if (msginfo != NULL) {
+ if (ret == 0)
+ remove_msginfo_from_cache(item, msginfo);
+ procmsg_msginfo_free(&msginfo);
}
return ret;
cm_return_val_if_fail(xmlnode != NULL, NULL);
cm_return_val_if_fail(folder != NULL, NULL);
- if (strcmp2(xmlnode->tag->tag, "folderitem") != 0) {
+ if (g_strcmp0(xmlnode->tag->tag, "folderitem") != 0) {
g_warning("tag name != \"folderitem\"");
return NULL;
}
item = folder_item_new(folder, "", "");
+ g_node_destroy(item->node);
if (folder->klass->item_set_xml != NULL)
folder->klass->item_set_xml(folder, item, xmlnode->tag);
else
cm_return_val_if_fail(node->data != NULL, NULL);
xmlnode = node->data;
- if (strcmp2(xmlnode->tag->tag, "folder") != 0) {
+ if (g_strcmp0(xmlnode->tag->tag, "folder") != 0) {
g_warning("tag name != \"folder\"");
return NULL;
}
processing_list = item->prefs->processing;
- if (!pre_global_processing && !processing_list
- && !post_global_processing)
+ if (!processing_enabled(pre_global_processing) &&
+ !processing_enabled(processing_list) &&
+ !processing_enabled(post_global_processing))
return;
debug_print("processing %s\n", item->name);
if (!item)
return;
if (item->prefs->offlinesync && item->folder->klass->synchronise) {
- statuswindow_print_all(_("Synchronising %s for offline use...\n"), item->path ? item->path : "(null)");
+ statusbar_print_all(_("Synchronising %s for offline use...\n"), item->path ? item->path : "(null)");
item->folder->klass->synchronise(item,
item->prefs->offlinesync_days);
if (item->prefs->offlinesync_days > 0 &&
item->prefs->remove_old_bodies)
folder_item_clean_local_files(item, item->prefs->offlinesync_days);
- statuswindow_pop_all();
+ statusbar_pop_all();
}
}
}
processed_count++;
+ procmsg_msginfo_free(&msg);
+
if (progress_cb != NULL
&& !progress_cb(progress_data, FALSE, processed_count,
matched_count, msgcount))