* src/procmsg.[ch]
authorColin Leroy <colin@colino.net>
Thu, 21 Nov 2002 14:19:29 +0000 (14:19 +0000)
committerColin Leroy <colin@colino.net>
Thu, 21 Nov 2002 14:19:29 +0000 (14:19 +0000)
Add procmsg_remove_special_headers()
* src/mh.c
Use procmsg_remove_special_headers() for
previous fix

ChangeLog.claws
configure.in
src/mh.c
src/procmsg.c
src/procmsg.h

index 15ab0fdaee0679abfbcccf174889c448722ebd13..a14d0594847149c7fe3f3fc0eda1262ff89c4c5d 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-21 [colin]     0.8.5claws175
+
+       * src/procmsg.[ch]
+               Add procmsg_remove_special_headers()
+       * src/mh.c
+               Use procmsg_remove_special_headers() for 
+               previous fix
+
 2002-11-21 [colin]     0.8.5claws174
 
        * src/mh.c
index 252fb03e710c7a30658e04308a2592c4648a204a..de2063dc41c77254abb0e13a61fc447ed3b9f3e5 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws174
+EXTRA_VERSION=claws175
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index b8d5f0bca38d85389b62a4f92df931cac32fc0a3..55bcf56b3202911faaf5c5b25ffa736424048cd7 100644 (file)
--- a/src/mh.c
+++ b/src/mh.c
@@ -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;
@@ -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)
index 98e0edce80657f4568ebb004b229bfcebe368f63..aca7ca05b18237e20f65c9b60455dd6f8cb39a9a 100644 (file)
@@ -903,12 +903,33 @@ gint procmsg_send_queue(FolderItem *queue, gboolean save_msgs)
 
        return ret;
 }
+gint procmsg_remove_special_headers(const gchar *in, const gchar *out)
+{
+       FILE *fp, *outfp;
+       gchar buf[BUFFSIZE];
+       
+       if ((fp = fopen(in, "rb")) == NULL) {
+               FILE_OP_ERROR(in, "fopen");
+               return -1;
+       }
+       if ((outfp = fopen(out, "wb")) == NULL) {
+               FILE_OP_ERROR(out, "fopen");
+               fclose(fp);
+               return -1;
+       }
+       while (fgets(buf, sizeof(buf), fp) != NULL)
+               if (buf[0] == '\r' || buf[0] == '\n') break;
+       while (fgets(buf, sizeof(buf), fp) != NULL)
+               fputs(buf, outfp);
+       fclose(outfp);
+       fclose(fp);
+       return 0;
 
+}
 gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
                            gboolean is_queued)
 {
        gint num;
-       FILE *fp;
        MsgInfo *msginfo;
 
        debug_print("saving sent message...\n");
@@ -920,26 +941,12 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
        /* remove queueing headers */
        if (is_queued) {
                gchar tmp[MAXPATHLEN + 1];
-               gchar buf[BUFFSIZE];
-               FILE *outfp;
 
                g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.out.%08x",
                           get_rc_dir(), G_DIR_SEPARATOR, (guint)random());
-               if ((fp = fopen(file, "rb")) == NULL) {
-                       FILE_OP_ERROR(file, "fopen");
-                       return -1;
-               }
-               if ((outfp = fopen(tmp, "wb")) == NULL) {
-                       FILE_OP_ERROR(tmp, "fopen");
-                       fclose(fp);
+               
+               if (procmsg_remove_special_headers(file, tmp) !=0)
                        return -1;
-               }
-               while (fgets(buf, sizeof(buf), fp) != NULL)
-                       if (buf[0] == '\r' || buf[0] == '\n') break;
-               while (fgets(buf, sizeof(buf), fp) != NULL)
-                       fputs(buf, outfp);
-               fclose(outfp);
-               fclose(fp);
 
                folder_item_scan(outbox);
                if ((num = folder_item_add_msg(outbox, tmp, TRUE)) < 0) {
index e618b32d5182f1d63c5c14cd28cb7da4234e5ed3..f493b98838fc1859eea5c7eb45bd7b427b401d5e 100644 (file)
@@ -287,4 +287,7 @@ gint msginfo_update_callback_register(MsgInfoUpdateFunc func, gpointer data);
 void msginfo_update_callback_unregister(gint id);
 
 void msginfo_update_item               (MsgInfo        *info);
+gint procmsg_remove_special_headers    (const gchar    *in, 
+                                        const gchar    *out);
+
 #endif /* __PROCMSG_H__ */