Fix copying from queue/draft folders
authorColin Leroy <colin@colino.net>
Thu, 21 Nov 2002 08:42:25 +0000 (08:42 +0000)
committerColin Leroy <colin@colino.net>
Thu, 21 Nov 2002 08:42:25 +0000 (08:42 +0000)
for MH folders
VS: ----------------------------------------------------------------------

ChangeLog.claws
configure.in
src/mh.c

index ed3a329..15ab0fd 100644 (file)
@@ -1,3 +1,9 @@
+2002-11-21 [colin]     0.8.5claws174
+
+       * src/mh.c
+               Fix moving/copying from queue/draft folders
+               for MH folders
+
 2002-11-21 [christoph] 0.8.5claws173
 
        * src/crash.c
index 5f4df90..252fb03 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws173
+EXTRA_VERSION=claws174
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 75b54e7..b8d5f0b 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -566,6 +566,40 @@ 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;
@@ -607,6 +641,10 @@ gint mh_copy_msg(Folder *folder, FolderItem *dest, MsgInfo *msginfo)
                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)
                        FILE_OP_ERROR(destfile, "chmod");