/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 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
#include "defs.h"
#include <glib.h>
+#include <glib/gi18n.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
# include <sys/time.h>
#endif
-#include "intl.h"
#include "folder.h"
#include "mh.h"
#include "procmsg.h"
#include "procheader.h"
#include "utils.h"
-
-static void mh_folder_init(Folder * folder,
- const gchar * name, const gchar * path);
-
-static Folder *mh_folder_new(const gchar * name, const gchar * path);
-static void mh_folder_destroy(Folder * folder);
-static gchar *mh_fetch_msg(Folder * folder, FolderItem * item, gint num);
-static MsgInfo *mh_get_msginfo(Folder * folder,
- FolderItem * item, gint num);
-static gint mh_add_msg(Folder * folder,
- FolderItem * dest,
- const gchar * file,
- MsgFlags * flags);
-static gint mh_add_msgs(Folder * folder,
- FolderItem * dest, GSList * file_list, GRelation *relation);
-static gint mh_copy_msg(Folder * folder,
- FolderItem * dest, MsgInfo * msginfo);
-static gint mh_remove_msg(Folder * folder, FolderItem * item, gint num);
-static gint mh_remove_all_msg(Folder * folder, FolderItem * item);
-static gboolean mh_is_msg_changed(Folder * folder,
- FolderItem * item, MsgInfo * msginfo);
-
-static gint mh_get_num_list(Folder * folder,
- FolderItem * item, GSList ** list);
-static void mh_scan_tree(Folder * folder);
-
-static gint mh_create_tree(Folder * folder);
-static FolderItem *mh_create_folder(Folder * folder,
- FolderItem * parent,
- const gchar * name);
-static gint mh_rename_folder(Folder * folder,
- FolderItem * item, const gchar * name);
-static gint mh_remove_folder(Folder * folder, FolderItem * item);
-
-static gchar *mh_get_new_msg_filename(FolderItem * dest);
-
-static MsgInfo *mh_parse_msg(const gchar * file, FolderItem * item);
-static void mh_scan_tree_recursive(FolderItem * item);
-
-static gboolean mh_rename_folder_func(GNode * node, gpointer data);
-static gchar *mh_item_get_path(Folder *folder, FolderItem *item);
-
-FolderClass mh_class =
-{
- F_MH,
- "mh",
- "MH",
-
- /* Folder functions */
- mh_folder_new,
- mh_folder_destroy,
- mh_scan_tree,
- mh_create_tree,
-
- /* FolderItem functions */
- NULL,
- NULL,
- mh_item_get_path,
- mh_create_folder,
- mh_rename_folder,
- mh_remove_folder,
- NULL,
- mh_get_num_list,
- NULL,
- NULL,
- NULL,
- NULL,
-
- /* Message functions */
- mh_get_msginfo,
- NULL,
- mh_fetch_msg,
- mh_add_msg,
- mh_add_msgs,
- mh_copy_msg,
- NULL,
- mh_remove_msg,
- mh_remove_all_msg,
- mh_is_msg_changed,
- NULL,
-};
+#include "codeconv.h"
+
+static void mh_folder_init (Folder *folder,
+ const gchar *name,
+ const gchar *path);
+
+static Folder *mh_folder_new (const gchar *name,
+ const gchar *path);
+static void mh_folder_destroy (Folder *folder);
+static gchar *mh_fetch_msg (Folder *folder,
+ FolderItem *item,
+ gint num);
+static MsgInfo *mh_get_msginfo (Folder *folder,
+ FolderItem *item,
+ gint num);
+static gint mh_add_msg (Folder *folder,
+ FolderItem *dest,
+ const gchar *file,
+ MsgFlags *flags);
+static gint mh_add_msgs (Folder *folder,
+ FolderItem *dest,
+ GSList *file_list,
+ GRelation *relation);
+static gint mh_copy_msg (Folder *folder,
+ FolderItem *dest,
+ MsgInfo *msginfo);
+static gint mh_remove_msg (Folder *folder,
+ FolderItem *item,
+ gint num);
+static gint mh_remove_all_msg (Folder *folder,
+ FolderItem *item);
+static gboolean mh_is_msg_changed (Folder *folder,
+ FolderItem *item,
+ MsgInfo *msginfo);
+
+static gint mh_get_num_list (Folder *folder,
+ FolderItem *item,
+ GSList **list,
+ gboolean *old_uids_valid);
+static gint mh_scan_tree (Folder *folder);
+
+static gint mh_create_tree (Folder *folder);
+static FolderItem *mh_create_folder (Folder *folder,
+ FolderItem *parent,
+ const gchar *name);
+static gint mh_rename_folder (Folder *folder,
+ FolderItem *item,
+ const gchar *name);
+static gint mh_remove_folder (Folder *folder,
+ FolderItem *item);
+
+static gchar *mh_get_new_msg_filename (FolderItem *dest);
+
+static MsgInfo *mh_parse_msg (const gchar *file,
+ FolderItem *item);
+static void mh_remove_missing_folder_items (Folder *folder);
+static gchar *mh_filename_from_utf8 (const gchar *path);
+static gchar *mh_filename_to_utf8 (const gchar *path);
+static void mh_scan_tree_recursive (FolderItem *item);
+
+static gboolean mh_rename_folder_func (GNode *node,
+ gpointer data);
+static gchar *mh_item_get_path (Folder *folder,
+ FolderItem *item);
+
+static gboolean mh_scan_required (Folder *folder,
+ FolderItem *item);
+
+static FolderClass mh_class;
FolderClass *mh_get_class(void)
{
+ if (mh_class.idstr == NULL) {
+ mh_class.type = F_MH;
+ mh_class.idstr = "mh";
+ mh_class.uistr = "MH";
+
+ /* Folder functions */
+ mh_class.new_folder = mh_folder_new;
+ mh_class.destroy_folder = mh_folder_destroy;
+ mh_class.set_xml = folder_local_set_xml;
+ mh_class.get_xml = folder_local_get_xml;
+ mh_class.scan_tree = mh_scan_tree;
+ mh_class.create_tree = mh_create_tree;
+
+ /* FolderItem functions */
+ mh_class.item_get_path = mh_item_get_path;
+ mh_class.create_folder = mh_create_folder;
+ mh_class.rename_folder = mh_rename_folder;
+ mh_class.remove_folder = mh_remove_folder;
+ mh_class.get_num_list = mh_get_num_list;
+ mh_class.scan_required = mh_scan_required;
+
+ /* Message functions */
+ mh_class.get_msginfo = mh_get_msginfo;
+ mh_class.fetch_msg = mh_fetch_msg;
+ mh_class.add_msg = mh_add_msg;
+ mh_class.add_msgs = mh_add_msgs;
+ mh_class.copy_msg = mh_copy_msg;
+ mh_class.remove_msg = mh_remove_msg;
+ mh_class.remove_all_msg = mh_remove_all_msg;
+ mh_class.is_msg_changed = mh_is_msg_changed;
+ }
+
return &mh_class;
}
-Folder *mh_folder_new(const gchar *name, const gchar *path)
+static Folder *mh_folder_new(const gchar *name, const gchar *path)
{
Folder *folder;
}
+gboolean mh_scan_required(Folder *folder, FolderItem *item)
+{
+ gchar *path;
+ struct stat s;
+
+ path = folder_item_get_path(item);
+ g_return_val_if_fail(path != NULL, FALSE);
+
+ if (stat(path, &s) < 0) {
+ FILE_OP_ERROR(path, "stat");
+ g_free(path);
+ return FALSE;
+ }
+
+ if ((s.st_mtime > item->mtime) &&
+ (s.st_mtime - 3600 != item->mtime)) {
+ debug_print("MH scan required, folder updated: %s (%ld > %ld)\n",
+ path,
+ s.st_mtime,
+ item->mtime);
+ g_free(path);
+ return TRUE;
+ }
+
+ debug_print("MH scan not required: %s (%ld <= %ld)\n",
+ path,
+ s.st_mtime,
+ item->mtime);
+ g_free(path);
+ return FALSE;
+}
+
void mh_get_last_num(Folder *folder, FolderItem *item)
{
gchar *path;
DIR *dp;
struct dirent *d;
- struct stat s;
gint max = 0;
gint num;
}
while ((d = readdir(dp)) != NULL) {
- if ((num = to_number(d->d_name)) >= 0 &&
- stat(d->d_name, &s) == 0 &&
- S_ISREG(s.st_mode)) {
+ if ((num = to_number(d->d_name)) > 0 &&
+ dirent_is_regular_file(d)) {
if (max < num)
max = num;
}
item->last_num = max;
}
-gint mh_get_num_list(Folder *folder, FolderItem *item, GSList **list)
+gint mh_get_num_list(Folder *folder, FolderItem *item, GSList **list, gboolean *old_uids_valid)
{
gchar *path;
DIR *dp;
struct dirent *d;
- struct stat s;
gint num, nummsgs = 0;
g_return_val_if_fail(item != NULL, -1);
- debug_print("mh_get_last_num(): Scanning %s ...\n", item->path);
+ debug_print("mh_get_num_list(): Scanning %s ...\n", item->path);
+
+ *old_uids_valid = TRUE;
path = folder_item_get_path(item);
g_return_val_if_fail(path != NULL, -1);
}
while ((d = readdir(dp)) != NULL) {
- if ((num = to_number(d->d_name)) >= 0 &&
- stat(d->d_name, &s) == 0 &&
- S_ISREG(s.st_mode)) {
+ if ((num = to_number(d->d_name)) > 0) {
*list = g_slist_prepend(*list, GINT_TO_POINTER(num));
- nummsgs++;
+ nummsgs++;
}
}
closedir(dp);
+ item->mtime = time(NULL);
return nummsgs;
}
-gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
+static gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
{
gchar *path;
gchar *file;
path = folder_item_get_path(item);
file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
- g_free(path);
+
if (!is_file_exist(file)) {
g_free(file);
+ g_free(path);
return NULL;
}
-
+ g_free(path);
return file;
}
-MsgInfo *mh_get_msginfo(Folder *folder, FolderItem *item, gint num)
+static MsgInfo *mh_get_msginfo(Folder *folder, FolderItem *item, gint num)
{
MsgInfo *msginfo;
gchar *file;
return msginfo;
}
-gchar *mh_get_new_msg_filename(FolderItem *dest)
+static gchar *mh_get_new_msg_filename(FolderItem *dest)
{
gchar *destfile;
gchar *destpath;
return destfile;
}
-#define SET_DEST_MSG_FLAGS(fp, dest, msginfo) \
-{ \
- MsgInfo newmsginfo; \
- \
- newmsginfo.msgnum = dest->last_num; \
- newmsginfo.flags = msginfo->flags; \
- if (dest->stype == F_OUTBOX || \
- dest->stype == F_QUEUE || \
- dest->stype == F_DRAFT || \
- dest->stype == F_TRASH) \
- MSG_UNSET_PERM_FLAGS(newmsginfo.flags, \
- MSG_NEW|MSG_UNREAD|MSG_DELETED); \
- \
- procmsg_write_flags(&newmsginfo, fp); \
-}
-
-gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file, MsgFlags *flags)
+static gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file, MsgFlags *flags)
{
gint ret;
GSList file_list;
g_return_val_if_fail(file != NULL, -1);
+ fileinfo.msginfo = NULL;
fileinfo.file = (gchar *)file;
fileinfo.flags = flags;
file_list.data = &fileinfo;
return ret;
}
-gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
+static gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
GRelation *relation)
{
gchar *destfile;
}
if (relation != NULL)
g_relation_insert(relation, fileinfo, GINT_TO_POINTER(dest->last_num + 1));
-
g_free(destfile);
dest->last_num++;
}
return dest->last_num;
}
-gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
+static gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
{
+ gboolean dest_need_scan = FALSE;
gchar *srcfile;
gchar *destfile;
gint filemode = 0;
return -1;
}
+ dest_need_scan = mh_scan_required(dest->folder, dest);
+ if (!dest_need_scan)
+ dest->mtime = time(NULL);
+
if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
if (chmod(destfile, prefs->folder_chmod) < 0)
return dest->last_num;
}
-gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
+static gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
{
+ gboolean need_scan = FALSE;
gchar *file;
g_return_val_if_fail(item != NULL, -1);
file = mh_fetch_msg(folder, item, num);
g_return_val_if_fail(file != NULL, -1);
+ need_scan = mh_scan_required(folder, item);
+
if (unlink(file) < 0) {
FILE_OP_ERROR(file, "unlink");
g_free(file);
return -1;
}
+ if (!need_scan)
+ item->mtime = time(NULL);
+
g_free(file);
return 0;
}
-gint mh_remove_all_msg(Folder *folder, FolderItem *item)
+static gint mh_remove_all_msg(Folder *folder, FolderItem *item)
{
gchar *path;
gint val;
return val;
}
-gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo)
+static gboolean mh_is_msg_changed(Folder *folder, FolderItem *item,
+ MsgInfo *msginfo)
{
struct stat s;
if (stat(itos(msginfo->msgnum), &s) < 0 ||
- msginfo->size != s.st_size ||
- msginfo->mtime != s.st_mtime)
+ msginfo->size != s.st_size || (
+ (msginfo->mtime - s.st_mtime != 0) &&
+ (msginfo->mtime - s.st_mtime != 3600) &&
+ (msginfo->mtime - s.st_mtime != -3600)))
return TRUE;
return FALSE;
}
-void mh_scan_tree(Folder *folder)
+static gint mh_scan_tree(Folder *folder)
{
FolderItem *item;
gchar *rootpath;
- g_return_if_fail(folder != NULL);
+ g_return_val_if_fail(folder != NULL, -1);
- item = folder_item_new(folder, folder->name, NULL);
- item->folder = folder;
- folder->node = g_node_new(item);
+ if (!folder->node) {
+ item = folder_item_new(folder, folder->name, NULL);
+ item->folder = folder;
+ folder->node = item->node = g_node_new(item);
+ } else
+ item = FOLDER_ITEM(folder->node->data);
rootpath = folder_item_get_path(item);
if (change_dir(rootpath) < 0) {
g_free(rootpath);
- return;
+ return -1;
}
g_free(rootpath);
mh_create_tree(folder);
+ mh_remove_missing_folder_items(folder);
mh_scan_tree_recursive(item);
+
+ return 0;
}
#define MAKE_DIR_IF_NOT_EXIST(dir) \
} \
}
-gint mh_create_tree(Folder *folder)
+static gint mh_create_tree(Folder *folder)
{
gchar *rootpath;
#undef MAKE_DIR_IF_NOT_EXIST
-gchar *mh_item_get_path(Folder *folder, FolderItem *item)
+static gchar *mh_item_get_path(Folder *folder, FolderItem *item)
{
gchar *folder_path, *path;
return path;
}
-FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
- const gchar *name)
+static FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
+ const gchar *name)
{
- gchar *path;
+ gchar *path, *real_name;
gchar *fullpath;
FolderItem *new_item;
gchar *mh_sequences_filename;
if (make_dir_hier(path) != 0)
return NULL;
- fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
+ real_name = mh_filename_from_utf8(name);
+ fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, real_name, NULL);
+ g_free(real_name);
g_free(path);
if (make_dir(fullpath) < 0) {
return new_item;
}
-gint mh_rename_folder(Folder *folder, FolderItem *item, const gchar *name)
+static gint mh_rename_folder(Folder *folder, FolderItem *item,
+ const gchar *name)
{
+ gchar *real_name;
gchar *oldpath;
gchar *dirname;
- gchar *newpath;
- GNode *node;
+ gchar *newpath, *utf8newpath;
gchar *paths[2];
g_return_val_if_fail(folder != NULL, -1);
if (!is_dir_exist(oldpath))
make_dir_hier(oldpath);
- dirname = g_dirname(oldpath);
- newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
- g_free(dirname);
+ dirname = g_path_get_dirname(oldpath);
+ real_name = mh_filename_from_utf8(name);
+ newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, real_name, NULL);
+ g_free(real_name);
if (rename(oldpath, newpath) < 0) {
FILE_OP_ERROR(oldpath, "rename");
g_free(newpath);
if (strchr(item->path, G_DIR_SEPARATOR) != NULL) {
- dirname = g_dirname(item->path);
- newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
+ dirname = g_path_get_dirname(item->path);
+ utf8newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S,
+ name, NULL);
g_free(dirname);
} else
- newpath = g_strdup(name);
+ utf8newpath = g_strdup(name);
g_free(item->name);
item->name = g_strdup(name);
- node = g_node_find(item->folder->node, G_PRE_ORDER, G_TRAVERSE_ALL,
- item);
paths[0] = g_strdup(item->path);
- paths[1] = newpath;
- g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ paths[1] = utf8newpath;
+ g_node_traverse(item->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
mh_rename_folder_func, paths);
g_free(paths[0]);
return 0;
}
-gint mh_remove_folder(Folder *folder, FolderItem *item)
+static gint mh_remove_folder(Folder *folder, FolderItem *item)
{
gchar *path;
static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
{
- struct stat s;
MsgInfo *msginfo;
MsgFlags flags;
- flags.perm_flags = MSG_NEW|MSG_UNREAD;
- flags.tmp_flags = 0;
-
g_return_val_if_fail(item != NULL, NULL);
g_return_val_if_fail(file != NULL, NULL);
+ flags.perm_flags = MSG_NEW|MSG_UNREAD;
+ flags.tmp_flags = 0;
+
if (item->stype == F_QUEUE) {
MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
} else if (item->stype == F_DRAFT) {
msginfo->msgnum = atoi(file);
msginfo->folder = item;
- if (stat(file, &s) < 0) {
- FILE_OP_ERROR(file, "stat");
- msginfo->size = 0;
- msginfo->mtime = 0;
- } else {
- msginfo->size = s.st_size;
- msginfo->mtime = s.st_mtime;
- }
-
return msginfo;
}
}
#endif
+static gboolean mh_remove_missing_folder_items_func(GNode *node, gpointer data)
+{
+ FolderItem *item;
+ gchar *path;
+
+ g_return_val_if_fail(node->data != NULL, FALSE);
+
+ if (G_NODE_IS_ROOT(node))
+ return FALSE;
+
+ item = FOLDER_ITEM(node->data);
+
+ path = folder_item_get_path(item);
+ if (!is_dir_exist(path)) {
+ debug_print("folder '%s' not found. removing...\n", path);
+ folder_item_remove(item);
+ }
+ g_free(path);
+
+ return FALSE;
+}
+
+static void mh_remove_missing_folder_items(Folder *folder)
+{
+ g_return_if_fail(folder != NULL);
+
+ debug_print("searching missing folders...\n");
+
+ g_node_traverse(folder->node, G_POST_ORDER, G_TRAVERSE_ALL, -1,
+ mh_remove_missing_folder_items_func, folder);
+}
+
static void mh_scan_tree_recursive(FolderItem *item)
{
+ Folder *folder;
DIR *dp;
struct dirent *d;
struct stat s;
- gchar *entry;
+ gchar *real_path, *entry, *utf8entry, *utf8name;
gint n_msg = 0;
g_return_if_fail(item != NULL);
g_return_if_fail(item->folder != NULL);
- dp = opendir(item->path ? item->path : ".");
+ folder = item->folder;
+
+ real_path = item->path ? mh_filename_from_utf8(item->path) : g_strdup(".");
+ dp = opendir(real_path);
if (!dp) {
- FILE_OP_ERROR(item->path ? item->path : ".", "opendir");
+ FILE_OP_ERROR(real_path, "opendir");
return;
}
+ g_free(real_path);
debug_print("scanning %s ...\n",
item->path ? item->path
: LOCAL_FOLDER(item->folder)->rootpath);
- if (item->folder->ui_func)
- item->folder->ui_func(item->folder, item,
- item->folder->ui_func_data);
+ if (folder->ui_func)
+ folder->ui_func(folder, item, folder->ui_func_data);
while ((d = readdir(dp)) != NULL) {
if (d->d_name[0] == '.') continue;
+ utf8name = mh_filename_to_utf8(d->d_name);
if (item->path)
- entry = g_strconcat(item->path, G_DIR_SEPARATOR_S,
- d->d_name, NULL);
+ utf8entry = g_strconcat(item->path, G_DIR_SEPARATOR_S,
+ utf8name, NULL);
else
- entry = g_strdup(d->d_name);
-
- if (stat(entry, &s) < 0) {
- FILE_OP_ERROR(entry, "stat");
- g_free(entry);
- continue;
- }
+ utf8entry = g_strdup(utf8name);
+ entry = mh_filename_from_utf8(utf8entry);
- if (S_ISDIR(s.st_mode)) {
- FolderItem *new_item;
+ if (
+#ifdef HAVE_DIRENT_D_TYPE
+ d->d_type == DT_DIR ||
+ (d->d_type == DT_UNKNOWN &&
+#endif
+ stat(entry, &s) == 0 && S_ISDIR(s.st_mode)
+#ifdef HAVE_DIRENT_D_TYPE
+ )
+#endif
+ ) {
+ FolderItem *new_item = NULL;
+ GNode *node;
#if 0
if (mh_is_maildir(entry)) {
g_free(entry);
+ g_free(utf8entry);
+ g_free(utf8name);
continue;
}
#endif
- new_item = folder_item_new(item->folder, d->d_name, entry);
- folder_item_append(item, new_item);
+ node = item->node;
+ for (node = node->children; node != NULL; node = node->next) {
+ FolderItem *cur_item = FOLDER_ITEM(node->data);
+ if (!strcmp2(cur_item->path, entry)) {
+ new_item = cur_item;
+ break;
+ }
+ }
+ if (!new_item) {
+ debug_print("new folder '%s' found.\n", entry);
+ new_item = folder_item_new(folder, utf8name, utf8entry);
+ folder_item_append(item, new_item);
+ }
+
if (!item->path) {
- if (!strcmp(d->d_name, INBOX_DIR)) {
+ if (!folder->inbox &&
+ !strcmp(d->d_name, INBOX_DIR)) {
new_item->stype = F_INBOX;
- item->folder->inbox = new_item;
- } else if (!strcmp(d->d_name, OUTBOX_DIR)) {
+ folder->inbox = new_item;
+ } else if (!folder->outbox &&
+ !strcmp(d->d_name, OUTBOX_DIR)) {
new_item->stype = F_OUTBOX;
- item->folder->outbox = new_item;
- } else if (!strcmp(d->d_name, DRAFT_DIR)) {
+ folder->outbox = new_item;
+ } else if (!folder->draft &&
+ !strcmp(d->d_name, DRAFT_DIR)) {
new_item->stype = F_DRAFT;
- item->folder->draft = new_item;
- } else if (!strcmp(d->d_name, QUEUE_DIR)) {
+ folder->draft = new_item;
+ } else if (!folder->queue &&
+ !strcmp(d->d_name, QUEUE_DIR)) {
new_item->stype = F_QUEUE;
- item->folder->queue = new_item;
- } else if (!strcmp(d->d_name, TRASH_DIR)) {
+ folder->queue = new_item;
+ } else if (!folder->trash &&
+ !strcmp(d->d_name, TRASH_DIR)) {
new_item->stype = F_TRASH;
- item->folder->trash = new_item;
+ folder->trash = new_item;
}
}
+
mh_scan_tree_recursive(new_item);
} else if (to_number(d->d_name) != -1) n_msg++;
g_free(entry);
+ g_free(utf8entry);
+ g_free(utf8name);
}
closedir(dp);
+ item->mtime = time(NULL);
+
/*
if (item->path) {
gint new, unread, total, min, max;
return FALSE;
}
+
+static gchar *mh_filename_from_utf8(const gchar *path)
+{
+ const gchar *src_codeset = CS_UTF_8;
+ const gchar *dest_codeset = conv_get_locale_charset_str();
+ gchar *real_path;
+
+ real_path = conv_codeset_strdup(path, src_codeset, dest_codeset);
+ if (!real_path) {
+ g_warning("mh_filename_from_utf8: faild to convert character set\n");
+ /* FIXME: show dialog? */
+ real_path = g_strdup(path);
+ }
+
+ return real_path;
+}
+
+static gchar *mh_filename_to_utf8(const gchar *path)
+{
+ const gchar *src_codeset = conv_get_locale_charset_str();
+ const gchar *dest_codeset = CS_UTF_8;
+ gchar *utf8path;
+
+ utf8path = conv_codeset_strdup(path, src_codeset, dest_codeset);
+ if (!utf8path) {
+ g_warning("mh_filename_to_utf8: faild to convert character set\n");
+ /* FIXME: show dialog? */
+ utf8path = g_strdup(path);
+ }
+
+ return utf8path;
+}