talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 302c2dfcae9028ae38b34e6f6b299ff8bba57096
parent d5b6496a51fc272242bd52a4d6d47e0aa5ebe9a4
Author: Paul <paul@claws-mail.org>
Date:   Sat, 28 Sep 2024 07:03:00 +0100

clean up procmsg_save_to_outbox()

is_queded is always TRUE, we don't need it; add an alertpanel_warning which is, nevertheless, unlikely to ever be reached; improve the English used

Diffstat:
Msrc/compose.c | 4++--
Msrc/procmsg.c | 60+++++++++++++++++++++++-------------------------------------
Msrc/procmsg.h | 3+--
3 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/src/compose.c b/src/compose.c @@ -5991,7 +5991,7 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool if (!outbox) outbox = folder_get_default_outbox(); - procmsg_save_to_outbox(outbox, tmp_enc_file, TRUE); + procmsg_save_to_outbox(outbox, tmp_enc_file); claws_unlink(tmp_enc_file); } else { g_warning("can't open file '%s'", tmp_enc_file); @@ -7611,7 +7611,7 @@ static void compose_savemsg_select_cb(GtkWidget *widget, Compose *compose) gchar * path; dest = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL, FALSE, - _("Select folder to save message to")); + _("Select the folder where you want to save the sent message")); if (!dest) return; path = folder_item_get_identifier(dest); diff --git a/src/procmsg.c b/src/procmsg.c @@ -1153,8 +1153,7 @@ gint procmsg_remove_special_headers(const gchar *in, const gchar *out) return 0; } -gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file, - gboolean is_queued) +gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file) { gint num; MsgInfo *msginfo, *tmp_msginfo; @@ -1169,48 +1168,35 @@ gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file, cm_return_val_if_fail(outbox != NULL, -1); outbox_path = folder_item_get_path(outbox); - debug_print("saving sent message to %s...\n", outbox_path); + debug_print("attempting to save sent message to %s...\n", outbox_path); g_free(outbox_path); - /* remove queueing headers */ - if (is_queued) { - gchar tmp[MAXPATHLEN + 1]; + gchar tmp[MAXPATHLEN + 1]; - g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.out.%08x", - get_rc_dir(), G_DIR_SEPARATOR, (guint) rand()); - - if (procmsg_remove_special_headers(file, tmp) !=0) - return -1; + g_snprintf(tmp, sizeof(tmp), "%s%ctmpmsg.out.%08x", + get_rc_dir(), G_DIR_SEPARATOR, (guint) rand()); + + if (procmsg_remove_special_headers(file, tmp) !=0) + return -1; - while (folder_item_scan(outbox) < 0) { - outbox = foldersel_folder_sel(NULL, FOLDER_SEL_SAVE, NULL, FALSE, - _("Select folder to save message to")); - if (outbox == NULL) { - g_warning("not saving message"); - claws_unlink(tmp); - return -1; - } - } - if ((num = folder_item_add_msg(outbox, tmp, &flag, TRUE)) < 0) { - g_warning("not saving message"); + while (folder_item_scan(outbox) < 0) { + outbox = foldersel_folder_sel(NULL, FOLDER_SEL_SAVE, NULL, FALSE, + _("Select the folder where you want to save the sent message")); + if (outbox == NULL) { + g_warning("not saving sent message"); claws_unlink(tmp); return -1; } - } else { - while (folder_item_scan(outbox) < 0) { - outbox = foldersel_folder_sel(NULL, FOLDER_SEL_SAVE, NULL, FALSE, - _("Select folder to save message to")); - if (outbox == NULL) { - g_warning("not saving message"); - return -1; - } - } - if ((num = folder_item_add_msg - (outbox, file, &flag, FALSE)) < 0) { - g_warning("not saving message"); - return -1; - } } + if ((num = folder_item_add_msg(outbox, tmp, &flag, TRUE)) < 0) { + g_warning("not saving sent message"); + outbox_path = folder_item_get_path(outbox); + alertpanel_warning(_("Could not save sent message to %s."), outbox_path); + claws_unlink(tmp); + g_free(outbox_path); + return -1; + } + msginfo = folder_item_get_msginfo(outbox, num); /* refcnt++ */ tmp_msginfo = procmsg_msginfo_get_full_info(msginfo); /* refcnt++ */ if (msginfo != NULL) { @@ -1820,7 +1806,7 @@ send_mail: } if (!saved) { debug_print("resaving queued mail to sent folder\n"); - procmsg_save_to_outbox(outbox, file, TRUE); + procmsg_save_to_outbox(outbox, file); } } } diff --git a/src/procmsg.h b/src/procmsg.h @@ -370,8 +370,7 @@ void procmsg_msginfo_change_flags (MsgInfo *msginfo, gint procmsg_remove_special_headers (const gchar *in, const gchar *out); -gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file, - gboolean is_queued); +gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file); gboolean procmsg_msg_has_flagged_parent (MsgInfo *info, MsgPermFlags perm_flags); gboolean procmsg_msg_has_marked_parent (MsgInfo *info);