Save an email.
782{
784 return -1;
785
786 int rc = -1;
787 int tagged_progress_count = 0;
790
792 struct stat st = { 0 };
794
796 const bool is_passphrase_needed = security_flags &
SEC_ENCRYPT;
797
798 const char *prompt = NULL;
799 const char *progress_msg = NULL;
800
801
802 switch (save_opt)
803 {
805
806 progress_msg = (msg_count > 1) ?
_(
"Copying tagged messages...") : NULL;
807 switch (transform_opt)
808 {
810 prompt = (msg_count > 1) ?
_(
"Copy tagged to mailbox") :
_(
"Copy to mailbox");
811 break;
813 prompt = (msg_count > 1) ?
_(
"Decrypt-copy tagged to mailbox") :
814 _(
"Decrypt-copy to mailbox");
815 break;
817 prompt = (msg_count > 1) ?
_(
"Decode-copy tagged to mailbox") :
818 _(
"Decode-copy to mailbox");
819 break;
820 }
821 break;
822
824
825 progress_msg = (msg_count > 1) ?
_(
"Saving tagged messages...") : NULL;
826 switch (transform_opt)
827 {
829 prompt = (msg_count > 1) ?
_(
"Save tagged to mailbox") :
_(
"Save to mailbox");
830 break;
832 prompt = (msg_count > 1) ?
_(
"Decrypt-save tagged to mailbox") :
833 _(
"Decrypt-save to mailbox");
834 break;
836 prompt = (msg_count > 1) ?
_(
"Decode-save tagged to mailbox") :
837 _(
"Decode-save to mailbox");
838 break;
839 }
840 break;
841 }
842
846
848 {
849 goto cleanup;
850 }
851
853 if (pathlen == 0)
854 goto cleanup;
855
857
858
859
864 else
866
868
869
871 goto cleanup;
872
875 {
876 rc = -1;
877 goto errcleanup;
878 }
879
881
884 {
886 switch (rc)
887 {
888
889 case 0:
891 rc = 0;
893 {
895 if (c_delete_untag)
896 {
897 struct Email **ep = NULL;
899 {
901 }
902 }
903 }
904 goto cleanup;
905
906 case 1:
907 break;
908
909 case -1:
910 goto errcleanup;
911 }
912 }
913
916 bool old_append = m_save->
append;
918
919
920 if (msg_count > 1)
923 {
924 rc = -1;
926 goto errcleanup;
927 }
929
930
931
934 {
936 }
937
939 m_comp = NULL;
940
942 {
944 if (rc != 0)
945 {
947 m_save->
append = old_append;
948 goto errcleanup;
949 }
950
951 if (m_comp)
952 {
955 {
959 }
962 }
963 }
964 else
965 {
966 rc = 0;
967
968#ifdef USE_NOTMUCH
971#endif
974 struct Email **ep = NULL;
976 {
977 struct Email *e = *ep;
981 if (rc != 0)
982 break;
983
984 if (m_comp)
985 {
986 struct Email *e2 = e;
989 {
993 }
996 }
997 }
999
1000#ifdef USE_NOTMUCH
1003#endif
1004 if (rc != 0)
1005 {
1007 m_save->
append = old_append;
1008 goto errcleanup;
1009 }
1010 }
1011
1012 const bool need_mailbox_cleanup = ((m_save->
type ==
MUTT_MBOX) ||
1014
1016 m_save->
append = old_append;
1017
1018 if (need_mailbox_cleanup)
1020
1022 rc = 0;
1023
1024errcleanup:
1025 if (rc != 0)
1026 {
1027 switch (save_opt)
1028 {
1030 if (msg_count > 1)
1031 {
1032
1034 }
1035 else
1036 {
1037
1039 }
1040 break;
1042 if (msg_count > 1)
1043 {
1044
1046 }
1047 else
1048 {
1049
1051 }
1052 break;
1053 }
1054 }
1055
1057
1058cleanup:
1060 return rc;
1061}
#define MUTT_SEL_NO_FLAGS
No flags are set.
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
MailboxType
Supported mailbox formats.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
@ MUTT_MMDF
'mmdf' Mailbox type
@ MUTT_IMAP
'IMAP' Mailbox type
@ MUTT_MBOX
'mbox' Mailbox type
int mutt_save_message_mbox(struct Mailbox *m_src, struct Email *e, enum MessageSaveOpt save_opt, enum MessageTransformOpt transform_opt, struct Mailbox *m_dst)
Save a message to a given mailbox.
@ SAVE_COPY
Copy message, making a duplicate in another mailbox.
void mutt_file_resolve_symlink(struct Buffer *buf)
Resolve a symlink in place.
int mw_enter_fname(const char *prompt, struct Buffer *fname, bool mailbox, struct Mailbox *m, bool multiple, char ***files, int *numfiles, SelectFileFlags flags)
Ask the user to select a file -.
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox?
void mutt_default_save(struct Buffer *path, struct Email *e)
Find the default save path for an email.
int imap_copy_messages(struct Mailbox *m, struct EmailArray *ea, const char *dest, enum MessageSaveOpt save_opt)
Server COPY messages to another folder.
bool mutt_path_tidy(struct Buffer *path, bool is_dir)
Remove unnecessary parts of a path.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
void mailbox_restore_timestamp(const char *path, struct stat *st)
Restore the timestamp of a mailbox.
void pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
uint8_t OpenMailboxFlags
Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT.
#define MUTT_APPEND
Open mailbox for appending messages.
#define MUTT_QUIET
Do not print any messages.
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
#define SEC_NO_FLAGS
No flags are set.
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
@ MUTT_PROGRESS_WRITE
Progress tracks elements, according to $write_inc
struct Progress * progress_new(enum ProgressType type, size_t size)
Create a new Progress Bar.
void progress_free(struct Progress **ptr)
Free a Progress Bar.
void progress_set_message(struct Progress *progress, const char *fmt,...) __attribute__((__format__(__printf__
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
bool old
Email is seen, but unread.
bool flagged
Marked important?
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
bool append
Mailbox is opened in append mode.
int msg_new
Number of new messages.
int msg_count
Total number of messages.
enum MailboxType type
Mailbox type.
int msg_flagged
Number of flagged messages.
void * compress_info
Compressed mbox module private data.
int msg_unread
Number of unread messages.