2007-08-03 [paul] 2.10.0cvs85
[claws.git] / src / mh.c
index ee49241b4737708eecc8b579da99336f4c208b95..2b8f9cf68d2681340c2514c9f945a8789b63e9b0 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
  *
  * 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -13,8 +13,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
@@ -233,7 +233,7 @@ gboolean mh_scan_required(Folder *folder, FolderItem *item)
        return FALSE;
 }
 
-void mh_get_last_num(Folder *folder, FolderItem *item)
+static void mh_get_last_num(Folder *folder, FolderItem *item)
 {
        gchar *path;
        DIR *dp;
@@ -264,6 +264,8 @@ void mh_get_last_num(Folder *folder, FolderItem *item)
                        if (max < num)
                                max = num;
                }
+               if (num % 100 == 0)
+                       GTK_EVENTS_FLUSH();
        }
        closedir(dp);
 
@@ -454,6 +456,8 @@ static gint mh_copy_msgs(Folder *folder, FolderItem *dest, MsgInfoList *msglist,
                         GRelation *relation)
 {
        gboolean dest_need_scan = FALSE;
+       gboolean src_need_scan = FALSE;
+       FolderItem *src = NULL;
        gchar *srcfile;
        gchar *destfile;
        gint filemode = 0;
@@ -463,7 +467,8 @@ static gint mh_copy_msgs(Folder *folder, FolderItem *dest, MsgInfoList *msglist,
        gint curnum = 0, total = 0;
        gchar *srcpath = NULL;
        gboolean full_fetch = FALSE;
-       time_t last_mtime = (time_t)0;
+       time_t last_dest_mtime = (time_t)0;
+       time_t last_src_mtime = (time_t)0;
 
        g_return_val_if_fail(dest != NULL, -1);
        g_return_val_if_fail(msglist != NULL, -1);
@@ -479,6 +484,10 @@ static gint mh_copy_msgs(Folder *folder, FolderItem *dest, MsgInfoList *msglist,
 
        if (msginfo->folder->folder != dest->folder)
                full_fetch = TRUE;
+       
+       if (FOLDER_TYPE(msginfo->folder->folder) == F_MH) {
+               src = msginfo->folder;
+       }
 
        if (dest->last_num < 0) {
                mh_get_last_num(folder, dest);
@@ -490,7 +499,12 @@ static gint mh_copy_msgs(Folder *folder, FolderItem *dest, MsgInfoList *msglist,
        srcpath = folder_item_get_path(msginfo->folder);
 
        dest_need_scan = mh_scan_required(dest->folder, dest);
-       last_mtime = dest->mtime;
+       last_dest_mtime = dest->mtime;
+
+       if (src) {
+               src_need_scan = mh_scan_required(src->folder, src);
+               last_src_mtime = src->mtime;
+       }
 
        total = g_slist_length(msglist);
        if (total > 100) {
@@ -571,9 +585,14 @@ static gint mh_copy_msgs(Folder *folder, FolderItem *dest, MsgInfoList *msglist,
        g_free(srcpath);
        mh_write_sequences(dest, TRUE);
 
-       if (dest->mtime == last_mtime && !dest_need_scan) {
+       if (dest->mtime == last_dest_mtime && !dest_need_scan) {
                mh_set_mtime(dest);
        }
+
+       if (src && src->mtime == last_src_mtime && !src_need_scan) {
+               mh_set_mtime(src);
+       }
+
        if (total > 100) {
                statusbar_progress_all(0,0,0);
                statusbar_pop_all();
@@ -745,7 +764,7 @@ static gint mh_scan_tree(Folder *folder)
                                    "Can't create folder.", dir); \
                        return -1; \
                } \
-               if (make_dir(dir) < 0) \
+               if (make_dir_hier(dir) < 0) \
                        return -1; \
        } \
 }
@@ -1055,12 +1074,12 @@ static void mh_scan_tree_recursive(FolderItem *item)
                entry = mh_filename_from_utf8(utf8entry);
 
                if (
-#if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE)
+#if !defined(G_OS_WIN32) && !defined(MAEMO) && defined(HAVE_DIRENT_D_TYPE)
                        d->d_type == DT_DIR ||
                        (d->d_type == DT_UNKNOWN &&
 #endif
                        g_stat(entry, &s) == 0 && S_ISDIR(s.st_mode)
-#if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE)
+#if !defined(G_OS_WIN32) && !defined(MAEMO) && defined(HAVE_DIRENT_D_TYPE)
                        )
 #endif
                   ) {
@@ -1159,7 +1178,7 @@ static gchar *mh_filename_from_utf8(const gchar *path)
        gchar *real_path = g_filename_from_utf8(path, -1, NULL, NULL, NULL);
 
        if (!real_path) {
-               g_warning("mh_filename_from_utf8: faild to convert character set\n");
+               g_warning("mh_filename_from_utf8: failed to convert character set\n");
                real_path = g_strdup(path);
        }
 
@@ -1170,7 +1189,7 @@ static gchar *mh_filename_to_utf8(const gchar *path)
 {
        gchar *utf8path = g_filename_to_utf8(path, -1, NULL, NULL, NULL);
        if (!utf8path) {
-               g_warning("mh_filename_to_utf8: faild to convert character set\n");
+               g_warning("mh_filename_to_utf8: failed to convert character set\n");
                utf8path = g_strdup(path);
        }