NeoMutt  2022-04-29-178-g3b62e6
Teaching an old dog new tricks
DOXYGEN
recvattach.h File Reference

Routines for managing attachments. More...

#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "format_flags.h"
+ Include dependency graph for recvattach.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void mutt_attach_init (struct AttachCtx *actx)
 Create a new Attachment context. More...
 
void mutt_update_tree (struct AttachCtx *actx)
 Refresh the list of attachments. More...
 
const char * attach_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
 Format a string for the attachment menu - Implements format_t -. More...
 
void dlg_select_attachment (struct ConfigSubset *sub, struct Mailbox *m, struct Email *e, FILE *fp)
 Show the attachments in a Menu. More...
 
void mutt_generate_recvattach_list (struct AttachCtx *actx, struct Email *e, struct Body *parts, FILE *fp, int parent_type, int level, bool decrypted)
 Create a list of attachments. More...
 
struct AttachPtrcurrent_attachment (struct AttachCtx *actx, struct Menu *menu)
 Get the current attachment. More...
 
void mutt_update_recvattach_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Update the Attachment Menu. More...
 
void recvattach_edit_content_type (struct AttachCtx *actx, struct Menu *menu, struct Email *e)
 Edit the content type of an attachment. More...
 
int ba_add_tagged (struct BodyArray *ba, struct AttachCtx *actx, struct Menu *menu)
 Get an array of tagged Attachments. More...
 

Detailed Description

Routines for managing attachments.

Authors
  • Michael R. Elkins
  • Thomas Roessler

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file recvattach.h.

Function Documentation

◆ mutt_attach_init()

void mutt_attach_init ( struct AttachCtx actx)

Create a new Attachment context.

Parameters
actxAttachment context

Definition at line 1168 of file recvattach.c.

1169{
1170 /* Collapse the attachments if '$digest_collapse' is set AND if...
1171 * the outer container is of type 'multipart/digest' */
1172 bool digest = mutt_istr_equal(actx->email->body->subtype, "digest");
1173
1174 const bool c_digest_collapse = cs_subset_bool(NeoMutt->sub, "digest_collapse");
1175 for (int i = 0; i < actx->idxlen; i++)
1176 {
1177 actx->idx[i]->body->tagged = false;
1178
1179 /* OR an inner container is of type 'multipart/digest' */
1180 actx->idx[i]->collapsed = (c_digest_collapse &&
1181 (digest ||
1182 ((actx->idx[i]->body->type == TYPE_MULTIPART) &&
1183 mutt_istr_equal(actx->idx[i]->body->subtype, "digest"))));
1184 }
1185}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:796
struct Email * email
Used by recvattach for updating.
Definition: attach.h:52
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:55
short idxlen
Number of attachmentes.
Definition: attach.h:56
struct Body * body
Attachment.
Definition: attach.h:36
bool collapsed
Group is collapsed.
Definition: attach.h:44
bool tagged
This attachment is tagged.
Definition: body.h:89
char * subtype
content-type subtype
Definition: body.h:60
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
struct Body * body
List of MIME parts.
Definition: email.h:67
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_update_tree()

void mutt_update_tree ( struct AttachCtx actx)

Refresh the list of attachments.

Parameters
actxAttachment context

Definition at line 112 of file recvattach.c.

113{
114 char buf[256] = { 0 };
115 char *s = NULL;
116
117 mutt_update_v2r(actx);
118
119 for (int vindex = 0; vindex < actx->vcount; vindex++)
120 {
121 const int rindex = actx->v2r[vindex];
122 actx->idx[rindex]->num = vindex;
123 if ((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf))
124 {
125 if (actx->idx[rindex]->level)
126 {
127 s = buf + 2 * (actx->idx[rindex]->level - 1);
128 *s++ = (actx->idx[rindex]->body->next) ? MUTT_TREE_LTEE : MUTT_TREE_LLCORNER;
129 *s++ = MUTT_TREE_HLINE;
130 *s++ = MUTT_TREE_RARROW;
131 }
132 else
133 s = buf;
134 *s = '\0';
135 }
136
137 if (actx->idx[rindex]->tree)
138 {
139 if (!mutt_str_equal(actx->idx[rindex]->tree, buf))
140 mutt_str_replace(&actx->idx[rindex]->tree, buf);
141 }
142 else
143 actx->idx[rindex]->tree = mutt_str_dup(buf);
144
145 if (((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf)) &&
146 actx->idx[rindex]->level)
147 {
148 s = buf + 2 * (actx->idx[rindex]->level - 1);
149 *s++ = (actx->idx[rindex]->body->next) ? '\005' : '\006';
150 *s++ = '\006';
151 }
152 }
153}
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:784
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:326
@ MUTT_TREE_LLCORNER
Lower left corner.
Definition: mutt_thread.h:44
@ MUTT_TREE_RARROW
Right arrow.
Definition: mutt_thread.h:50
@ MUTT_TREE_LTEE
Left T-piece.
Definition: mutt_thread.h:46
@ MUTT_TREE_HLINE
Horizontal line.
Definition: mutt_thread.h:47
static void mutt_update_v2r(struct AttachCtx *actx)
Update the virtual list of attachments.
Definition: recvattach.c:83
short vcount
The number of virtual attachments.
Definition: attach.h:60
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:59
char * tree
Tree characters to display.
Definition: attach.h:39
int num
Attachment index number.
Definition: attach.h:41
int level
Nesting depth of attachment.
Definition: attach.h:40
struct Body * next
next attachment in the list
Definition: body.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlg_select_attachment()

