#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;
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;
const gchar *path = NULL;
PrefsAccount *account = NULL;
gboolean no_sub = FALSE, no_select = FALSE, collapsed = FALSE,
- threaded = TRUE, 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;
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,
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;
+}
+