NeoMutt  2025-12-11-435-g4ac674
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_attachment_attach_file (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Attach files to this message - Implements compose_function_t -.
 
static int op_attachment_attach_key (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Attach a PGP public key - Implements compose_function_t -.
 
static int op_attachment_attach_message (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Attach messages to this message - Implements compose_function_t -.
 
static int op_attachment_detach (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Delete the current entry - Implements compose_function_t -.
 
static int op_attachment_edit_content_id (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit the 'Content-ID' of the attachment - Implements compose_function_t -.
 
static int op_attachment_edit_description (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment description - Implements compose_function_t -.
 
static int op_attachment_edit_encoding (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment transfer-encoding - Implements compose_function_t -.
 
static int op_attachment_edit_language (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit the 'Content-Language' of the attachment - Implements compose_function_t -.
 
static int op_attachment_edit_mime (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment using mailcap entry - Implements compose_function_t -.
 
static int op_attachment_edit_type (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Edit attachment content type - Implements compose_function_t -.
 
static int op_attachment_filter (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Filter attachment through a shell command - Implements compose_function_t -.
 
static int op_attachment_get_attachment (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Get a temporary copy of an attachment - Implements compose_function_t -.
 
static int op_attachment_group_alts (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Group tagged attachments as 'multipart/alternative' - Implements compose_function_t -.
 
static int op_attachment_group_lingual (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Group tagged attachments as 'multipart/multilingual' - Implements compose_function_t -.
 
static int op_attachment_group_related (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Group tagged attachments as 'multipart/related' - Implements compose_function_t -.
 
static int op_attachment_move_down (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Move an attachment down in the attachment list - Implements compose_function_t -.
 
static int op_attachment_move_up (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Move an attachment up in the attachment list - Implements compose_function_t -.
 
static int op_attachment_new_mime (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Compose new attachment using mailcap entry - Implements compose_function_t -.
 
static int op_attachment_print (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Print the current entry - Implements compose_function_t -.
 
static int op_attachment_rename_attachment (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Send attachment with a different name - Implements compose_function_t -.
 
static int op_attachment_save (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Save message/attachment to a mailbox/file - Implements compose_function_t -.
 
static int op_attachment_toggle_disposition (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Toggle disposition between inline/attachment - Implements compose_function_t -.
 
static int op_attachment_toggle_recode (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Toggle recoding of this attachment - Implements compose_function_t -.
 
static int op_attachment_toggle_unlink (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Toggle whether to delete file after sending it - Implements compose_function_t -.
 
static int op_attachment_ungroup (struct ComposeSharedData *shared, const struct KeyEvent *event)
 Ungroup a 'multipart' attachment - Implements compose_function_t -.
 
static int op_attachment_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_attachment_attach_file()

static int op_attachment_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.

747{
748 char *prompt = _("Attach file");
749 int numfiles = 0;
750 char **files = NULL;
751
752 struct Buffer *fname = buf_pool_get();
753 if ((mw_enter_fname(prompt, fname, false, NULL, true, &files, &numfiles,
754 MUTT_SEL_MULTI) == -1) ||
755 buf_is_empty(fname))
756 {
757 for (int i = 0; i < numfiles; i++)
758 FREE(&files[i]);
759
760 FREE(&files);
761 buf_pool_release(&fname);
762 return FR_NO_ACTION;
763 }
764
765 bool error = false;
766 bool added_attachment = false;
767 if (numfiles > 1)
768 {
769 mutt_message(ngettext("Attaching selected file...",
770 "Attaching selected files...", numfiles));
771 }
772 for (int i = 0; i < numfiles; i++)
773 {
774 char *att = files[i];
775 if (!att)
776 continue;
777
778 struct AttachPtr *ap = mutt_aptr_new();
779 ap->unowned = true;
780 ap->body = mutt_make_file_attach(att, shared->sub);
781 if (ap->body)
782 {
783 added_attachment = true;
784 update_idx(shared->adata->menu, shared->adata->actx, ap);
785 }
786 else
787 {
788 error = true;
789 mutt_error(_("Unable to attach %s"), att);
790 mutt_aptr_free(&ap);
791 }
792 FREE(&files[i]);
793 }
794
795 FREE(&files);
796 buf_pool_release(&fname);
797
798 if (!error)
800
803 if (added_attachment)
804 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
805 return FR_SUCCESS;
806}
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:606
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_attachment_attach_key()

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

Attach a PGP public key - Implements compose_function_t -.

Definition at line 811 of file functions.c.

813{
815 return FR_NOT_IMPL;
816 struct AttachPtr *ap = mutt_aptr_new();
818 if (ap->body)
819 {
820 update_idx(shared->adata->menu, shared->adata->actx, ap);
822 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
823 }
824 else
825 {
826 mutt_aptr_free(&ap);
827 }
828
830 return FR_SUCCESS;
831}
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_attachment_attach_message()

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

Attach messages to this message - Implements compose_function_t -.

This function handles:

  • OP_ATTACHMENT_ATTACH_MESSAGE
  • OP_ATTACHMENT_ATTACH_NEWS_MESSAGE

Definition at line 840 of file functions.c.

842{
843 char *prompt = _("Open mailbox to attach message from");
844
845 OptNews = false;
846 const int op = event->op;
847 if (shared->mailbox && (op == OP_ATTACHMENT_ATTACH_NEWS_MESSAGE))
848 {
849 const char *const c_news_server = cs_subset_string(shared->sub, "news_server");
850 CurrentNewsSrv = nntp_select_server(shared->mailbox, c_news_server, false);
851 if (!CurrentNewsSrv)
852 return FR_NO_ACTION;
853
854 prompt = _("Open newsgroup to attach message from");
855 OptNews = true;
856 }
857
858 struct Buffer *fname = buf_pool_get();
859 if (shared->mailbox)
860 {
861 if ((op == OP_ATTACHMENT_ATTACH_MESSAGE) ^ (shared->mailbox->type == MUTT_NNTP))
862 {
863 buf_strcpy(fname, mailbox_path(shared->mailbox));
864 pretty_mailbox(fname);
865 }
866 }
867
868 if ((mw_enter_fname(prompt, fname, true, shared->mailbox, false, NULL, NULL,
869 MUTT_SEL_NO_FLAGS) == -1) ||
870 buf_is_empty(fname))
871 {
872 buf_pool_release(&fname);
873 return FR_NO_ACTION;
874 }
875
876 if (OptNews)
877 nntp_expand_path(fname->data, fname->dsize, &CurrentNewsSrv->conn->account);
878 else
879 expand_path(fname, false);
880
881 if (imap_path_probe(buf_string(fname), NULL) != MUTT_IMAP)
882 {
883 if (pop_path_probe(buf_string(fname), NULL) != MUTT_POP)
884 {
885 if (!OptNews && (nntp_path_probe(buf_string(fname), NULL) != MUTT_NNTP))
886 {
888 {
889 /* check to make sure the file exists and is readable */
890 if (access(buf_string(fname), R_OK) == -1)
891 {
892 mutt_perror("%s", buf_string(fname));
893 buf_pool_release(&fname);
894 return FR_ERROR;
895 }
896 }
897 }
898 }
899 }
900
902
903 struct Mailbox *m_attach = mx_path_resolve(buf_string(fname));
904 const bool old_readonly = m_attach->readonly;
905 if (!mx_mbox_open(m_attach, MUTT_READONLY))
906 {
907 mutt_error(_("Unable to open mailbox %s"), buf_string(fname));
908 mx_fastclose_mailbox(m_attach, false);
909 m_attach = NULL;
910 buf_pool_release(&fname);
911 return FR_ERROR;
912 }
913 buf_pool_release(&fname);
914
915 if (m_attach->msg_count == 0)
916 {
917 mx_mbox_close(m_attach);
918 mutt_error(_("No messages in that folder"));
919 return FR_NO_ACTION;
920 }
921
922 /* `$sort`, `$sort_aux`, `$use_threads` could be changed in dlg_index() */
923 const enum EmailSortType old_sort = cs_subset_sort(shared->sub, "sort");
924 const enum EmailSortType old_sort_aux = cs_subset_sort(shared->sub, "sort_aux");
925 const unsigned char old_use_threads = cs_subset_enum(shared->sub, "use_threads");
926
927 mutt_message(_("Tag the messages you want to attach"));
928 struct MuttWindow *dlg = index_pager_init();
929 struct IndexSharedData *index_shared = dlg->wdata;
930 index_shared->attach_msg = true;
931 dialog_push(dlg);
932 struct Mailbox *m_attach_new = dlg_index(dlg, m_attach);
933 dialog_pop();
934 mutt_window_free(&dlg);
935
936 if (!shared->mailbox)
937 {
938 /* Restore old $sort variables */
939 cs_subset_str_native_set(shared->sub, "sort", old_sort, NULL);
940 cs_subset_str_native_set(shared->sub, "sort_aux", old_sort_aux, NULL);
941 cs_subset_str_native_set(shared->sub, "use_threads", old_use_threads, NULL);
944 return FR_SUCCESS;
945 }
946
947 bool added_attachment = false;
948 for (int i = 0; i < m_attach_new->msg_count; i++)
949 {
950 if (!m_attach_new->emails[i])
951 break;
952 if (!message_is_tagged(m_attach_new->emails[i]))
953 continue;
954
955 struct AttachPtr *ap = mutt_aptr_new();
956 ap->body = mutt_make_message_attach(m_attach_new, m_attach_new->emails[i],
957 true, shared->sub);
958 if (ap->body)
959 {
960 added_attachment = true;
961 update_idx(shared->adata->menu, shared->adata->actx, ap);
962 }
963 else
964 {
965 mutt_error(_("Unable to attach"));
966 mutt_aptr_free(&ap);
967 }
968 }
970
971 if (m_attach_new == m_attach)
972 {
973 m_attach->readonly = old_readonly;
974 }
975 mx_fastclose_mailbox(m_attach_new, false);
976
977 /* Restore old $sort variables */
978 cs_subset_str_native_set(shared->sub, "sort", old_sort, NULL);
979 cs_subset_str_native_set(shared->sub, "sort_aux", old_sort_aux, NULL);
980 cs_subset_str_native_set(shared->sub, "use_threads", old_use_threads, NULL);
982 if (added_attachment)
983 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
984 return FR_SUCCESS;
985}
#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:1437
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:1099
#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:2783
enum MailboxType pop_path_probe(const char *path, const struct stat *st)
Is this a POP Mailbox?
Definition pop.c:1161
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox?
Definition imap.c:2543
#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:427
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:121
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:944
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_attachment_detach()

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

Delete the current entry - Implements compose_function_t -.

Definition at line 990 of file functions.c.

991{
992 struct AttachCtx *actx = shared->adata->actx;
993 if (!check_count(actx))
994 return FR_NO_ACTION;
995
996 struct Menu *menu = shared->adata->menu;
997 struct AttachPtr *cur_att = current_attachment(actx, menu);
998 if (cur_att->unowned)
999 cur_att->body->unlink = false;
1000
1001 int index = menu_get_index(menu);
1002 if (delete_attachment(actx, index) == -1)
1003 return FR_ERROR;
1004
1005 menu->num_tagged = 0;
1006 for (int i = 0; i < actx->idxlen; i++)
1007 {
1008 if (actx->idx[i]->body->tagged)
1009 menu->num_tagged++;
1010 }
1011
1012 update_menu(actx, menu, false);
1014
1015 index = menu_get_index(menu);
1016 if (index == 0)
1017 shared->email->body = actx->idx[0]->body;
1018
1019 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1020 return FR_SUCCESS;
1021}
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_attachment_edit_content_id()

static int op_attachment_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 1026 of file functions.c.

1028{
1029 if (!check_count(shared->adata->actx))
1030 return FR_NO_ACTION;
1031
1032 int rc = FR_NO_ACTION;
1033 struct Buffer *buf = buf_pool_get();
1034 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1035 shared->adata->menu);
1036
1037 char *id = cur_att->body->content_id;
1038 if (id)
1039 {
1040 buf_strcpy(buf, id);
1041 }
1042 else
1043 {
1044 id = gen_cid();
1045 buf_strcpy(buf, id);
1046 FREE(&id);
1047 }
1048
1049 if (mw_get_field("Content-ID: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
1050 {
1051 if (!mutt_str_equal(id, buf_string(buf)))
1052 {
1053 if (check_cid(buf_string(buf)))
1054 {
1055 mutt_str_replace(&cur_att->body->content_id, buf_string(buf));
1058 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1059 rc = FR_SUCCESS;
1060 }
1061 else
1062 {
1063 mutt_error(_("Content-ID can only contain the characters: -.0-9@A-Z_a-z"));
1064 rc = FR_ERROR;
1065 }
1066 }
1067 }
1068
1069 buf_pool_release(&buf);
1070
1071 if (rc != FR_ERROR)
1073
1074 return rc;
1075}
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:270
@ 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:662
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_attachment_edit_description()

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

Edit attachment description - Implements compose_function_t -.

Definition at line 1080 of file functions.c.

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

◆ op_attachment_edit_encoding()

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

Edit attachment transfer-encoding - Implements compose_function_t -.

Definition at line 1112 of file functions.c.

1114{
1115 if (!check_count(shared->adata->actx))
1116 return FR_NO_ACTION;
1117
1118 int rc = FR_NO_ACTION;
1119 struct Buffer *buf = buf_pool_get();
1120
1121 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1122 shared->adata->menu);
1123 buf_strcpy(buf, ENCODING(cur_att->body->encoding));
1124
1125 if ((mw_get_field("Content-Transfer-Encoding: ", buf, MUTT_COMP_NO_FLAGS,
1126 HC_OTHER, NULL, NULL) == 0) &&
1127 !buf_is_empty(buf))
1128 {
1129 int enc = mutt_check_encoding(buf_string(buf));
1130 if ((enc != ENC_OTHER) && (enc != ENC_UUENCODED))
1131 {
1132 if (enc != cur_att->body->encoding)
1133 {
1134 cur_att->body->encoding = enc;
1138 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1139 rc = FR_SUCCESS;
1140 }
1141 }
1142 else
1143 {
1144 mutt_error(_("Invalid encoding"));
1145 rc = FR_ERROR;
1146 }
1147 }
1148
1149 buf_pool_release(&buf);
1150 return rc;
1151}
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_attachment_edit_language()

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

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

Definition at line 1156 of file functions.c.

1158{
1159 if (!check_count(shared->adata->actx))
1160 return FR_NO_ACTION;
1161
1162 int rc = FR_NO_ACTION;
1163 struct Buffer *buf = buf_pool_get();
1164 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1165 shared->adata->menu);
1166
1167 buf_strcpy(buf, cur_att->body->language);
1168 if (mw_get_field("Content-Language: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) == 0)
1169 {
1170 if (!mutt_str_equal(cur_att->body->language, buf_string(buf)))
1171 {
1172 mutt_str_replace(&cur_att->body->language, buf_string(buf));
1175 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1176 rc = FR_SUCCESS;
1177 }
1179 }
1180 else
1181 {
1182 mutt_warning(_("Empty 'Content-Language'"));
1183 rc = FR_ERROR;
1184 }
1185
1186 buf_pool_release(&buf);
1187 return rc;
1188}
#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_attachment_edit_mime()

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

Edit attachment using mailcap entry - Implements compose_function_t -.

Definition at line 1193 of file functions.c.

1195{
1196 if (!check_count(shared->adata->actx))
1197 return FR_NO_ACTION;
1198 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1199 shared->adata->menu);
1200 if (!mutt_edit_attachment(cur_att->body))
1201 return FR_NO_ACTION;
1202
1203 mutt_update_encoding(cur_att->body, shared->sub);
1205 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1206 return FR_SUCCESS;
1207}
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_attachment_edit_type()

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

Edit attachment content type - Implements compose_function_t -.

Definition at line 1212 of file functions.c.

1214{
1215 if (!check_count(shared->adata->actx))
1216 return FR_NO_ACTION;
1217
1218 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1219 shared->adata->menu);
1220 if (!mutt_edit_content_type(NULL, cur_att->body, NULL))
1221 return FR_NO_ACTION;
1222
1223 /* this may have been a change to text/something */
1224 mutt_update_encoding(cur_att->body, shared->sub);
1226 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1227 return FR_SUCCESS;
1228}
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_attachment_filter()

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

Filter attachment through a shell command - Implements compose_function_t -.

This function handles:

  • OP_ATTACHMENT_FILTER
  • OP_PIPE

Definition at line 1237 of file functions.c.

1238{
1239 struct AttachCtx *actx = shared->adata->actx;
1240 if (!check_count(actx))
1241 return FR_NO_ACTION;
1242
1243 struct Menu *menu = shared->adata->menu;
1244 struct AttachPtr *cur_att = current_attachment(actx, menu);
1245 if (cur_att->body->type == TYPE_MULTIPART)
1246 {
1247 mutt_error(_("Can't filter multipart attachments"));
1248 return FR_ERROR;
1249 }
1250
1251 const int op = event->op;
1252 mutt_pipe_attachment_list(actx, NULL, menu->tag_prefix, cur_att->body,
1253 (op == OP_ATTACHMENT_FILTER));
1254 if (op == OP_ATTACHMENT_FILTER) /* cte might have changed */
1255 {
1257 }
1259 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1260 return FR_SUCCESS;
1261}
@ 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:718
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_attachment_get_attachment()

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

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

Definition at line 1266 of file functions.c.

1268{
1269 struct AttachCtx *actx = shared->adata->actx;
1270 if (!check_count(actx))
1271 return FR_NO_ACTION;
1272
1273 int rc = FR_ERROR;
1274 struct Menu *menu = shared->adata->menu;
1275 struct BodyArray ba = ARRAY_HEAD_INITIALIZER;
1276 ba_add_tagged(&ba, actx, menu);
1277 if (ARRAY_EMPTY(&ba))
1278 goto done;
1279
1280 struct Body **bp = NULL;
1281 ARRAY_FOREACH(bp, &ba)
1282 {
1283 if ((*bp)->type == TYPE_MULTIPART)
1284 {
1285 mutt_warning(_("Can't get multipart attachments"));
1286 continue;
1287 }
1289 }
1290
1292 rc = FR_SUCCESS;
1293
1294done:
1295 ARRAY_FREE(&ba);
1296 /* No send2hook since this doesn't change the message. */
1297 return rc;
1298}
#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_attachment_group_alts()

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

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

Definition at line 1303 of file functions.c.

1305{
1306 if (shared->adata->menu->num_tagged < 2)
1307 {
1308 mutt_error(_("Grouping 'alternatives' requires at least 2 tagged messages"));
1309 return FR_ERROR;
1310 }
1311
1312 return group_attachments(shared, "alternative");
1313}
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_attachment_group_lingual()

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

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

Definition at line 1318 of file functions.c.

1320{
1321 if (shared->adata->menu->num_tagged < 2)
1322 {
1323 mutt_error(_("Grouping 'multilingual' requires at least 2 tagged messages"));
1324 return FR_ERROR;
1325 }
1326
1327 /* traverse to see whether all the parts have Content-Language: set */
1328 int tagged_with_lang_num = 0;
1329 for (struct Body *b = shared->email->body; b; b = b->next)
1330 if (b->tagged && b->language && *b->language)
1331 tagged_with_lang_num++;
1332
1333 if (shared->adata->menu->num_tagged != tagged_with_lang_num)
1334 {
1335 if (query_yesorno(_("Not all parts have 'Content-Language' set, continue?"),
1336 MUTT_YES) != MUTT_YES)
1337 {
1338 mutt_message(_("Not sending this message"));
1339 return FR_ERROR;
1340 }
1341 }
1342
1343 return group_attachments(shared, "multilingual");
1344}
@ 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:326
struct Body * next
next attachment in the list
Definition body.h:72
+ Here is the call graph for this function:

◆ op_attachment_group_related()

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

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

Definition at line 1349 of file functions.c.

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

◆ op_attachment_move_down()

static int op_attachment_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 1376 of file functions.c.

1378{
1379 int index = menu_get_index(shared->adata->menu);
1380
1381 struct AttachCtx *actx = shared->adata->actx;
1382
1383 if (index < 0)
1384 return FR_ERROR;
1385
1386 if (index == (actx->idxlen - 1))
1387 {
1388 mutt_error(_("Attachment is already at bottom"));
1389 return FR_NO_ACTION;
1390 }
1391 if ((actx->idx[index]->parent_type == TYPE_MULTIPART) &&
1392 !actx->idx[index]->body->next)
1393 {
1394 mutt_error(_("Attachment can't be moved out of group"));
1395 return FR_ERROR;
1396 }
1397
1398 // find next attachment at current level
1399 int nextidx = index + 1;
1400 while ((nextidx < actx->idxlen) &&
1401 (actx->idx[nextidx]->level > actx->idx[index]->level))
1402 {
1403 nextidx++;
1404 }
1405 if (nextidx == actx->idxlen)
1406 {
1407 mutt_error(_("Attachment is already at bottom"));
1408 return FR_NO_ACTION;
1409 }
1410
1411 // find final position
1412 int finalidx = index + 1;
1413 if (nextidx < actx->idxlen - 1)
1414 {
1415 if ((actx->idx[nextidx]->body->type == TYPE_MULTIPART) &&
1416 (actx->idx[nextidx + 1]->level > actx->idx[nextidx]->level))
1417 {
1418 finalidx += attach_body_count(actx->idx[nextidx]->body->parts, true);
1419 }
1420 }
1421
1422 compose_attach_swap(shared->email, shared->adata->actx, index, nextidx);
1423 mutt_update_tree(shared->adata->actx);
1426 menu_set_index(shared->adata->menu, finalidx);
1427 return FR_SUCCESS;
1428}
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_attachment_move_up()

static int op_attachment_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 1433 of file functions.c.

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

◆ op_attachment_new_mime()

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

Compose new attachment using mailcap entry - Implements compose_function_t -.

Definition at line 1468 of file functions.c.

1469{
1470 int rc = FR_NO_ACTION;
1471 struct Buffer *fname = buf_pool_get();
1472 struct Buffer *type = NULL;
1473 struct AttachPtr *ap = NULL;
1474
1475 struct FileCompletionData cdata = { false, shared->mailbox, NULL, NULL, NULL };
1476 if ((mw_get_field(_("New file: "), fname, MUTT_COMP_NO_FLAGS, HC_FILE,
1477 &CompleteFileOps, &cdata) != 0) ||
1478 buf_is_empty(fname))
1479 {
1480 goto done;
1481 }
1482 expand_path(fname, false);
1483
1484 /* Call to lookup_mime_type () ? maybe later */
1485 type = buf_pool_get();
1486 if ((mw_get_field("Content-Type: ", type, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0) ||
1487 buf_is_empty(type))
1488 {
1489 goto done;
1490 }
1491
1492 rc = FR_ERROR;
1493 char *p = strchr(buf_string(type), '/');
1494 if (!p)
1495 {
1496 mutt_error(_("Content-Type is of the form base/sub"));
1497 goto done;
1498 }
1499 *p++ = 0;
1500 enum ContentType itype = mutt_check_mime_type(buf_string(type));
1501 if (itype == TYPE_OTHER)
1502 {
1503 mutt_error(_("Unknown Content-Type %s"), buf_string(type));
1504 goto done;
1505 }
1506
1507 ap = mutt_aptr_new();
1508 /* Touch the file */
1509 if (!mutt_file_touch(buf_string(fname)))
1510 {
1511 mutt_error(_("Can't create file %s"), buf_string(fname));
1512 goto done;
1513 }
1514
1515 ap->body = mutt_make_file_attach(buf_string(fname), shared->sub);
1516 if (!ap->body)
1517 {
1518 mutt_error(_("Error attaching file"));
1519 goto done;
1520 }
1521 update_idx(shared->adata->menu, shared->adata->actx, ap);
1522 ap = NULL; // shared->adata->actx has taken ownership
1523
1524 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1525 shared->adata->menu);
1526 cur_att->body->type = itype;
1527 mutt_str_replace(&cur_att->body->subtype, p);
1528 cur_att->body->unlink = true;
1531
1532 if (mutt_compose_attachment(cur_att->body))
1533 {
1534 mutt_update_encoding(cur_att->body, shared->sub);
1536 }
1537 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1538 rc = FR_SUCCESS;
1539
1540done:
1541 mutt_aptr_free(&ap);
1542 buf_pool_release(&type);
1543 buf_pool_release(&fname);
1544 return rc;
1545}
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:978
@ 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_attachment_print()

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

Print the current entry - Implements compose_function_t -.

Definition at line 1550 of file functions.c.

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

◆ op_attachment_rename_attachment()

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

Send attachment with a different name - Implements compose_function_t -.

Definition at line 1572 of file functions.c.

1574{
1575 if (!check_count(shared->adata->actx))
1576 return FR_NO_ACTION;
1577 char *src = NULL;
1578 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1579 shared->adata->menu);
1580 if (cur_att->body->d_filename)
1581 src = cur_att->body->d_filename;
1582 else
1583 src = cur_att->body->filename;
1584 struct Buffer *fname = buf_pool_get();
1585 buf_strcpy(fname, mutt_path_basename(NONULL(src)));
1586 struct FileCompletionData cdata = { false, shared->mailbox, NULL, NULL, NULL };
1587 int rc = mw_get_field(_("Send attachment with name: "), fname,
1589 if (rc == 0)
1590 {
1591 // It's valid to set an empty string here, to erase what was set
1592 mutt_str_replace(&cur_att->body->d_filename, buf_string(fname));
1594 }
1595 buf_pool_release(&fname);
1596 return FR_SUCCESS;
1597}
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_attachment_save()

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

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

Definition at line 1602 of file functions.c.

1603{
1604 struct AttachCtx *actx = shared->adata->actx;
1605 if (!check_count(actx))
1606 return FR_NO_ACTION;
1607
1608 struct Menu *menu = shared->adata->menu;
1609 struct AttachPtr *cur_att = current_attachment(actx, menu);
1610 if (cur_att->body->type == TYPE_MULTIPART)
1611 {
1612 mutt_error(_("Can't save multipart attachments"));
1613 return FR_ERROR;
1614 }
1615
1616 mutt_save_attachment_list(actx, NULL, menu->tag_prefix, cur_att->body, NULL, menu);
1617 /* no send2hook, since this doesn't modify the message */
1618 return FR_SUCCESS;
1619}
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_attachment_toggle_disposition()

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

Toggle disposition between inline/attachment - Implements compose_function_t -.

Definition at line 1624 of file functions.c.

1626{
1627 /* toggle the content-disposition between inline/attachment */
1628 if (!check_count(shared->adata->actx))
1629 return FR_NO_ACTION;
1630 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1631 shared->adata->menu);
1632 cur_att->body->disposition = (cur_att->body->disposition == DISP_INLINE) ?
1633 DISP_ATTACH :
1637 return FR_SUCCESS;
1638}
@ 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_attachment_toggle_recode()

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

Toggle recoding of this attachment - Implements compose_function_t -.

Definition at line 1643 of file functions.c.

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

◆ op_attachment_toggle_unlink()

static int op_attachment_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 1668 of file functions.c.

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

◆ op_attachment_ungroup()

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

Ungroup a 'multipart' attachment - Implements compose_function_t -.

Definition at line 1685 of file functions.c.

1686{
1687 if (shared->adata->actx->idx[shared->adata->menu->current]->body->type != TYPE_MULTIPART)
1688 {
1689 mutt_error(_("Attachment is not 'multipart'"));
1690 return FR_ERROR;
1691 }
1692
1693 int aidx = shared->adata->menu->current;
1694 struct AttachCtx *actx = shared->adata->actx;
1695 struct Body *b = actx->idx[aidx]->body;
1696 struct Body *b_next = b->next;
1697 struct Body *b_previous = NULL;
1698 struct Body *b_parent = NULL;
1699 int parent_type = actx->idx[aidx]->parent_type;
1700 int level = actx->idx[aidx]->level;
1701
1702 // reorder body pointers
1703 if (attach_body_previous(shared->email->body, b, &b_previous))
1704 b_previous->next = b->parts;
1705 else if (attach_body_parent(shared->email->body, NULL, b, &b_parent))
1706 b_parent->parts = b->parts;
1707 else
1708 shared->email->body = b->parts;
1709
1710 // update attachment list
1711 int i = aidx + 1;
1712 while ((i < actx->idxlen) && (actx->idx[i]->level > level))
1713 {
1714 actx->idx[i]->level--;
1715 if (actx->idx[i]->level == level)
1716 {
1717 actx->idx[i]->parent_type = parent_type;
1718 // set body->next for final attachment in group
1719 if (!actx->idx[i]->body->next)
1720 actx->idx[i]->body->next = b_next;
1721 }
1722 i++;
1723 }
1724
1725 // free memory
1726 actx->idx[aidx]->body->parts = NULL;
1727 actx->idx[aidx]->body->next = NULL;
1728 actx->idx[aidx]->body->email = NULL;
1729 mutt_body_free(&actx->idx[aidx]->body);
1730 FREE(&actx->idx[aidx]->tree);
1731 FREE(&actx->idx[aidx]);
1732
1733 // reorder attachment list
1734 for (int j = aidx; j < (actx->idxlen - 1); j++)
1735 actx->idx[j] = actx->idx[j + 1];
1736 actx->idx[actx->idxlen - 1] = NULL;
1737 actx->idxlen--;
1738 update_menu(actx, shared->adata->menu, false);
1739
1740 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1741 return FR_SUCCESS;
1742}
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_attachment_update_encoding()

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

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

Definition at line 1747 of file functions.c.

1749{
1750 struct AttachCtx *actx = shared->adata->actx;
1751 if (!check_count(actx))
1752 return FR_NO_ACTION;
1753
1754 int rc = FR_NO_ACTION;
1755 struct Menu *menu = shared->adata->menu;
1756 struct BodyArray ba = ARRAY_HEAD_INITIALIZER;
1757 ba_add_tagged(&ba, actx, menu);
1758 if (ARRAY_EMPTY(&ba))
1759 goto done;
1760
1761 struct Body **bp = NULL;
1762 ARRAY_FOREACH(bp, &ba)
1763 {
1764 mutt_update_encoding(*bp, shared->sub);
1765 }
1766
1769 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1770 rc = FR_SUCCESS;
1771
1772done:
1773 ARRAY_FREE(&ba);
1774 return rc;
1775}
+ 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 1782 of file functions.c.

1784{
1786 const char *tag = NULL;
1787 char *err = NULL;
1788 mutt_env_to_local(shared->email->env);
1789 const char *const c_editor = cs_subset_string(shared->sub, "editor");
1790 if (shared->email->body->type == TYPE_MULTIPART)
1791 {
1792 struct Body *b = shared->email->body->parts;
1793 while (b && b->parts)
1794 b = b->parts;
1795 if (b)
1796 mutt_edit_headers(NONULL(c_editor), b->filename, shared->email, shared->fcc);
1797 }
1798 else
1799 {
1800 mutt_edit_headers(NONULL(c_editor), shared->email->body->filename,
1801 shared->email, shared->fcc);
1802 }
1803
1804 if (mutt_env_to_intl(shared->email->env, &tag, &err))
1805 {
1806 mutt_error(_("Bad IDN in '%s': '%s'"), tag, err);
1807 FREE(&err);
1808 }
1810
1812 mutt_update_encoding(shared->email->body, shared->sub);
1813
1814 /* attachments may have been added */
1815 if (shared->adata->actx->idxlen &&
1816 shared->adata->actx->idx[shared->adata->actx->idxlen - 1]->body->next)
1817 {
1819 update_menu(shared->adata->actx, shared->adata->menu, true);
1820 }
1821
1823 /* Unconditional hook since editor was invoked */
1824 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1825 return FR_SUCCESS;
1826}
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 1831 of file functions.c.

1832{
1833 if (!check_count(shared->adata->actx))
1834 return FR_NO_ACTION;
1835 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1836 shared->adata->menu);
1837 if (cur_att->body->type == TYPE_MULTIPART)
1838 {
1839 mutt_error(_("Can't edit multipart attachments"));
1840 return FR_ERROR;
1841 }
1842 const char *const c_editor = cs_subset_string(shared->sub, "editor");
1843 mutt_edit_file(NONULL(c_editor), cur_att->body->filename);
1844 mutt_update_encoding(cur_att->body, shared->sub);
1847 /* Unconditional hook since editor was invoked */
1848 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1849 return FR_SUCCESS;
1850}
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 1855 of file functions.c.

1857{
1858 const bool c_edit_headers = cs_subset_bool(shared->sub, "edit_headers");
1859 if (!c_edit_headers)
1860 {
1862 const char *const c_editor = cs_subset_string(shared->sub, "editor");
1863 mutt_edit_file(c_editor, shared->email->body->filename);
1865 mutt_update_encoding(shared->email->body, shared->sub);
1867 /* Unconditional hook since editor was invoked */
1868 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1869 return FR_SUCCESS;
1870 }
1871
1872 return op_envelope_edit_headers(shared, event);
1873}
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:1782
+ 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 1878 of file functions.c.

1879{
1880 endwin();
1881 const char *const c_ispell = cs_subset_string(shared->sub, "ispell");
1882 struct Buffer *cmd = buf_pool_get();
1883 struct Buffer *quoted = buf_pool_get();
1884 buf_quote_filename(quoted, shared->email->body->filename, true);
1885 buf_printf(cmd, "%s -x %s", NONULL(c_ispell), buf_string(quoted));
1886 buf_pool_release(&quoted);
1887 if (mutt_system(buf_string(cmd)) == -1)
1888 {
1889 mutt_error(_("Error running \"%s\""), buf_string(cmd));
1890 buf_pool_release(&cmd);
1891 return FR_ERROR;
1892 }
1893 buf_pool_release(&cmd);
1894
1895 mutt_update_encoding(shared->email->body, shared->sub);
1897 return FR_SUCCESS;
1898}
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:807
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 1903 of file functions.c.

1905{
1906 if (check_attachments(shared->adata->actx, shared->sub) != 0)
1907 {
1909 return FR_ERROR;
1910 }
1911
1912 shared->rc = 1;
1913 return FR_DONE;
1914}
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 1919 of file functions.c.

1920{
1921 if (!check_count(shared->adata->actx))
1922 return FR_NO_ACTION;
1923 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
1924 shared->adata->menu);
1925 if (cur_att->body->type == TYPE_MULTIPART)
1926 {
1927 mutt_error(_("Can't rename multipart attachments"));
1928 return FR_ERROR;
1929 }
1930 struct Buffer *fname = buf_pool_get();
1931 buf_strcpy(fname, cur_att->body->filename);
1932 pretty_mailbox(fname);
1933 struct FileCompletionData cdata = { false, shared->mailbox, NULL, NULL, NULL };
1934 if ((mw_get_field(_("Rename to: "), fname, MUTT_COMP_NO_FLAGS, HC_FILE,
1935 &CompleteFileOps, &cdata) == 0) &&
1936 !buf_is_empty(fname))
1937 {
1938 struct stat st = { 0 };
1939 if (stat(cur_att->body->filename, &st) == -1)
1940 {
1941 /* L10N: "stat" is a system call. Do "man 2 stat" for more information. */
1942 mutt_error(_("Can't stat %s: %s"), buf_string(fname), strerror(errno));
1943 buf_pool_release(&fname);
1944 return FR_ERROR;
1945 }
1946
1947 expand_path(fname, false);
1948 if (mutt_file_rename(cur_att->body->filename, buf_string(fname)))
1949 {
1950 buf_pool_release(&fname);
1951 return FR_ERROR;
1952 }
1953
1954 mutt_str_replace(&cur_att->body->filename, buf_string(fname));
1956
1957 if (cur_att->body->stamp >= st.st_mtime)
1958 mutt_stamp_attachment(cur_att->body);
1959 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1960 }
1961 buf_pool_release(&fname);
1962 return FR_SUCCESS;
1963}
int mutt_file_rename(const char *oldfile, const char *newfile)
Rename a file.
Definition file.c:1261
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 1968 of file functions.c.

1970{
1971 /* Note: We don't invoke send2-hook here, since we want to leave
1972 * users an opportunity to change settings from the ":" prompt. */
1973 if (check_attachments(shared->adata->actx, shared->sub) != 0)
1974 {
1976 return FR_NO_ACTION;
1977 }
1978
1979 if (!shared->fcc_set && !buf_is_empty(shared->fcc))
1980 {
1981 enum QuadOption ans = query_quadoption(_("Save a copy of this message?"),
1982 shared->sub, "copy");
1983 if (ans == MUTT_ABORT)
1984 return FR_NO_ACTION;
1985 else if (ans == MUTT_NO)
1986 buf_reset(shared->fcc);
1987 }
1988
1989 shared->rc = 0;
1990 return FR_DONE;
1991}
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:378
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 1996 of file functions.c.

1998{
1999 int rc = FR_NO_ACTION;
2000 struct Buffer *fname = buf_pool_get();
2001 if (shared->mailbox)
2002 {
2003 buf_strcpy(fname, mailbox_path(shared->mailbox));
2004 pretty_mailbox(fname);
2005 }
2006 if (shared->adata->actx->idxlen)
2007 shared->email->body = shared->adata->actx->idx[0]->body;
2008 if ((mw_enter_fname(_("Write message to mailbox"), fname, true, shared->mailbox,
2009 false, NULL, NULL, MUTT_SEL_NO_FLAGS) != -1) &&
2010 !buf_is_empty(fname))
2011 {
2012 mutt_message(_("Writing message to %s ..."), buf_string(fname));
2013 expand_path(fname, false);
2014
2015 if (shared->email->body->next)
2016 shared->email->body = mutt_make_multipart(shared->email->body);
2017
2018 if (mutt_write_fcc(buf_string(fname), shared->email, NULL, false, NULL,
2019 NULL, shared->sub) == 0)
2020 mutt_message(_("Message written"));
2021
2022 shared->email->body = mutt_remove_multipart(shared->email->body);
2023 rc = FR_SUCCESS;
2024 }
2025 buf_pool_release(&fname);
2026 return rc;
2027}
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition multipart.c:126
struct Body * mutt_make_multipart(struct Body *b)
Create a multipart email.
Definition multipart.c:100
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:1017
+ 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_ATTACHMENT_VIEW
  • OP_ATTACHMENT_VIEW_MAILCAP
  • OP_ATTACHMENT_VIEW_PAGER
  • OP_ATTACHMENT_VIEW_TEXT
  • OP_DISPLAY_HEADERS

Definition at line 2039 of file functions.c.

2040{
2041 if (!check_count(shared->adata->actx))
2042 return FR_NO_ACTION;
2043
2044 enum ViewAttachMode mode = MUTT_VA_REGULAR;
2045
2046 const int op = event->op;
2047 switch (op)
2048 {
2049 case OP_ATTACHMENT_VIEW:
2050 case OP_DISPLAY_HEADERS:
2051 break;
2052
2053 case OP_ATTACHMENT_VIEW_MAILCAP:
2054 mode = MUTT_VA_MAILCAP;
2055 break;
2056
2057 case OP_ATTACHMENT_VIEW_PAGER:
2058 mode = MUTT_VA_PAGER;
2059 break;
2060
2061 case OP_ATTACHMENT_VIEW_TEXT:
2062 mode = MUTT_VA_AS_TEXT;
2063 break;
2064 }
2065
2066 if (mode == MUTT_VA_REGULAR)
2067 {
2068 mutt_attach_display_loop(shared->sub, shared->adata->menu, op,
2069 shared->email, shared->adata->actx, false);
2070 }
2071 else
2072 {
2073 struct AttachPtr *cur_att = current_attachment(shared->adata->actx,
2074 shared->adata->menu);
2075 mutt_view_attachment(NULL, cur_att->body, mode, shared->email,
2076 shared->adata->actx, shared->adata->menu->win);
2077 }
2078
2080 /* no send2hook, since this doesn't modify the message */
2081 return FR_SUCCESS;
2082}
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:959
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 2087 of file functions.c.

2088{
2089 enum QuadOption ans = query_quadoption(_("Save (postpone) draft message?"),
2090 shared->sub, "postpone");
2091 if (ans == MUTT_NO)
2092 {
2093 for (int i = 0; i < shared->adata->actx->idxlen; i++)
2094 if (shared->adata->actx->idx[i]->unowned)
2095 shared->adata->actx->idx[i]->body->unlink = false;
2096
2097 if (!(shared->flags & MUTT_COMPOSE_NOFREEHEADER))
2098 {
2099 for (int i = 0; i < shared->adata->actx->idxlen; i++)
2100 {
2101 /* avoid freeing other attachments */
2102 shared->adata->actx->idx[i]->body->next = NULL;
2103 if (!shared->adata->actx->idx[i]->body->email)
2104 shared->adata->actx->idx[i]->body->parts = NULL;
2105 mutt_body_free(&shared->adata->actx->idx[i]->body);
2106 }
2107 }
2108 shared->rc = -1;
2109 return FR_DONE;
2110 }
2111 else if (ans == MUTT_ABORT)
2112 {
2113 return FR_NO_ACTION;
2114 }
2115
2116 return op_compose_postpone_message(shared, event);
2117}
#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:1903
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 2122 of file functions.c.

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