NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Compose Function API

Prototype for a Compose Function. More...

+ Collaboration diagram for Compose Function API:

Functions

static int op_attach_attach_file (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Attach files to this message - Implements compose_function_t -.
 
static int op_attach_attach_key (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Attach a PGP public key - Implements compose_function_t -.
 
static int op_attach_attach_message (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Attach messages to this message - Implements compose_function_t -.
 
static int op_attach_detach (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Delete the current entry - Implements compose_function_t -.
 
static int op_attach_edit_content_id (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit the 'Content-ID' of the attachment - Implements compose_function_t -.
 
static int op_attach_edit_description (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment description - Implements compose_function_t -.
 
static int op_attach_edit_encoding (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment transfer-encoding - Implements compose_function_t -.
 
static int op_attach_edit_language (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit the 'Content-Language' of the attachment - Implements compose_function_t -.
 
static int op_attach_edit_mime (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment using mailcap entry - Implements compose_function_t -.
 
static int op_attach_edit_type (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment content type - Implements compose_function_t -.
 
static int op_attach_filter (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Filter attachment through a shell command - Implements compose_function_t -.
 
static int op_attach_get_attachment (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Get a temporary copy of an attachment - Implements compose_function_t -.
 
static int op_attach_group_alts (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Group tagged attachments as 'multipart/alternative' - Implements compose_function_t -.
 
static int op_attach_group_lingual (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Group tagged attachments as 'multipart/multilingual' - Implements compose_function_t -.
 
static int op_attach_group_related (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Group tagged attachments as 'multipart/related' - Implements compose_function_t -.
 
static int op_attach_move_down (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Move an attachment down in the attachment list - Implements compose_function_t -.
 
static int op_attach_move_up (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Move an attachment up in the attachment list - Implements compose_function_t -.
 
static int op_attach_new_mime (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Compose new attachment using mailcap entry - Implements compose_function_t -.
 
static int op_attach_print (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Print the current entry - Implements compose_function_t -.
 
static int op_attach_rename_attachment (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Send attachment with a different name - Implements compose_function_t -.
 
static int op_attach_save (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Save message/attachment to a mailbox/file - Implements compose_function_t -.
 
static int op_attach_toggle_disposition (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Toggle disposition between inline/attachment - Implements compose_function_t -.
 
static int op_attach_toggle_recode (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Toggle recoding of this attachment - Implements compose_function_t -.
 
static int op_attach_toggle_unlink (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Toggle whether to delete file after sending it - Implements compose_function_t -.
 
static int op_attach_ungroup (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Ungroup a 'multipart' attachment - Implements compose_function_t -.
 
static int op_attach_update_encoding (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Update an attachment's encoding info - Implements compose_function_t -.
 
static int op_envelope_edit_headers (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit the message with headers - Implements compose_function_t -.
 
static int op_compose_edit_file (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit the file to be attached - Implements compose_function_t -.
 
static int op_compose_edit_message (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit the message - Implements compose_function_t -.
 
static int op_compose_ispell (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Run ispell on the message - Implements compose_function_t -.
 
static int op_compose_postpone_message (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Save this message to send later - Implements compose_function_t -.
 
static int op_compose_rename_file (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Rename/move an attached file - Implements compose_function_t -.
 
static int op_compose_send_message (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Send the message - Implements compose_function_t -.
 
static int op_compose_write_message (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Write the message to a folder - Implements compose_function_t -.
 
static int op_display_headers (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Display message and toggle header weeding - Implements compose_function_t -.
 
static int op_exit (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Exit this menu - Implements compose_function_t -.
 
static int op_forget_passphrase (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Wipe passphrases from memory - Implements compose_function_t -.
 

Detailed Description

Prototype for a Compose Function.

Parameters
sharedShared Compose data
eventEvent to process
Return values
enumFunctionRetval
Precondition
shared is not NULL
event is not NULL

Function Documentation

◆ op_attach_attach_file()

static int op_attach_attach_file ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Attach files to this message - Implements compose_function_t -.

Definition at line 745 of file functions.c.

746{
747 char *prompt = _("Attach file");
748 int numfiles = 0;
749 char **files = NULL;
750
751 struct Buffer *fname = buf_pool_get();
752 if ((mw_enter_fname(prompt, fname, false, NULL, true, &files, &numfiles,
753 MUTT_SEL_MULTI) == -1) ||
754 buf_is_empty(fname))
755 {
756 for (int i = 0; i < numfiles; i++)
757 FREE(&files[i]);
758
759 FREE(&files);
760 buf_pool_release(&fname);
761 return FR_NO_ACTION;
762 }
763
764 bool error = false;
765 bool added_attachment = false;
766 if (numfiles > 1)
767 {
768 mutt_message(ngettext("Attaching selected file...",
769 "Attaching selected files...", numfiles));
770 }
771 for (int i = 0; i < numfiles; i++)
772 {
773 char *att = files[i];
774 if (!att)
775 continue;
776
777 struct AttachPtr *ap = mutt_aptr_new();
778 ap->unowned = true;
779 ap->body = mutt_make_file_attach(att, shared->sub);
780 if (ap->body)
781 {
782 added_attachment = true;
783 update_idx(shared->adata->menu, shared->adata->actx, ap);
784 }
785 else
786 {
787 error = true;
788 mutt_error(_("Unable to attach %s"), att);
789 mutt_aptr_free(&ap);
790 }
791 FREE(&files[i]);
792 }
793
794 FREE(&files);
795 buf_pool_release(&fname);
796
797 if (!error)
799
802 if (added_attachment)
803 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
804 return FR_SUCCESS;
805}
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
Definition attach.c:40
void mutt_aptr_free(struct AttachPtr **ptr)
Free an Attachment Pointer.
Definition attach.c:49
#define MUTT_SEL_MULTI
Multi-selection is enabled.
Definition lib.h:60
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
@ CMD_SEND2_HOOK
:send2-hook
Definition command.h:106
static void update_idx(struct Menu *menu, struct AttachCtx *actx, struct AttachPtr *ap)
Add a new attachment to the message.
Definition functions.c:436
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
@ NT_EMAIL_CHANGE_ATTACH
Email's Attachments have changed.
Definition email.h:188
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 -.
Definition curs_lib.c:236
#define mutt_error(...)
Definition logging2.h:94
#define mutt_message(...)
Definition logging2.h:93
void exec_message_hook(struct Mailbox *m, struct Email *e, enum CommandId id)
Perform a message hook.
Definition exec.c:135
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:57
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:188
#define _(a)
Definition message.h:28
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition notify_type.h:44
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
struct Body * mutt_make_file_attach(const char *path, struct ConfigSubset *sub)
Create a file attachment.
Definition sendlib.c:613
An email to which things will be attached.
Definition attach.h:35
struct Body * body
Attachment.
Definition attach.h:36
bool unowned
Don't unlink on detach.
Definition attach.h:42
String manipulation buffer.
Definition buffer.h:36
struct Menu * menu
Menu displaying the attachments.
Definition attach_data.h:35
struct AttachCtx * actx
Set of attachments.
Definition attach_data.h:34
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:36
struct ComposeAttachData * adata
Attachments.
Definition shared_data.h:39
struct Email * email
Email being composed.
Definition shared_data.h:38
struct Notify * notify
Notifications: NotifyEmail, EventEmail.
Definition email.h:73
+ Here is the call graph for this function:

◆ op_attach_attach_key()

static int op_attach_attach_key ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Attach a PGP public key - Implements compose_function_t -.

Definition at line 810 of file functions.c.

811{
813 return FR_NOT_IMPL;
814 struct AttachPtr *ap = mutt_aptr_new();
816 if (ap->body)
817 {
818 update_idx(shared->adata->menu, shared->adata->actx, ap);
820 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
821 }
822 else
823 {
824 mutt_aptr_free(&ap);
825 }
826
828 return FR_SUCCESS;
829}
struct Body * crypt_pgp_make_key_attachment(void)
Wrapper for CryptModuleSpecs::pgp_make_key_attachment()
Definition cryptglue.c:304
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition dispatcher.h:37
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:98
#define WithCrypto
Definition lib.h:124
+ Here is the call graph for this function:

◆ op_attach_attach_message()

static int op_attach_attach_message ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Attach messages to this message - Implements compose_function_t -.

This function handles:

  • OP_ATTACH_ATTACH_MESSAGE
  • OP_ATTACH_ATTACH_NEWS_MESSAGE

Definition at line 838 of file functions.c.

840{
841 char *prompt = _("Open mailbox to attach message from");
842
843 OptNews = false;
844 const int op = event->op;
845 if (shared->mailbox && (op == OP_ATTACH_ATTACH_NEWS_MESSAGE))
846 {
847 const char *const c_news_server = cs_subset_string(shared->sub, "news_server");
848 CurrentNewsSrv = nntp_select_server(shared->mailbox, c_news_server, false);
849 if (!CurrentNewsSrv)
850 return FR_NO_ACTION;
851
852 prompt = _("Open newsgroup to attach message from");
853 OptNews = true;
854 }
855
856 struct Buffer *fname = buf_pool_get();
857 if (shared->mailbox)
858 {
859 if ((op == OP_ATTACH_ATTACH_MESSAGE) ^ (shared->mailbox->type == MUTT_NNTP))
860 {
861 buf_strcpy(fname, mailbox_path(shared->mailbox));
862 pretty_mailbox(fname);
863 }
864 }
865
866 if ((mw_enter_fname(prompt, fname, true, shared->mailbox, false, NULL, NULL,
867 MUTT_SEL_NO_FLAGS) == -1) ||
868 buf_is_empty(fname))
869 {
870 buf_pool_release(&fname);
871 return FR_NO_ACTION;
872 }
873
874 if (OptNews)
875 nntp_expand_path(fname->data, fname->dsize, &CurrentNewsSrv->conn->account);
876 else
877 expand_path(fname, false);
878
879 if (imap_path_probe(buf_string(fname), NULL) != MUTT_IMAP)
880 {
881 if (pop_path_probe(buf_string(fname), NULL) != MUTT_POP)
882 {
883 if (!OptNews && (nntp_path_probe(buf_string(fname), NULL) != MUTT_NNTP))
884 {
886 {
887 /* check to make sure the file exists and is readable */
888 if (access(buf_string(fname), R_OK) == -1)
889 {
890 mutt_perror("%s", buf_string(fname));
891 buf_pool_release(&fname);
892 return FR_ERROR;
893 }
894 }
895 }
896 }
897 }
898
900
901 struct Mailbox *m_attach = mx_path_resolve(buf_string(fname));
902 const bool old_readonly = m_attach->readonly;
903 if (!mx_mbox_open(m_attach, MUTT_READONLY))
904 {
905 mutt_error(_("Unable to open mailbox %s"), buf_string(fname));
906 mx_fastclose_mailbox(m_attach, false);
907 m_attach = NULL;
908 buf_pool_release(&fname);
909 return FR_ERROR;
910 }
911 buf_pool_release(&fname);
912
913 if (m_attach->msg_count == 0)
914 {
915 mx_mbox_close(m_attach);
916 mutt_error(_("No messages in that folder"));
917 return FR_NO_ACTION;
918 }
919
920 /* `$sort`, `$sort_aux`, `$use_threads` could be changed in dlg_index() */
921 const enum EmailSortType old_sort = cs_subset_sort(shared->sub, "sort");
922 const enum EmailSortType old_sort_aux = cs_subset_sort(shared->sub, "sort_aux");
923 const unsigned char old_use_threads = cs_subset_enum(shared->sub, "use_threads");
924
925 mutt_message(_("Tag the messages you want to attach"));
926 struct MuttWindow *dlg = index_pager_init();
927 struct IndexSharedData *index_shared = dlg->wdata;
928 index_shared->attach_msg = true;
929 dialog_push(dlg);
930 struct Mailbox *m_attach_new = dlg_index(dlg, m_attach);
931 dialog_pop();
932 mutt_window_free(&dlg);
933
934 if (!shared->mailbox)
935 {
936 /* Restore old $sort variables */
937 cs_subset_str_native_set(shared->sub, "sort", old_sort, NULL);
938 cs_subset_str_native_set(shared->sub, "sort_aux", old_sort_aux, NULL);
939 cs_subset_str_native_set(shared->sub, "use_threads", old_use_threads, NULL);
942 return FR_SUCCESS;
943 }
944
945 bool added_attachment = false;
946 for (int i = 0; i < m_attach_new->msg_count; i++)
947 {
948 if (!m_attach_new->emails[i])
949 break;
950 if (!message_is_tagged(m_attach_new->emails[i]))
951 continue;
952
953 struct AttachPtr *ap = mutt_aptr_new();
954 ap->body = mutt_make_message_attach(m_attach_new, m_attach_new->emails[i],
955 true, shared->sub);
956 if (ap->body)
957 {
958 added_attachment = true;
959 update_idx(shared->adata->menu, shared->adata->actx, ap);
960 }
961 else
962 {
963 mutt_error(_("Unable to attach"));
964 mutt_aptr_free(&ap);
965 }
966 }
968
969 if (m_attach_new == m_attach)
970 {
971 m_attach->readonly = old_readonly;
972 }
973 mx_fastclose_mailbox(m_attach_new, false);
974
975 /* Restore old $sort variables */
976 cs_subset_str_native_set(shared->sub, "sort", old_sort, NULL);
977 cs_subset_str_native_set(shared->sub, "sort_aux", old_sort_aux, NULL);
978 cs_subset_str_native_set(shared->sub, "use_threads", old_use_threads, NULL);
980 if (added_attachment)
981 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
982 return FR_SUCCESS;
983}
#define MUTT_SEL_NO_FLAGS
No flags are set.
Definition lib.h:58
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
unsigned char cs_subset_enum(const struct ConfigSubset *sub, const char *name)
Get a enumeration config item by name.
Definition helpers.c:71
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition helpers.c:266
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:213
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
@ MUTT_POP
'POP3' Mailbox type
Definition mailbox.h:51
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition mailbox.h:48
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:49
void dialog_push(struct MuttWindow *dlg)
Display a Window to the user.
Definition dialog.c:109
void dialog_pop(void)
Hide a Window from the user.
Definition dialog.c:142
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
struct MuttWindow * index_pager_init(void)
Allocate the Windows for the Index/Pager.
Definition dlg_index.c:1456
EmailSortType
Methods for sorting Emails.
Definition sort.h:53
bool OptNews
(pseudo) used to change reader mode
Definition globals.c:53
struct Mailbox * dlg_index(struct MuttWindow *dlg, struct Mailbox *m_init)
Display a list of emails -.
Definition dlg_index.c:1118
#define mutt_perror(...)
Definition logging2.h:95
enum MailboxType nntp_path_probe(const char *path, const struct stat *st)
Is this an NNTP Mailbox?
Definition nntp.c:2787
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox?
Definition pop.c:1162
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox?
Definition imap.c:2546
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:60
void mutt_window_free(struct MuttWindow **ptr)
Free a Window and its children.
void pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition muttlib.c:428
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:122
bool message_is_tagged(struct Email *e)
Is a message in the index tagged (and within limit)
Definition mview.c:361
void mx_fastclose_mailbox(struct Mailbox *m, bool keep_account)
Free up memory associated with the Mailbox.
Definition mx.c:411
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition mx.c:285
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition mx.c:1323
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition mx.c:1647
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
Definition mx.c:595
#define MUTT_READONLY
Open in read-only mode.
Definition mxapi.h:42
void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct)
Make fully qualified url from newsgroup name.
Definition newsrc.c:555
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition nntp.c:74
struct NntpAccountData * nntp_select_server(struct Mailbox *m, const char *server, bool leave_lock)
Open a connection to an NNTP server.
Definition newsrc.c:951
struct Body * mutt_make_message_attach(struct Mailbox *m, struct Email *e, bool attach_msg, struct ConfigSubset *sub)
Create a message attachment.
Definition sendlib.c:453
size_t dsize
Length of data.
Definition buffer.h:39
char * data
Pointer to data.
Definition buffer.h:37
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:37
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
bool attach_msg
Are we in "attach message" mode?
Definition shared_data.h:46
A mailbox.
Definition mailbox.h:78
int msg_count
Total number of messages.
Definition mailbox.h:87
enum MailboxType type
Mailbox type.
Definition mailbox.h:101
struct Email ** emails
Array of Emails.
Definition mailbox.h:95
bool readonly
Don't allow changes to the mailbox.
Definition mailbox.h:115
void * wdata
Private data.
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition subset.c:303
+ Here is the call graph for this function:

◆ op_attach_detach()

static int op_attach_detach ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Delete the current entry - Implements compose_function_t -.

Definition at line 988 of file functions.c.

989{
990 struct AttachCtx *actx = shared->adata->actx;
991 if (!check_count(actx))
992 return FR_NO_ACTION;
993
994 struct Menu *menu = shared->adata->menu;
995 struct AttachPtr *cur_att = current_attachment(actx, menu);
996 if (cur_att->unowned)
997 cur_att->body->unlink = false;
998
999 int index = menu_get_index(menu);
1000 if (delete_attachment(actx, index) == -1)
1001 return FR_ERROR;
1002
1003 menu->num_tagged = 0;
1004 for (int i = 0; i < actx->idxlen; i++)
1005 {
1006 if (actx->idx[i]->body->tagged)
1007 menu->num_tagged++;
1008 }
1009
1010 update_menu(actx, menu, false);
1012
1013 index = menu_get_index(menu);
1014 if (index == 0)
1015 shared->email->body = actx->idx[0]->body;
1016
1017 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1018 return FR_SUCCESS;
1019}
static bool check_count(struct AttachCtx *actx)
Check if there are any attachments.
Definition functions.c:230
static int delete_attachment(struct AttachCtx *actx, int aidx)
Delete an attachment.
Definition functions.c:346
void update_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Redraw the compose window.
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:164
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
Definition recvattach.c:71
A set of attachments.
Definition attach.h:63
struct AttachPtr ** idx
Array of attachments.
Definition attach.h:67
short idxlen
Number of attachmentes.
Definition attach.h:68
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition body.h:68
bool tagged
This attachment is tagged.
Definition body.h:90
struct Body * body
List of MIME parts.
Definition email.h:69
Definition lib.h:80
int num_tagged
Number of tagged entries.
Definition lib.h:95
+ Here is the call graph for this function:

◆ op_attach_edit_content_id()

static int op_attach_edit_content_id ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit the 'Content-ID' of the attachment - Implements compose_function_t -.

Definition at line 1024 of file functions.c.

1026{
1027 if (!check_count(shared->adata->actx))
1028 return FR_NO_ACTION;
1029
1030 int rc = FR_NO_ACTION;
1031 struct Buffer *buf = buf_pool_get();
1032 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1033 shared->adata->menu);
1034
1035 char *id = cur_att->body->content_id;
1036 if (id)
1037 {
1038 buf_strcpy(buf, id);
1039 }
1040 else
1041 {
1042 id = gen_cid();
1043 buf_strcpy(buf, id);
1044 FREE(&id);
1045 }
1046
1047 if (mw_get_field("Content-ID: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
1048 {
1049 if (!mutt_str_equal(id, buf_string(buf)))
1050 {
1051 if (check_cid(buf_string(buf)))
1052 {
1053 mutt_str_replace(&cur_att->body->content_id, buf_string(buf));
1056 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1057 rc = FR_SUCCESS;
1058 }
1059 else
1060 {
1061 mutt_error(_("Content-ID can only contain the characters: -.0-9@A-Z_a-z"));
1062 rc = FR_ERROR;
1063 }
1064 }
1065 }
1066
1067 buf_pool_release(&buf);
1068
1069 if (rc != FR_ERROR)
1071
1072 return rc;
1073}
static char * gen_cid(void)
Generate a random Content ID.
Definition functions.c:247
static bool check_cid(const char *cid)
Check if a Content-ID is valid.
Definition functions.c:263
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition wdata.h:42
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition window.c:463
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:60
#define MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition lib.h:59
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
char * content_id
Content-Id (RFC2392)
Definition body.h:58
+ Here is the call graph for this function:

◆ op_attach_edit_description()

static int op_attach_edit_description ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit attachment description - Implements compose_function_t -.

Definition at line 1078 of file functions.c.

1080{
1081 if (!check_count(shared->adata->actx))
1082 return FR_NO_ACTION;
1083
1084 int rc = FR_NO_ACTION;
1085 struct Buffer *buf = buf_pool_get();
1086
1087 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1088 shared->adata->menu);
1089 buf_strcpy(buf, cur_att->body->description);
1090
1091 /* header names should not be translated */
1092 if (mw_get_field("Description: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
1093 {
1094 if (!mutt_str_equal(cur_att->body->description, buf_string(buf)))
1095 {
1096 mutt_str_replace(&cur_att->body->description, buf_string(buf));
1098 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1099 rc = FR_SUCCESS;
1100 }
1101 }
1102
1103 buf_pool_release(&buf);
1104 return rc;
1105}
char * description
content-description
Definition body.h:55
+ Here is the call graph for this function:

◆ op_attach_edit_encoding()

static int op_attach_edit_encoding ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit attachment transfer-encoding - Implements compose_function_t -.

Definition at line 1110 of file functions.c.

1112{
1113 if (!check_count(shared->adata->actx))
1114 return FR_NO_ACTION;
1115
1116 int rc = FR_NO_ACTION;
1117 struct Buffer *buf = buf_pool_get();
1118
1119 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1120 shared->adata->menu);
1121 buf_strcpy(buf, ENCODING(cur_att->body->encoding));
1122
1123 if ((mw_get_field("Content-Transfer-Encoding: ", buf, MUTT_COMP_NO_FLAGS,
1124 HC_OTHER, NULL, NULL) == 0) &&
1125 !buf_is_empty(buf))
1126 {
1127 int enc = mutt_check_encoding(buf_string(buf));
1128 if ((enc != ENC_OTHER) && (enc != ENC_UUENCODED))
1129 {
1130 if (enc != cur_att->body->encoding)
1131 {
1132 cur_att->body->encoding = enc;
1136 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1137 rc = FR_SUCCESS;
1138 }
1139 }
1140 else
1141 {
1142 mutt_error(_("Invalid encoding"));
1143 rc = FR_ERROR;
1144 }
1145 }
1146
1147 buf_pool_release(&buf);
1148 return rc;
1149}
int mutt_check_encoding(const char *c)
Check the encoding type.
Definition parse.c:442
@ ENC_UUENCODED
UUEncoded text.
Definition mime.h:54
@ ENC_OTHER
Encoding unknown.
Definition mime.h:48
#define ENCODING(x)
Get the encoding name for an encoding type.
Definition mime.h:97
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition body.h:41
+ Here is the call graph for this function:

◆ op_attach_edit_language()

static int op_attach_edit_language ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit the 'Content-Language' of the attachment - Implements compose_function_t -.

Definition at line 1154 of file functions.c.

1156{
1157 if (!check_count(shared->adata->actx))
1158 return FR_NO_ACTION;
1159
1160 int rc = FR_NO_ACTION;
1161 struct Buffer *buf = buf_pool_get();
1162 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1163 shared->adata->menu);
1164
1165 buf_strcpy(buf, cur_att->body->language);
1166 if (mw_get_field("Content-Language: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
1167 {
1168 if (!mutt_str_equal(cur_att->body->language, buf_string(buf)))
1169 {
1170 mutt_str_replace(&cur_att->body->language, buf_string(buf));
1173 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1174 rc = FR_SUCCESS;
1175 }
1177 }
1178 else
1179 {
1180 mutt_warning(_("Empty 'Content-Language'"));
1181 rc = FR_ERROR;
1182 }
1183
1184 buf_pool_release(&buf);
1185 return rc;
1186}
#define mutt_warning(...)
Definition logging2.h:92
char * language
content-language (RFC8255)
Definition body.h:78
+ Here is the call graph for this function:

◆ op_attach_edit_mime()

static int op_attach_edit_mime ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit attachment using mailcap entry - Implements compose_function_t -.

Definition at line 1191 of file functions.c.

1192{
1193 if (!check_count(shared->adata->actx))
1194 return FR_NO_ACTION;
1195 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1196 shared->adata->menu);
1197 if (!mutt_edit_attachment(cur_att->body))
1198 return FR_NO_ACTION;
1199
1200 mutt_update_encoding(cur_att->body, shared->sub);
1202 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1203 return FR_SUCCESS;
1204}
bool mutt_edit_attachment(struct Body *b)
Edit an attachment.
void mutt_update_encoding(struct Body *b, struct ConfigSubset *sub)
Update the encoding type.
Definition sendlib.c:421
+ Here is the call graph for this function:

◆ op_attach_edit_type()

static int op_attach_edit_type ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit attachment content type - Implements compose_function_t -.

Definition at line 1209 of file functions.c.

1210{
1211 if (!check_count(shared->adata->actx))
1212 return FR_NO_ACTION;
1213
1214 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1215 shared->adata->menu);
1216 if (!mutt_edit_content_type(NULL, cur_att->body, NULL))
1217 return FR_NO_ACTION;
1218
1219 /* this may have been a change to text/something */
1220 mutt_update_encoding(cur_att->body, shared->sub);
1222 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1223 return FR_SUCCESS;
1224}
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Definition external.c:1072
+ Here is the call graph for this function:

◆ op_attach_filter()

static int op_attach_filter ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Filter attachment through a shell command - Implements compose_function_t -.

This function handles:

  • OP_ATTACH_FILTER
  • OP_PIPE

Definition at line 1233 of file functions.c.

1234{
1235 struct AttachCtx *actx = shared->adata->actx;
1236 if (!check_count(actx))
1237 return FR_NO_ACTION;
1238
1239 struct Menu *menu = shared->adata->menu;
1240 struct AttachPtr *cur_att = current_attachment(actx, menu);
1241 if (cur_att->body->type == TYPE_MULTIPART)
1242 {
1243 mutt_error(_("Can't filter multipart attachments"));
1244 return FR_ERROR;
1245 }
1246
1247 const int op = event->op;
1248 mutt_pipe_attachment_list(actx, NULL, menu->tag_prefix, cur_att->body,
1249 (op == OP_ATTACH_FILTER));
1250 if (op == OP_ATTACH_FILTER) /* cte might have changed */
1251 {
1253 }
1255 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1256 return FR_SUCCESS;
1257}
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition mime.h:37
void mutt_pipe_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, bool filter)
Pipe a list of attachments to a command.
Definition recvattach.c:721
unsigned int type
content-type primary type, ContentType
Definition body.h:40
bool tag_prefix
User has pressed <tag-prefix>
Definition lib.h:86
+ Here is the call graph for this function:

◆ op_attach_get_attachment()

static int op_attach_get_attachment ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Get a temporary copy of an attachment - Implements compose_function_t -.

Definition at line 1262 of file functions.c.

1264{
1265 struct AttachCtx *actx = shared->adata->actx;
1266 if (!check_count(actx))
1267 return FR_NO_ACTION;
1268
1269 int rc = FR_ERROR;
1270 struct Menu *menu = shared->adata->menu;
1271 struct BodyArray ba = ARRAY_HEAD_INITIALIZER;
1272 ba_add_tagged(&ba, actx, menu);
1273 if (ARRAY_EMPTY(&ba))
1274 goto done;
1275
1276 struct Body **bp = NULL;
1277 ARRAY_FOREACH(bp, &ba)
1278 {
1279 if ((*bp)->type == TYPE_MULTIPART)
1280 {
1281 mutt_warning(_("Can't get multipart attachments"));
1282 continue;
1283 }
1285 }
1286
1288 rc = FR_SUCCESS;
1289
1290done:
1291 ARRAY_FREE(&ba);
1292 /* No send2hook since this doesn't change the message. */
1293 return rc;
1294}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
int mutt_get_tmp_attachment(struct Body *b)
Get a temporary copy of an attachment.
Definition mutt_attach.c:68
int ba_add_tagged(struct BodyArray *ba, struct AttachCtx *actx, struct Menu *menu)
Get an array of tagged Attachments.
The body of an email.
Definition body.h:36
+ Here is the call graph for this function:

◆ op_attach_group_alts()

static int op_attach_group_alts ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Group tagged attachments as 'multipart/alternative' - Implements compose_function_t -.

Definition at line 1299 of file functions.c.

1300{
1301 if (shared->adata->menu->num_tagged < 2)
1302 {
1303 mutt_error(_("Grouping 'alternatives' requires at least 2 tagged messages"));
1304 return FR_ERROR;
1305 }
1306
1307 return group_attachments(shared, "alternative");
1308}
static int group_attachments(struct ComposeSharedData *shared, char *subtype)
Group tagged attachments into a multipart group.
Definition functions.c:527
+ Here is the call graph for this function:

◆ op_attach_group_lingual()

static int op_attach_group_lingual ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Group tagged attachments as 'multipart/multilingual' - Implements compose_function_t -.

Definition at line 1313 of file functions.c.

1315{
1316 if (shared->adata->menu->num_tagged < 2)
1317 {
1318 mutt_error(_("Grouping 'multilingual' requires at least 2 tagged messages"));
1319 return FR_ERROR;
1320 }
1321
1322 /* traverse to see whether all the parts have Content-Language: set */
1323 int tagged_with_lang_num = 0;
1324 for (struct Body *b = shared->email->body; b; b = b->next)
1325 if (b->tagged && b->language && *b->language)
1326 tagged_with_lang_num++;
1327
1328 if (shared->adata->menu->num_tagged != tagged_with_lang_num)
1329 {
1330 if (query_yesorno(_("Not all parts have 'Content-Language' set, continue?"),
1331 MUTT_YES) != MUTT_YES)
1332 {
1333 mutt_message(_("Not sending this message"));
1334 return FR_ERROR;
1335 }
1336 }
1337
1338 return group_attachments(shared, "multilingual");
1339}
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition quad.h:39
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
Definition question.c:329
struct Body * next
next attachment in the list
Definition body.h:72
+ Here is the call graph for this function:

◆ op_attach_group_related()

static int op_attach_group_related ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Group tagged attachments as 'multipart/related' - Implements compose_function_t -.

Definition at line 1344 of file functions.c.

1346{
1347 if (shared->adata->menu->num_tagged < 2)
1348 {
1349 mutt_error(_("Grouping 'related' requires at least 2 tagged messages"));
1350 return FR_ERROR;
1351 }
1352
1353 // ensure Content-ID is set for tagged attachments
1354 for (struct Body *b = shared->email->body; b; b = b->next)
1355 {
1356 if (!b->tagged || (b->type == TYPE_MULTIPART))
1357 continue;
1358
1359 if (!b->content_id)
1360 {
1361 b->content_id = gen_cid();
1362 }
1363 }
1364
1365 return group_attachments(shared, "related");
1366}
+ Here is the call graph for this function:

◆ op_attach_move_down()

static int op_attach_move_down ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Move an attachment down in the attachment list - Implements compose_function_t -.

Definition at line 1371 of file functions.c.

1372{
1373 int index = menu_get_index(shared->adata->menu);
1374
1375 struct AttachCtx *actx = shared->adata->actx;
1376
1377 if (index < 0)
1378 return FR_ERROR;
1379
1380 if (index == (actx->idxlen - 1))
1381 {
1382 mutt_error(_("Attachment is already at bottom"));
1383 return FR_NO_ACTION;
1384 }
1385 if ((actx->idx[index]->parent_type == TYPE_MULTIPART) &&
1386 !actx->idx[index]->body->next)
1387 {
1388 mutt_error(_("Attachment can't be moved out of group"));
1389 return FR_ERROR;
1390 }
1391
1392 // find next attachment at current level
1393 int nextidx = index + 1;
1394 while ((nextidx < actx->idxlen) &&
1395 (actx->idx[nextidx]->level > actx->idx[index]->level))
1396 {
1397 nextidx++;
1398 }
1399 if (nextidx == actx->idxlen)
1400 {
1401 mutt_error(_("Attachment is already at bottom"));
1402 return FR_NO_ACTION;
1403 }
1404
1405 // find final position
1406 int finalidx = index + 1;
1407 if (nextidx < actx->idxlen - 1)
1408 {
1409 if ((actx->idx[nextidx]->body->type == TYPE_MULTIPART) &&
1410 (actx->idx[nextidx + 1]->level > actx->idx[nextidx]->level))
1411 {
1412 finalidx += attach_body_count(actx->idx[nextidx]->body->parts, true);
1413 }
1414 }
1415
1416 compose_attach_swap(shared->email, shared->adata->actx, index, nextidx);
1417 mutt_update_tree(shared->adata->actx);
1420 menu_set_index(shared->adata->menu, finalidx);
1421 return FR_SUCCESS;
1422}
int attach_body_count(struct Body *body, bool recurse)
Count bodies.
Definition lib.c:42
static void compose_attach_swap(struct Email *e, struct AttachCtx *actx, int first, int second)
Swap two adjacent entries in the attachment list.
Definition functions.c:461
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:178
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition recvattach.c:116
int level
Nesting depth of attachment.
Definition attach.h:40
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition attach.h:38
struct Body * parts
parts of a multipart or message/rfc822
Definition body.h:73
+ Here is the call graph for this function:

◆ op_attach_move_up()

static int op_attach_move_up ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Move an attachment up in the attachment list - Implements compose_function_t -.

Definition at line 1427 of file functions.c.

1428{
1429 int index = menu_get_index(shared->adata->menu);
1430 if (index < 0)
1431 return FR_ERROR;
1432
1433 struct AttachCtx *actx = shared->adata->actx;
1434
1435 if (index == 0)
1436 {
1437 mutt_error(_("Attachment is already at top"));
1438 return FR_NO_ACTION;
1439 }
1440 if (actx->idx[index - 1]->level < actx->idx[index]->level)
1441 {
1442 mutt_error(_("Attachment can't be moved out of group"));
1443 return FR_ERROR;
1444 }
1445
1446 // find previous attachment at current level
1447 int previdx = index - 1;
1448 while ((previdx > 0) && (actx->idx[previdx]->level > actx->idx[index]->level))
1449 previdx--;
1450
1451 compose_attach_swap(shared->email, actx, previdx, index);
1452 mutt_update_tree(actx);
1455 menu_set_index(shared->adata->menu, previdx);
1456 return FR_SUCCESS;
1457}
+ Here is the call graph for this function:

◆ op_attach_new_mime()

static int op_attach_new_mime ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Compose new attachment using mailcap entry - Implements compose_function_t -.

Definition at line 1462 of file functions.c.

1463{
1464 int rc = FR_NO_ACTION;
1465 struct Buffer *fname = buf_pool_get();
1466 struct Buffer *type = NULL;
1467 struct AttachPtr *ap = NULL;
1468
1469 struct FileCompletionData cdata = { false, shared->mailbox, NULL, NULL, NULL };
1470 if ((mw_get_field(_("New file: "), fname, MUTT_COMP_NO_FLAGS, HC_FILE,
1471 &CompleteFileOps, &cdata) != 0) ||
1472 buf_is_empty(fname))
1473 {
1474 goto done;
1475 }
1476 expand_path(fname, false);
1477
1478 /* Call to lookup_mime_type () ? maybe later */
1479 type = buf_pool_get();
1480 if ((mw_get_field("Content-Type: ", type, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0) ||
1481 buf_is_empty(type))
1482 {
1483 goto done;
1484 }
1485
1486 rc = FR_ERROR;
1487 char *p = strchr(buf_string(type), '/');
1488 if (!p)
1489 {
1490 mutt_error(_("Content-Type is of the form base/sub"));
1491 goto done;
1492 }
1493 *p++ = 0;
1494 enum ContentType itype = mutt_check_mime_type(buf_string(type));
1495 if (itype == TYPE_OTHER)
1496 {
1497 mutt_error(_("Unknown Content-Type %s"), buf_string(type));
1498 goto done;
1499 }
1500
1501 ap = mutt_aptr_new();
1502 /* Touch the file */
1503 if (!mutt_file_touch(buf_string(fname)))
1504 {
1505 mutt_error(_("Can't create file %s"), buf_string(fname));
1506 goto done;
1507 }
1508
1509 ap->body = mutt_make_file_attach(buf_string(fname), shared->sub);
1510 if (!ap->body)
1511 {
1512 mutt_error(_("Error attaching file"));
1513 goto done;
1514 }
1515 update_idx(shared->adata->menu, shared->adata->actx, ap);
1516 ap = NULL; // shared->adata->actx has taken ownership
1517
1518 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1519 shared->adata->menu);
1520 cur_att->body->type = itype;
1521 mutt_str_replace(&cur_att->body->subtype, p);
1522 cur_att->body->unlink = true;
1525
1526 if (mutt_compose_attachment(cur_att->body))
1527 {
1528 mutt_update_encoding(cur_att->body, shared->sub);
1530 }
1531 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1532 rc = FR_SUCCESS;
1533
1534done:
1535 mutt_aptr_free(&ap);
1536 buf_pool_release(&type);
1537 buf_pool_release(&fname);
1538 return rc;
1539}
const struct CompleteOps CompleteFileOps
Auto-Completion of Files.
Definition complete.c:152
enum ContentType mutt_check_mime_type(const char *s)
Check a MIME type string.
Definition parse.c:371
bool mutt_file_touch(const char *path)
Make sure a file exists.
Definition file.c:974
@ HC_FILE
Files.
Definition lib.h:58
ContentType
Content-Type.
Definition mime.h:30
@ TYPE_OTHER
Unknown Content-Type.
Definition mime.h:31
int mutt_compose_attachment(struct Body *b)
Create an attachment.
char * subtype
content-type subtype
Definition body.h:61
Input for the file completion function.
Definition curs_lib.h:39
+ Here is the call graph for this function:

◆ op_attach_print()

static int op_attach_print ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Print the current entry - Implements compose_function_t -.

Definition at line 1544 of file functions.c.

1545{
1546 struct AttachCtx *actx = shared->adata->actx;
1547 if (!check_count(actx))
1548 return FR_NO_ACTION;
1549
1550 struct Menu *menu = shared->adata->menu;
1551 struct AttachPtr *cur_att = current_attachment(actx, menu);
1552 if (cur_att->body->type == TYPE_MULTIPART)
1553 {
1554 mutt_error(_("Can't print multipart attachments"));
1555 return FR_ERROR;
1556 }
1557
1558 mutt_print_attachment_list(actx, NULL, menu->tag_prefix, cur_att->body);
1559 /* no send2hook, since this doesn't modify the message */
1560 return FR_SUCCESS;
1561}
void mutt_print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b)
Print a list of Attachments.
Definition recvattach.c:887
+ Here is the call graph for this function:

◆ op_attach_rename_attachment()

static int op_attach_rename_attachment ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Send attachment with a different name - Implements compose_function_t -.

Definition at line 1566 of file functions.c.

1568{
1569 if (!check_count(shared->adata->actx))
1570 return FR_NO_ACTION;
1571 char *src = NULL;
1572 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1573 shared->adata->menu);
1574 if (cur_att->body->d_filename)
1575 src = cur_att->body->d_filename;
1576 else
1577 src = cur_att->body->filename;
1578 struct Buffer *fname = buf_pool_get();
1579 buf_strcpy(fname, mutt_path_basename(NONULL(src)));
1580 struct FileCompletionData cdata = { false, shared->mailbox, NULL, NULL, NULL };
1581 int rc = mw_get_field(_("Send attachment with name: "), fname,
1583 if (rc == 0)
1584 {
1585 // It's valid to set an empty string here, to erase what was set
1586 mutt_str_replace(&cur_att->body->d_filename, buf_string(fname));
1588 }
1589 buf_pool_release(&fname);
1590 return FR_SUCCESS;
1591}
const char * mutt_path_basename(const char *path)
Find the last component for a pathname.
Definition path.c:282
#define NONULL(x)
Definition string2.h:44
char * d_filename
filename to be used for the content-disposition header If NULL, filename is used instead.
Definition body.h:56
char * filename
When sending a message, this is the file to which this structure refers.
Definition body.h:59
+ Here is the call graph for this function:

◆ op_attach_save()

static int op_attach_save ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Save message/attachment to a mailbox/file - Implements compose_function_t -.

Definition at line 1596 of file functions.c.

1597{
1598 struct AttachCtx *actx = shared->adata->actx;
1599 if (!check_count(actx))
1600 return FR_NO_ACTION;
1601
1602 struct Menu *menu = shared->adata->menu;
1603 struct AttachPtr *cur_att = current_attachment(actx, menu);
1604 if (cur_att->body->type == TYPE_MULTIPART)
1605 {
1606 mutt_error(_("Can't save multipart attachments"));
1607 return FR_ERROR;
1608 }
1609
1610 mutt_save_attachment_list(actx, NULL, menu->tag_prefix, cur_att->body, NULL, menu);
1611 /* no send2hook, since this doesn't modify the message */
1612 return FR_SUCCESS;
1613}
void mutt_save_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *b, struct Email *e, struct Menu *menu)
Save a list of attachments.
Definition recvattach.c:426
+ Here is the call graph for this function:

◆ op_attach_toggle_disposition()

static int op_attach_toggle_disposition ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Toggle disposition between inline/attachment - Implements compose_function_t -.

Definition at line 1618 of file functions.c.

1620{
1621 /* toggle the content-disposition between inline/attachment */
1622 if (!check_count(shared->adata->actx))
1623 return FR_NO_ACTION;
1624 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1625 shared->adata->menu);
1626 cur_att->body->disposition = (cur_att->body->disposition == DISP_INLINE) ?
1627 DISP_ATTACH :
1631 return FR_SUCCESS;
1632}
@ DISP_ATTACH
Content is attached.
Definition mime.h:63
@ DISP_INLINE
Content is inline.
Definition mime.h:62
unsigned int disposition
content-disposition, ContentDisposition
Definition body.h:42
+ Here is the call graph for this function:

◆ op_attach_toggle_recode()

static int op_attach_toggle_recode ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Toggle recoding of this attachment - Implements compose_function_t -.

Definition at line 1637 of file functions.c.

1639{
1640 if (!check_count(shared->adata->actx))
1641 return FR_NO_ACTION;
1642 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1643 shared->adata->menu);
1644 if (!mutt_is_text_part(cur_att->body))
1645 {
1646 mutt_error(_("Recoding only affects text attachments"));
1647 return FR_ERROR;
1648 }
1649 cur_att->body->noconv = !cur_att->body->noconv;
1650 if (cur_att->body->noconv)
1651 mutt_message(_("The current attachment won't be converted"));
1652 else
1653 mutt_message(_("The current attachment will be converted"));
1655 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1656 return FR_SUCCESS;
1657}
bool mutt_is_text_part(const struct Body *b)
Is this part of an email in plain text?
Definition muttlib.c:396
bool noconv
Don't do character set conversion.
Definition body.h:46
+ Here is the call graph for this function:

◆ op_attach_toggle_unlink()

static int op_attach_toggle_unlink ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Toggle whether to delete file after sending it - Implements compose_function_t -.

Definition at line 1662 of file functions.c.

1664{
1665 if (!check_count(shared->adata->actx))
1666 return FR_NO_ACTION;
1667 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1668 shared->adata->menu);
1669 cur_att->body->unlink = !cur_att->body->unlink;
1670
1672 /* No send2hook since this doesn't change the message. */
1673 return FR_SUCCESS;
1674}
+ Here is the call graph for this function:

◆ op_attach_ungroup()

static int op_attach_ungroup ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Ungroup a 'multipart' attachment - Implements compose_function_t -.

Definition at line 1679 of file functions.c.

1680{
1681 if (shared->adata->actx->idx[shared->adata->menu->current]->body->type != TYPE_MULTIPART)
1682 {
1683 mutt_error(_("Attachment is not 'multipart'"));
1684 return FR_ERROR;
1685 }
1686
1687 int aidx = shared->adata->menu->current;
1688 struct AttachCtx *actx = shared->adata->actx;
1689 struct Body *b = actx->idx[aidx]->body;
1690 struct Body *b_next = b->next;
1691 struct Body *b_previous = NULL;
1692 struct Body *b_parent = NULL;
1693 int parent_type = actx->idx[aidx]->parent_type;
1694 int level = actx->idx[aidx]->level;
1695
1696 // reorder body pointers
1697 if (attach_body_previous(shared->email->body, b, &b_previous))
1698 b_previous->next = b->parts;
1699 else if (attach_body_parent(shared->email->body, NULL, b, &b_parent))
1700 b_parent->parts = b->parts;
1701 else
1702 shared->email->body = b->parts;
1703
1704 // update attachment list
1705 int i = aidx + 1;
1706 while ((i < actx->idxlen) && (actx->idx[i]->level > level))
1707 {
1708 actx->idx[i]->level--;
1709 if (actx->idx[i]->level == level)
1710 {
1711 actx->idx[i]->parent_type = parent_type;
1712 // set body->next for final attachment in group
1713 if (!actx->idx[i]->body->next)
1714 actx->idx[i]->body->next = b_next;
1715 }
1716 i++;
1717 }
1718
1719 // free memory
1720 actx->idx[aidx]->body->parts = NULL;
1721 actx->idx[aidx]->body->next = NULL;
1722 actx->idx[aidx]->body->email = NULL;
1723 mutt_body_free(&actx->idx[aidx]->body);
1724 FREE(&actx->idx[aidx]->tree);
1725 FREE(&actx->idx[aidx]);
1726
1727 // reorder attachment list
1728 for (int j = aidx; j < (actx->idxlen - 1); j++)
1729 actx->idx[j] = actx->idx[j + 1];
1730 actx->idx[actx->idxlen - 1] = NULL;
1731 actx->idxlen--;
1732 update_menu(actx, shared->adata->menu, false);
1733
1734 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1735 return FR_SUCCESS;
1736}
bool attach_body_parent(struct Body *start, struct Body *start_parent, struct Body *body, struct Body **body_parent)
Find the parent of a body.
Definition lib.c:71
bool attach_body_previous(struct Body *start, struct Body *body, struct Body **previous)
Find the previous body of a body.
Definition lib.c:142
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition body.c:58
char * tree
Tree characters to display.
Definition attach.h:39
struct Email * email
header information for message/rfc822
Definition body.h:74
int current
Current entry.
Definition lib.h:81
+ Here is the call graph for this function:

◆ op_attach_update_encoding()

static int op_attach_update_encoding ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Update an attachment's encoding info - Implements compose_function_t -.

Definition at line 1741 of file functions.c.

1743{
1744 struct AttachCtx *actx = shared->adata->actx;
1745 if (!check_count(actx))
1746 return FR_NO_ACTION;
1747
1748 int rc = FR_NO_ACTION;
1749 struct Menu *menu = shared->adata->menu;
1750 struct BodyArray ba = ARRAY_HEAD_INITIALIZER;
1751 ba_add_tagged(&ba, actx, menu);
1752 if (ARRAY_EMPTY(&ba))
1753 goto done;
1754
1755 struct Body **bp = NULL;
1756 ARRAY_FOREACH(bp, &ba)
1757 {
1758 mutt_update_encoding(*bp, shared->sub);
1759 }
1760
1763 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1764 rc = FR_SUCCESS;
1765
1766done:
1767 ARRAY_FREE(&ba);
1768 return rc;
1769}
+ Here is the call graph for this function:

◆ op_envelope_edit_headers()

static int op_envelope_edit_headers ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit the message with headers - Implements compose_function_t -.

Definition at line 1776 of file functions.c.

1778{
1780 const char *tag = NULL;
1781 char *err = NULL;
1782 mutt_env_to_local(shared->email->env);
1783 const char *const c_editor = cs_subset_string(shared->sub, "editor");
1784 if (shared->email->body->type == TYPE_MULTIPART)
1785 {
1786 struct Body *b = shared->email->body->parts;
1787 while (b && b->parts)
1788 b = b->parts;
1789 if (b)
1790 mutt_edit_headers(NONULL(c_editor), b->filename, shared->email, shared->fcc);
1791 }
1792 else
1793 {
1794 mutt_edit_headers(NONULL(c_editor), shared->email->body->filename,
1795 shared->email, shared->fcc);
1796 }
1797
1798 if (mutt_env_to_intl(shared->email->env, &tag, &err))
1799 {
1800 mutt_error(_("Bad IDN in '%s': '%s'"), tag, err);
1801 FREE(&err);
1802 }
1804
1806 mutt_update_encoding(shared->email->body, shared->sub);
1807
1808 /* attachments may have been added */
1809 if (shared->adata->actx->idxlen &&
1810 shared->adata->actx->idx[shared->adata->actx->idxlen - 1]->body->next)
1811 {
1813 update_menu(shared->adata->actx, shared->adata->menu, true);
1814 }
1815
1817 /* Unconditional hook since editor was invoked */
1818 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1819 return FR_SUCCESS;
1820}
void mutt_actx_entries_free(struct AttachCtx *actx)
Free entries in an Attachment Context.
Definition attach.c:162
void mutt_edit_headers(const char *editor, const char *body, struct Email *e, struct Buffer *fcc)
Let the user edit the message header and body.
Definition header.c:181
@ NT_EMAIL_CHANGE_ENVELOPE
Email's Envelope has changed.
Definition email.h:187
int mutt_env_to_intl(struct Envelope *env, const char **tag, char **err)
Convert an Envelope's Address fields to Punycode format.
Definition envelope.c:350
void mutt_env_to_local(struct Envelope *env)
Convert an Envelope's Address fields to local format.
Definition envelope.c:316
void mutt_rfc3676_space_unstuff(struct Email *e)
Remove RFC3676 space stuffing.
Definition rfc3676.c:503
void mutt_rfc3676_space_stuff(struct Email *e)
Perform RFC3676 space stuffing on an Email.
Definition rfc3676.c:490
struct Buffer * fcc
Buffer to save FCC.
Definition shared_data.h:44
struct Envelope * env
Envelope information.
Definition email.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_compose_edit_file()

static int op_compose_edit_file ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit the file to be attached - Implements compose_function_t -.

Definition at line 1825 of file functions.c.

1826{
1827 if (!check_count(shared->adata->actx))
1828 return FR_NO_ACTION;
1829 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1830 shared->adata->menu);
1831 if (cur_att->body->type == TYPE_MULTIPART)
1832 {
1833 mutt_error(_("Can't edit multipart attachments"));
1834 return FR_ERROR;
1835 }
1836 const char *const c_editor = cs_subset_string(shared->sub, "editor");
1837 mutt_edit_file(NONULL(c_editor), cur_att->body->filename);
1838 mutt_update_encoding(cur_att->body, shared->sub);
1841 /* Unconditional hook since editor was invoked */
1842 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1843 return FR_SUCCESS;
1844}
void mutt_edit_file(const char *editor, const char *file)
Let the user edit a file.
Definition curs_lib.c:116
+ Here is the call graph for this function:

◆ op_compose_edit_message()

static int op_compose_edit_message ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Edit the message - Implements compose_function_t -.

Definition at line 1849 of file functions.c.

1851{
1852 const bool c_edit_headers = cs_subset_bool(shared->sub, "edit_headers");
1853 if (!c_edit_headers)
1854 {
1856 const char *const c_editor = cs_subset_string(shared->sub, "editor");
1857 mutt_edit_file(c_editor, shared->email->body->filename);
1859 mutt_update_encoding(shared->email->body, shared->sub);
1861 /* Unconditional hook since editor was invoked */
1862 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1863 return FR_SUCCESS;
1864 }
1865
1866 return op_envelope_edit_headers(shared, event);
1867}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
static int op_envelope_edit_headers(struct ComposeSharedData *shared, const struct KeyEvent *event)
Edit the message with headers - Implements compose_function_t -.
Definition functions.c:1776
+ Here is the call graph for this function:

◆ op_compose_ispell()

static int op_compose_ispell ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Run ispell on the message - Implements compose_function_t -.

Definition at line 1872 of file functions.c.

1873{
1874 endwin();
1875 const char *const c_ispell = cs_subset_string(shared->sub, "ispell");
1876 struct Buffer *cmd = buf_pool_get();
1877 struct Buffer *quoted = buf_pool_get();
1878 buf_quote_filename(quoted, shared->email->body->filename, true);
1879 buf_printf(cmd, "%s -x %s", NONULL(c_ispell), buf_string(quoted));
1880 buf_pool_release(&quoted);
1881 if (mutt_system(buf_string(cmd)) == -1)
1882 {
1883 mutt_error(_("Error running \"%s\""), buf_string(cmd));
1884 buf_pool_release(&cmd);
1885 return FR_ERROR;
1886 }
1887 buf_pool_release(&cmd);
1888
1889 mutt_update_encoding(shared->email->body, shared->sub);
1891 return FR_SUCCESS;
1892}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
void buf_quote_filename(struct Buffer *buf, const char *filename, bool add_outer)
Quote a filename to survive the shell's quoting rules.
Definition file.c:803
int mutt_system(const char *cmd)
Run an external command.
Definition system.c:51
int endwin(void)
+ Here is the call graph for this function:

◆ op_compose_postpone_message()

static int op_compose_postpone_message ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Save this message to send later - Implements compose_function_t -.

Definition at line 1897 of file functions.c.

1899{
1900 if (check_attachments(shared->adata->actx, shared->sub) != 0)
1901 {
1903 return FR_ERROR;
1904 }
1905
1906 shared->rc = 1;
1907 return FR_DONE;
1908}
static int check_attachments(struct AttachCtx *actx, struct ConfigSubset *sub)
Check if any attachments have changed or been deleted.
Definition functions.c:283
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:36
int rc
Return code to leave compose.
Definition shared_data.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ op_compose_rename_file()

static int op_compose_rename_file ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Rename/move an attached file - Implements compose_function_t -.

Definition at line 1913 of file functions.c.

1914{
1915 if (!check_count(shared->adata->actx))
1916 return FR_NO_ACTION;
1917 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1918 shared->adata->menu);
1919 if (cur_att->body->type == TYPE_MULTIPART)
1920 {
1921 mutt_error(_("Can't rename multipart attachments"));
1922 return FR_ERROR;
1923 }
1924 struct Buffer *fname = buf_pool_get();
1925 buf_strcpy(fname, cur_att->body->filename);
1926 pretty_mailbox(fname);
1927 struct FileCompletionData cdata = { false, shared->mailbox, NULL, NULL, NULL };
1928 if ((mw_get_field(_("Rename to: "), fname, MUTT_COMP_NO_FLAGS, HC_FILE,
1929 &CompleteFileOps, &cdata) == 0) &&
1930 !buf_is_empty(fname))
1931 {
1932 struct stat st = { 0 };
1933 if (stat(cur_att->body->filename, &st) == -1)
1934 {
1935 /* L10N: "stat" is a system call. Do "man 2 stat" for more information. */
1936 mutt_error(_("Can't stat %s: %s"), buf_string(fname), strerror(errno));
1937 buf_pool_release(&fname);
1938 return FR_ERROR;
1939 }
1940
1941 expand_path(fname, false);
1942 if (mutt_file_rename(cur_att->body->filename, buf_string(fname)))
1943 {
1944 buf_pool_release(&fname);
1945 return FR_ERROR;
1946 }
1947
1948 mutt_str_replace(&cur_att->body->filename, buf_string(fname));
1950
1951 if (cur_att->body->stamp >= st.st_mtime)
1952 mutt_stamp_attachment(cur_att->body);
1953 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1954 }
1955 buf_pool_release(&fname);
1956 return FR_SUCCESS;
1957}
int mutt_file_rename(const char *oldfile, const char *newfile)
Rename a file.
Definition file.c:1257
void mutt_stamp_attachment(struct Body *b)
Timestamp an Attachment.
Definition sendlib.c:409
time_t stamp
Time stamp of last encoding update.
Definition body.h:77
+ Here is the call graph for this function:

◆ op_compose_send_message()

static int op_compose_send_message ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Send the message - Implements compose_function_t -.

Definition at line 1962 of file functions.c.

1964{
1965 /* Note: We don't invoke send2-hook here, since we want to leave
1966 * users an opportunity to change settings from the ":" prompt. */
1967 if (check_attachments(shared->adata->actx, shared->sub) != 0)
1968 {
1970 return FR_NO_ACTION;
1971 }
1972
1973 if (!shared->fcc_set && !buf_is_empty(shared->fcc))
1974 {
1975 enum QuadOption ans = query_quadoption(_("Save a copy of this message?"),
1976 shared->sub, "copy");
1977 if (ans == MUTT_ABORT)
1978 return FR_NO_ACTION;
1979 else if (ans == MUTT_NO)
1980 buf_reset(shared->fcc);
1981 }
1982
1983 shared->rc = 0;
1984 return FR_DONE;
1985}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
QuadOption
Possible values for a quad-option.
Definition quad.h:36
@ MUTT_ABORT
User aborted the question (with Ctrl-G)
Definition quad.h:37
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition quad.h:38
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
Definition question.c:384
bool fcc_set
User has edited the Fcc: field.
Definition shared_data.h:46
+ Here is the call graph for this function:

◆ op_compose_write_message()

static int op_compose_write_message ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Write the message to a folder - Implements compose_function_t -.

Definition at line 1990 of file functions.c.

1992{
1993 int rc = FR_NO_ACTION;
1994 struct Buffer *fname = buf_pool_get();
1995 if (shared->mailbox)
1996 {
1997 buf_strcpy(fname, mailbox_path(shared->mailbox));
1998 pretty_mailbox(fname);
1999 }
2000 if (shared->adata->actx->idxlen)
2001 shared->email->body = shared->adata->actx->idx[0]->body;
2002 if ((mw_enter_fname(_("Write message to mailbox"), fname, true, shared->mailbox,
2003 false, NULL, NULL, MUTT_SEL_NO_FLAGS) != -1) &&
2004 !buf_is_empty(fname))
2005 {
2006 mutt_message(_("Writing message to %s ..."), buf_string(fname));
2007 expand_path(fname, false);
2008
2009 if (shared->email->body->next)
2010 shared->email->body = mutt_make_multipart(shared->email->body);
2011
2012 if (mutt_write_fcc(buf_string(fname), shared->email, NULL, false, NULL,
2013 NULL, shared->sub) == 0)
2014 mutt_message(_("Message written"));
2015
2016 shared->email->body = mutt_remove_multipart(shared->email->body);
2017 rc = FR_SUCCESS;
2018 }
2019 buf_pool_release(&fname);
2020 return rc;
2021}
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition multipart.c:133
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
Definition multipart.c:107
int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, bool post, const char *fcc, char **finalpath, struct ConfigSubset *sub)
Write email to FCC mailbox.
Definition sendlib.c:1024
+ Here is the call graph for this function:

◆ op_display_headers()

static int op_display_headers ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Display message and toggle header weeding - Implements compose_function_t -.

This function handles:

  • OP_ATTACH_VIEW
  • OP_ATTACH_VIEW_MAILCAP
  • OP_ATTACH_VIEW_PAGER
  • OP_ATTACH_VIEW_TEXT
  • OP_DISPLAY_HEADERS

Definition at line 2033 of file functions.c.

2034{
2035 if (!check_count(shared->adata->actx))
2036 return FR_NO_ACTION;
2037
2038 enum ViewAttachMode mode = MUTT_VA_REGULAR;
2039
2040 const int op = event->op;
2041 switch (op)
2042 {
2043 case OP_ATTACH_VIEW:
2044 case OP_DISPLAY_HEADERS:
2045 break;
2046
2047 case OP_ATTACH_VIEW_MAILCAP:
2048 mode = MUTT_VA_MAILCAP;
2049 break;
2050
2051 case OP_ATTACH_VIEW_PAGER:
2052 mode = MUTT_VA_PAGER;
2053 break;
2054
2055 case OP_ATTACH_VIEW_TEXT:
2056 mode = MUTT_VA_AS_TEXT;
2057 break;
2058 }
2059
2060 if (mode == MUTT_VA_REGULAR)
2061 {
2062 mutt_attach_display_loop(shared->sub, shared->adata->menu, op,
2063 shared->email, shared->adata->actx, false);
2064 }
2065 else
2066 {
2067 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
2068 shared->adata->menu);
2069 mutt_view_attachment(NULL, cur_att->body, mode, shared->email,
2070 shared->adata->actx, shared->adata->menu->win);
2071 }
2072
2074 /* no send2hook, since this doesn't modify the message */
2075 return FR_SUCCESS;
2076}
int mutt_view_attachment(FILE *fp, struct Body *b, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx, struct MuttWindow *win)
View an attachment.
ViewAttachMode
Options for mutt_view_attachment()
Definition mutt_attach.h:43
@ MUTT_VA_MAILCAP
Force viewing using mailcap entry.
Definition mutt_attach.h:45
@ MUTT_VA_REGULAR
View using default method.
Definition mutt_attach.h:44
@ MUTT_VA_PAGER
View attachment in pager using copiousoutput mailcap.
Definition mutt_attach.h:47
@ MUTT_VA_AS_TEXT
Force viewing as text.
Definition mutt_attach.h:46
int mutt_attach_display_loop(struct ConfigSubset *sub, struct Menu *menu, int op, struct Email *e, struct AttachCtx *actx, bool recv)
Event loop for the Attachment menu.
Definition recvattach.c:962
struct MuttWindow * win
Window holding the Menu.
Definition lib.h:88
+ Here is the call graph for this function:

◆ op_exit()

static int op_exit ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Exit this menu - Implements compose_function_t -.

Definition at line 2081 of file functions.c.

2082{
2083 enum QuadOption ans = query_quadoption(_("Save (postpone) draft message?"),
2084 shared->sub, "postpone");
2085 if (ans == MUTT_NO)
2086 {
2087 for (int i = 0; i < shared->adata->actx->idxlen; i++)
2088 if (shared->adata->actx->idx[i]->unowned)
2089 shared->adata->actx->idx[i]->body->unlink = false;
2090
2091 if (!(shared->flags & MUTT_COMPOSE_NOFREEHEADER))
2092 {
2093 for (int i = 0; i < shared->adata->actx->idxlen; i++)
2094 {
2095 /* avoid freeing other attachments */
2096 shared->adata->actx->idx[i]->body->next = NULL;
2097 if (!shared->adata->actx->idx[i]->body->email)
2098 shared->adata->actx->idx[i]->body->parts = NULL;
2099 mutt_body_free(&shared->adata->actx->idx[i]->body);
2100 }
2101 }
2102 shared->rc = -1;
2103 return FR_DONE;
2104 }
2105 else if (ans == MUTT_ABORT)
2106 {
2107 return FR_NO_ACTION;
2108 }
2109
2110 return op_compose_postpone_message(shared, event);
2111}
#define MUTT_COMPOSE_NOFREEHEADER
Don't free the header when closing compose dialog.
Definition lib.h:54
static int op_compose_postpone_message(struct ComposeSharedData *shared, const struct KeyEvent *event)
Save this message to send later - Implements compose_function_t -.
Definition functions.c:1897
int flags
Flags, e.g. MUTT_COMPOSE_NOFREEHEADER.
Definition shared_data.h:45
+ Here is the call graph for this function:

◆ op_forget_passphrase()

static int op_forget_passphrase ( struct ComposeSharedData * shared,
const struct KeyEvent * event )
static

Wipe passphrases from memory - Implements compose_function_t -.

Definition at line 2116 of file functions.c.

2117{
2119 return FR_SUCCESS;
2120}
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
Definition crypt.c:89
+ Here is the call graph for this function: