Save an email.
786{
788 return -1;
789
790 int rc = -1;
791 int tagged_progress_count = 0;
794
796 struct stat st = { 0 };
798
800 const bool is_passphrase_needed = security_flags &
SEC_ENCRYPT;
801
802 const char *prompt = NULL;
803 const char *progress_msg = NULL;
804
805
806 switch (save_opt)
807 {
809
810 progress_msg = (msg_count > 1) ?
_(
"Copying tagged messages...") : NULL;
811 switch (transform_opt)
812 {
814 prompt = (msg_count > 1) ?
_(
"Copy tagged to mailbox") :
_(
"Copy to mailbox");
815 break;
817 prompt = (msg_count > 1) ?
_(
"Decrypt-copy tagged to mailbox") :
818 _(
"Decrypt-copy to mailbox");
819 break;
821 prompt = (msg_count > 1) ?
_(
"Decode-copy tagged to mailbox") :
822 _(
"Decode-copy to mailbox");
823 break;
824 }
825 break;
826
828
829 progress_msg = (msg_count > 1) ?
_(
"Saving tagged messages...") : NULL;
830 switch (transform_opt)
831 {
833 prompt = (msg_count > 1) ?
_(
"Save tagged to mailbox") :
_(
"Save to mailbox");
834 break;
836 prompt = (msg_count > 1) ?
_(
"Decrypt-save tagged to mailbox") :
837 _(
"Decrypt-save to mailbox");
838 break;
840 prompt = (msg_count > 1) ?
_(
"Decode-save tagged to mailbox") :
841 _(
"Decode-save to mailbox");
842 break;
843 }
844 break;
845 }
846
850
852 {
853 goto cleanup;
854 }
855
857 if (pathlen == 0)
858 goto cleanup;
859
861
862
863
868 else
870
872
873
875 goto cleanup;
876
879 {
880 rc = -1;
881 goto errcleanup;
882 }
883
885
888 {
890 switch (rc)
891 {
892
893 case 0:
895 rc = 0;
897 {
899 if (c_delete_untag)
900 {
901 struct Email **ep = NULL;
903 {
905 }
906 }
907 }
908 goto cleanup;
909
910 case 1:
911 break;
912
913 case -1:
914 default:
915 goto errcleanup;
916 }
917 }
918
921 bool old_append = m_save->
append;
923
924
925 if (msg_count > 1)
928 {
929 rc = -1;
931 goto errcleanup;
932 }
934
935
936
939 {
941 }
942
944 m_comp = NULL;
945
947 {
949 if (rc != 0)
950 {
952 m_save->
append = old_append;
953 goto errcleanup;
954 }
955
956 if (m_comp)
957 {
960 {
964 }
967 }
968 }
969 else
970 {
971 rc = 0;
972
973#ifdef USE_NOTMUCH
976#endif
979 struct Email **ep = NULL;
981 {
982 struct Email *e = *ep;
986 if (rc != 0)
987 break;
988
989 if (m_comp)
990 {
991 struct Email *e2 = e;
994 {
998 }
1001 }
1002 }
1004
1005#ifdef USE_NOTMUCH
1008#endif
1009 if (rc != 0)
1010 {
1012 m_save->
append = old_append;
1013 goto errcleanup;
1014 }
1015 }
1016
1017 const bool need_mailbox_cleanup = ((m_save->
type ==
MUTT_MBOX) ||
1019
1021 m_save->
append = old_append;
1022
1023 if (need_mailbox_cleanup)
1025
1027 rc = 0;
1028
1029errcleanup:
1030 if (rc != 0)
1031 {
1032 switch (save_opt)
1033 {
1035 if (msg_count > 1)
1036 {
1037
1039 }
1040 else
1041 {
1042
1044 }
1045 break;
1047 if (msg_count > 1)
1048 {
1049
1051 }
1052 else
1053 {
1054
1056 }
1057 break;
1058 }
1059 }
1060
1062
1063cleanup:
1065 return rc;
1066}
@ MUTT_SEL_NONE
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.
@ MUTT_QUIET
Do not print any messages.
@ MUTT_APPEND
Open mailbox for appending messages.
@ SEC_NONE
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.