void dlg_select_attachment ( struct ConfigSubset sub,
struct Mailbox m,
struct Email e,
FILE *  fp 
)

Show the attachments in a Menu.

Parameters
subConfig Subset
mMailbox
eEmail
fpFile with the content of the email, or NULL

Definition at line 449 of file dlg_attach.c.

451{
452 if (!m || !e || !fp)
453 return;
454
455 /* make sure we have parsed this message */
458
460 struct Menu *menu = dlg->wdata;
462 menu->tag = attach_tag;
463
464 struct AttachCtx *actx = mutt_actx_new();
465 actx->email = e;
466 actx->fp_root = fp;
467 mutt_update_recvattach_menu(actx, menu, true);
468
470 priv->menu = menu;
471 priv->actx = actx;
472 priv->sub = sub;
473 priv->mailbox = m;
474 menu->mdata = priv;
476
477 // NT_COLOR is handled by the SimpleDialog
480
481 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
482 sbar_set_title(sbar, _("Attachments"));
483
484 // ---------------------------------------------------------------------------
485 // Event Loop
486 int rc = 0;
487 int op = OP_NULL;
488 do
489 {
490 menu_tagging_dispatcher(menu->win, op);
491 window_redraw(NULL);
492
493 op = km_dokey(MENU_ATTACH);
494 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
495 if (op < 0)
496 continue;
497 if (op == OP_NULL)
498 {
500 continue;
501 }
503
504 rc = attach_function_dispatcher(dlg, op);
505 if (rc == FR_UNKNOWN)
506 rc = menu_function_dispatcher(menu->win, op);
507 if (rc == FR_UNKNOWN)
508 rc = global_function_dispatcher(NULL, op);
509
510 if (rc == FR_CONTINUE)
511 {
512 op = priv->op;
513 }
514
515 } while (rc != FR_DONE);
516 // ---------------------------------------------------------------------------
517
518 simple_dialog_free(&dlg);
519}
struct AttachCtx * mutt_actx_new(void)
Create a new Attachment Context.
Definition: attach.c:189
struct AttachPrivateData * attach_private_data_new(void)
Create new Attach Data.
Definition: private_data.c:52
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:592
@ FR_DONE
Exit the Dialog.
Definition: dispatcher.h:35
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
@ FR_CONTINUE
Remain in the Dialog.
Definition: dispatcher.h:34
static const struct Mapping AttachHelp[]
Help Bar for the Attachment selection dialog.
Definition: dlg_attach.c:94
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int attach_function_dispatcher(struct MuttWindow *win, int op)
Perform a Attach function - Implements function_dispatcher_t -.
Definition: functions.c:641
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static void attach_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the attachment list - Implements Menu::make_entry() -.
Definition: dlg_attach.c:386
void attach_private_data_free(struct Menu *menu, void **ptr)
Free Attach Data - Implements Menu::mdata_free() -.
Definition: private_data.c:38
static int attach_tag(struct Menu *menu, int sel, int act)
Tag an attachment - Implements Menu::tag() -.
Definition: dlg_attach.c:400
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_attach.c:110
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_attach.c:419
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:658
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:45
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
#define _(a)
Definition: message.h:28
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:189
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
@ WT_DLG_ATTACH
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:78
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:46
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1193
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
A set of attachments.
Definition: attach.h:51
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:53
Private state data for Attachments.
Definition: private_data.h:34
int op
Op returned from the Pager, e.g. OP_NEXT_ENTRY.
Definition: private_data.h:39
struct Menu * menu
Current Menu.
Definition: private_data.h:35
struct ConfigSubset * sub
Config subset.
Definition: private_data.h:37
struct AttachCtx * actx
List of all Attachments.
Definition: private_data.h:36
struct Mailbox * mailbox
Current Mailbox.
Definition: private_data.h:38
Definition: lib.h:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:121
void * mdata
Private data.
Definition: lib.h:137
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
@ MENU_ATTACH
Select an attachment.
Definition: type.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_generate_recvattach_list()

