#include "account.h"
#include "prefs_account.h"
#include "mbox_folder.h"
+#include "prefs_folder_item.h"
+
+#include <sys/stat.h>
+#include <sys/types.h>
static GList *folder_list = NULL;
item->no_sub = FALSE;
item->no_select = FALSE;
item->collapsed = FALSE;
- item->threaded = FALSE;
+ item->threaded = TRUE;
item->ret_rcpt = FALSE;
item->parent = NULL;
item->folder = NULL;
g_warning("failed to write folder list.\n");
}
+struct TotalMsgCount
+{
+ guint new;
+ guint unread;
+ guint total;
+};
+
+static gboolean folder_count_total_msgs_func(GNode *node, gpointer data)
+{
+ FolderItem *item;
+ struct TotalMsgCount *count = (struct TotalMsgCount *)data;
+
+ g_return_val_if_fail(node->data != NULL, FALSE);
+
+ item = FOLDER_ITEM(node->data);
+ count->new += item->new;
+ count->unread += item->unread;
+ count->total += item->total;
+
+ return FALSE;
+}
+
+void folder_count_total_msgs(guint *new, guint *unread, guint *total)
+{
+ GList *list;
+ Folder *folder;
+ struct TotalMsgCount count;
+
+ count.new = count.unread = count.total = 0;
+
+ debug_print(_("Counting total number of messages...\n"));
+
+ for (list = folder_list; list != NULL; list = list->next) {
+ folder = FOLDER(list->data);
+ if (folder->node)
+ g_node_traverse(folder->node, G_PRE_ORDER,
+ G_TRAVERSE_ALL, -1,
+ folder_count_total_msgs_func,
+ &count);
+ }
+
+ *new = count.new;
+ *unread = count.unread;
+ *total = count.total;
+
+ return;
+}
+
Folder *folder_find_from_path(const gchar *path)
{
GList *list;
return ret;
}
+gint folder_item_remove_msgs(FolderItem *item, GSList *msglist)
+{
+ gint ret = 0;
+
+ g_return_val_if_fail(item != NULL, -1);
+
+ while (msglist != NULL) {
+ MsgInfo *msginfo = (MsgInfo *)msglist->data;
+
+ ret = folder_item_remove_msg(item, msginfo->msgnum);
+ if (ret != 0) break;
+ msglist = msglist->next;
+ }
+
+ return ret;
+}
+
gint folder_item_remove_all_msg(FolderItem *item)
{
Folder *folder;
const gchar *path = NULL;
PrefsAccount *account = NULL;
gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE,
- threaded = FALSE, ret_rcpt = FALSE;
+ threaded = TRUE, ret_rcpt = FALSE, hidereadmsgs = FALSE;
gint mtime = 0, new = 0, unread = 0, total = 0;
g_return_val_if_fail(node->data != NULL, FALSE);
collapsed = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "threaded"))
threaded = *attr->value == '1' ? TRUE : FALSE;
+ else if (!strcmp(attr->name, "hidereadmsgs"))
+ hidereadmsgs = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "reqretrcpt"))
ret_rcpt = *attr->value == '1' ? TRUE : FALSE;
}
item->no_select = no_select;
item->collapsed = collapsed;
item->threaded = threaded;
+ item->hide_read_msgs = hidereadmsgs;
item->ret_rcpt = ret_rcpt;
item->parent = FOLDER_ITEM(node->parent->data);
item->folder = folder;
const gchar *name = NULL;
const gchar *path = NULL;
PrefsAccount *account = NULL;
- gboolean collapsed = FALSE, threaded = FALSE, ret_rcpt = FALSE;
+ gboolean collapsed = FALSE, threaded = TRUE, ret_rcpt = FALSE;
if (g_node_depth(node) != 2) return FALSE;
g_return_val_if_fail(node->data != NULL, FALSE);
folder->account->account_id);
if (item->collapsed && node->children)
fputs(" collapsed=\"1\"", fp);
- if (item->threaded)
- fputs(" threaded=\"1\"", fp);
if (item->ret_rcpt)
fputs(" reqretrcpt=\"1\"", fp);
} else {
fputs(" collapsed=\"1\"", fp);
if (item->threaded)
fputs(" threaded=\"1\"", fp);
+ else
+ fputs(" threaded=\"0\"", fp);
+ if (item->hide_read_msgs)
+ fputs(" hidereadmsgs=\"1\"", fp);
+ else
+ fputs(" hidereadmsgs=\"0\"", fp);
if (item->ret_rcpt)
fputs(" reqretrcpt=\"1\"", fp);
fprintf(fp,
- " mtime=\"%ld\" new=\"%d\" unread=\"%d\" total=\"%d\"",
+ " mtime=\"%lu\" new=\"%d\" unread=\"%d\" total=\"%d\"",
item->mtime, item->new, item->unread, item->total);
}
gchar * folder_item_get_identifier(FolderItem * item)
{
- gchar * path;
gchar * id;
gchar * folder_str;
- folder_str = folder_get_identifier(item->folder);
-
- if (item->path == NULL) {
- g_free(folder_str);
- return NULL;
- }
+ g_return_val_if_fail(item->path != NULL, NULL);
+ folder_str = folder_get_identifier(item->folder);
id = g_strconcat(folder_str, "/", item->path, NULL);
+ g_free(folder_str);
return id;
}
gchar * name;
gchar * path;
- Xalloca(str, strlen(identifier) + 1, return NULL);
- strcpy(str, identifier);
+ Xstrdup_a(str, identifier, return NULL);
/* extract box type */
folder_item_find_func, d);
return d[1];
}
+
+/* CLAWS: temporary local folder for filtering */
+
+static Folder *processing_folder;
+static FolderItem *processing_folder_item;
+
+static void folder_create_processing_folder(void)
+{
+#define PROCESSING_FOLDER ".processing"
+ Folder *tmpparent;
+ FolderItem *tmpfolder;
+ gchar *tmpname;
+ struct stat s;
+
+ tmpparent = folder_get_default_folder();
+ g_assert(tmpparent);
+ debug_print("tmpparentroot %s\n", LOCAL_FOLDER(tmpparent)->rootpath);
+ if (LOCAL_FOLDER(tmpparent)->rootpath[0] == '/')
+ tmpname = g_strconcat(LOCAL_FOLDER(tmpparent)->rootpath,
+ G_DIR_SEPARATOR_S, PROCESSING_FOLDER,
+ NULL);
+ else
+ tmpname = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
+ LOCAL_FOLDER(tmpparent)->rootpath,
+ G_DIR_SEPARATOR_S, PROCESSING_FOLDER,
+ NULL);
+
+ processing_folder = folder_new(F_MH, "PROCESSING", LOCAL_FOLDER(tmpparent)->rootpath);
+ g_assert(processing_folder);
+
+ if (!is_dir_exist(tmpname)) {
+ debug_print("*TMP* creating %s\n", tmpname);
+ processing_folder_item = processing_folder->create_folder(processing_folder,
+ processing_folder->node->data,
+ PROCESSING_FOLDER);
+ g_assert(processing_folder_item);
+ }
+ else {
+ debug_print("*TMP* already created\n");
+ processing_folder_item = folder_item_new(".processing", ".processing");
+ g_assert(processing_folder_item);
+ folder_item_append(processing_folder->node->data, processing_folder_item);
+ }
+ g_free(tmpname);
+}
+
+FolderItem *folder_get_default_processing(void)
+{
+ if (!processing_folder_item) {
+ folder_create_processing_folder();
+ }
+ return processing_folder_item;
+}
+