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);
52 static gboolean mh_rename_folder_func (GNode *node,
56 GSList *mh_get_msg_list(Folder *folder, FolderItem *item, gboolean use_cache)
59 GHashTable *msg_table;
62 gboolean scan_new = TRUE;
64 struct timeval tv_before, tv_after, tv_result;
66 gettimeofday(&tv_before, NULL);
69 g_return_val_if_fail(item != NULL, NULL);
71 path = folder_item_get_path(item);
72 if (stat(path, &s) < 0) {
73 FILE_OP_ERROR(path, "stat");
75 if (item->mtime == s.st_mtime) {
76 debug_print("Folder is not modified.\n");
79 item->mtime = s.st_mtime;
83 if (use_cache && !scan_new) {
84 mlist = procmsg_read_cache(item, FALSE);
86 mlist = mh_get_uncached_msgs(NULL, item);
87 } else if (use_cache) {
90 mlist = procmsg_read_cache(item, TRUE);
91 msg_table = procmsg_msg_hash_table_create(mlist);
93 newlist = mh_get_uncached_msgs(msg_table, item);
95 g_hash_table_destroy(msg_table);
97 mlist = g_slist_concat(mlist, newlist);
99 mlist = mh_get_uncached_msgs(NULL, item);
101 procmsg_set_flags(mlist, item);
104 gettimeofday(&tv_after, NULL);
106 timersub(&tv_after, &tv_before, &tv_result);
107 g_print("mh_get_msg_list: %s: elapsed time: %ld.%06ld sec\n",
108 item->path, tv_result.tv_sec, tv_result.tv_usec);
114 gchar *mh_fetch_msg(Folder *folder, FolderItem *item, gint num)
119 g_return_val_if_fail(item != NULL, NULL);
120 g_return_val_if_fail(num > 0 && num <= item->last_num, NULL);
122 path = folder_item_get_path(item);
123 file = g_strconcat(path, G_DIR_SEPARATOR_S, itos(num), NULL);
125 if (!is_file_exist(file)) {
133 gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file,
134 gboolean remove_source)
139 g_return_val_if_fail(dest != NULL, -1);
140 g_return_val_if_fail(file != NULL, -1);
142 if (dest->last_num < 0) {
143 mh_scan_folder(folder, dest);
144 if (dest->last_num < 0) return -1;
147 destpath = folder_item_get_path(dest);
148 g_return_val_if_fail(destpath != NULL, -1);
149 if (!is_dir_exist(destpath))
150 make_dir_hier(destpath);
152 destfile = g_strdup_printf("%s%c%d", destpath, G_DIR_SEPARATOR,
155 if (link(file, destfile) < 0) {
156 if (EXDEV == errno) {
157 if (copy_file(file, destfile) < 0) {
158 g_warning(_("can't copy message %s to %s\n"),
164 FILE_OP_ERROR(file, "link");
171 if (unlink(file) < 0)
172 FILE_OP_ERROR(file, "unlink");
177 return dest->last_num;
180 gint mh_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
187 PrefsFolderItem *prefs;
189 g_return_val_if_fail(dest != NULL, -1);
190 g_return_val_if_fail(msginfo != NULL, -1);
192 if (msginfo->folder == dest) {
193 g_warning(_("the src folder is identical to the dest.\n"));
197 if (dest->last_num < 0) {
198 mh_scan_folder(folder, dest);
199 if (dest->last_num < 0) return -1;
204 destdir = folder_item_get_path(dest);
205 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
206 g_warning(_("Can't open mark file.\n"));
208 debug_print(_("Moving message %s%c%d to %s ...\n"),
209 msginfo->folder->path, G_DIR_SEPARATOR,
210 msginfo->msgnum, dest->path);
211 srcfile = procmsg_get_message_file_path(msginfo);
212 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
216 if (move_file(srcfile, destfile) < 0) {
223 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
224 if (chmod(destfile, prefs->folder_chmod) < 0)
225 FILE_OP_ERROR(destfile, "chmod");
228 filemode = prefs->folder_chmod;
229 if (filemode & S_IRGRP) filemode |= S_IWGRP;
230 if (filemode & S_IROTH) filemode |= S_IWOTH;
240 newmsginfo.msgnum = dest->last_num;
241 newmsginfo.flags = msginfo->flags;
242 if (dest->stype == F_OUTBOX ||
243 dest->stype == F_QUEUE ||
244 dest->stype == F_DRAFT ||
245 dest->stype == F_TRASH)
246 MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
247 MSG_NEW|MSG_UNREAD|MSG_DELETED);
249 procmsg_write_flags(&newmsginfo, fp);
253 fchmod(fileno(fp), filemode);
255 markfile = folder_item_get_mark_file(dest);
257 chmod(markfile, filemode);
266 return dest->last_num;
269 gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
277 PrefsFolderItem *prefs;
279 g_return_val_if_fail(dest != NULL, -1);
280 g_return_val_if_fail(msglist != NULL, -1);
282 if (dest->last_num < 0) {
283 mh_scan_folder(folder, dest);
284 if (dest->last_num < 0) return -1;
289 destdir = folder_item_get_path(dest);
290 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
291 g_warning(_("Can't open mark file.\n"));
293 for (cur = msglist; cur != NULL; cur = cur->next) {
294 msginfo = (MsgInfo *)cur->data;
296 if (msginfo->folder == dest) {
297 g_warning(_("the src folder is identical to the dest.\n"));
300 debug_print(_("Moving message %s%c%d to %s ...\n"),
301 msginfo->folder->path, G_DIR_SEPARATOR,
302 msginfo->msgnum, dest->path);
304 srcfile = procmsg_get_message_file_path(msginfo);
305 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
308 if (move_file(srcfile, destfile) < 0) {
321 newmsginfo.msgnum = dest->last_num;
322 newmsginfo.flags = msginfo->flags;
323 if (dest->stype == F_OUTBOX ||
324 dest->stype == F_QUEUE ||
325 dest->stype == F_DRAFT ||
326 dest->stype == F_TRASH)
329 MSG_NEW|MSG_UNREAD|MSG_DELETED);
331 procmsg_write_flags(&newmsginfo, fp);
338 return dest->last_num;
341 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
348 PrefsFolderItem *prefs;
350 g_return_val_if_fail(dest != NULL, -1);
351 g_return_val_if_fail(msginfo != NULL, -1);
353 if (msginfo->folder == dest) {
354 g_warning(_("the src folder is identical to the dest.\n"));
358 if (dest->last_num < 0) {
359 mh_scan_folder(folder, dest);
360 if (dest->last_num < 0) return -1;
365 destdir = folder_item_get_path(dest);
366 if (!is_dir_exist(destdir))
367 make_dir_hier(destdir);
369 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
370 g_warning(_("Can't open mark file.\n"));
372 debug_print(_("Copying message %s%c%d to %s ...\n"),
373 msginfo->folder->path, G_DIR_SEPARATOR,
374 msginfo->msgnum, dest->path);
375 srcfile = procmsg_get_message_file_path(msginfo);
376 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
382 if (is_file_exist(destfile)) {
383 g_warning(_("%s already exists."), destfile);
390 if (copy_file(srcfile, destfile) < 0) {
391 FILE_OP_ERROR(srcfile, "copy");
398 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
399 if (chmod(destfile, prefs->folder_chmod) < 0)
400 FILE_OP_ERROR(destfile, "chmod");
403 filemode = prefs->folder_chmod;
404 if (filemode & S_IRGRP) filemode |= S_IWGRP;
405 if (filemode & S_IROTH) filemode |= S_IWOTH;
415 newmsginfo.msgnum = dest->last_num;
416 newmsginfo.flags = msginfo->flags;
417 if (dest->stype == F_OUTBOX ||
418 dest->stype == F_QUEUE ||
419 dest->stype == F_DRAFT ||
420 dest->stype == F_TRASH)
421 MSG_UNSET_PERM_FLAGS(newmsginfo.flags,
422 MSG_NEW|MSG_UNREAD|MSG_DELETED);
423 procmsg_write_flags(&newmsginfo, fp);
427 fchmod(fileno(fp), filemode);
429 markfile = folder_item_get_mark_file(dest);
431 chmod(markfile, filemode);
440 return dest->last_num;
444 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
452 src_folder = msginfo->folder->folder;
454 g_return_val_if_fail(src_folder->fetch_msg != NULL, -1);
456 filename = src_folder->fetch_msg(src_folder,
459 if (filename == NULL)
462 num = folder->add_msg(folder, dest, filename, FALSE);
464 destdir = folder_item_get_path(dest);
465 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
466 g_warning(_("Can't open mark file.\n"));
471 newmsginfo.msgnum = dest->last_num;
472 newmsginfo.flags = msginfo->flags;
473 if (dest->stype == F_OUTBOX ||
474 dest->stype == F_QUEUE ||
475 dest->stype == F_DRAFT ||
476 dest->stype == F_TRASH)
477 MSG_UNSET_FLAGS(newmsginfo.flags,
478 MSG_NEW|MSG_UNREAD|MSG_DELETED);
480 procmsg_write_flags(&newmsginfo, fp);
488 gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
497 g_return_val_if_fail(dest != NULL, -1);
498 g_return_val_if_fail(msglist != NULL, -1);
500 if (dest->last_num < 0) {
501 mh_scan_folder(folder, dest);
502 if (dest->last_num < 0) return -1;
505 destdir = folder_item_get_path(dest);
506 if (!is_dir_exist(destdir))
507 make_dir_hier(destdir);
509 if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
510 g_warning(_("Can't open mark file.\n"));
512 for (cur = msglist; cur != NULL; cur = cur->next) {
513 msginfo = (MsgInfo *)cur->data;
515 if (msginfo->folder == dest) {
516 g_warning(_("the src folder is identical to the dest.\n"));
519 debug_print(_("Copying message %s%c%d to %s ...\n"),
520 msginfo->folder->path, G_DIR_SEPARATOR,
521 msginfo->msgnum, dest->path);
523 srcfile = procmsg_get_message_file_path(msginfo);
524 destfile = g_strdup_printf("%s%c%d", destdir, G_DIR_SEPARATOR,
527 if (is_file_exist(destfile)) {
528 g_warning(_("%s already exists."), destfile);
534 if (copy_file(srcfile, destfile) < 0) {
535 FILE_OP_ERROR(srcfile, "copy");
548 newmsginfo.msgnum = dest->last_num;
549 newmsginfo.flags = msginfo->flags;
550 if (dest->stype == F_OUTBOX ||
551 dest->stype == F_QUEUE ||
552 dest->stype == F_DRAFT ||
553 dest->stype == F_TRASH)
556 MSG_NEW|MSG_UNREAD|MSG_DELETED);
557 procmsg_write_flags(&newmsginfo, fp);
564 return dest->last_num;
567 gint mh_remove_msg(Folder *folder, FolderItem *item, gint num)
571 g_return_val_if_fail(item != NULL, -1);
573 file = mh_fetch_msg(folder, item, num);
574 g_return_val_if_fail(file != NULL, -1);
576 if (unlink(file) < 0) {
577 FILE_OP_ERROR(file, "unlink");
586 gint mh_remove_all_msg(Folder *folder, FolderItem *item)
591 g_return_val_if_fail(item != NULL, -1);
593 path = folder_item_get_path(item);
594 g_return_val_if_fail(path != NULL, -1);
595 val = remove_all_numbered_files(path);
601 gboolean mh_is_msg_changed(Folder *folder, FolderItem *item, MsgInfo *msginfo)
605 if (stat(itos(msginfo->msgnum), &s) < 0 ||
606 msginfo->size != s.st_size ||
607 msginfo->mtime != s.st_mtime)
613 void mh_scan_folder(Folder *folder, FolderItem *item)
623 g_return_if_fail(item != NULL);
625 debug_print("mh_scan_folder(): Scanning %s ...\n", item->path);
627 path = folder_item_get_path(item);
628 g_return_if_fail(path != NULL);
629 if (change_dir(path) < 0) {
635 if ((dp = opendir(".")) == NULL) {
636 FILE_OP_ERROR(item->path, "opendir");
641 folder->ui_func(folder, item, folder->ui_func_data);
643 while ((d = readdir(dp)) != NULL) {
644 if ((num = to_number(d->d_name)) >= 0 &&
645 stat(d->d_name, &s) == 0 &&
646 S_ISREG(s.st_mode)) {
656 item->new = item->unread = item->total = 0;
658 gint new, unread, total;
660 procmsg_get_mark_sum(".", &new, &unread, &total);
662 new += n_msg - total;
663 unread += n_msg - total;
666 item->unread = unread;
670 debug_print(_("Last number in dir %s = %d\n"), item->path, max);
671 item->last_num = max;
674 void mh_scan_tree(Folder *folder)
679 g_return_if_fail(folder != NULL);
681 folder_tree_destroy(folder);
682 item = folder_item_new(folder->name, NULL);
683 item->folder = folder;
684 folder->node = g_node_new(item);
686 rootpath = folder_item_get_path(item);
687 if (change_dir(rootpath) < 0) {
693 mh_scan_tree_recursive(item);
696 #define MAKE_DIR_IF_NOT_EXIST(dir) \
698 if (!is_dir_exist(dir)) { \
699 if (is_file_exist(dir)) { \
700 g_warning(_("File `%s' already exists.\n" \
701 "Can't create folder."), dir); \
704 if (mkdir(dir, S_IRWXU) < 0) { \
705 FILE_OP_ERROR(dir, "mkdir"); \
708 if (chmod(dir, S_IRWXU) < 0) \
709 FILE_OP_ERROR(dir, "chmod"); \
713 gint mh_create_tree(Folder *folder)
717 g_return_val_if_fail(folder != NULL, -1);
719 CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), -1);
720 rootpath = LOCAL_FOLDER(folder)->rootpath;
721 MAKE_DIR_IF_NOT_EXIST(rootpath);
722 CHDIR_RETURN_VAL_IF_FAIL(rootpath, -1);
723 MAKE_DIR_IF_NOT_EXIST(INBOX_DIR);
724 MAKE_DIR_IF_NOT_EXIST(OUTBOX_DIR);
725 MAKE_DIR_IF_NOT_EXIST(QUEUE_DIR);
726 MAKE_DIR_IF_NOT_EXIST(DRAFT_DIR);
727 MAKE_DIR_IF_NOT_EXIST(TRASH_DIR);
732 #undef MAKE_DIR_IF_NOT_EXIST
734 FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
739 FolderItem *new_item;
741 g_return_val_if_fail(folder != NULL, NULL);
742 g_return_val_if_fail(parent != NULL, NULL);
743 g_return_val_if_fail(name != NULL, NULL);
745 path = folder_item_get_path(parent);
746 if (!is_dir_exist(path))
749 fullpath = g_strconcat(path, G_DIR_SEPARATOR_S, name, NULL);
752 if (mkdir(fullpath, S_IRWXU) < 0) {
753 FILE_OP_ERROR(fullpath, "mkdir");
757 if (chmod(fullpath, S_IRWXU) < 0)
758 FILE_OP_ERROR(fullpath, "chmod");
763 path = g_strconcat(parent->path, G_DIR_SEPARATOR_S, name,
766 path = g_strdup(name);
767 new_item = folder_item_new(name, path);
768 folder_item_append(parent, new_item);
774 gint mh_rename_folder(Folder *folder, FolderItem *item, const gchar *name)
782 g_return_val_if_fail(folder != NULL, -1);
783 g_return_val_if_fail(item != NULL, -1);
784 g_return_val_if_fail(item->path != NULL, -1);
785 g_return_val_if_fail(name != NULL, -1);
787 oldpath = folder_item_get_path(item);
788 if (!is_dir_exist(oldpath))
789 make_dir_hier(oldpath);
791 dirname = g_dirname(oldpath);
792 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
795 if (rename(oldpath, newpath) < 0) {
796 FILE_OP_ERROR(oldpath, "rename");
805 if (strchr(item->path, G_DIR_SEPARATOR) != NULL) {
806 dirname = g_dirname(item->path);
807 newpath = g_strconcat(dirname, G_DIR_SEPARATOR_S, name, NULL);
810 newpath = g_strdup(name);
813 item->name = g_strdup(name);
815 node = g_node_find(item->folder->node, G_PRE_ORDER, G_TRAVERSE_ALL,
817 paths[0] = g_strdup(item->path);
819 g_node_traverse(node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
820 mh_rename_folder_func, paths);
827 gint mh_remove_folder(Folder *folder, FolderItem *item)
831 g_return_val_if_fail(folder != NULL, -1);
832 g_return_val_if_fail(item != NULL, -1);
833 g_return_val_if_fail(item->path != NULL, -1);
835 path = folder_item_get_path(item);
836 if (remove_dir_recursive(path) < 0) {
837 g_warning("can't remove directory `%s'\n", path);
843 folder_item_remove(item);
848 static GSList *mh_get_uncached_msgs(GHashTable *msg_table, FolderItem *item)
854 GSList *newlist = NULL;
860 g_return_val_if_fail(item != NULL, NULL);
862 path = folder_item_get_path(item);
863 g_return_val_if_fail(path != NULL, NULL);
864 if (change_dir(path) < 0) {
870 if ((dp = opendir(".")) == NULL) {
871 FILE_OP_ERROR(item->path, "opendir");
875 debug_print(_("\tSearching uncached messages... "));
878 while ((d = readdir(dp)) != NULL) {
879 if ((num = to_number(d->d_name)) < 0) continue;
880 if (stat(d->d_name, &s) < 0) {
881 FILE_OP_ERROR(d->d_name, "stat");
884 if (!S_ISREG(s.st_mode)) continue;
886 msginfo = g_hash_table_lookup
887 (msg_table, GUINT_TO_POINTER(num));
890 /* not found in the cache (uncached message) */
891 msginfo = mh_parse_msg(d->d_name, item);
892 if (!msginfo) continue;
896 g_slist_append(NULL, msginfo);
898 last = g_slist_append(last, msginfo);
905 /* discard all previous cache */
906 while ((d = readdir(dp)) != NULL) {
907 if (to_number(d->d_name) < 0) continue;
908 if (stat(d->d_name, &s) < 0) {
909 FILE_OP_ERROR(d->d_name, "stat");
912 if (!S_ISREG(s.st_mode)) continue;
914 msginfo = mh_parse_msg(d->d_name, item);
915 if (!msginfo) continue;
918 last = newlist = g_slist_append(NULL, msginfo);
920 last = g_slist_append(last, msginfo);
930 debug_print(_("%d uncached message(s) found.\n"), n_newmsg);
932 debug_print(_("done.\n"));
934 /* sort new messages in numerical order */
936 debug_print(_("\tSorting uncached messages in numerical order... "));
937 newlist = g_slist_sort
938 (newlist, (GCompareFunc)procmsg_cmp_msgnum_for_sort);
939 debug_print(_("done.\n"));
945 static MsgInfo *mh_parse_msg(const gchar *file, FolderItem *item)
951 flags.perm_flags = MSG_NEW|MSG_UNREAD;
954 g_return_val_if_fail(item != NULL, NULL);
955 g_return_val_if_fail(file != NULL, NULL);
957 if (item->stype == F_QUEUE) {
958 MSG_SET_TMP_FLAGS(flags, MSG_QUEUED);
959 } else if (item->stype == F_DRAFT) {
960 MSG_SET_TMP_FLAGS(flags, MSG_DRAFT);
963 msginfo = procheader_parse(file, flags, FALSE);
964 if (!msginfo) return NULL;
966 msginfo->msgnum = atoi(file);
967 msginfo->folder = item;
969 if (stat(file, &s) < 0) {
970 FILE_OP_ERROR(file, "stat");
974 msginfo->size = s.st_size;
975 msginfo->mtime = s.st_mtime;
981 static gboolean mh_is_maildir_one(const gchar *path, const gchar *dir)
986 entry = g_strconcat(path, G_DIR_SEPARATOR_S, dir, NULL);
987 result = is_dir_exist(entry);
994 * check whether PATH is a Maildir style mailbox.
995 * This is the case if the 3 subdir: new, cur, tmp are existing.
996 * This functon assumes that entry is an directory
998 static gboolean mh_is_maildir(const gchar *path)
1000 return mh_is_maildir_one(path, "new") &&
1001 mh_is_maildir_one(path, "cur") &&
1002 mh_is_maildir_one(path, "tmp");
1005 static void mh_scan_tree_recursive(FolderItem *item)
1013 g_return_if_fail(item != NULL);
1014 g_return_if_fail(item->folder != NULL);
1016 dp = opendir(item->path ? item->path : ".");
1018 FILE_OP_ERROR(item->path ? item->path : ".", "opendir");
1022 debug_print("scanning %s ...\n",
1023 item->path ? item->path
1024 : LOCAL_FOLDER(item->folder)->rootpath);
1025 if (item->folder->ui_func)
1026 item->folder->ui_func(item->folder, item,
1027 item->folder->ui_func_data);
1029 while ((d = readdir(dp)) != NULL) {
1030 if (d->d_name[0] == '.') continue;
1033 entry = g_strconcat(item->path, G_DIR_SEPARATOR_S,
1036 entry = g_strdup(d->d_name);
1038 if (stat(entry, &s) < 0) {
1039 FILE_OP_ERROR(entry, "stat");
1044 if (S_ISDIR(s.st_mode)) {
1045 FolderItem *new_item;
1047 if (mh_is_maildir(entry)) {
1052 new_item = folder_item_new(d->d_name, entry);
1053 folder_item_append(item, new_item);
1055 if (!strcmp(d->d_name, "inbox")) {
1056 new_item->stype = F_INBOX;
1057 item->folder->inbox = new_item;
1058 } else if (!strcmp(d->d_name, "outbox")) {
1059 new_item->stype = F_OUTBOX;
1060 item->folder->outbox = new_item;
1061 } else if (!strcmp(d->d_name, "draft")) {
1062 new_item->stype = F_DRAFT;
1063 item->folder->draft = new_item;
1064 } else if (!strcmp(d->d_name, "queue")) {
1065 new_item->stype = F_QUEUE;
1066 item->folder->queue = new_item;
1067 } else if (!strcmp(d->d_name, "trash")) {
1068 new_item->stype = F_TRASH;
1069 item->folder->trash = new_item;
1072 mh_scan_tree_recursive(new_item);
1073 } else if (to_number(d->d_name) != -1) n_msg++;
1081 gint new, unread, total;
1083 procmsg_get_mark_sum(item->path, &new, &unread, &total);
1084 if (n_msg > total) {
1085 new += n_msg - total;
1086 unread += n_msg - total;
1089 item->unread = unread;
1090 item->total = n_msg;
1094 static gboolean mh_rename_folder_func(GNode *node, gpointer data)
1096 FolderItem *item = node->data;
1097 gchar **paths = data;
1098 const gchar *oldpath = paths[0];
1099 const gchar *newpath = paths[1];
1101 gchar *new_itempath;
1104 oldpathlen = strlen(oldpath);
1105 if (strncmp(oldpath, item->path, oldpathlen) != 0) {
1106 g_warning("path doesn't match: %s, %s\n", oldpath, item->path);
1110 base = item->path + oldpathlen;
1111 while (*base == G_DIR_SEPARATOR) base++;
1113 new_itempath = g_strdup(newpath);
1115 new_itempath = g_strconcat(newpath, G_DIR_SEPARATOR_S, base,
1118 item->path = new_itempath;