2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 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 void mh_folder_init (Folder *folder,
50 GSList *mh_get_msg_list (Folder *folder,
53 gchar *mh_fetch_msg (Folder *folder,
56 MsgInfo *mh_get_msginfo (Folder *folder,
59 gint mh_add_msg (Folder *folder,
62 gboolean remove_source);
63 gint mh_move_msg (Folder *folder,
66 gint mh_move_msgs_with_dest (Folder *folder,
69 gint mh_copy_msg (Folder *folder,
72 gint mh_copy_msgs_with_dest (Folder *folder,
75 gint mh_remove_msg (Folder *folder,
78 gint mh_remove_all_msg (Folder *folder,
80 gboolean mh_is_msg_changed (Folder *folder,
84 gint mh_scan_folder (Folder *folder,
86 gint mh_get_num_list (Folder *folder,
89 void mh_scan_tree (Folder *folder);
91 gint mh_create_tree (Folder *folder);
92 FolderItem *mh_create_folder (Folder *folder,
95 gint mh_rename_folder (Folder *folder,
98 gint mh_remove_folder (Folder *folder,
101 gchar *mh_get_new_msg_filename (FolderItem *dest);
103 static MsgInfo *mh_parse_msg (const gchar *file,
105 static void mh_scan_tree_recursive (FolderItem *item);
107 static gboolean mh_rename_folder_func (GNode *node,
111 Folder *mh_folder_new(const gchar *name, const gchar *path)
115 folder = (Folder *)g_new0(MHFolder, 1);
116 mh_folder_init(folder, name, path);
121 void mh_folder_destroy(Folder *folder)
123 folder_local_folder_destroy(LOCAL_FOLDER(folder));
126 static void mh_folder_init(Folder *folder, const gchar *name, const gchar *path)
130 folder_local_folder_init(folder, name, path);
132 /* folder->get_msg_list = mh_get_msg_list; */
133 folder->fetch_msg = mh_fetch_msg;
134 folder->get_msginfo = mh_get_msginfo;
135 folder->add_msg = mh_add_msg;
136 folder->move_msg = mh_move_msg;
137 folder->move_msgs_with_dest = mh_move_msgs_with_dest;
138 folder->copy_msg = mh_copy_msg;
139 folder->copy_msgs_with_dest = mh_copy_msgs_with_dest;
140 folder->remove_msg = mh_remove_msg;
141 folder->remove_all_msg = mh_remove_all_msg;
142 folder->is_msg_changed = mh_is_msg_changed;
143 /* folder->scan = mh_scan_folder; */
144 folder->get_num_list = mh_get_num_list;
145 folder->scan_tree = mh_scan_tree;
146 folder->create_tree = mh_create_tree;
147 folder->create_folder = mh_create_folder;
148 folder->rename_folder = mh_rename_folder;
149 folder->remove_folder = mh_remove_folder;
150 folder->destroy = mh_folder_destroy;
153 void mh_get_last_num(Folder *folder, FolderItem *item)
162 g_return_if_fail(item != NULL);
164 debug_print("mh_get_last_num(): Scanning %s ...\n", item->path);
166 path = folder_item_get_path(item);
167 g_return_if_fail(path != NULL);
168 if (change_dir(path) < 0) {
174 if ((dp = opendir(".")) == NULL) {
175 FILE_OP_ERROR(item->path, "opendir");
179 while ((d = readdir(dp)) != NULL) {
180 if ((num = to_number(d->d_name)) >= 0 &&
181 stat(d->d_name, &s) == 0 &&
182 S_ISREG(s.st_mode)) {
189 debug_print("Last number in dir %s = %d\n", item->path, max);
190 item->last_num = max;
193 gint mh_get_num_list(Folder *folder, FolderItem *item, GSList **list)
200 gint num, nummsgs = 0;
202 g_return_val_if_fail(item != NULL, -1);
204 debug_print("mh_get_last_num(): Scanning %s ...\n", item->path);
206 path = folder_item_get_path(item);
207 g_return_val_if_fail(path != NULL, -1);
208 if (change_dir(path) < 0) {
214 if ((dp = opendir(".")) == NULL) {
215 FILE_OP_ERROR(item->path, "opendir");
219 while ((d = readdir(dp)) != NULL) {
220 if ((num = to_number(d->d_name)) >= 0 &&
221 stat(d->d_name, &s) == 0 &&
222 S_ISREG(s.st_mode)) {
223 *list = g_slist_prepend(*list, GINT_TO_POINTER(num));
232 gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
237 g_return_val_if_fail(item != NULL, NULL);
238 g_return_val_if_fail(num > 0, NULL);
240 path = folder_item_get_path(item);
241 file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
243 if (!is_file_exist(file)) {
251 MsgInfo *mh_get_msginfo(Folder *folder, FolderItem *item, gint num)
256 g_return_val_if_fail(item != NULL, NULL);
257 g_return_val_if_fail(num > 0, NULL);
259 file = mh_fetch_msg(folder, item, num);
260 if (!file) return NULL;
262 msginfo = mh_parse_msg(file, item);
264 msginfo->msgnum = num;
271 gchar *mh_get_new_msg_filename(FolderItem *dest)
276 destpath = folder_item_get_path(dest);
277 g_return_val_if_fail(destpath != NULL, NULL);
279 if (!is_dir_exist(destpath))
280 make_dir_hier(destpath);
283 destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR,
285 if (is_file_entry_exist(destfile)) {
297 #define SET_DEST_MSG_FLAGS(fp, dest, msginfo) \
299 MsgInfo newmsginfo; \
301 newmsginfo.msgnum = dest->last_num; \
302 newmsginfo.flags = msginfo->flags; \
303 if (dest->stype == F_OUTBOX || \
304 dest->stype == F_QUEUE || \
305 dest->stype == F_DRAFT || \
306 dest->stype == F_TRASH) \
307 MSG_UNSET_PERM_FLAGS(newmsginfo.flags, \
308 MSG_NEW|MSG_UNREAD|MSG_DELETED); \
310 procmsg_write_flags(&newmsginfo, fp); \
313 gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file,
314 gboolean remove_source)
318 g_return_val_if_fail(dest != NULL, -1);
319 g_return_val_if_fail(file != NULL, -1);
321 if (dest->last_num < 0) {
322 mh_get_last_num(folder, dest);
323 if (dest->last_num < 0) return -1;
326 destfile = mh_get_new_msg_filename(dest);
327 g_return_val_if_fail(destfile != NULL, -1);
329 if (link(file, destfile) < 0) {
330 if (copy_file(file, destfile, TRUE) < 0) {
331 g_warning("can't copy message %s to %s\n",
339 if (unlink(file) < 0)
340 FILE_OP_ERROR(file, "unlink");
345 return dest->last_num;
348 static gint mh_do_move(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
353 PrefsFolderItem *prefs;
355 g_return_val_if_fail(dest != NULL, -1);
356 g_return_val_if_fail(msginfo != NULL, -1);
358 if (msginfo->folder == dest) {
359 g_warning("the src folder is identical to the dest.\n");
363 if (dest->last_num < 0) {
364 mh_get_last_num(folder, dest);
365 if (dest->last_num < 0) return -1;
370 destfile = mh_get_new_msg_filename(dest);
371 if (!destfile) return -1;
373 srcfile = procmsg_get_message_file(msginfo);
375 debug_print("Moving message %s%c%d to %s ...\n",
376 msginfo->folder->path, G_DIR_SEPARATOR,
377 msginfo->msgnum, dest->path);
379 if (move_file(srcfile, destfile, FALSE) < 0) {
385 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
386 if (chmod(destfile, prefs->folder_chmod) < 0)
387 FILE_OP_ERROR(destfile, "chmod");
390 filemode = prefs->folder_chmod;
391 if (filemode & S_IRGRP) filemode |= S_IWGRP;
392 if (filemode & S_IROTH) filemode |= S_IWOTH;
399 return dest->last_num;
402 gint mh_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
407 g_return_val_if_fail(folder != NULL, -1);
408 g_return_val_if_fail(dest != NULL, -1);
409 g_return_val_if_fail(msginfo != NULL, -1);
410 g_return_val_if_fail(msginfo->folder != NULL, -1);
412 if (folder == msginfo->folder->folder)
413 return mh_do_move(folder, dest, msginfo);
415 srcfile = procmsg_get_message_file(msginfo);
416 if (!srcfile) return -1;
418 ret = mh_add_msg(folder, dest, srcfile, FALSE);
422 ret = folder_item_remove_msg(msginfo->folder, msginfo->msgnum);
427 static gint mh_do_move_msgs_with_dest(Folder *folder, FolderItem *dest,
434 PrefsFolderItem *prefs;
436 g_return_val_if_fail(dest != NULL, -1);
437 g_return_val_if_fail(msglist != NULL, -1);
439 if (dest->last_num < 0) {
440 mh_get_last_num(folder, dest);
441 if (dest->last_num < 0) return -1;
446 for (cur = msglist; cur != NULL; cur = cur->next) {
447 msginfo = (MsgInfo *)cur->data;
449 if (msginfo->folder == dest) {
450 g_warning("the src folder is identical to the dest.\n");
453 debug_print("Moving message %s%c%d to %s ...\n",
454 msginfo->folder->path, G_DIR_SEPARATOR,
455 msginfo->msgnum, dest->path);
457 destfile = mh_get_new_msg_filename(dest);
458 if (!destfile) return -1;
459 srcfile = procmsg_get_message_file(msginfo);
461 if (move_file(srcfile, destfile, FALSE) < 0) {
472 return dest->last_num;
475 gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
481 msginfo = (MsgInfo *)msglist->data;
482 if (folder == msginfo->folder->folder)
483 return mh_do_move_msgs_with_dest(folder, dest, msglist);
485 for (cur = msglist; cur != NULL; cur = cur->next) {
486 msginfo = (MsgInfo *)cur->data;
487 ret = mh_move_msg(folder, dest, msginfo);
488 if (ret == -1) break;
494 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
499 PrefsFolderItem *prefs;
501 g_return_val_if_fail(dest != NULL, -1);
502 g_return_val_if_fail(msginfo != NULL, -1);
504 if (msginfo->folder == dest) {
505 g_warning("the src folder is identical to the dest.\n");
509 if (dest->last_num < 0) {
510 mh_get_last_num(folder, dest);
511 if (dest->last_num < 0) return -1;
516 srcfile = procmsg_get_message_file(msginfo);
517 destfile = mh_get_new_msg_filename(dest);
523 debug_print("Copying message %s%c%d to %s ...\n",
524 msginfo->folder->path, G_DIR_SEPARATOR,
525 msginfo->msgnum, dest->path);
528 if ((MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags))
529 && dest->stype != F_QUEUE && dest->stype != F_DRAFT) {
530 if (procmsg_remove_special_headers(srcfile, destfile) !=0) {
535 } else if (copy_file(srcfile, destfile, TRUE) < 0) {
536 FILE_OP_ERROR(srcfile, "copy");
543 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
544 if (chmod(destfile, prefs->folder_chmod) < 0)
545 FILE_OP_ERROR(destfile, "chmod");
548 filemode = prefs->folder_chmod;
549 if (filemode & S_IRGRP) filemode |= S_IWGRP;
550 if (filemode & S_IROTH) filemode |= S_IWOTH;
557 return dest->last_num;
561 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
569 src_folder = msginfo->folder->folder;
571 g_return_val_if_fail(src_folder->fetch_msg != NULL, -1);
573 filename = src_folder->fetch_msg(src_folder,
576 if (filename == NULL)
579 num = folder->add_msg(folder, dest, filename, FALSE);
581 destdir = folder_item_get_path(dest);
586 newmsginfo.msgnum = dest->last_num;
587 newmsginfo.flags = msginfo->flags;
588 if (dest->stype == F_OUTBOX ||
589 dest->stype == F_QUEUE ||
590 dest->stype == F_DRAFT ||
591 dest->stype == F_TRASH)
592 MSG_UNSET_FLAGS(newmsginfo.flags,
593 MSG_NEW|MSG_UNREAD|MSG_DELETED);
595 procmsg_write_flags(&newmsginfo, fp);
603 gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
610 g_return_val_if_fail(dest != NULL, -1);
611 g_return_val_if_fail(msglist != NULL, -1);
613 if (dest->last_num < 0) {
614 mh_get_last_num(folder, dest);
615 if (dest->last_num < 0) return -1;
618 for (cur = msglist; cur != NULL; cur = cur->next) {
619 msginfo = (MsgInfo *)cur->data;
621 if (msginfo->folder == dest) {
622 g_warning("the src folder is identical to the dest.\n");
625 debug_print("Copying message %s%c%d to %s ...\n",
626 msginfo->folder->path, G_DIR_SEPARATOR,
627 msginfo->msgnum, dest->path);
629 destfile = mh_get_new_msg_filename(dest);
630 if (!destfile) break;
631 srcfile = procmsg_get_message_file(msginfo);
633 if (copy_file(srcfile, destfile, TRUE) < 0) {
634 FILE_OP_ERROR(srcfile, "copy");
645 return dest->last_num;
648 gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
652 g_return_val_if_fail(item != NULL, -1);
654 file = mh_fetch_msg(folder, item, num);
655 g_return_val_if_fail(file != NULL, -1);
657 if (unlink(file) < 0) {
658 FILE_OP_ERROR(file, "unlink");
667 gint mh_remove_all_msg(Folder *folder, FolderItem *item)
672 g_return_val_if_fail(item != NULL, -1);
674 path = folder_item_get_path(item);
675 g_return_val_if_fail(path != NULL, -1);
676 val = remove_all_numbered_files(path);
682 gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo)
686 if (stat(itos(msginfo->msgnum), &s) < 0 ||
687 msginfo->size != s.st_size ||
688 msginfo->mtime != s.st_mtime)
694 gint mh_scan_folder(Folder *folder, FolderItem *item)
703 g_return_val_if_fail(item != NULL, -1);
705 debug_print("mh_scan_folder(): Scanning %s ...\n", item->path);
707 path = folder_item_get_path(item);
708 g_return_val_if_fail(path != NULL, -1);
709 if (change_dir(path) < 0) {
715 if ((dp = opendir(".")) == NULL) {
716 FILE_OP_ERROR(item->path, "opendir");
721 folder->ui_func(folder, item, folder->ui_func_data);
723 while ((d = readdir(dp)) != NULL) {
724 if ((num = to_number(d->d_name)) >= 0 &&
725 stat(d->d_name, &s) == 0 &&
726 S_ISREG(s.st_mode)) {
738 item->new = item->unread = item->total = 0;
740 gint new, unread, total, min, max;
742 procmsg_get_mark_sum(".", &new, &unread, &total, &min, &max, 0);
744 new += n_msg - total;
745 unread += n_msg - total;
748 item->unread = unread;
752 debug_print("Last number in dir %s = %d\n", item->path, max);
753 item->last_num = max;
758 void mh_scan_tree(Folder *folder)
763 g_return_if_fail(folder != NULL);
765 item = folder_item_new(folder, folder->name, NULL);
766 item->folder = folder;
767 folder->node = g_node_new(item);
769 rootpath = folder_item_get_path(item);
770 if (change_dir(rootpath) < 0) {
776 mh_create_tree(folder);
777 mh_scan_tree_recursive(item);
780 #define MAKE_DIR_IF_NOT_EXIST(dir) \
782 if (!is_dir_exist(dir)) { \
783 if (is_file_exist(dir)) { \
784 g_warning("File `%s' already exists.\n" \
785 "Can't create folder.", dir); \
788 if (make_dir(dir) < 0) \
793 gint mh_create_tree(Folder *folder)
797 g_return_val_if_fail(folder != NULL, -1);
799 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), -1);
800 rootpath = LOCAL_FOLDER(folder)->rootpath;
801 MAKE_DIR_IF_NOT_EXIST(rootpath);
802 CHDIR_RETURN_VAL_IF_FAIL(rootpath, -1);
803 MAKE_DIR_IF_NOT_EXIST(INBOX_DIR);
804 MAKE_DIR_IF_NOT_EXIST(OUTBOX_DIR);
805 MAKE_DIR_IF_NOT_EXIST(QUEUE_DIR);
806 MAKE_DIR_IF_NOT_EXIST(DRAFT_DIR);
807 MAKE_DIR_IF_NOT_EXIST(TRASH_DIR);
812 #undef MAKE_DIR_IF_NOT_EXIST
814 FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
819 FolderItem *new_item;
820 gchar *mh_sequences_filename;
821 FILE *mh_sequences_file;
823 g_return_val_if_fail(folder != NULL, NULL);
824 g_return_val_if_fail(parent != NULL, NULL);
825 g_return_val_if_fail(name != NULL, NULL);
827 path = folder_item_get_path(parent);
828 if (!is_dir_exist(path))
829 if (make_dir_hier(path) != 0)
832 fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
835 if (make_dir(fullpath) < 0) {
843 path = g_strconcat(parent->path, G_DIR_SEPARATOR_S, name,
846 path = g_strdup(name);
847 new_item = folder_item_new(folder, name, path);
848 folder_item_append(parent, new_item);
852 path = folder_item_get_path(new_item);
853 mh_sequences_filename = g_strconcat(path, G_DIR_SEPARATOR_S,
854 ".mh_sequences", NULL);
855 if ((mh_sequences_file = fopen(mh_sequences_filename, "a+b")) != NULL) {
856 fclose(mh_sequences_file);
858 g_free(mh_sequences_filename);
864 gint mh_rename_folder(Folder *folder, FolderItem *item, const gchar *name)
872 g_return_val_if_fail(folder != NULL, -1);
873 g_return_val_if_fail(item != NULL, -1);
874 g_return_val_if_fail(item->path != NULL, -1);
875 g_return_val_if_fail(name != NULL, -1);
877 oldpath = folder_item_get_path(item);
878 if (!is_dir_exist(oldpath))
879 make_dir_hier(oldpath);
881 dirname = g_dirname(oldpath);
882 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
885 if (rename(oldpath, newpath) < 0) {
886 FILE_OP_ERROR(oldpath, "rename");
895 if (strchr(item->path, G_DIR_SEPARATOR) != NULL) {
896 dirname = g_dirname(item->path);
897 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
900 newpath = g_strdup(name);
903 item->name = g_strdup(name);
905 node = g_node_find(item->folder->node, G_PRE_ORDER, G_TRAVERSE_ALL,
907 paths[0] = g_strdup(item->path);
909 g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
910 mh_rename_folder_func, paths);
917 gint mh_remove_folder(Folder *folder, FolderItem *item)
921 g_return_val_if_fail(folder != NULL, -1);
922 g_return_val_if_fail(item != NULL, -1);
923 g_return_val_if_fail(item->path != NULL, -1);
925 path = folder_item_get_path(item);
926 if (remove_dir_recursive(path) < 0) {
927 g_warning("can't remove directory `%s'\n", path);
933 folder_item_remove(item);
937 static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
943 flags.perm_flags = MSG_NEW|MSG_UNREAD;
946 g_return_val_if_fail(item != NULL, NULL);
947 g_return_val_if_fail(file != NULL, NULL);
949 if (item->stype == F_QUEUE) {
950 MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
951 } else if (item->stype == F_DRAFT) {
952 MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
955 msginfo = procheader_parse_file(file, flags, FALSE, FALSE);
956 if (!msginfo) return NULL;
958 msginfo->msgnum = atoi(file);
959 msginfo->folder = item;
961 if (stat(file, &s) < 0) {
962 FILE_OP_ERROR(file, "stat");
966 msginfo->size = s.st_size;
967 msginfo->mtime = s.st_mtime;
974 static gboolean mh_is_maildir_one(const gchar *path, const gchar *dir)
979 entry = g_strconcat(path, G_DIR_SEPARATOR_S, dir, NULL);
980 result = is_dir_exist(entry);
987 * check whether PATH is a Maildir style mailbox.
988 * This is the case if the 3 subdir: new, cur, tmp are existing.
989 * This functon assumes that entry is an directory
991 static gboolean mh_is_maildir(const gchar *path)
993 return mh_is_maildir_one(path, "new") &&
994 mh_is_maildir_one(path, "cur") &&
995 mh_is_maildir_one(path, "tmp");
999 static void mh_scan_tree_recursive(FolderItem *item)
1007 g_return_if_fail(item != NULL);
1008 g_return_if_fail(item->folder != NULL);
1010 dp = opendir(item->path ? item->path : ".");
1012 FILE_OP_ERROR(item->path ? item->path : ".", "opendir");
1016 debug_print("scanning %s ...\n",
1017 item->path ? item->path
1018 : LOCAL_FOLDER(item->folder)->rootpath);
1019 if (item->folder->ui_func)
1020 item->folder->ui_func(item->folder, item,
1021 item->folder->ui_func_data);
1023 while ((d = readdir(dp)) != NULL) {
1024 if (d->d_name[0] == '.') continue;
1027 entry = g_strconcat(item->path, G_DIR_SEPARATOR_S,
1030 entry = g_strdup(d->d_name);
1032 if (stat(entry, &s) < 0) {
1033 FILE_OP_ERROR(entry, "stat");
1038 if (S_ISDIR(s.st_mode)) {
1039 FolderItem *new_item;
1042 if (mh_is_maildir(entry)) {
1048 new_item = folder_item_new(item->folder, d->d_name, entry);
1049 folder_item_append(item, new_item);
1051 if (!strcmp(d->d_name, INBOX_DIR)) {
1052 new_item->stype = F_INBOX;
1053 item->folder->inbox = new_item;
1054 } else if (!strcmp(d->d_name, OUTBOX_DIR)) {
1055 new_item->stype = F_OUTBOX;
1056 item->folder->outbox = new_item;
1057 } else if (!strcmp(d->d_name, DRAFT_DIR)) {
1058 new_item->stype = F_DRAFT;
1059 item->folder->draft = new_item;
1060 } else if (!strcmp(d->d_name, QUEUE_DIR)) {
1061 new_item->stype = F_QUEUE;
1062 item->folder->queue = new_item;
1063 } else if (!strcmp(d->d_name, TRASH_DIR)) {
1064 new_item->stype = F_TRASH;
1065 item->folder->trash = new_item;
1068 mh_scan_tree_recursive(new_item);
1069 } else if (to_number(d->d_name) != -1) n_msg++;
1078 gint new, unread, total, min, max;
1080 procmsg_get_mark_sum(item->path, &new, &unread, &total,
1082 if (n_msg > total) {
1083 new += n_msg - total;
1084 unread += n_msg - total;
1087 item->unread = unread;
1088 item->total = n_msg;
1093 static gboolean mh_rename_folder_func(GNode *node, gpointer data)
1095 FolderItem *item = node->data;
1096 gchar **paths = data;
1097 const gchar *oldpath = paths[0];
1098 const gchar *newpath = paths[1];
1100 gchar *new_itempath;
1103 oldpathlen = strlen(oldpath);
1104 if (strncmp(oldpath, item->path, oldpathlen) != 0) {
1105 g_warning("path doesn't match: %s, %s\n", oldpath, item->path);
1109 base = item->path + oldpathlen;
1110 while (*base == G_DIR_SEPARATOR) base++;
1112 new_itempath = g_strdup(newpath);
1114 new_itempath = g_strconcat(newpath, G_DIR_SEPARATOR_S, base,
1117 item->path = new_itempath;