g_warning("failed to write folder list.\n");
}
-static void folder_count_total_msgs_func(GNode *node, guint *new,
- guint *unread, guint *total)
+struct TotalMsgCount
{
- g_return_if_fail(node != NULL);
+ guint new;
+ guint unread;
+ guint total;
+};
- if (node->data) {
- FolderItem *item = FOLDER_ITEM(node->data);
- *new += item->new;
- *unread += item->unread;
- *total += item->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);
- if (node->children)
- folder_count_total_msgs_func(node->children,
- new, unread, total);
- if (node->next)
- folder_count_total_msgs_func(node->next, new, unread, total);
+ 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;
- *new = *unread = *total = 0;
+ 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);
- folder_count_total_msgs_func(folder->node, new, unread, total);
+ 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;
}
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;
+
+ tmpparent = folder_get_default_folder();
+ g_assert(tmpparent);
+ debug_print("tmpparentroot %s\n", LOCAL_FOLDER(tmpparent)->rootpath);
+ 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;
+}
+