Save an email.
783{
785 return -1;
786
787 int rc = -1;
788 int tagged_progress_count = 0;
791
793 struct stat st = { 0 };
795
797 const bool is_passphrase_needed = security_flags &
SEC_ENCRYPT;
798
799 const char *prompt = NULL;
800 const char *progress_msg = NULL;
801
802
803 switch (save_opt)
804 {
806
807 progress_msg = (msg_count > 1) ?
_(
"Copying tagged messages...") : NULL;
808 switch (transform_opt)
809 {
811 prompt = (msg_count > 1) ?
_(
"Copy tagged to mailbox") :
_(
"Copy to mailbox");
812 break;
814 prompt = (msg_count > 1) ?
_(
"Decrypt-copy tagged to mailbox") :
815 _(
"Decrypt-copy to mailbox");
816 break;
818 prompt = (msg_count > 1) ?
_(
"Decode-copy tagged to mailbox") :
819 _(
"Decode-copy to mailbox");
820 break;
821 }
822 break;
823
825
826 progress_msg = (msg_count > 1) ?
_(
"Saving tagged messages...") : NULL;
827 switch (transform_opt)
828 {
830 prompt = (msg_count > 1) ?
_(
"Save tagged to mailbox") :
_(
"Save to mailbox");
831 break;
833 prompt = (msg_count > 1) ?
_(
"Decrypt-save tagged to mailbox") :
834 _(
"Decrypt-save to mailbox");
835 break;
837 prompt = (msg_count > 1) ?
_(
"Decode-save tagged to mailbox") :
838 _(
"Decode-save to mailbox");
839 break;
840 }
841 break;
842 }
843
847
849 {
850 goto cleanup;
851 }
852
854 if (pathlen == 0)
855 goto cleanup;
856
858
859
860
865 else
867
869
870
872 goto cleanup;
873
876 {
877 rc = -1;
878 goto errcleanup;
879 }
880
882
885 {
887 switch (rc)
888 {
889
890 case 0:
892 rc = 0;
894 {
896 if (c_delete_untag)
897 {
898 struct Email **ep = NULL;
900 {
902 }
903 }
904 }
905 goto cleanup;
906
907 case 1:
908 break;
909
910 case -1:
911 goto errcleanup;
912 }
913 }
914
917 bool old_append = m_save->
append;
919
920
921 if (msg_count > 1)
924 {
925 rc = -1;
927 goto errcleanup;
928 }
930
931
932
935 {
937 }
938
940 m_comp = NULL;
941
943 {
945 if (rc != 0)
946 {
948 m_save->
append = old_append;
949 goto errcleanup;
950 }
951
952 if (m_comp)
953 {
956 {
960 }
963 }
964 }
965 else
966 {
967 rc = 0;
968
969#ifdef USE_NOTMUCH
972#endif
975 struct Email **ep = NULL;
977 {
978 struct Email *e = *ep;
982 if (rc != 0)
983 break;
984
985 if (m_comp)
986 {
987 struct Email *e2 = e;
990 {
994 }
997 }
998 }
1000
1001#ifdef USE_NOTMUCH
1004#endif
1005 if (rc != 0)
1006 {
1008 m_save->
append = old_append;
1009 goto errcleanup;
1010 }
1011 }
1012
1013 const bool need_mailbox_cleanup = ((m_save->
type ==
MUTT_MBOX) ||
1015
1017 m_save->
append = old_append;
1018
1019 if (need_mailbox_cleanup)
1021
1023 rc = 0;
1024
1025errcleanup:
1026 if (rc != 0)
1027 {
1028 switch (save_opt)
1029 {
1031 if (msg_count > 1)
1032 {
1033
1035 }
1036 else
1037 {
1038
1040 }
1041 break;
1043 if (msg_count > 1)
1044 {
1045
1047 }
1048 else
1049 {
1050
1052 }
1053 break;
1054 }
1055 }
1056
1058
1059cleanup:
1061 return rc;
1062}
#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 buf_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.