sync with 0.7.4cvs11
authorPaul Mangan <paul@claws-mail.org>
Thu, 21 Mar 2002 07:22:47 +0000 (07:22 +0000)
committerPaul Mangan <paul@claws-mail.org>
Thu, 21 Mar 2002 07:22:47 +0000 (07:22 +0000)
configure.in
src/compose.c
src/main.c
src/mainwindow.c
src/procmsg.c
src/procmsg.h

index 6319eef25a61efea87063c1756d24a5ed739b691..ca06b0c892b86a3162649dc06a4ddc6218199847 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws28
+EXTRA_VERSION=claws29
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 2f3f165ad6369a81b967b26954b081907deaa83b..1392c82cbcc82d90d96a389bfb4220980098405c 100644 (file)
@@ -203,8 +203,6 @@ static gint compose_write_to_file           (Compose        *compose,
                                                 gboolean        is_draft);
 static gint compose_write_body_to_file         (Compose        *compose,
                                                 const gchar    *file);
-static gint compose_save_to_outbox             (Compose        *compose,
-                                                const gchar    *file);
 static gint compose_remove_reedit_target       (Compose        *compose);
 static gint compose_queue                      (Compose        *compose,
                                                 gint           *msgnum,
@@ -2698,13 +2696,17 @@ gint compose_send(Compose *compose)
                                folderview_update_item
                                        (compose->targetinfo->folder, TRUE);
                }
-       }
-
-       /* save message to outbox */
-       if (ok == 0 && prefs_common.savemsg) {
-               if (compose_save_to_outbox(compose, tmp) < 0)
-                       alertpanel_error
-                               (_("Can't save the message to outbox."));
+               /* save message to outbox */
+               if (prefs_common.savemsg) {
+                       Folder *folder = FOLDER(compose->account->folder);
+                       FolderItem *outbox = NULL;
+
+                       if (folder)
+                               outbox = folder->outbox;
+                       if (procmsg_save_to_outbox(outbox, tmp, FALSE) < 0)
+                               alertpanel_error
+                                       (_("Can't save the message to outbox."));
+               }
        }
 
        unlink(tmp);
@@ -3097,43 +3099,6 @@ static gint compose_write_body_to_file(Compose *compose, const gchar *file)
        return 0;
 }
 
-static gint compose_save_to_outbox(Compose *compose, const gchar *file)
-{
-       FolderItem *outbox;
-       gchar *path;
-       gint num;
-       FILE *fp;
-
-       debug_print(_("saving sent message...\n"));
-
-       outbox = folder_get_default_outbox();
-       path = folder_item_get_path(outbox);
-       if (!is_dir_exist(path))
-               make_dir_hier(path);
-
-       folder_item_scan(outbox);
-       if ((num = folder_item_add_msg(outbox, file, FALSE)) < 0) {
-               g_free(path);
-               g_warning(_("can't save message\n"));
-               return -1;
-       }
-
-       if ((fp = procmsg_open_mark_file(path, TRUE)) == NULL)
-               g_warning(_("can't open mark file\n"));
-       else {
-               MsgInfo newmsginfo;
-
-               newmsginfo.msgnum = num;
-               newmsginfo.flags.perm_flags = 0;
-               newmsginfo.flags.tmp_flags = 0;
-               procmsg_write_flags(&newmsginfo, fp);
-               fclose(fp);
-       }
-       g_free(path);
-
-       return 0;
-}
-
 static gint compose_remove_reedit_target(Compose *compose)
 {
        FolderItem *item;
index 32d3780356d8349e50b775a422c8864ae5178cae..a9530ea851bcc7dd43c2232d4abfc40cab76db53 100644 (file)
@@ -569,7 +569,7 @@ static void send_queue(void)
 {
        GList *list;
 
-       if (procmsg_send_queue() < 0)
+       if (procmsg_send_queue(prefs_common.savemsg) < 0)
                alertpanel_error(_("Some errors occurred while sending queued messages."));
 
        statusbar_pop_all();
index 53aaf15c7f71a29fc9dc5ec9fe00268b7c3da69e..80e081452a422919a6653dc79d8a077ce154a679 100644 (file)
@@ -2571,7 +2571,7 @@ static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        GList *list;
 
-       if (procmsg_send_queue() < 0)
+       if (procmsg_send_queue(prefs_common.savemsg) < 0)
                alertpanel_error(_("Some errors occurred while sending queued messages."));
 
        statusbar_pop_all();
index 9fa17a8e547df04b21f664de16e1fb084d7288e0..8d3ef593df520c071d2dddaf956c3358543fde89 100644 (file)
@@ -827,7 +827,7 @@ void procmsg_empty_trash(void)
        }
 }
 
-gint procmsg_send_queue(void)
+gint procmsg_send_queue(gboolean save_msgs)
 {
        FolderItem *queue;
        gint i;
@@ -847,8 +847,13 @@ gint procmsg_send_queue(void)
                        if (procmsg_send_message_queue(file) < 0) {
                                g_warning(_("Sending queued message %d failed.\n"), i);
                                ret = -1;
-                       } else
+                       } else {
+                               if (save_msgs)
+                                       procmsg_save_to_outbox
+                                               (queue->folder->outbox,
+                                                file, TRUE);
                                folder_item_remove_msg(queue, i);
+                       }
                        g_free(file);
                }
        }
@@ -856,6 +861,68 @@ gint procmsg_send_queue(void)
        return ret;
 }
 
+gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
+                           gboolean is_queued)
+{
+       gint num;
+       FILE *fp;
+       gchar *path;
+
+       debug_print(_("saving sent message...\n"));
+
+       if (!outbox)
+               outbox = folder_get_default_outbox();
+       g_return_val_if_fail(outbox != NULL, -1);
+
+       /* 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);
+                       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);
+               Xstrdup_a(file, tmp, return -1);
+       }
+
+       folder_item_scan(outbox);
+       if ((num = folder_item_add_msg(outbox, file, FALSE)) < 0) {
+               g_warning(_("can't save message\n"));
+               return -1;
+       }
+
+       path = folder_item_get_path(outbox);
+       if ((fp = procmsg_open_mark_file(path, TRUE)) == NULL)
+               g_warning(_("can't open mark file\n"));
+       else {
+               MsgInfo newmsginfo;
+
+               newmsginfo.msgnum = num;
+               newmsginfo.flags.perm_flags = 0;
+               newmsginfo.flags.tmp_flags = 0;
+               procmsg_write_flags(&newmsginfo, fp);
+               fclose(fp);
+       }
+       g_free(path);
+
+       return 0;
+}
+
 void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline)
 {
        static const gchar *def_cmd = "lpr %s";
index 6895c2a057e5d380154ea7555f7f612f91a57b18..e30578ad3bc22fe01a3ec655416dd64d2ba33c2e 100644 (file)
@@ -242,7 +242,10 @@ FILE   *procmsg_open_message_decrypted     (MsgInfo        *msginfo,
 gboolean procmsg_msg_exist             (MsgInfo        *msginfo);
 
 void   procmsg_empty_trash             (void);
-gint   procmsg_send_queue              (void);
+gint   procmsg_send_queue              (gboolean        save_msgs);
+gint   procmsg_save_to_outbox          (FolderItem     *outbox,
+                                        const gchar    *file,
+                                        gboolean        is_queued);
 void   procmsg_print_message           (MsgInfo        *msginfo,
                                         const gchar    *cmdline);