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 ed3a329f4433dbb908de5eb98dc4313c6a15858b..15ab0fdaee0679abfbcccf174889c448722ebd13 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 5f4df90313e9a5be9681174563490ac773691ab0..252fb03e710c7a30658e04308a2592c4648a204a 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 75b54e770c2c11d8a4ced0fd527e8320eff1541e..b8d5f0bca38d85389b62a4f92df931cac32fc0a3 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");