void mutt_generate_recvattach_list ( struct AttachCtx actx,
struct Email e,
struct Body parts,
FILE *  fp,
int  parent_type,
int  level,
bool  decrypted 
)

Create a list of attachments.

Parameters
actxAttachment context
eEmail
partsBody of email
fpFile to read from
parent_typeType, e.g. TYPE_MULTIPART
levelAttachment depth
decryptedTrue if attachment has been decrypted

Definition at line 1061 of file recvattach.c.

1064{
1065 struct Body *m = NULL;
1066 struct Body *new_body = NULL;
1067 FILE *fp_new = NULL;
1069 int need_secured, secured;
1070
1071 for (m = parts; m; m = m->next)
1072 {
1073 need_secured = 0;
1074 secured = 0;
1075
1077 {
1078 need_secured = 1;
1079
1080 if (type & SEC_ENCRYPT)
1081 {
1083 goto decrypt_failed;
1084
1085 if (e->env)
1087 }
1088
1089 secured = !crypt_smime_decrypt_mime(fp, &fp_new, m, &new_body);
1090 /* If the decrypt/verify-opaque doesn't generate mime output, an empty
1091 * text/plain type will still be returned by mutt_read_mime_header().
1092 * We can't distinguish an actual part from a failure, so only use a
1093 * text/plain that results from a single top-level part. */
1094 if (secured && (new_body->type == TYPE_TEXT) &&
1095 mutt_istr_equal("plain", new_body->subtype) && ((parts != m) || m->next))
1096 {
1097 mutt_body_free(&new_body);
1098 mutt_file_fclose(&fp_new);
1099 goto decrypt_failed;
1100 }
1101
1102 if (secured && (type & SEC_ENCRYPT))
1103 e->security |= SMIME_ENCRYPT;
1104 }
1105
1106 if (((WithCrypto & APPLICATION_PGP) != 0) &&
1108 {
1109 need_secured = 1;
1110
1112 goto decrypt_failed;
1113
1114 secured = !crypt_pgp_decrypt_mime(fp, &fp_new, m, &new_body);
1115
1116 if (secured)
1117 e->security |= PGP_ENCRYPT;
1118 }
1119
1120 if (need_secured && secured)
1121 {
1122 mutt_actx_add_fp(actx, fp_new);
1123 mutt_actx_add_body(actx, new_body);
1124 mutt_generate_recvattach_list(actx, e, new_body, fp_new, parent_type, level, 1);
1125 continue;
1126 }
1127
1128 decrypt_failed:
1129 /* Fall through and show the original parts if decryption fails */
1130 if (need_secured && !secured)
1131 mutt_error(_("Can't decrypt encrypted message"));
1132
1133 /* Strip out the top level multipart */
1134 if ((m->type == TYPE_MULTIPART) && m->parts && !need_secured &&
1135 ((parent_type == -1) && !mutt_istr_equal("alternative", m->subtype) &&
1136 !mutt_istr_equal("multilingual", m->subtype)))
1137 {
1138 mutt_generate_recvattach_list(actx, e, m->parts, fp, m->type, level, decrypted);
1139 }
1140 else
1141 {
1142 struct AttachPtr *ap = mutt_aptr_new();
1143 mutt_actx_add_attach(actx, ap);
1144
1145 ap->body = m;
1146 ap->fp = fp;
1147 m->aptr = ap;
1149 ap->level = level;
1150 ap->decrypted = decrypted;
1151
1152 if (m->type == TYPE_MULTIPART)
1153 mutt_generate_recvattach_list(actx, e, m->parts, fp, m->type, level + 1, decrypted);
1154 else if (mutt_is_message_type(m->type, m->subtype))
1155 {
1157 level + 1, decrypted);
1158 e->security |= m->email->security;
1159 }
1160 }
1161 }
1162}
void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body)
Add an email body to an Attachment Context.
Definition: attach.c:142
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
Definition: attach.c:65
void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new)
Save a File handle to the Attachment Context.
Definition: attach.c:121
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
Definition: attach.c:40
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
Definition: crypt.c:601
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:134
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:439
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:500
int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition: cryptglue.c:433
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:455
int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
Wrapper for CryptModuleSpecs::decrypt_mime()
Definition: cryptglue.c:211
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
#define mutt_error(...)
Definition: logging.h:87
@ TYPE_TEXT
Type: 'text/*'.
Definition: mime.h:38
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: lib.h:76
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define PGP_ENCRYPT
Definition: lib.h:96
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:91
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:78
#define SMIME_ENCRYPT
Definition: lib.h:102
#define WithCrypto
Definition: lib.h:116
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1442
void mutt_generate_recvattach_list(struct AttachCtx *actx, struct Email *e, struct Body *parts, FILE *fp, int parent_type, int level, bool decrypted)
Create a list of attachments.
Definition: recvattach.c:1061
An email to which things will be attached.
Definition: attach.h:35
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
bool decrypted
Not part of message as stored in the email->body.
Definition: attach.h:43
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:38
The body of an email.
Definition: body.h:36
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:72
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:74
struct Email * email
header information for message/rfc822
Definition: body.h:73
struct Envelope * env
Envelope information.
Definition: email.h:66
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current_attachment()

