0.8.6claws105
[claws.git] / src / mh.c
index b8d5f0bca38d85389b62a4f92df931cac32fc0a3..8ff5fcaaa60168e818c564736f2da792fc4e8723 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -390,7 +390,7 @@ gint mh_add_msg(Folder *folder, FolderItem *dest, const gchar *file,
 
        if (link(file, destfile) < 0) {
                if (copy_file(file, destfile, TRUE) < 0) {
-                       g_warning(_("can't copy message %s to %s\n"),
+                       g_warning("can't copy message %s to %s\n",
                                  file, destfile);
                        g_free(destfile);
                        return -1;
@@ -418,7 +418,7 @@ static gint mh_do_move(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
        g_return_val_if_fail(msginfo != NULL, -1);
 
        if (msginfo->folder == dest) {
-               g_warning(_("the src folder is identical to the dest.\n"));
+               g_warning("the src folder is identical to the dest.\n");
                return -1;
        }
 
@@ -486,7 +486,7 @@ gint mh_move_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
  
                destdir = folder_item_get_path(dest);
                if ((fp = procmsg_open_mark_file(destdir, TRUE)) == NULL)
-                       g_warning(_("Can't open mark file.\n"));
+                       g_warning("Can't open mark file.\n");
                else {
                        SET_DEST_MSG_FLAGS(fp, dest, msginfo);
                        fclose(fp);
@@ -522,7 +522,7 @@ static gint mh_do_move_msgs_with_dest(Folder *folder, FolderItem *dest,
                msginfo = (MsgInfo *)cur->data;
 
                if (msginfo->folder == dest) {
-                       g_warning(_("the src folder is identical to the dest.\n"));
+                       g_warning("the src folder is identical to the dest.\n");
                        continue;
                }
                debug_print("Moving message %s%c%d to %s ...\n",
@@ -566,40 +566,6 @@ gint mh_move_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
        return ret;
 }
 
-static void mh_remove_queue_headers (const gchar *file)
-{
-       FILE *fp, *fp2;
-       char *tmp;
-       fp = fopen(file, "rb");
-       tmp = get_tmp_file();
-       
-       fp2 = fopen(tmp, "wb");
-       if (fp && fp2) {
-               char buf[BUFFSIZE];
-               int len;
-               while (fgets(buf, sizeof(buf), fp) != NULL)
-                       if (buf[0] == '\r' || buf[0] == '\n') 
-                               break;
-
-               while ((len=fread(buf, sizeof(char), sizeof(buf), fp)) > 0) {
-                       fwrite(buf, len, 1, fp2);
-               }
-               fclose(fp);
-               fclose(fp2);
-               move_file(tmp, file, TRUE);
-       } else {
-               if (fp)
-                       fclose(fp);
-               else 
-                       g_warning (_("Couldn't fopen(\"%s\",\"rb\")\n"), file);
-               if (fp2)
-                       fclose(fp2);
-               else 
-                       g_warning (_("Couldn't fopen(\"%s\",\"wb\")\n"), tmp);
-       }
-       g_free(tmp);
-}
-
 gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
 {
        gchar *srcfile;
@@ -611,7 +577,7 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
        g_return_val_if_fail(msginfo != NULL, -1);
 
        if (msginfo->folder == dest) {
-               g_warning(_("the src folder is identical to the dest.\n"));
+               g_warning("the src folder is identical to the dest.\n");
                return -1;
        }
 
@@ -634,16 +600,20 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
                    msginfo->msgnum, dest->path);
        
 
-       if (copy_file(srcfile, destfile, TRUE) < 0) {
+       if ((MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags))
+       &&  dest->stype != F_QUEUE && dest->stype != F_DRAFT) {
+               if (procmsg_remove_special_headers(srcfile, destfile) !=0) {
+                       g_free(srcfile);
+                       g_free(destfile);
+                       return -1;
+               }
+       } else if (copy_file(srcfile, destfile, TRUE) < 0) {
                FILE_OP_ERROR(srcfile, "copy");
                g_free(srcfile);
                g_free(destfile);
                return -1;
        }
 
-       if ((MSG_IS_QUEUED(msginfo->flags) || MSG_IS_DRAFT(msginfo->flags))
-       &&  dest->stype != F_QUEUE && dest->stype != F_DRAFT)
-               mh_remove_queue_headers(destfile);
 
        if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
                if (chmod(destfile, prefs->folder_chmod) < 0)
@@ -724,7 +694,7 @@ gint mh_copy_msgs_with_dest(Folder *folder, FolderItem *dest, GSList *msglist)
                msginfo = (MsgInfo *)cur->data;
 
                if (msginfo->folder == dest) {
-                       g_warning(_("the src folder is identical to the dest.\n"));
+                       g_warning("the src folder is identical to the dest.\n");
                        continue;
                }
                debug_print("Copying message %s%c%d to %s ...\n",
@@ -886,8 +856,8 @@ void mh_scan_tree(Folder *folder)
 { \
        if (!is_dir_exist(dir)) { \
                if (is_file_exist(dir)) { \
-                       g_warning(_("File `%s' already exists.\n" \
-                                   "Can't create folder."), dir); \
+                       g_warning("File `%s' already exists.\n" \
+                                   "Can't create folder.", dir); \
                        return -1; \
                } \
                if (make_dir(dir) < 0) \
@@ -922,6 +892,8 @@ FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
        gchar *path;
        gchar *fullpath;
        FolderItem *new_item;
+       gchar *mh_sequences_filename;
+       FILE *mh_sequences_file;
 
        g_return_val_if_fail(folder != NULL, NULL);
        g_return_val_if_fail(parent != NULL, NULL);
@@ -949,8 +921,17 @@ FolderItem *mh_create_folder(Folder *folder, FolderItem *parent,
                path = g_strdup(name);
        new_item = folder_item_new(folder, name, path);
        folder_item_append(parent, new_item);
+
        g_free(path);
 
+       path = folder_item_get_path(new_item);
+       mh_sequences_filename = g_strconcat(path, G_DIR_SEPARATOR_S,
+                                           ".mh_sequences", NULL);
+       if ((mh_sequences_file = fopen(mh_sequences_filename, "a+b")) != NULL) {
+               fclose(mh_sequences_file);
+       }
+       g_free(mh_sequences_filename);
+
        return new_item;
 }