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 gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file,
135 gboolean remove_source)
140 g_return_val_if_fail(dest != NULL, -1);
141 g_return_val_if_fail(file != NULL, -1);
143 if (dest->last_num < 0) {
144 mh_scan_folder(folder, dest);
145 if (dest->last_num < 0) return -1;
148 destpath = folder_item_get_path(dest);
149 g_return_val_if_fail(destpath != NULL, -1);
150 if (!is_dir_exist(destpath))
151 make_dir_hier(destpath);
153 destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR,
156 if (link(file, destfile) < 0) {
157 if (copy_file(file, destfile) < 0) {
158 g_warning(_("can't copy message %s to %s\n"),
166 if (unlink(file) < 0)
167 FILE_OP_ERROR(file, "unlink");
172 return dest->last_num;
175 gint mh_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
182 PrefsFolderItem *prefs;
184 g_return_val_if_fail(dest != NULL, -1);
185 g_return_val_if_fail(msginfo != NULL, -1);
187 if (msginfo->folder == dest) {
188 g_warning(_("the src folder is identical to the dest.\n"));
192 if (dest->last_num < 0) {
193 mh_scan_folder(folder, dest);
194 if (dest->last_num < 0) return -1;
199 destdir = folder_item_get_path(dest);
200 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
201 g_warning(_("Can't open mark file.\n"));
203 debug_print(_("Moving message %s%c%d to %s ...\n"),
204 msginfo->folder->path, G_DIR_SEPARATOR,
205 msginfo->msgnum, dest->path);
206 srcfile = procmsg_get_message_file_path(msginfo);
207 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
211 if (move_file(srcfile, destfile) < 0) {
218 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
219 if (chmod(destfile, prefs->folder_chmod) < 0)
220 FILE_OP_ERROR(destfile, "chmod");
223 filemode = prefs->folder_chmod;
224 if (filemode & S_IRGRP) filemode |= S_IWGRP;
225 if (filemode & S_IROTH) filemode |= S_IWOTH;
235 newmsginfo.msgnum = dest->last_num;
236 newmsginfo.flags = msginfo->flags;
237 if (dest->stype == F_OUTBOX ||
238 dest->stype == F_QUEUE ||
239 dest->stype == F_DRAFT ||
240 dest->stype == F_TRASH)
241 MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
242 MSG_NEW|MSG_UNREAD|MSG_DELETED);
244 procmsg_write_flags(&newmsginfo, fp);
248 fchmod(fileno(fp), filemode);
252 markfile = folder_item_get_mark_file(dest);
254 chmod(markfile, filemode);
263 return dest->last_num;
266 gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
274 PrefsFolderItem *prefs;
276 g_return_val_if_fail(dest != NULL, -1);
277 g_return_val_if_fail(msglist != NULL, -1);
279 if (dest->last_num < 0) {
280 mh_scan_folder(folder, dest);
281 if (dest->last_num < 0) return -1;
286 destdir = folder_item_get_path(dest);
287 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
288 g_warning(_("Can't open mark file.\n"));
290 for (cur = msglist; cur != NULL; cur = cur->next) {
291 msginfo = (MsgInfo *)cur->data;
293 if (msginfo->folder == dest) {
294 g_warning(_("the src folder is identical to the dest.\n"));
297 debug_print(_("Moving message %s%c%d to %s ...\n"),
298 msginfo->folder->path, G_DIR_SEPARATOR,
299 msginfo->msgnum, dest->path);
301 srcfile = procmsg_get_message_file_path(msginfo);
302 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
305 if (move_file(srcfile, destfile) < 0) {
318 newmsginfo.msgnum = dest->last_num;
319 newmsginfo.flags = msginfo->flags;
320 if (dest->stype == F_OUTBOX ||
321 dest->stype == F_QUEUE ||
322 dest->stype == F_DRAFT ||
323 dest->stype == F_TRASH)
326 MSG_NEW|MSG_UNREAD|MSG_DELETED);
328 procmsg_write_flags(&newmsginfo, fp);
335 return dest->last_num;
338 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
345 PrefsFolderItem *prefs;
347 g_return_val_if_fail(dest != NULL, -1);
348 g_return_val_if_fail(msginfo != NULL, -1);
350 if (msginfo->folder == dest) {
351 g_warning(_("the src folder is identical to the dest.\n"));
355 if (dest->last_num < 0) {
356 mh_scan_folder(folder, dest);
357 if (dest->last_num < 0) return -1;
362 destdir = folder_item_get_path(dest);
363 if (!is_dir_exist(destdir))
364 make_dir_hier(destdir);
366 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
367 g_warning(_("Can't open mark file.\n"));
369 debug_print(_("Copying message %s%c%d to %s ...\n"),
370 msginfo->folder->path, G_DIR_SEPARATOR,
371 msginfo->msgnum, dest->path);
372 srcfile = procmsg_get_message_file_path(msginfo);
373 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
379 if (is_file_exist(destfile)) {
380 g_warning(_("%s already exists."), destfile);
387 if (copy_file(srcfile, destfile) < 0) {
388 FILE_OP_ERROR(srcfile, "copy");
395 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
396 if (chmod(destfile, prefs->folder_chmod) < 0)
397 FILE_OP_ERROR(destfile, "chmod");
400 filemode = prefs->folder_chmod;
401 if (filemode & S_IRGRP) filemode |= S_IWGRP;
402 if (filemode & S_IROTH) filemode |= S_IWOTH;
412 newmsginfo.msgnum = dest->last_num;
413 newmsginfo.flags = msginfo->flags;
414 if (dest->stype == F_OUTBOX ||
415 dest->stype == F_QUEUE ||
416 dest->stype == F_DRAFT ||
417 dest->stype == F_TRASH)
418 MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
419 MSG_NEW|MSG_UNREAD|MSG_DELETED);
420 procmsg_write_flags(&newmsginfo, fp);
424 fchmod(fileno(fp), filemode);
428 markfile = folder_item_get_mark_file(dest);
430 chmod(markfile, filemode);
439 return dest->last_num;
443 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
451 src_folder = msginfo->folder->folder;
453 g_return_val_if_fail(src_folder->fetch_msg != NULL, -1);
455 filename = src_folder->fetch_msg(src_folder,
458 if (filename == NULL)
461 num = folder->add_msg(folder, dest, filename, FALSE);
463 destdir = folder_item_get_path(dest);
464 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
465 g_warning(_("Can't open mark file.\n"));
470 newmsginfo.msgnum = dest->last_num;
471 newmsginfo.flags = msginfo->flags;
472 if (dest->stype == F_OUTBOX ||
473 dest->stype == F_QUEUE ||
474 dest->stype == F_DRAFT ||
475 dest->stype == F_TRASH)
476 MSG_UNSET_FLAGS(newmsginfo.flags,
477 MSG_NEW|MSG_UNREAD|MSG_DELETED);
479 procmsg_write_flags(&newmsginfo, fp);
487 gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
496 g_return_val_if_fail(dest != NULL, -1);
497 g_return_val_if_fail(msglist != NULL, -1);
499 if (dest->last_num < 0) {
500 mh_scan_folder(folder, dest);
501 if (dest->last_num < 0) return -1;
504 destdir = folder_item_get_path(dest);
505 if (!is_dir_exist(destdir))
506 make_dir_hier(destdir);
508 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
509 g_warning(_("Can't open mark file.\n"));
511 for (cur = msglist; cur != NULL; cur = cur->next) {
512 msginfo = (MsgInfo *)cur->data;
514 if (msginfo->folder == dest) {
515 g_warning(_("the src folder is identical to the dest.\n"));
518 debug_print(_("Copying message %s%c%d to %s ...\n"),
519 msginfo->folder->path, G_DIR_SEPARATOR,
520 msginfo->msgnum, dest->path);
522 srcfile = procmsg_get_message_file_path(msginfo);
523 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
526 if (is_file_exist(destfile)) {
527 g_warning(_("%s already exists."), destfile);
533 if (copy_file(srcfile, destfile) < 0) {
534 FILE_OP_ERROR(srcfile, "copy");
547 newmsginfo.msgnum = dest->last_num;
548 newmsginfo.flags = msginfo->flags;
549 if (dest->stype == F_OUTBOX ||
550 dest->stype == F_QUEUE ||
551 dest->stype == F_DRAFT ||
552 dest->stype == F_TRASH)
555 MSG_NEW|MSG_UNREAD|MSG_DELETED);
556 procmsg_write_flags(&newmsginfo, fp);
563 return dest->last_num;
566 gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
570 g_return_val_if_fail(item != NULL, -1);
572 file = mh_fetch_msg(folder, item, num);
573 g_return_val_if_fail(file != NULL, -1);
575 if (unlink(file) < 0) {
576 FILE_OP_ERROR(file, "unlink");
585 gint mh_remove_all_msg(Folder *folder, FolderItem *item)
590 g_return_val_if_fail(item != NULL, -1);
592 path = folder_item_get_path(item);
593 g_return_val_if_fail(path != NULL, -1);
594 val = remove_all_numbered_files(path);
600 gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo)
604 if (stat(itos(msginfo->msgnum), &s) < 0 ||
605 msginfo->size != s.st_size ||
606 msginfo->mtime != s.st_mtime)
612 void mh_scan_folder(Folder *folder, FolderItem *item)
622 g_return_if_fail(item != NULL);
624 debug_print("mh_scan_folder(): Scanning %s ...\n", item->path);
626 path = folder_item_get_path(item);
627 g_return_if_fail(path != NULL);
628 if (change_dir(path) < 0) {
634 if ((dp = opendir(".")) == NULL) {
635 FILE_OP_ERROR(item->path, "opendir");
640 folder->ui_func(folder, item, folder->ui_func_data);
642 while ((d = readdir(dp)) != NULL) {
643 if ((num = to_number(d->d_name)) >= 0 &&
644 stat(d->d_name, &s) == 0 &&
645 S_ISREG(s.st_mode)) {
655 item->new = item->unread = item->total = 0;
657 gint new, unread, total;
659 procmsg_get_mark_sum(".", &new, &unread, &total);
661 new += n_msg - total;
662 unread += n_msg - total;
665 item->unread = unread;
669 debug_print(_("Last number in dir %s = %d\n"), item->path, max);
670 item->last_num = max;
673 void mh_scan_tree(Folder *folder)
679 g_return_if_fail(folder != NULL);
681 pptable = folder_persist_prefs_new(folder);
683 folder_tree_destroy(folder);
684 item = folder_item_new(folder->name, NULL);
685 item->folder = folder;
686 folder->node = g_node_new(item);
688 rootpath = folder_item_get_path(item);
689 if (change_dir(rootpath) < 0) {
695 mh_scan_tree_recursive(item, pptable);
697 folder_persist_prefs_free(pptable);
700 #define MAKE_DIR_IF_NOT_EXIST(dir) \
702 if (!is_dir_exist(dir)) { \
703 if (is_file_exist(dir)) { \
704 g_warning(_("File `%s' already exists.\n" \
705 "Can't create folder."), dir); \
708 if (mkdir(dir, S_IRWXU) < 0) { \
709 FILE_OP_ERROR(dir, "mkdir"); \
712 if (chmod(dir, S_IRWXU) < 0) \
713 FILE_OP_ERROR(dir, "chmod"); \
717 gint mh_create_tree(Folder *folder)
721 g_return_val_if_fail(folder != NULL, -1);
723 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), -1);
724 rootpath = LOCAL_FOLDER(folder)->rootpath;
725 MAKE_DIR_IF_NOT_EXIST(rootpath);
726 CHDIR_RETURN_VAL_IF_FAIL(rootpath, -1);
727 MAKE_DIR_IF_NOT_EXIST(INBOX_DIR);
728 MAKE_DIR_IF_NOT_EXIST(OUTBOX_DIR);
729 MAKE_DIR_IF_NOT_EXIST(QUEUE_DIR);
730 MAKE_DIR_IF_NOT_EXIST(DRAFT_DIR);
731 MAKE_DIR_IF_NOT_EXIST(TRASH_DIR);
736 #undef MAKE_DIR_IF_NOT_EXIST
738 FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
743 FolderItem *new_item;
745 g_return_val_if_fail(folder != NULL, NULL);
746 g_return_val_if_fail(parent != NULL, NULL);
747 g_return_val_if_fail(name != NULL, NULL);
749 path = folder_item_get_path(parent);
750 if (!is_dir_exist(path))
753 fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
756 if (mkdir(fullpath, S_IRWXU) < 0) {
757 FILE_OP_ERROR(fullpath, "mkdir");
761 if (chmod(fullpath, S_IRWXU) < 0)
762 FILE_OP_ERROR(fullpath, "chmod");
767 path = g_strconcat(parent->path, G_DIR_SEPARATOR_S, name,
770 path = g_strdup(name);
771 new_item = folder_item_new(name, path);
772 folder_item_append(parent, new_item);
778 gint mh_rename_folder(Folder *folder, FolderItem *item, const gchar *name)
786 g_return_val_if_fail(folder != NULL, -1);
787 g_return_val_if_fail(item != NULL, -1);
788 g_return_val_if_fail(item->path != NULL, -1);
789 g_return_val_if_fail(name != NULL, -1);
791 oldpath = folder_item_get_path(item);
792 if (!is_dir_exist(oldpath))
793 make_dir_hier(oldpath);
795 dirname = g_dirname(oldpath);
796 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
799 if (rename(oldpath, newpath) < 0) {
800 FILE_OP_ERROR(oldpath, "rename");
809 if (strchr(item->path, G_DIR_SEPARATOR) != NULL) {
810 dirname = g_dirname(item->path);
811 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
814 newpath = g_strdup(name);
817 item->name = g_strdup(name);
819 node = g_node_find(item->folder->node, G_PRE_ORDER, G_TRAVERSE_ALL,
821 paths[0] = g_strdup(item->path);
823 g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
824 mh_rename_folder_func, paths);
831 gint mh_remove_folder(Folder *folder, FolderItem *item)
835 g_return_val_if_fail(folder != NULL, -1);
836 g_return_val_if_fail(item != NULL, -1);
837 g_return_val_if_fail(item->path != NULL, -1);
839 path = folder_item_get_path(item);
840 if (remove_dir_recursive(path) < 0) {
841 g_warning("can't remove directory `%s'\n", path);
847 folder_item_remove(item);
852 static GSList *mh_get_uncached_msgs(GHashTable *msg_table, FolderItem *item)
858 GSList *newlist = NULL;
864 g_return_val_if_fail(item != NULL, NULL);
866 path = folder_item_get_path(item);
867 g_return_val_if_fail(path != NULL, NULL);
868 if (change_dir(path) < 0) {
874 if ((dp = opendir(".")) == NULL) {
875 FILE_OP_ERROR(item->path, "opendir");
879 debug_print(_("\tSearching uncached messages... "));
882 while ((d = readdir(dp)) != NULL) {
883 if ((num = to_number(d->d_name)) < 0) continue;
884 if (stat(d->d_name, &s) < 0) {
885 FILE_OP_ERROR(d->d_name, "stat");
888 if (!S_ISREG(s.st_mode)) continue;
890 msginfo = g_hash_table_lookup
891 (msg_table, GUINT_TO_POINTER(num));
894 /* not found in the cache (uncached message) */
895 msginfo = mh_parse_msg(d->d_name, item);
896 if (!msginfo) continue;
900 g_slist_append(NULL, msginfo);
902 last = g_slist_append(last, msginfo);
909 /* discard all previous cache */
910 while ((d = readdir(dp)) != NULL) {
911 if (to_number(d->d_name) < 0) continue;
912 if (stat(d->d_name, &s) < 0) {
913 FILE_OP_ERROR(d->d_name, "stat");
916 if (!S_ISREG(s.st_mode)) continue;
918 msginfo = mh_parse_msg(d->d_name, item);
919 if (!msginfo) continue;
922 last = newlist = g_slist_append(NULL, msginfo);
924 last = g_slist_append(last, msginfo);
934 debug_print(_("%d uncached message(s) found.\n"), n_newmsg);
936 debug_print(_("done.\n"));
938 /* sort new messages in numerical order */
940 debug_print(_("\tSorting uncached messages in numerical order... "));
941 newlist = g_slist_sort
942 (newlist, (GCompareFunc)procmsg_cmp_msgnum_for_sort);
943 debug_print(_("done.\n"));
949 static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
955 flags.perm_flags = MSG_NEW|MSG_UNREAD;
958 g_return_val_if_fail(item != NULL, NULL);
959 g_return_val_if_fail(file != NULL, NULL);
961 if (item->stype == F_QUEUE) {
962 MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
963 } else if (item->stype == F_DRAFT) {
964 MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
967 msginfo = procheader_parse(file, flags, FALSE, FALSE);
968 if (!msginfo) return NULL;
970 msginfo->msgnum = atoi(file);
971 msginfo->folder = item;
973 if (stat(file, &s) < 0) {
974 FILE_OP_ERROR(file, "stat");
978 msginfo->size = s.st_size;
979 msginfo->mtime = s.st_mtime;
985 static gboolean mh_is_maildir_one(const gchar *path, const gchar *dir)
990 entry = g_strconcat(path, G_DIR_SEPARATOR_S, dir, NULL);
991 result = is_dir_exist(entry);
998 * check whether PATH is a Maildir style mailbox.
999 * This is the case if the 3 subdir: new, cur, tmp are existing.
1000 * This functon assumes that entry is an directory
1002 static gboolean mh_is_maildir(const gchar *path)
1004 return mh_is_maildir_one(path, "new") &&
1005 mh_is_maildir_one(path, "cur") &&
1006 mh_is_maildir_one(path, "tmp");
1009 static void mh_scan_tree_recursive(FolderItem *item, GHashTable *pptable)
1017 g_return_if_fail(item != NULL);
1018 g_return_if_fail(item->folder != NULL);
1020 dp = opendir(item->path ? item->path : ".");
1022 FILE_OP_ERROR(item->path ? item->path : ".", "opendir");
1026 debug_print("scanning %s ...\n",
1027 item->path ? item->path
1028 : LOCAL_FOLDER(item->folder)->rootpath);
1029 if (item->folder->ui_func)
1030 item->folder->ui_func(item->folder, item,
1031 item->folder->ui_func_data);
1033 while ((d = readdir(dp)) != NULL) {
1034 if (d->d_name[0] == '.') continue;
1037 entry = g_strconcat(item->path, G_DIR_SEPARATOR_S,
1040 entry = g_strdup(d->d_name);
1042 if (stat(entry, &s) < 0) {
1043 FILE_OP_ERROR(entry, "stat");
1048 if (S_ISDIR(s.st_mode)) {
1049 FolderItem *new_item;
1051 if (mh_is_maildir(entry)) {
1056 new_item = folder_item_new(d->d_name, entry);
1057 folder_item_append(item, new_item);
1059 if (!strcmp(d->d_name, "inbox")) {
1060 new_item->stype = F_INBOX;
1061 item->folder->inbox = new_item;
1062 } else if (!strcmp(d->d_name, "outbox")) {
1063 new_item->stype = F_OUTBOX;
1064 item->folder->outbox = new_item;
1065 } else if (!strcmp(d->d_name, "draft")) {
1066 new_item->stype = F_DRAFT;
1067 item->folder->draft = new_item;
1068 } else if (!strcmp(d->d_name, "queue")) {
1069 new_item->stype = F_QUEUE;
1070 item->folder->queue = new_item;
1071 } else if (!strcmp(d->d_name, "trash")) {
1072 new_item->stype = F_TRASH;
1073 item->folder->trash = new_item;
1076 folder_item_restore_persist_prefs(new_item, pptable);
1077 mh_scan_tree_recursive(new_item, pptable);
1078 } else if (to_number(d->d_name) != -1) n_msg++;
1086 gint new, unread, total;
1088 procmsg_get_mark_sum(item->path, &new, &unread, &total);
1089 if (n_msg > total) {
1090 new += n_msg - total;
1091 unread += n_msg - total;
1094 item->unread = unread;
1095 item->total = n_msg;
1099 static gboolean mh_rename_folder_func(GNode *node, gpointer data)
1101 FolderItem *item = node->data;
1102 gchar **paths = data;
1103 const gchar *oldpath = paths[0];
1104 const gchar *newpath = paths[1];
1106 gchar *new_itempath;
1109 oldpathlen = strlen(oldpath);
1110 if (strncmp(oldpath, item->path, oldpathlen) != 0) {
1111 g_warning("path doesn't match: %s, %s\n", oldpath, item->path);
1115 base = item->path + oldpathlen;
1116 while (*base == G_DIR_SEPARATOR) base++;
1118 new_itempath = g_strdup(newpath);
1120 new_itempath = g_strconcat(newpath, G_DIR_SEPARATOR_S, base,
1123 item->path = new_itempath;