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
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,
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);
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;
{
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();
{
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();
}
}
-gint procmsg_send_queue(void)
+gint procmsg_send_queue(gboolean save_msgs)
{
FolderItem *queue;
gint i;
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);
}
}
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";
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);