struct AttachPtr * current_attachment ( struct AttachCtx actx,
struct Menu menu 
)

Get the current attachment.

Parameters
actxAttachment context
menuMenu
Return values
ptrCurrent Attachment

Definition at line 69 of file recvattach.c.

70{
71 const int virt = menu_get_index(menu);
72 const int index = actx->v2r[virt];
73
74 return actx->idx[index];
75}
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_update_recvattach_menu()

void mutt_update_recvattach_menu ( struct AttachCtx actx,
struct Menu menu,
bool  init 
)

Update the Attachment Menu.

Parameters
actxAttachment context
menuMenu listing Attachments
initIf true, create a new Attachments context

Definition at line 1193 of file recvattach.c.

1194{
1195 if (init)
1196 {
1197 mutt_generate_recvattach_list(actx, actx->email, actx->email->body,
1198 actx->fp_root, -1, 0, 0);
1199 mutt_attach_init(actx);
1200 }
1201
1202 mutt_update_tree(actx);
1203
1204 menu->max = actx->vcount;
1205
1206 const int index = menu_get_index(menu);
1207 if (index >= menu->max)
1208 menu_set_index(menu, menu->max - 1);
1210}
#define MENU_REDRAW_INDEX
Redraw the index.
Definition: lib.h:56
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:178
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:168
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
Definition: recvattach.c:1168
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition: recvattach.c:112
int max
Number of entries in the menu.
Definition: lib.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recvattach_edit_content_type()

void recvattach_edit_content_type ( struct AttachCtx actx,
struct Menu menu,
struct Email e 
)

Edit the content type of an attachment.

Parameters
actxAttachment context
menuMenu listing Attachments
eEmail

Definition at line 908 of file recvattach.c.

909{
910 struct AttachPtr *cur_att = current_attachment(actx, menu);
911 if (!mutt_edit_content_type(e, cur_att->body, cur_att->fp))
912 return;
913
914 /* The mutt_update_recvattach_menu() will overwrite any changes
915 * made to a decrypted cur_att->body, so warn the user. */
916 if (cur_att->decrypted)
917 {
918 mutt_message(_("Structural changes to decrypted attachments are not supported"));
919 mutt_sleep(1);
920 }
921 /* Editing the content type can rewrite the body structure. */
922 for (int i = 0; i < actx->idxlen; i++)
923 actx->idx[i]->body = NULL;
925 mutt_update_recvattach_menu(actx, menu, true);
926}
void mutt_actx_entries_free(struct AttachCtx *actx)
Free entries in an Attachment Context.
Definition: attach.c:162
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Definition: commands.c:1105
#define mutt_message(...)
Definition: logging.h:86
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1455
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
Definition: recvattach.c:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ba_add_tagged()

int ba_add_tagged ( struct BodyArray *  ba,
struct AttachCtx actx,
struct Menu menu 
)

Get an array of tagged Attachments.

Parameters
baEmpty BodyArray to populate
actxList of Attachments
menuMenu
Return values
numNumber of selected Attachments
-1Error

Definition at line 1220 of file recvattach.c.

1221{
1222 if (!ba || !actx || !menu)
1223 return -1;
1224
1225 if (menu->tag_prefix)
1226 {
1227 for (int i = 0; i < actx->idxlen; i++)
1228 {
1229 struct Body *b = actx->idx[i]->body;
1230 if (b->tagged)
1231 {
1232 ARRAY_ADD(ba, b);
1233 }
1234 }
1235 }
1236 else
1237 {
1238 struct AttachPtr *cur = current_attachment(actx, menu);
1239 if (!cur)
1240 return -1;
1241
1242 ARRAY_ADD(ba, cur->body);
1243 }
1244
1245 return ARRAY_SIZE(ba);
1246}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:155
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:86
bool tag_prefix
User has pressed <tag-prefix>
Definition: lib.h:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function: