2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 # include <sys/time.h>
43 #include "procheader.h"
46 static GSList *mh_get_uncached_msgs (GHashTable *msg_table,
48 static MsgInfo *mh_parse_msg (const gchar *file,
50 static void mh_scan_tree_recursive (FolderItem *item,
53 static gboolean mh_rename_folder_func (GNode *node,
57 GSList *mh_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache)
60 GHashTable *msg_table;
63 gboolean scan_new = TRUE;
65 struct timeval tv_before, tv_after, tv_result;
67 gettimeofday(&tv_before, NULL);
70 g_return_val_if_fail(item != NULL, NULL);
72 path = folder_item_get_path(item);
73 if (stat(path, &s) < 0) {
74 FILE_OP_ERROR(path, "stat");
76 if (item->mtime == s.st_mtime) {
77 debug_print("Folder is not modified.\n");
80 item->mtime = s.st_mtime;
84 if (use_cache && !scan_new) {
85 mlist = procmsg_read_cache(item, FALSE);
87 mlist = mh_get_uncached_msgs(NULL, item);
88 } else if (use_cache) {
91 mlist = procmsg_read_cache(item, TRUE);
92 msg_table = procmsg_msg_hash_table_create(mlist);
94 newlist = mh_get_uncached_msgs(msg_table, item);
96 g_hash_table_destroy(msg_table);
98 mlist = g_slist_concat(mlist, newlist);
100 mlist = mh_get_uncached_msgs(NULL, item);
102 procmsg_set_flags(mlist, item);
105 gettimeofday(&tv_after, NULL);
107 timersub(&tv_after, &tv_before, &tv_result);
108 g_print("mh_get_msg_list: %s: elapsed time: %ld.%06ld sec\n",
109 item->path, tv_result.tv_sec, tv_result.tv_usec);
115 gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
120 g_return_val_if_fail(item != NULL, NULL);
121 g_return_val_if_fail(num > 0 && num <= item->last_num, NULL);
123 path = folder_item_get_path(item);
124 file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
126 if (!is_file_exist(file)) {
134 gchar *mh_get_newmsg_filename(FolderItem *dest)
138 gboolean found = FALSE;
140 destpath = folder_item_get_path(dest);
141 g_return_val_if_fail(destpath != NULL, NULL);
142 if (!is_dir_exist(destpath))
143 make_dir_hier(destpath);
146 destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR,
148 if(is_file_exist(destfile)) {
160 gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file,
161 gboolean remove_source)
165 g_return_val_if_fail(dest != NULL, -1);
166 g_return_val_if_fail(file != NULL, -1);
168 if (dest->last_num < 0) {
169 mh_scan_folder(folder, dest);
170 if (dest->last_num < 0) return -1;
173 destfile = mh_get_newmsg_filename(dest);
174 if(!destfile) return -1;
176 if (link(file, destfile) < 0) {
177 if (copy_file(file, destfile) < 0) {
178 g_warning(_("can't copy message %s to %s\n"),
186 if (unlink(file) < 0)
187 FILE_OP_ERROR(file, "unlink");
192 return dest->last_num;
195 gint mh_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
202 PrefsFolderItem *prefs;
204 g_return_val_if_fail(dest != NULL, -1);
205 g_return_val_if_fail(msginfo != NULL, -1);
207 if (msginfo->folder == dest) {
208 g_warning(_("the src folder is identical to the dest.\n"));
212 if (dest->last_num < 0) {
213 mh_scan_folder(folder, dest);
214 if (dest->last_num < 0) return -1;
219 destdir = folder_item_get_path(dest);
220 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
221 g_warning(_("Can't open mark file.\n"));
223 debug_print(_("Moving message %s%c%d to %s ...\n"),
224 msginfo->folder->path, G_DIR_SEPARATOR,
225 msginfo->msgnum, dest->path);
226 srcfile = procmsg_get_message_file_path(msginfo);
228 destfile = mh_get_newmsg_filename(dest);
229 if(!destfile) return -1;
233 if (move_file(srcfile, destfile) < 0) {
240 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
241 if (chmod(destfile, prefs->folder_chmod) < 0)
242 FILE_OP_ERROR(destfile, "chmod");
245 filemode = prefs->folder_chmod;
246 if (filemode & S_IRGRP) filemode |= S_IWGRP;
247 if (filemode & S_IROTH) filemode |= S_IWOTH;
257 newmsginfo.msgnum = dest->last_num;
258 newmsginfo.flags = msginfo->flags;
259 if (dest->stype == F_OUTBOX ||
260 dest->stype == F_QUEUE ||
261 dest->stype == F_DRAFT ||
262 dest->stype == F_TRASH)
263 MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
264 MSG_NEW|MSG_UNREAD|MSG_DELETED);
266 procmsg_write_flags(&newmsginfo, fp);
270 fchmod(fileno(fp), filemode);
274 markfile = folder_item_get_mark_file(dest);
276 chmod(markfile, filemode);
285 return dest->last_num;
288 gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
296 PrefsFolderItem *prefs;
298 g_return_val_if_fail(dest != NULL, -1);
299 g_return_val_if_fail(msglist != NULL, -1);
301 if (dest->last_num < 0) {
302 mh_scan_folder(folder, dest);
303 if (dest->last_num < 0) return -1;
308 destdir = folder_item_get_path(dest);
309 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
310 g_warning(_("Can't open mark file.\n"));
312 for (cur = msglist; cur != NULL; cur = cur->next) {
313 msginfo = (MsgInfo *)cur->data;
315 if (msginfo->folder == dest) {
316 g_warning(_("the src folder is identical to the dest.\n"));
319 debug_print(_("Moving message %s%c%d to %s ...\n"),
320 msginfo->folder->path, G_DIR_SEPARATOR,
321 msginfo->msgnum, dest->path);
323 srcfile = procmsg_get_message_file_path(msginfo);
324 destfile = mh_get_newmsg_filename(dest);
325 if(!destfile) return -1;
327 if (move_file(srcfile, destfile) < 0) {
340 newmsginfo.msgnum = dest->last_num;
341 newmsginfo.flags = msginfo->flags;
342 if (dest->stype == F_OUTBOX ||
343 dest->stype == F_QUEUE ||
344 dest->stype == F_DRAFT ||
345 dest->stype == F_TRASH)
348 MSG_NEW|MSG_UNREAD|MSG_DELETED);
350 procmsg_write_flags(&newmsginfo, fp);
357 return dest->last_num;
360 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
367 PrefsFolderItem *prefs;
369 g_return_val_if_fail(dest != NULL, -1);
370 g_return_val_if_fail(msginfo != NULL, -1);
372 if (msginfo->folder == dest) {
373 g_warning(_("the src folder is identical to the dest.\n"));
377 if (dest->last_num < 0) {
378 mh_scan_folder(folder, dest);
379 if (dest->last_num < 0) return -1;
384 destdir = folder_item_get_path(dest);
385 if (!is_dir_exist(destdir))
386 make_dir_hier(destdir);
388 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
389 g_warning(_("Can't open mark file.\n"));
391 debug_print(_("Copying message %s%c%d to %s ...\n"),
392 msginfo->folder->path, G_DIR_SEPARATOR,
393 msginfo->msgnum, dest->path);
394 srcfile = procmsg_get_message_file_path(msginfo);
395 destfile = mh_get_newmsg_filename(dest);
406 if (copy_file(srcfile, destfile) < 0) {
407 FILE_OP_ERROR(srcfile, "copy");
414 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
415 if (chmod(destfile, prefs->folder_chmod) < 0)
416 FILE_OP_ERROR(destfile, "chmod");
419 filemode = prefs->folder_chmod;
420 if (filemode & S_IRGRP) filemode |= S_IWGRP;
421 if (filemode & S_IROTH) filemode |= S_IWOTH;
431 newmsginfo.msgnum = dest->last_num;
432 newmsginfo.flags = msginfo->flags;
433 if (dest->stype == F_OUTBOX ||
434 dest->stype == F_QUEUE ||
435 dest->stype == F_DRAFT ||
436 dest->stype == F_TRASH)
437 MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
438 MSG_NEW|MSG_UNREAD|MSG_DELETED);
439 procmsg_write_flags(&newmsginfo, fp);
443 fchmod(fileno(fp), filemode);
447 markfile = folder_item_get_mark_file(dest);
449 chmod(markfile, filemode);
458 return dest->last_num;
462 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
470 src_folder = msginfo->folder->folder;
472 g_return_val_if_fail(src_folder->fetch_msg != NULL, -1);
474 filename = src_folder->fetch_msg(src_folder,
477 if (filename == NULL)
480 num = folder->add_msg(folder, dest, filename, FALSE);
482 destdir = folder_item_get_path(dest);
483 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
484 g_warning(_("Can't open mark file.\n"));
489 newmsginfo.msgnum = dest->last_num;
490 newmsginfo.flags = msginfo->flags;
491 if (dest->stype == F_OUTBOX ||
492 dest->stype == F_QUEUE ||
493 dest->stype == F_DRAFT ||
494 dest->stype == F_TRASH)
495 MSG_UNSET_FLAGS(newmsginfo.flags,
496 MSG_NEW|MSG_UNREAD|MSG_DELETED);
498 procmsg_write_flags(&newmsginfo, fp);
506 gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
515 g_return_val_if_fail(dest != NULL, -1);
516 g_return_val_if_fail(msglist != NULL, -1);
518 if (dest->last_num < 0) {
519 mh_scan_folder(folder, dest);
520 if (dest->last_num < 0) return -1;
523 destdir = folder_item_get_path(dest);
524 if (!is_dir_exist(destdir))
525 make_dir_hier(destdir);
527 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
528 g_warning(_("Can't open mark file.\n"));
530 for (cur = msglist; cur != NULL; cur = cur->next) {
531 msginfo = (MsgInfo *)cur->data;
533 if (msginfo->folder == dest) {
534 g_warning(_("the src folder is identical to the dest.\n"));
537 debug_print(_("Copying message %s%c%d to %s ...\n"),
538 msginfo->folder->path, G_DIR_SEPARATOR,
539 msginfo->msgnum, dest->path);
541 srcfile = procmsg_get_message_file_path(msginfo);
542 destfile = mh_get_newmsg_filename(dest);
548 if (copy_file(srcfile, destfile) < 0) {
549 FILE_OP_ERROR(srcfile, "copy");
562 newmsginfo.msgnum = dest->last_num;
563 newmsginfo.flags = msginfo->flags;
564 if (dest->stype == F_OUTBOX ||
565 dest->stype == F_QUEUE ||
566 dest->stype == F_DRAFT ||
567 dest->stype == F_TRASH)
570 MSG_NEW|MSG_UNREAD|MSG_DELETED);
571 procmsg_write_flags(&newmsginfo, fp);
578 return dest->last_num;
581 gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
585 g_return_val_if_fail(item != NULL, -1);
587 file = mh_fetch_msg(folder, item, num);
588 g_return_val_if_fail(file != NULL, -1);
590 if (unlink(file) < 0) {
591 FILE_OP_ERROR(file, "unlink");
600 gint mh_remove_all_msg(Folder *folder, FolderItem *item)
605 g_return_val_if_fail(item != NULL, -1);
607 path = folder_item_get_path(item);
608 g_return_val_if_fail(path != NULL, -1);
609 val = remove_all_numbered_files(path);
615 gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo)
619 if (stat(itos(msginfo->msgnum), &s) < 0 ||
620 msginfo->size != s.st_size ||
621 msginfo->mtime != s.st_mtime)
627 void mh_scan_folder(Folder *folder, FolderItem *item)
637 g_return_if_fail(item != NULL);
639 debug_print("mh_scan_folder(): Scanning %s ...\n", item->path);
641 path = folder_item_get_path(item);
642 g_return_if_fail(path != NULL);
643 if (change_dir(path) < 0) {
649 if ((dp = opendir(".")) == NULL) {
650 FILE_OP_ERROR(item->path, "opendir");
655 folder->ui_func(folder, item, folder->ui_func_data);
657 while ((d = readdir(dp)) != NULL) {
658 if ((num = to_number(d->d_name)) >= 0 &&
659 stat(d->d_name, &s) == 0 &&
660 S_ISREG(s.st_mode)) {
670 item->new = item->unread = item->total = 0;
672 gint new, unread, total;
674 procmsg_get_mark_sum(".", &new, &unread, &total);
676 new += n_msg - total;
677 unread += n_msg - total;
680 item->unread = unread;
684 debug_print(_("Last number in dir %s = %d\n"), item->path, max);
685 item->last_num = max;
688 void mh_scan_tree(Folder *folder)
694 g_return_if_fail(folder != NULL);
696 pptable = folder_persist_prefs_new(folder);
698 folder_tree_destroy(folder);
699 item = folder_item_new(folder->name, NULL);
700 item->folder = folder;
701 folder->node = g_node_new(item);
703 rootpath = folder_item_get_path(item);
704 if (change_dir(rootpath) < 0) {
710 mh_scan_tree_recursive(item, pptable);
712 folder_persist_prefs_free(pptable);
715 #define MAKE_DIR_IF_NOT_EXIST(dir) \
717 if (!is_dir_exist(dir)) { \
718 if (is_file_exist(dir)) { \
719 g_warning(_("File `%s' already exists.\n" \
720 "Can't create folder."), dir); \
723 if (mkdir(dir, S_IRWXU) < 0) { \
724 FILE_OP_ERROR(dir, "mkdir"); \
727 if (chmod(dir, S_IRWXU) < 0) \
728 FILE_OP_ERROR(dir, "chmod"); \
732 gint mh_create_tree(Folder *folder)
736 g_return_val_if_fail(folder != NULL, -1);
738 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), -1);
739 rootpath = LOCAL_FOLDER(folder)->rootpath;
740 MAKE_DIR_IF_NOT_EXIST(rootpath);
741 CHDIR_RETURN_VAL_IF_FAIL(rootpath, -1);
742 MAKE_DIR_IF_NOT_EXIST(INBOX_DIR);
743 MAKE_DIR_IF_NOT_EXIST(OUTBOX_DIR);
744 MAKE_DIR_IF_NOT_EXIST(QUEUE_DIR);
745 MAKE_DIR_IF_NOT_EXIST(DRAFT_DIR);
746 MAKE_DIR_IF_NOT_EXIST(TRASH_DIR);
751 #undef MAKE_DIR_IF_NOT_EXIST
753 FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
758 FolderItem *new_item;
760 g_return_val_if_fail(folder != NULL, NULL);
761 g_return_val_if_fail(parent != NULL, NULL);
762 g_return_val_if_fail(name != NULL, NULL);
764 path = folder_item_get_path(parent);
765 if (!is_dir_exist(path))
768 fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
771 if (mkdir(fullpath, S_IRWXU) < 0) {
772 FILE_OP_ERROR(fullpath, "mkdir");
776 if (chmod(fullpath, S_IRWXU) < 0)
777 FILE_OP_ERROR(fullpath, "chmod");
782 path = g_strconcat(parent->path, G_DIR_SEPARATOR_S, name,
785 path = g_strdup(name);
786 new_item = folder_item_new(name, path);
787 folder_item_append(parent, new_item);
793 gint mh_rename_folder(Folder *folder, FolderItem *item, const gchar *name)
801 g_return_val_if_fail(folder != NULL, -1);
802 g_return_val_if_fail(item != NULL, -1);
803 g_return_val_if_fail(item->path != NULL, -1);
804 g_return_val_if_fail(name != NULL, -1);
806 oldpath = folder_item_get_path(item);
807 if (!is_dir_exist(oldpath))
808 make_dir_hier(oldpath);
810 dirname = g_dirname(oldpath);
811 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
814 if (rename(oldpath, newpath) < 0) {
815 FILE_OP_ERROR(oldpath, "rename");
824 if (strchr(item->path, G_DIR_SEPARATOR) != NULL) {
825 dirname = g_dirname(item->path);
826 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
829 newpath = g_strdup(name);
832 item->name = g_strdup(name);
834 node = g_node_find(item->folder->node, G_PRE_ORDER, G_TRAVERSE_ALL,
836 paths[0] = g_strdup(item->path);
838 g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
839 mh_rename_folder_func, paths);
846 gint mh_remove_folder(Folder *folder, FolderItem *item)
850 g_return_val_if_fail(folder != NULL, -1);
851 g_return_val_if_fail(item != NULL, -1);
852 g_return_val_if_fail(item->path != NULL, -1);
854 path = folder_item_get_path(item);
855 if (remove_dir_recursive(path) < 0) {
856 g_warning("can't remove directory `%s'\n", path);
862 folder_item_remove(item);
867 static GSList *mh_get_uncached_msgs(GHashTable *msg_table, FolderItem *item)
873 GSList *newlist = NULL;
879 g_return_val_if_fail(item != NULL, NULL);
881 path = folder_item_get_path(item);
882 g_return_val_if_fail(path != NULL, NULL);
883 if (change_dir(path) < 0) {
889 if ((dp = opendir(".")) == NULL) {
890 FILE_OP_ERROR(item->path, "opendir");
894 debug_print(_("\tSearching uncached messages... "));
897 while ((d = readdir(dp)) != NULL) {
898 if ((num = to_number(d->d_name)) < 0) continue;
899 if (stat(d->d_name, &s) < 0) {
900 FILE_OP_ERROR(d->d_name, "stat");
903 if (!S_ISREG(s.st_mode)) continue;
905 msginfo = g_hash_table_lookup
906 (msg_table, GUINT_TO_POINTER(num));
909 /* not found in the cache (uncached message) */
910 msginfo = mh_parse_msg(d->d_name, item);
911 if (!msginfo) continue;
915 g_slist_append(NULL, msginfo);
917 last = g_slist_append(last, msginfo);
924 /* discard all previous cache */
925 while ((d = readdir(dp)) != NULL) {
926 if (to_number(d->d_name) < 0) continue;
927 if (stat(d->d_name, &s) < 0) {
928 FILE_OP_ERROR(d->d_name, "stat");
931 if (!S_ISREG(s.st_mode)) continue;
933 msginfo = mh_parse_msg(d->d_name, item);
934 if (!msginfo) continue;
937 last = newlist = g_slist_append(NULL, msginfo);
939 last = g_slist_append(last, msginfo);
949 debug_print(_("%d uncached message(s) found.\n"), n_newmsg);
951 debug_print(_("done.\n"));
953 /* sort new messages in numerical order */
955 debug_print(_("\tSorting uncached messages in numerical order... "));
956 newlist = g_slist_sort
957 (newlist, (GCompareFunc)procmsg_cmp_msgnum_for_sort);
958 debug_print(_("done.\n"));
964 static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
970 flags.perm_flags = MSG_NEW|MSG_UNREAD;
973 g_return_val_if_fail(item != NULL, NULL);
974 g_return_val_if_fail(file != NULL, NULL);
976 if (item->stype == F_QUEUE) {
977 MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
978 } else if (item->stype == F_DRAFT) {
979 MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
982 msginfo = procheader_parse(file, flags, FALSE, FALSE);
983 if (!msginfo) return NULL;
985 msginfo->msgnum = atoi(file);
986 msginfo->folder = item;
988 if (stat(file, &s) < 0) {
989 FILE_OP_ERROR(file, "stat");
993 msginfo->size = s.st_size;
994 msginfo->mtime = s.st_mtime;
1000 static gboolean mh_is_maildir_one(const gchar *path, const gchar *dir)
1005 entry = g_strconcat(path, G_DIR_SEPARATOR_S, dir, NULL);
1006 result = is_dir_exist(entry);
1013 * check whether PATH is a Maildir style mailbox.
1014 * This is the case if the 3 subdir: new, cur, tmp are existing.
1015 * This functon assumes that entry is an directory
1017 static gboolean mh_is_maildir(const gchar *path)
1019 return mh_is_maildir_one(path, "new") &&
1020 mh_is_maildir_one(path, "cur") &&
1021 mh_is_maildir_one(path, "tmp");
1024 static void mh_scan_tree_recursive(FolderItem *item, GHashTable *pptable)
1032 g_return_if_fail(item != NULL);
1033 g_return_if_fail(item->folder != NULL);
1035 dp = opendir(item->path ? item->path : ".");
1037 FILE_OP_ERROR(item->path ? item->path : ".", "opendir");
1041 debug_print("scanning %s ...\n",
1042 item->path ? item->path
1043 : LOCAL_FOLDER(item->folder)->rootpath);
1044 if (item->folder->ui_func)
1045 item->folder->ui_func(item->folder, item,
1046 item->folder->ui_func_data);
1048 while ((d = readdir(dp)) != NULL) {
1049 if (d->d_name[0] == '.') continue;
1052 entry = g_strconcat(item->path, G_DIR_SEPARATOR_S,
1055 entry = g_strdup(d->d_name);
1057 if (stat(entry, &s) < 0) {
1058 FILE_OP_ERROR(entry, "stat");
1063 if (S_ISDIR(s.st_mode)) {
1064 FolderItem *new_item;
1066 if (mh_is_maildir(entry)) {
1071 new_item = folder_item_new(d->d_name, entry);
1072 folder_item_append(item, new_item);
1074 if (!strcmp(d->d_name, "inbox")) {
1075 new_item->stype = F_INBOX;
1076 item->folder->inbox = new_item;
1077 } else if (!strcmp(d->d_name, "outbox")) {
1078 new_item->stype = F_OUTBOX;
1079 item->folder->outbox = new_item;
1080 } else if (!strcmp(d->d_name, "draft")) {
1081 new_item->stype = F_DRAFT;
1082 item->folder->draft = new_item;
1083 } else if (!strcmp(d->d_name, "queue")) {
1084 new_item->stype = F_QUEUE;
1085 item->folder->queue = new_item;
1086 } else if (!strcmp(d->d_name, "trash")) {
1087 new_item->stype = F_TRASH;
1088 item->folder->trash = new_item;
1091 folder_item_restore_persist_prefs(new_item, pptable);
1092 mh_scan_tree_recursive(new_item, pptable);
1093 } else if (to_number(d->d_name) != -1) n_msg++;
1101 gint new, unread, total;
1103 procmsg_get_mark_sum(item->path, &new, &unread, &total);
1104 if (n_msg > total) {
1105 new += n_msg - total;
1106 unread += n_msg - total;
1109 item->unread = unread;
1110 item->total = n_msg;
1114 static gboolean mh_rename_folder_func(GNode *node, gpointer data)
1116 FolderItem *item = node->data;
1117 gchar **paths = data;
1118 const gchar *oldpath = paths[0];
1119 const gchar *newpath = paths[1];
1121 gchar *new_itempath;
1124 oldpathlen = strlen(oldpath);
1125 if (strncmp(oldpath, item->path, oldpathlen) != 0) {
1126 g_warning("path doesn't match: %s, %s\n", oldpath, item->path);
1130 base = item->path + oldpathlen;
1131 while (*base == G_DIR_SEPARATOR) base++;
1133 new_itempath = g_strdup(newpath);
1135 new_itempath = g_strconcat(newpath, G_DIR_SEPARATOR_S, base,
1138 item->path = new_itempath;