/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
*
* 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
Folder *folder;
folder = folder_get_from_xml(node);
- folder_add(folder);
- folder_unloaded_list = g_slist_remove(folder_unloaded_list, node);
-
+ if (folder) {
+ folder_add(folder);
+ folder_unloaded_list = g_slist_remove(folder_unloaded_list, node);
+ }
cur = NULL;
continue;
}
item->unreadmarked_msgs = 0;
item->marked_msgs = 0;
item->total_msgs = 0;
+ item->replied_msgs = 0;
+ item->forwarded_msgs = 0;
+ item->locked_msgs = 0;
+ item->ignored_msgs = 0;
+ item->watched_msgs = 0;
item->order = 0;
item->last_num = -1;
item->cache = NULL;
{
GNode *node, *start_node;
FolderUpdateData hookdata;
+ gchar *tags_file = NULL;
g_return_if_fail(item != NULL);
g_return_if_fail(item->folder != NULL);
msgcache_destroy(item->cache);
item->cache = NULL;
}
+ tags_file = folder_item_get_tags_file(item);
+ if (tags_file)
+ claws_unlink(tags_file);
+ g_free(tags_file);
hookdata.folder = item->folder;
hookdata.update_flags = FOLDER_TREE_CHANGED | FOLDER_REMOVE_FOLDERITEM;
item->unreadmarked_msgs = atoi(attr->value);
else if (!strcmp(attr->name, "marked"))
item->marked_msgs = atoi(attr->value);
+ else if (!strcmp(attr->name, "replied"))
+ item->replied_msgs = atoi(attr->value);
+ else if (!strcmp(attr->name, "forwarded"))
+ item->forwarded_msgs = atoi(attr->value);
+ else if (!strcmp(attr->name, "locked"))
+ item->locked_msgs = atoi(attr->value);
+ else if (!strcmp(attr->name, "ignored"))
+ item->ignored_msgs = atoi(attr->value);
+ else if (!strcmp(attr->name, "watched"))
+ item->watched_msgs = atoi(attr->value);
else if (!strcmp(attr->name, "order"))
item->order = atoi(attr->value);
else if (!strcmp(attr->name, "total"))
xml_tag_add_attr(tag, xml_attr_new_int("unreadmarked", item->unreadmarked_msgs));
xml_tag_add_attr(tag, xml_attr_new_int("marked", item->marked_msgs));
xml_tag_add_attr(tag, xml_attr_new_int("total", item->total_msgs));
+ xml_tag_add_attr(tag, xml_attr_new_int("replied", item->replied_msgs));
+ xml_tag_add_attr(tag, xml_attr_new_int("forwarded", item->forwarded_msgs));
+ xml_tag_add_attr(tag, xml_attr_new_int("locked", item->locked_msgs));
+ xml_tag_add_attr(tag, xml_attr_new_int("ignore", item->ignored_msgs));
+ xml_tag_add_attr(tag, xml_attr_new_int("watched", item->watched_msgs));
xml_tag_add_attr(tag, xml_attr_new_int("order", item->order));
if (item->account)
g_return_if_fail(folder != NULL);
+ if ((FOLDER_TYPE(folder) == F_IMAP ||
+ FOLDER_TYPE(folder) == F_NEWS) &&
+ folder->account == NULL) {
+ return;
+ }
+
for (i = 0, cur = folder_list; cur != NULL; cur = cur->next, i++) {
cur_folder = FOLDER(cur->data);
if (cur_folder->sort < folder->sort)
FolderItem *folder_create_folder(FolderItem *parent, const gchar *name)
{
FolderItem *new_item;
+
+ g_return_val_if_fail(parent != NULL, NULL);
new_item = parent->folder->klass->create_folder(parent->folder, parent, name);
if (new_item) {
guint unreadmarked_msgs;
guint marked_msgs;
guint total_msgs;
+ guint replied_msgs;
+ guint forwarded_msgs;
+ guint locked_msgs;
+ guint ignored_msgs;
+ guint watched_msgs;
};
struct FuncToAllFoldersData
count->unreadmarked_msgs += item->unreadmarked_msgs;
count->marked_msgs += item->marked_msgs;
count->total_msgs += item->total_msgs;
+ count->replied_msgs += item->replied_msgs;
+ count->forwarded_msgs += item->forwarded_msgs;
+ count->locked_msgs += item->locked_msgs;
+ count->ignored_msgs += item->ignored_msgs;
+ count->watched_msgs += item->watched_msgs;
}
struct TotalMsgStatus
void folder_count_total_msgs(guint *new_msgs, guint *unread_msgs,
guint *unreadmarked_msgs, guint *marked_msgs,
- guint *total_msgs)
+ guint *total_msgs, guint *replied_msgs,
+ guint *forwarded_msgs, guint *locked_msgs,
+ guint *ignored_msgs, guint *watched_msgs)
{
struct TotalMsgCount count;
- count.new_msgs = count.unread_msgs = count.unreadmarked_msgs = count.total_msgs = 0;
+ count.new_msgs = count.unread_msgs = count.unreadmarked_msgs = 0;
+ count.total_msgs = count.replied_msgs = count.forwarded_msgs = 0;
+ count.locked_msgs = count.ignored_msgs = count.watched_msgs = 0;
+ count.marked_msgs = 0;
debug_print("Counting total number of messages...\n");
*unreadmarked_msgs = count.unreadmarked_msgs;
*marked_msgs = count.marked_msgs;
*total_msgs = count.total_msgs;
+ *replied_msgs = count.replied_msgs;
+ *forwarded_msgs = count.forwarded_msgs;
+ *locked_msgs = count.locked_msgs;
+ *ignored_msgs = count.ignored_msgs;
+ *watched_msgs = count.watched_msgs;
}
Folder *folder_find_from_path(const gchar *path)
return d[1];
}
+static gboolean folder_item_find_func_real_path(GNode *node, gpointer data)
+{
+ FolderItem *item = node->data;
+ gpointer *d = data;
+ const gchar *path = d[0];
+ gchar *tmp = folder_item_get_path(item);
+ if (path_cmp(path, tmp) != 0) {
+ g_free(tmp);
+ return FALSE;
+ }
+ g_free(tmp);
+ d[1] = item;
+
+ return TRUE;
+}
+
+FolderItem *folder_find_item_from_real_path(const gchar *path)
+{
+ Folder *folder;
+ gpointer d[2];
+ GList *list = folder_get_list();
+
+ folder = list ? list->data:NULL;
+
+ g_return_val_if_fail(folder != NULL, NULL);
+
+ d[0] = (gpointer)path;
+ d[1] = NULL;
+ while (d[1] == NULL && list) {
+ folder = FOLDER(list->data);
+ g_node_traverse(folder->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ folder_item_find_func_real_path, d);
+ list = list->next;
+ }
+ return d[1];
+}
+
FolderItem *folder_find_child_item_by_name(FolderItem *item, const gchar *name)
{
GNode *node;
FolderItem *child;
for (node = item->node->children; node != NULL; node = node->next) {
- gchar *base;
child = FOLDER_ITEM(node->data);
- base = g_path_get_basename(child->path);
- if (strcmp2(base, name) == 0) {
- g_free(base);
+ if (strcmp2(child->name, name) == 0) {
return child;
}
- g_free(base);
}
return NULL;
return NULL;
}
-static gchar *folder_get_identifier(Folder *folder)
+gchar *folder_get_identifier(Folder *folder)
{
gchar *type_str;
}
/* Processing */
- buf = g_strdup_printf(_("Processing (%s)...\n"),
+ if (item->prefs->enable_processing_when_opening) {
+ buf = g_strdup_printf(_("Processing (%s)...\n"),
item->path ? item->path : item->name);
- g_free(buf);
-
- if (before_proc_func)
- before_proc_func(data);
+ g_free(buf);
- folder_item_apply_processing(item);
+ if (before_proc_func)
+ before_proc_func(data);
- if (after_proc_func)
- after_proc_func(data);
+ folder_item_apply_processing(item);
+ if (after_proc_func)
+ after_proc_func(data);
+ }
item->processing_pending = FALSE;
return;
}
GSList *newmsg_list = NULL;
guint newcnt = 0, unreadcnt = 0, totalcnt = 0;
guint markedcnt = 0, unreadmarkedcnt = 0;
+ guint repliedcnt = 0, forwardedcnt = 0;
+ guint lockedcnt = 0, ignoredcnt = 0, watchedcnt = 0;
+
guint cache_max_num, folder_max_num, cache_cur_num, folder_cur_num;
gboolean update_flags = 0, old_uids_valid = FALSE;
GHashTable *subject_table = NULL;
}
/* Move to next folder number */
- folder_list_cur = folder_list_cur->next;
+ if (folder_list_cur)
+ folder_list_cur = folder_list_cur->next;
if (folder_list_cur != NULL)
folder_cur_num = GPOINTER_TO_INT(folder_list_cur->data);
debug_print("Removed message %d from cache.\n", cache_cur_num);
/* Move to next cache number */
- cache_list_cur = cache_list_cur->next;
+ if (cache_list_cur)
+ cache_list_cur = cache_list_cur->next;
if (cache_list_cur != NULL)
cache_cur_num = ((MsgInfo *)cache_list_cur->data)->msgnum;
}
/* Move to next folder and cache number */
- cache_list_cur = cache_list_cur->next;
- folder_list_cur = folder_list_cur->next;
+ if (cache_list_cur)
+ cache_list_cur = cache_list_cur->next;
+
+ if (folder_list_cur)
+ folder_list_cur = folder_list_cur->next;
if (cache_list_cur != NULL)
cache_cur_num = ((MsgInfo *)cache_list_cur->data)->msgnum;
unreadmarkedcnt++;
if (MSG_IS_MARKED(msginfo->flags))
markedcnt++;
+ if (MSG_IS_REPLIED(msginfo->flags))
+ repliedcnt++;
+ if (MSG_IS_FORWARDED(msginfo->flags))
+ forwardedcnt++;
+ if (MSG_IS_LOCKED(msginfo->flags))
+ lockedcnt++;
+ if (MSG_IS_IGNORE_THREAD(msginfo->flags))
+ ignoredcnt++;
+ if (MSG_IS_WATCH_THREAD(msginfo->flags))
+ watchedcnt++;
totalcnt++;
if (item->new_msgs != newcnt || item->unread_msgs != unreadcnt
|| item->total_msgs != totalcnt || item->marked_msgs != markedcnt
- || item->unreadmarked_msgs != unreadmarkedcnt) {
+ || item->unreadmarked_msgs != unreadmarkedcnt
+ || item->replied_msgs != repliedcnt || item->forwarded_msgs != forwardedcnt
+ || item->locked_msgs != lockedcnt || item->ignored_msgs != ignoredcnt
+ || item->watched_msgs != watchedcnt) {
update_flags |= F_ITEM_UPDATE_CONTENT;
}
item->total_msgs = totalcnt;
item->unreadmarked_msgs = unreadmarkedcnt;
item->marked_msgs = markedcnt;
+ item->replied_msgs = repliedcnt;
+ item->forwarded_msgs = forwardedcnt;
+ item->locked_msgs = lockedcnt;
+ item->ignored_msgs = ignoredcnt;
+ item->watched_msgs = watchedcnt;
update_flags |= F_ITEM_UPDATE_MSGCNT;
MsgInfoList *list, *cur;
guint newcnt = 0, unreadcnt = 0;
guint markedcnt = 0, unreadmarkedcnt = 0;
+ guint repliedcnt = 0, forwardedcnt = 0;
+ guint lockedcnt = 0, ignoredcnt = 0;
+ guint watchedcnt = 0;
MsgInfo *msginfo;
item->cache = msgcache_new();
unreadmarkedcnt++;
if (MSG_IS_MARKED(msginfo->flags))
markedcnt++;
+ if (MSG_IS_REPLIED(msginfo->flags))
+ repliedcnt++;
+ if (MSG_IS_FORWARDED(msginfo->flags))
+ forwardedcnt++;
+ if (MSG_IS_LOCKED(msginfo->flags))
+ lockedcnt++;
+ if (MSG_IS_IGNORE_THREAD(msginfo->flags))
+ ignoredcnt++;
+ if (MSG_IS_WATCH_THREAD(msginfo->flags))
+ watchedcnt++;
procmsg_msginfo_unset_flags(msginfo, MSG_FULLY_CACHED, 0);
}
item->new_msgs = newcnt;
item->unread_msgs = unreadcnt;
item->unreadmarked_msgs = unreadmarkedcnt;
item->marked_msgs = markedcnt;
+ item->replied_msgs = repliedcnt;
+ item->forwarded_msgs = forwardedcnt;
+ item->locked_msgs = lockedcnt;
+ item->ignored_msgs = ignoredcnt;
+ item->watched_msgs = watchedcnt;
procmsg_msg_list_free(list);
} else
msgcache_read_mark(item->cache, mark_file);
return;
last_mtime = item->mtime;
- need_scan = item->folder->klass->scan_required(item->folder, item);
+ if (item->folder->klass->scan_required)
+ need_scan = item->folder->klass->scan_required(item->folder, item);
+ else
+ need_scan = TRUE;
id = folder_item_get_identifier(item);
debug_print("Save cache for folder %s\n", id);
item->unreadmarked_msgs++;
if (MSG_IS_MARKED(newmsginfo->flags))
item->marked_msgs++;
+ if (MSG_IS_REPLIED(newmsginfo->flags))
+ item->replied_msgs++;
+ if (MSG_IS_FORWARDED(newmsginfo->flags))
+ item->forwarded_msgs++;
+ if (MSG_IS_LOCKED(newmsginfo->flags))
+ item->locked_msgs++;
+ if (MSG_IS_IGNORE_THREAD(newmsginfo->flags))
+ item->ignored_msgs++;
+ if (MSG_IS_WATCH_THREAD(newmsginfo->flags))
+ item->watched_msgs++;
item->total_msgs++;
folder_item_update_freeze();
msginfo->folder->unreadmarked_msgs--;
if (MSG_IS_MARKED(msginfo->flags))
item->marked_msgs--;
+ if (MSG_IS_REPLIED(msginfo->flags))
+ item->replied_msgs--;
+ if (MSG_IS_FORWARDED(msginfo->flags))
+ item->forwarded_msgs--;
+ if (MSG_IS_LOCKED(msginfo->flags))
+ item->locked_msgs--;
+ if (MSG_IS_IGNORE_THREAD(msginfo->flags))
+ item->ignored_msgs--;
+ if (MSG_IS_WATCH_THREAD(msginfo->flags))
+ item->watched_msgs--;
msginfo->folder->total_msgs--;
lastnum = num;
if (num >= 0 && remove_source) {
- if (g_unlink(fileinfo->file) < 0)
+ if (claws_unlink(fileinfo->file) < 0)
FILE_OP_ERROR(fileinfo->file, "unlink");
}
statusbar_print_all(_("Updating cache for %s..."), dest->path ? dest->path : "(null)");
total = g_slist_length(msglist);
+ if (FOLDER_TYPE(dest->folder) == F_IMAP && total > 1) {
+ folder_item_scan_full(dest, FALSE);
+ folderscan = TRUE;
+ }
folder_item_set_batch(dest, TRUE);
for (l = msglist; l != NULL; l = g_slist_next(l)) {
MsgInfo *msginfo = (MsgInfo *) l->data;
{
Folder *folder;
gint ret = 0;
+ GSList *real_list = NULL, *cur = NULL;
g_return_val_if_fail(item != NULL, -1);
folder = item->folder;
if (!item->cache) folder_item_read_cache(item);
folder_item_update_freeze();
+
+ /* filter out locked mails */
+ for (cur = msglist; cur; cur = cur->next) {
+ MsgInfo *info = (MsgInfo *)cur->data;
+ if (!MSG_IS_LOCKED(info->flags))
+ real_list = g_slist_prepend(real_list, info);
+ }
+
+ real_list = g_slist_reverse(real_list);
+
if (item->folder->klass->remove_msgs) {
ret = item->folder->klass->remove_msgs(item->folder,
item,
- msglist,
+ real_list,
NULL);
}
- while (ret == 0 && msglist != NULL) {
- MsgInfo *msginfo = (MsgInfo *)msglist->data;
+ while (ret == 0 && real_list != NULL) {
+ MsgInfo *msginfo = (MsgInfo *)real_list->data;
if (msginfo && MSG_IS_LOCKED(msginfo->flags)) {
- msglist = msglist->next;
+ real_list = real_list->next;
continue;
}
if (!item->folder->klass->remove_msgs)
ret = folder_item_remove_msg(item, msginfo->msgnum);
if (ret != 0) break;
msgcache_remove_msg(item->cache, msginfo->msgnum);
- msglist = msglist->next;
+ real_list = real_list->next;
}
+ g_slist_free(real_list);
folder_item_scan_full(item, FALSE);
folder_item_update_thaw();
inc_unlock();
item->unreadmarked_msgs = 0;
item->marked_msgs = 0;
item->total_msgs = 0;
+ item->replied_msgs = 0;
+ item->forwarded_msgs = 0;
+ item->locked_msgs = 0;
+ item->ignored_msgs = 0;
+ item->watched_msgs = 0;
folder_item_update(item, F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT);
}
cache = folder_item_get_cache_file(item);
if (is_file_exist(cache))
- g_unlink(cache);
+ claws_unlink(cache);
g_free(cache);
}
void folder_item_set_batch (FolderItem *item, gboolean batch)
{
+ if (!item || !item->folder)
+ return;
if (item->folder->klass->set_batch) {
item->folder->klass->set_batch(item->folder, item, batch);
}