NeoMutt  2018-07-16 +2388-bcedc8
Teaching an old dog new tricks
DOXYGEN
recvattach.c File Reference

Routines for managing attachments. More...

#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/mutt.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "recvattach.h"
#include "commands.h"
#include "context.h"
#include "curs_lib.h"
#include "filter.h"
#include "format_flags.h"
#include "globals.h"
#include "handler.h"
#include "hdrline.h"
#include "hook.h"
#include "keymap.h"
#include "mutt_attach.h"
#include "mutt_logging.h"
#include "mutt_menu.h"
#include "mutt_parse.h"
#include "mutt_window.h"
#include "muttlib.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
#include "options.h"
#include "recvcmd.h"
#include "rfc1524.h"
#include "send.h"
#include "sendlib.h"
#include "state.h"
#include <libintl.h>
+ Include dependency graph for recvattach.c:

Go to the source code of this file.

Macros

#define CHECK_READONLY
 
#define CUR_ATTACH   actx->idx[actx->v2r[menu->current]]
 
#define CHECK_ATTACH
 

Functions

static void mutt_update_recvattach_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Update the Attachment Menu. More...
 
static void mutt_update_v2r (struct AttachCtx *actx)
 Update the virtual list of attachments. 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, unsigned long data, MuttFormatFlags flags)
 Format a string for the attachment menu - Implements format_t. More...
 
static void attach_make_entry (char *buf, size_t buflen, struct Menu *menu, int line)
 Format a menu item for the attachment list - Implements Menu::menu_make_entry() More...
 
int attach_tag (struct Menu *menu, int sel, int act)
 Tag an attachment - Implements Menu::menu_tag() More...
 
static void prepend_savedir (char *buf, size_t bufsize)
 Add C_AttachSaveDir to the beginning of a path. More...
 
static bool has_a_message (struct Body *body)
 Determine if the Body has a message (to save) More...
 
static int query_save_attachment (FILE *fp, struct Body *body, struct Email *e, char **directory)
 Ask the user if we should save the attachment. More...
 
static int save_without_prompting (FILE *fp, struct Body *body, struct Email *e)
 Save the attachment, without prompting each time. More...
 
void mutt_save_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, struct Email *e, struct Menu *menu)
 Save a list of attachments. More...
 
static void query_pipe_attachment (char *command, FILE *fp, struct Body *body, bool filter)
 Ask the user if we should pipe the attachment. More...
 
static void pipe_attachment (FILE *fp, struct Body *b, struct State *state)
 Pipe the attachment to a command. More...
 
static void pipe_attachment_list (char *command, struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, bool filter, struct State *state)
 Pipe a list of attachments to a command. More...
 
void mutt_pipe_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, bool filter)
 Pipe a list of attachments to a command. More...
 
static bool can_print (struct AttachCtx *actx, struct Body *top, bool tag)
 Do we know how to print this attachment type? More...
 
static void print_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, struct State *state)
 Print a list of Attachments. More...
 
void mutt_print_attachment_list (struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top)
 Print a list of Attachments. More...
 
static void recvattach_extract_pgp_keys (struct AttachCtx *actx, struct Menu *menu)
 Extract PGP keys from attachments. More...
 
static int recvattach_pgp_check_traditional (struct AttachCtx *actx, struct Menu *menu)
 Is the Attachment inline PGP? More...
 
static void recvattach_edit_content_type (struct AttachCtx *actx, struct Menu *menu, struct Email *e)
 Edit the content type of an attachment. More...
 
int mutt_attach_display_loop (struct Menu *menu, int op, struct Email *e, struct AttachCtx *actx, bool recv)
 Event loop for the Attachment 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...
 
void mutt_attach_init (struct AttachCtx *actx)
 Create a new Attachment context. More...
 
static void attach_collapse (struct AttachCtx *actx, struct Menu *menu)
 Close the tree of the current attachment. More...
 
void mutt_view_attachments (struct Email *e)
 Show the attachments in a Menu. More...
 

Variables

char * C_AttachSaveDir
 Config: Default directory where attachments are saved. More...
 
char * C_AttachSaveWithoutPrompting
 Config: If true, then don't prompt to save. More...
 
char * C_AttachSep
 Config: Separator to add between saved/printed/piped attachments. More...
 
bool C_AttachSplit
 Config: Save/print/pipe tagged messages individually. More...
 
bool C_DigestCollapse
 Config: Hide the subparts of a multipart/digest. More...
 
char * C_MessageFormat
 Config: printf-like format string for listing attached messages. More...
 
static const char * Mailbox_is_read_only = N_("Mailbox is read-only")
 
static const struct Mapping AttachHelp []
 
static const char * Function_not_permitted
 

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.c.

Macro Definition Documentation

#define CHECK_READONLY
Value:
{ \
break; \
}
The "current" mailbox.
Definition: context.h:36
static const char * Mailbox_is_read_only
Definition: recvattach.c:82
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:800
#define _(a)
Definition: message.h:28
struct Mailbox * mailbox
Definition: context.h:50
bool readonly
Don&#39;t allow changes to the mailbox.
Definition: mailbox.h:130
#define mutt_error(...)
Definition: logging.h:84

Definition at line 84 of file recvattach.c.

#define CUR_ATTACH   actx->idx[actx->v2r[menu->current]]

Definition at line 92 of file recvattach.c.

#define CHECK_ATTACH
Value:
{ \
break; \
}
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:800
#define _(a)
Definition: message.h:28
WHERE bool OptAttachMsg
(pseudo) used by attach-message
Definition: options.h:31
#define mutt_error(...)
Definition: logging.h:84
static const char * Function_not_permitted
Definition: recvattach.c:99

Definition at line 102 of file recvattach.c.

Function Documentation

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

Update the Attachment Menu.

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

Definition at line 1346 of file recvattach.c.

1347 {
1348  if (init)
1349  {
1350  mutt_generate_recvattach_list(actx, actx->email, actx->email->content,
1351  actx->fp_root, -1, 0, 0);
1352  mutt_attach_init(actx);
1353  menu->data = actx;
1354  }
1355 
1356  mutt_update_tree(actx);
1357 
1358  menu->max = actx->vcount;
1359 
1360  if (menu->current >= menu->max)
1361  menu->current = menu->max - 1;
1362  menu_check_recenter(menu);
1363  menu->redraw |= REDRAW_INDEX;
1364 }
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:1214
struct Email * email
Used by recvattach for updating.
Definition: attach.h:51
struct Body * content
List of MIME parts.
Definition: email.h:92
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:52
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
Definition: recvattach.c:1321
int max
the number of entries in the menu
Definition: mutt_menu.h:88
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition: recvattach.c:144
void * data
extra data for the current menu
Definition: mutt_menu.h:86
int current
current entry
Definition: mutt_menu.h:87
short vcount
The number of virtual attachments.
Definition: attach.h:59

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void mutt_update_v2r ( struct AttachCtx actx)
static

Update the virtual list of attachments.

Parameters
actxAttachment context

Update the record of the number of attachments and the status of the tree.

Definition at line 116 of file recvattach.c.

117 {
118  int vindex, rindex, curlevel;
119 
120  vindex = 0;
121  rindex = 0;
122 
123  while (rindex < actx->idxlen)
124  {
125  actx->v2r[vindex++] = rindex;
126  if (actx->idx[rindex]->content->collapsed)
127  {
128  curlevel = actx->idx[rindex]->level;
129  do
130  rindex++;
131  while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel));
132  }
133  else
134  rindex++;
135  }
136 
137  actx->vcount = vindex;
138 }
bool collapsed
Used by recvattach.
Definition: body.h:88
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:58
struct Body * content
Attachment.
Definition: attach.h:36
int level
Nesting depth of attachment.
Definition: attach.h:40
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54
short vcount
The number of virtual attachments.
Definition: attach.h:59

+ Here is the caller graph for this function:

void mutt_update_tree ( struct AttachCtx actx)

Refresh the list of attachments.

Parameters
actxAttachment context

Definition at line 144 of file recvattach.c.

145 {
146  char buf[256];
147  char *s = NULL;
148 
149  mutt_update_v2r(actx);
150 
151  for (int vindex = 0; vindex < actx->vcount; vindex++)
152  {
153  const int rindex = actx->v2r[vindex];
154  actx->idx[rindex]->num = vindex;
155  if ((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf))
156  {
157  if (actx->idx[rindex]->level)
158  {
159  s = buf + 2 * (actx->idx[rindex]->level - 1);
160  *s++ = (actx->idx[rindex]->content->next) ? MUTT_TREE_LTEE : MUTT_TREE_LLCORNER;
161  *s++ = MUTT_TREE_HLINE;
162  *s++ = MUTT_TREE_RARROW;
163  }
164  else
165  s = buf;
166  *s = '\0';
167  }
168 
169  if (actx->idx[rindex]->tree)
170  {
171  if (mutt_str_strcmp(actx->idx[rindex]->tree, buf) != 0)
172  mutt_str_replace(&actx->idx[rindex]->tree, buf);
173  }
174  else
175  actx->idx[rindex]->tree = mutt_str_strdup(buf);
176 
177  if (((2 * (actx->idx[rindex]->level + 2)) < sizeof(buf)) &&
178  actx->idx[rindex]->level)
179  {
180  s = buf + 2 * (actx->idx[rindex]->level - 1);
181  *s++ = (actx->idx[rindex]->content->next) ? '\005' : '\006';
182  *s++ = '\006';
183  }
184  }
185 }
Lower left corner.
Definition: mutt_menu.h:61
struct Body * next
next attachment in the list
Definition: body.h:53
Right arrow.
Definition: mutt_menu.h:67
char * tree
Tree characters to display.
Definition: attach.h:39
static void mutt_update_v2r(struct AttachCtx *actx)
Update the virtual list of attachments.
Definition: recvattach.c:116
int num
Attachment index number.
Definition: attach.h:41
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:58
struct Body * content
Attachment.
Definition: attach.h:36
int level
Nesting depth of attachment.
Definition: attach.h:40
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54
Left T-piece.
Definition: mutt_menu.h:63
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
short vcount
The number of virtual attachments.
Definition: attach.h:59
Horizontal line.
Definition: mutt_menu.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
unsigned long  data,
MuttFormatFlags  flags 
)

Format a string for the attachment menu - Implements format_t.

Expando Description
%C Character set
%c Character set: convert?
%D Deleted flag
%d Description
%e MIME content-transfer-encoding
%f Filename
%F Filename for content-disposition header
%I Content-disposition, either I (inline) or A (attachment)
%m Major MIME type
%M MIME subtype
%n Attachment number
%Q 'Q', if MIME part qualifies for attachment counting
%s Size
%t Tagged flag
%T Tree chars
%u Unlink
%X Number of qualifying MIME parts in this part and its children

Definition at line 210 of file recvattach.c.

214 {
215  char fmt[128];
216  char charset[128];
217  struct AttachPtr *aptr = (struct AttachPtr *) data;
218  int optional = (flags & MUTT_FORMAT_OPTIONAL);
219 
220  switch (op)
221  {
222  case 'C':
223  if (!optional)
224  {
225  if (mutt_is_text_part(aptr->content) &&
226  mutt_body_get_charset(aptr->content, charset, sizeof(charset)))
227  {
228  mutt_format_s(buf, buflen, prec, charset);
229  }
230  else
231  mutt_format_s(buf, buflen, prec, "");
232  }
233  else if (!mutt_is_text_part(aptr->content) ||
234  !mutt_body_get_charset(aptr->content, charset, sizeof(charset)))
235  {
236  optional = 0;
237  }
238  break;
239  case 'c':
240  /* XXX */
241  if (!optional)
242  {
243  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
244  snprintf(buf, buflen, fmt,
245  ((aptr->content->type != TYPE_TEXT) || aptr->content->noconv) ? 'n' : 'c');
246  }
247  else if ((aptr->content->type != TYPE_TEXT) || aptr->content->noconv)
248  optional = 0;
249  break;
250  case 'd':
251  if (!optional)
252  {
253  if (aptr->content->description)
254  {
255  mutt_format_s(buf, buflen, prec, aptr->content->description);
256  break;
257  }
258  if (mutt_is_message_type(aptr->content->type, aptr->content->subtype) &&
259  C_MessageFormat && aptr->content->email)
260  {
261  char s[128];
262  mutt_make_string_flags(s, sizeof(s), C_MessageFormat, NULL, NULL,
263  aptr->content->email,
265  if (*s)
266  {
267  mutt_format_s(buf, buflen, prec, s);
268  break;
269  }
270  }
271  if (!aptr->content->d_filename && !aptr->content->filename)
272  {
273  mutt_format_s(buf, buflen, prec, "<no description>");
274  break;
275  }
276  }
277  else if (aptr->content->description ||
278  (mutt_is_message_type(aptr->content->type, aptr->content->subtype) &&
279  C_MessageFormat && aptr->content->email))
280  {
281  break;
282  }
283  /* fallthrough */
284  case 'F':
285  if (!optional)
286  {
287  if (aptr->content->d_filename)
288  {
289  mutt_format_s(buf, buflen, prec, aptr->content->d_filename);
290  break;
291  }
292  }
293  else if (!aptr->content->d_filename && !aptr->content->filename)
294  {
295  optional = 0;
296  break;
297  }
298  /* fallthrough */
299  case 'f':
300  if (!optional)
301  {
302  if (aptr->content->filename && (*aptr->content->filename == '/'))
303  {
304  char path[PATH_MAX];
305 
306  mutt_str_strfcpy(path, aptr->content->filename, sizeof(path));
307  mutt_pretty_mailbox(path, sizeof(path));
308  mutt_format_s(buf, buflen, prec, path);
309  }
310  else
311  mutt_format_s(buf, buflen, prec, NONULL(aptr->content->filename));
312  }
313  else if (!aptr->content->filename)
314  optional = 0;
315  break;
316  case 'D':
317  if (!optional)
318  snprintf(buf, buflen, "%c", aptr->content->deleted ? 'D' : ' ');
319  else if (!aptr->content->deleted)
320  optional = 0;
321  break;
322  case 'e':
323  if (!optional)
324  mutt_format_s(buf, buflen, prec, ENCODING(aptr->content->encoding));
325  break;
326  case 'I':
327  if (!optional)
328  {
329  const char dispchar[] = { 'I', 'A', 'F', '-' };
330  char ch;
331 
332  if (aptr->content->disposition < sizeof(dispchar))
333  ch = dispchar[aptr->content->disposition];
334  else
335  {
336  mutt_debug(LL_DEBUG1, "ERROR: invalid content-disposition %d\n",
337  aptr->content->disposition);
338  ch = '!';
339  }
340  snprintf(buf, buflen, "%c", ch);
341  }
342  break;
343  case 'm':
344  if (!optional)
345  mutt_format_s(buf, buflen, prec, TYPE(aptr->content));
346  break;
347  case 'M':
348  if (!optional)
349  mutt_format_s(buf, buflen, prec, aptr->content->subtype);
350  else if (!aptr->content->subtype)
351  optional = 0;
352  break;
353  case 'n':
354  if (!optional)
355  {
356  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
357  snprintf(buf, buflen, fmt, aptr->num + 1);
358  }
359  break;
360  case 'Q':
361  if (optional)
362  optional = aptr->content->attach_qualifies;
363  else
364  {
365  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
366  mutt_format_s(buf, buflen, fmt, "Q");
367  }
368  break;
369  case 's':
370  {
371  size_t l;
372  if (flags & MUTT_FORMAT_STAT_FILE)
373  {
374  struct stat st;
375  stat(aptr->content->filename, &st);
376  l = st.st_size;
377  }
378  else
379  l = aptr->content->length;
380 
381  if (!optional)
382  {
383  char tmp[128];
384  mutt_str_pretty_size(tmp, sizeof(tmp), l);
385  mutt_format_s(buf, buflen, prec, tmp);
386  }
387  else if (l == 0)
388  optional = 0;
389 
390  break;
391  }
392  case 't':
393  if (!optional)
394  snprintf(buf, buflen, "%c", aptr->content->tagged ? '*' : ' ');
395  else if (!aptr->content->tagged)
396  optional = 0;
397  break;
398  case 'T':
399  if (!optional)
400  mutt_format_s_tree(buf, buflen, prec, NONULL(aptr->tree));
401  else if (!aptr->tree)
402  optional = 0;
403  break;
404  case 'u':
405  if (!optional)
406  snprintf(buf, buflen, "%c", aptr->content->unlink ? '-' : ' ');
407  else if (!aptr->content->unlink)
408  optional = 0;
409  break;
410  case 'X':
411  if (optional)
412  optional = (aptr->content->attach_count + aptr->content->attach_qualifies) != 0;
413  else
414  {
415  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
416  snprintf(buf, buflen, fmt, aptr->content->attach_count + aptr->content->attach_qualifies);
417  }
418  break;
419  default:
420  *buf = '\0';
421  }
422 
423  if (optional)
424  mutt_expando_format(buf, buflen, col, cols, if_str, attach_format_str, data,
426  else if (flags & MUTT_FORMAT_OPTIONAL)
427  mutt_expando_format(buf, buflen, col, cols, else_str, attach_format_str,
428  data, MUTT_FORMAT_NO_FLAGS);
429  return src;
430 }
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, MuttFormatFlags flags)
Expand expandos (x) in a string.
Definition: muttlib.c:838
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#define NONULL(x)
Definition: string2.h:37
An email to which things will be attached.
Definition: attach.h:34
char * C_MessageFormat
Config: printf-like format string for listing attached messages.
Definition: recvattach.c:78
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1385
#define MUTT_FORMAT_FORCESUBJ
Print the subject even if unchanged.
Definition: format_flags.h:31
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: format_flags.h:35
bool noconv
Don&#39;t do character set conversion.
Definition: body.h:73
#define MUTT_FORMAT_STAT_FILE
Used by attach_format_str.
Definition: format_flags.h:34
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
unsigned int disposition
content-disposition
Definition: body.h:67
char * tree
Tree characters to display.
Definition: attach.h:39
bool attach_qualifies
This attachment should be counted.
Definition: body.h:89
#define ENCODING(x)
Definition: mime.h:85
void mutt_make_string_flags(char *buf, size_t buflen, const char *s, struct Context *ctx, struct Mailbox *m, struct Email *e, MuttFormatFlags flags)
Create formatted strings using mailbox expandos.
Definition: hdrline.c:1500
signed short attach_count
Number of attachments.
Definition: body.h:59
bool tagged
This attachment is tagged.
Definition: body.h:70
unsigned int encoding
content-transfer-encoding
Definition: body.h:66
char * subtype
content-type subtype
Definition: body.h:37
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
#define PATH_MAX
Definition: mutt.h:51
int num
Attachment index number.
Definition: attach.h:41
Type: &#39;text/*&#39;.
Definition: mime.h:38
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Definition: muttlib.c:1720
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
char * mutt_body_get_charset(struct Body *b, char *buf, size_t buflen)
Get a body&#39;s character set.
Definition: sendlib.c:1431
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:612
char * description
content-description
Definition: body.h:40
bool mutt_is_text_part(struct Body *b)
Is this part of an email in plain text?
Definition: muttlib.c:433
unsigned int type
content-type primary type
Definition: body.h:65
bool deleted
Attachment marked for deletion.
Definition: body.h:71
#define TYPE(body)
Definition: mime.h:83
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
Definition: curs_lib.c:1147
Log at debug level 1.
Definition: logging.h:56
struct Body * content
Attachment.
Definition: attach.h:36
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, unsigned long data, MuttFormatFlags flags)
Format a string for the attachment menu - Implements format_t.
Definition: recvattach.c:210
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition: body.h:69
#define MUTT_FORMAT_OPTIONAL
Allow optional field processing.
Definition: format_flags.h:33
char * d_filename
filename to be used for the content-disposition header.
Definition: body.h:47
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
struct Email * email
header information for message/rfc822
Definition: body.h:55
void mutt_format_s_tree(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string with tree characters.
Definition: curs_lib.c:1159

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void attach_make_entry ( char *  buf,
size_t  buflen,
struct Menu menu,
int  line 
)
static

Format a menu item for the attachment list - Implements Menu::menu_make_entry()

Definition at line 435 of file recvattach.c.

436 {
437  struct AttachCtx *actx = menu->data;
438 
440  attach_format_str, (unsigned long) (actx->idx[actx->v2r[line]]),
442 }
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t *callback, unsigned long data, MuttFormatFlags flags)
Expand expandos (x) in a string.
Definition: muttlib.c:838
#define NONULL(x)
Definition: string2.h:37
WHERE char * C_AttachFormat
Config: printf-like format string for the attachment menu.
Definition: globals.h:103
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: format_flags.h:35
const char * line
Definition: common.c:36
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:40
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:58
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, unsigned long data, MuttFormatFlags flags)
Format a string for the attachment menu - Implements format_t.
Definition: recvattach.c:210
void * data
extra data for the current menu
Definition: mutt_menu.h:86
A set of attachments.
Definition: attach.h:49
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int attach_tag ( struct Menu menu,
int  sel,
int  act 
)

Tag an attachment - Implements Menu::menu_tag()

Definition at line 447 of file recvattach.c.

448 {
449  struct AttachCtx *actx = menu->data;
450  struct Body *cur = actx->idx[actx->v2r[sel]]->content;
451  bool ot = cur->tagged;
452 
453  cur->tagged = ((act >= 0) ? act : !cur->tagged);
454  return cur->tagged - ot;
455 }
The body of an email.
Definition: body.h:34
bool tagged
This attachment is tagged.
Definition: body.h:70
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:58
struct Body * content
Attachment.
Definition: attach.h:36
void * data
extra data for the current menu
Definition: mutt_menu.h:86
A set of attachments.
Definition: attach.h:49
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the caller graph for this function:

static void prepend_savedir ( char *  buf,
size_t  bufsize 
)
static

Add C_AttachSaveDir to the beginning of a path.

Parameters
bufBuffer for the result, must be valid
bufsizeSize of the buffer

Definition at line 462 of file recvattach.c.

463 {
464  const char *savedir = C_AttachSaveDir;
465 
466  if (buf[0] == '/')
467  return;
468 
469  if (!savedir || !*savedir)
470  savedir = "./";
471 
472  size_t savedirlen = strlen(savedir);
473  size_t buflen = strlen(buf);
474  bool addsep = (savedir[savedirlen - 1] != '/');
475  size_t newbuflen = savedirlen + buflen + addsep;
476 
477  if (bufsize < newbuflen)
478  {
479  return;
480  }
481 
482  memmove(buf + savedirlen + addsep, buf, buflen);
483  memcpy(buf, savedir, savedirlen);
484  if (addsep)
485  {
486  buf[savedirlen] = '/';
487  }
488  buf[newbuflen] = '\0';
489 }
char * C_AttachSaveDir
Config: Default directory where attachments are saved.
Definition: recvattach.c:73

+ Here is the caller graph for this function:

static bool has_a_message ( struct Body body)
static

Determine if the Body has a message (to save)

Parameters
[in]bodyBody of the message
Return values
trueif suitable for saving

Definition at line 496 of file recvattach.c.

497 {
498  return (body->email && (body->encoding != ENC_BASE64) &&
499  (body->encoding != ENC_QUOTED_PRINTABLE) &&
500  mutt_is_message_type(body->type, body->subtype));
501 }
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1385
unsigned int encoding
content-transfer-encoding
Definition: body.h:66
Base-64 encoded text.
Definition: mime.h:52
char * subtype
content-type subtype
Definition: body.h:37
unsigned int type
content-type primary type
Definition: body.h:65
Quoted-printable text.
Definition: mime.h:51
struct Email * email
header information for message/rfc822
Definition: body.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int query_save_attachment ( FILE *  fp,
struct Body body,
struct Email e,
char **  directory 
)
static

Ask the user if we should save the attachment.

Parameters
[in]fpFile handle to the attachment (OPTIONAL)
[in]bodyAttachment
[in]eEmail
[out]directoryWhere the attachment was saved
Return values
0Success
-1Failure

Definition at line 512 of file recvattach.c.

513 {
514  char *prompt = NULL;
515  char buf[PATH_MAX], tfile[PATH_MAX];
516  enum SaveAttach opt = MUTT_SAVE_NO_FLAGS;
517  int rc;
518 
519  if (body->filename)
520  {
521  if (directory && *directory)
522  {
523  mutt_path_concat(buf, *directory, mutt_path_basename(body->filename), sizeof(buf));
524  }
525  else
526  mutt_str_strfcpy(buf, body->filename, sizeof(buf));
527  }
528  else if (has_a_message(body))
529  {
530  mutt_default_save(buf, sizeof(buf), body->email);
531  }
532  else
533  buf[0] = '\0';
534 
535  prepend_savedir(buf, sizeof(buf));
536 
537  prompt = _("Save to file: ");
538  while (prompt)
539  {
540  if ((mutt_get_field(prompt, buf, sizeof(buf), MUTT_FILE) != 0) || (buf[0] == '\0'))
541  {
543  return -1;
544  }
545 
546  prompt = NULL;
547  mutt_expand_path(buf, sizeof(buf));
548 
549  bool is_message = (fp && has_a_message(body));
550 
551  if (is_message)
552  {
553  struct stat st;
554 
555  /* check to make sure that this file is really the one the user wants */
556  rc = mutt_save_confirm(buf, &st);
557  if (rc == 1)
558  {
559  prompt = _("Save to file: ");
560  continue;
561  }
562  else if (rc == -1)
563  return -1;
564  mutt_str_strfcpy(tfile, buf, sizeof(tfile));
565  }
566  else
567  {
568  rc = mutt_check_overwrite(body->filename, buf, tfile, sizeof(tfile), &opt, directory);
569  if (rc == -1)
570  return -1;
571  else if (rc == 1)
572  {
573  prompt = _("Save to file: ");
574  continue;
575  }
576  }
577 
578  mutt_message(_("Saving..."));
579  if (mutt_save_attachment(fp, body, tfile, opt, (e || !is_message) ? e : body->email) == 0)
580  {
581  mutt_message(_("Attachment saved"));
582  return 0;
583  }
584  else
585  {
586  prompt = _("Save to file: ");
587  continue;
588  }
589  }
590  return 0;
591 }
char * mutt_path_concat(char *d, const char *dir, const char *fname, size_t l)
Join a directory name and a filename.
Definition: path.c:330
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
static bool has_a_message(struct Body *body)
Determine if the Body has a message (to save)
Definition: recvattach.c:496
#define mutt_message(...)
Definition: logging.h:83
No flags set.
Definition: mutt_attach.h:54
#define _(a)
Definition: message.h:28
int mutt_save_attachment(FILE *fp, struct Body *m, const char *path, enum SaveAttach opt, struct Email *e)
Save an attachment.
Definition: mutt_attach.c:791
static void prepend_savedir(char *buf, size_t bufsize)
Add C_AttachSaveDir to the beginning of a path.
Definition: recvattach.c:462
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
Definition: hook.c:662
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
Definition: muttlib.c:1408
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
const char * mutt_path_basename(const char *f)
Find the last component for a pathname.
Definition: path.c:307
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:143
int mutt_check_overwrite(const char *attname, const char *path, char *fname, size_t flen, enum SaveAttach *opt, char **directory)
Ask the user if overwriting is necessary.
Definition: muttlib.c:711
#define PATH_MAX
Definition: mutt.h:51
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
#define MUTT_FILE
Do file completion.
Definition: mutt.h:65
struct Email * email
header information for message/rfc822
Definition: body.h:55
SaveAttach
Options for saving attachments.
Definition: mutt_attach.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int save_without_prompting ( FILE *  fp,
struct Body body,
struct Email e 
)
static

Save the attachment, without prompting each time.

Parameters
[in]fpFile handle to the attachment (OPTIONAL)
[in]bodyAttachment
[in]eEmail
Return values
0Success
-1Failure

Definition at line 601 of file recvattach.c.

602 {
603  char buf[PATH_MAX], tfile[PATH_MAX];
604  enum SaveAttach opt = MUTT_SAVE_NO_FLAGS;
605  int rc;
606 
607  if (body->filename)
608  {
609  mutt_str_strfcpy(buf, body->filename, sizeof(buf));
610  }
611  else if (has_a_message(body))
612  {
613  mutt_default_save(buf, sizeof(buf), body->email);
614  }
615  else
616  {
617  buf[0] = '\0';
618  }
619 
620  prepend_savedir(buf, sizeof(buf));
621  mutt_expand_path(buf, sizeof(buf));
622 
623  bool is_message = (fp && has_a_message(body));
624 
625  if (is_message)
626  {
627  mutt_str_strfcpy(tfile, buf, sizeof(tfile));
628  }
629  else
630  {
631  rc = mutt_check_overwrite(body->filename, buf, tfile, sizeof(tfile), &opt, NULL);
632  if (rc == -1) // abort or cancel
633  {
634  return -1;
635  }
636  }
637 
638  return mutt_save_attachment(fp, body, tfile, opt, (e || !is_message) ? e : body->email);
639 }
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
static bool has_a_message(struct Body *body)
Determine if the Body has a message (to save)
Definition: recvattach.c:496
No flags set.
Definition: mutt_attach.h:54
int mutt_save_attachment(FILE *fp, struct Body *m, const char *path, enum SaveAttach opt, struct Email *e)
Save an attachment.
Definition: mutt_attach.c:791
static void prepend_savedir(char *buf, size_t bufsize)
Add C_AttachSaveDir to the beginning of a path.
Definition: recvattach.c:462
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
Definition: hook.c:662
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
int mutt_check_overwrite(const char *attname, const char *path, char *fname, size_t flen, enum SaveAttach *opt, char **directory)
Ask the user if overwriting is necessary.
Definition: muttlib.c:711
#define PATH_MAX
Definition: mutt.h:51
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
struct Email * email
header information for message/rfc822
Definition: body.h:55
SaveAttach
Options for saving attachments.
Definition: mutt_attach.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_save_attachment_list ( struct AttachCtx actx,
FILE *  fp,
bool  tag,
struct Body top,
struct Email e,
struct Menu menu 
)

Save a list of attachments.

Parameters
actxAttachment context
fpFile handle for the attachment (OPTIONAL)
tagIf true, only save the tagged attachments
topFirst Attachment
eEmail
menuMenu listing attachments

Definition at line 649 of file recvattach.c.

651 {
652  char buf[PATH_MAX], tfile[PATH_MAX];
653  char *directory = NULL;
654  int rc = 1;
655  int last = menu ? menu->current : -1;
656  FILE *fp_out = NULL;
657  int saved_attachments = 0;
658 
659  buf[0] = '\0';
660 
661  for (int i = 0; !tag || (i < actx->idxlen); i++)
662  {
663  if (tag)
664  {
665  fp = actx->idx[i]->fp;
666  top = actx->idx[i]->content;
667  }
668  if (!tag || top->tagged)
669  {
670  if (!C_AttachSplit)
671  {
672  if (buf[0] == '\0')
673  {
674  enum SaveAttach opt = MUTT_SAVE_NO_FLAGS;
675 
676  mutt_str_strfcpy(buf, mutt_path_basename(NONULL(top->filename)), sizeof(buf));
677  prepend_savedir(buf, sizeof(buf));
678 
679  if ((mutt_get_field(_("Save to file: "), buf, sizeof(buf), MUTT_FILE) != 0) ||
680  !buf[0])
681  {
682  return;
683  }
684  mutt_expand_path(buf, sizeof(buf));
685  if (mutt_check_overwrite(top->filename, buf, tfile, sizeof(tfile), &opt, NULL))
686  return;
687  rc = mutt_save_attachment(fp, top, tfile, opt, e);
688  if ((rc == 0) && C_AttachSep && (fp_out = fopen(tfile, "a")))
689  {
690  fprintf(fp_out, "%s", C_AttachSep);
691  mutt_file_fclose(&fp_out);
692  }
693  }
694  else
695  {
696  rc = mutt_save_attachment(fp, top, tfile, MUTT_SAVE_APPEND, e);
697  if ((rc == 0) && C_AttachSep && (fp_out = fopen(tfile, "a")))
698  {
699  fprintf(fp_out, "%s", C_AttachSep);
700  mutt_file_fclose(&fp_out);
701  }
702  }
703  }
704  else
705  {
706  if (tag && menu && top->aptr)
707  {
708  menu->oldcurrent = menu->current;
709  menu->current = top->aptr->num;
710  menu_check_recenter(menu);
711  menu->redraw |= REDRAW_MOTION;
712 
713  menu_redraw(menu);
714  }
716  {
717  // Save each file, with no prompting, using the configured 'AttachSaveDir'
718  rc = save_without_prompting(fp, top, e);
719  if (rc == 0)
720  saved_attachments++;
721  }
722  else
723  {
724  // Save each file, prompting the user for the location each time.
725  if (query_save_attachment(fp, top, e, &directory) == -1)
726  break;
727  }
728  }
729  }
730  if (!tag)
731  break;
732  }
733 
734  FREE(&directory);
735 
736  if (tag && menu)
737  {
738  menu->oldcurrent = menu->current;
739  menu->current = last;
740  menu_check_recenter(menu);
741  menu->redraw |= REDRAW_MOTION;
742  }
743 
744  if (!C_AttachSplit && (rc == 0))
745  mutt_message(_("Attachment saved"));
746 
747  if (C_AttachSaveWithoutPrompting && (rc == 0))
748  {
749  mutt_message(ngettext("Attachment saved", "%d attachments saved", saved_attachments),
750  saved_attachments);
751  }
752 }
bool C_AttachSplit
Config: Save/print/pipe tagged messages individually.
Definition: recvattach.c:76
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#define NONULL(x)
Definition: string2.h:37
#define mutt_message(...)
Definition: logging.h:83
int oldcurrent
for driver use only
Definition: mutt_menu.h:111
char * C_AttachSaveWithoutPrompting
Config: If true, then don&#39;t prompt to save.
Definition: recvattach.c:74
No flags set.
Definition: mutt_attach.h:54
char * C_AttachSep
Config: Separator to add between saved/printed/piped attachments.
Definition: recvattach.c:75
#define _(a)
Definition: message.h:28
short idxlen
Number of attachmentes.
Definition: attach.h:55
static int query_save_attachment(FILE *fp, struct Body *body, struct Email *e, char **directory)
Ask the user if we should save the attachment.
Definition: recvattach.c:512
int mutt_save_attachment(FILE *fp, struct Body *m, const char *path, enum SaveAttach opt, struct Email *e)
Save an attachment.
Definition: mutt_attach.c:791
static void prepend_savedir(char *buf, size_t bufsize)
Add C_AttachSaveDir to the beginning of a path.
Definition: recvattach.c:462
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
const char * mutt_path_basename(const char *f)
Find the last component for a pathname.
Definition: path.c:307
bool tagged
This attachment is tagged.
Definition: body.h:70
#define REDRAW_MOTION
Redraw after moving the menu list.
Definition: mutt_menu.h:43
int mutt_check_overwrite(const char *attname, const char *path, char *fname, size_t flen, enum SaveAttach *opt, char **directory)
Ask the user if overwriting is necessary.
Definition: muttlib.c:711
static int save_without_prompting(FILE *fp, struct Body *body, struct Email *e)
Save the attachment, without prompting each time.
Definition: recvattach.c:601
#define PATH_MAX
Definition: mutt.h:51
int num
Attachment index number.
Definition: attach.h:41
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:57
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:750
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
#define MUTT_FILE
Do file completion.
Definition: mutt.h:65
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
struct Body * content
Attachment.
Definition: attach.h:36
Append to existing file.
Definition: mutt_attach.h:55
#define FREE(x)
Definition: memory.h:40
int current
current entry
Definition: mutt_menu.h:87
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54
SaveAttach
Options for saving attachments.
Definition: mutt_attach.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void query_pipe_attachment ( char *  command,
FILE *  fp,
struct Body body,
bool  filter 
)
static

Ask the user if we should pipe the attachment.

Parameters
commandCommand to pipe the attachment to
fpFile handle to the attachment (OPTIONAL)
bodyAttachment
filterIs this command a filter?

Definition at line 761 of file recvattach.c.

762 {
763  char tfile[PATH_MAX];
764 
765  if (filter)
766  {
767  char warning[PATH_MAX + 256];
768  snprintf(warning, sizeof(warning),
769  _("WARNING! You are about to overwrite %s, continue?"), body->filename);
770  if (mutt_yesorno(warning, MUTT_NO) != MUTT_YES)
771  {
773  return;
774  }
775  mutt_mktemp(tfile, sizeof(tfile));
776  }
777  else
778  tfile[0] = '\0';
779 
780  if (mutt_pipe_attachment(fp, body, command, tfile))
781  {
782  if (filter)
783  {
784  mutt_file_unlink(body->filename);
785  mutt_file_rename(tfile, body->filename);
786  mutt_update_encoding(body);
787  mutt_message(_("Attachment filtered"));
788  }
789  }
790  else
791  {
792  if (filter && tfile[0])
793  mutt_file_unlink(tfile);
794  }
795 }
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#define mutt_message(...)
Definition: logging.h:83
int mutt_file_rename(const char *oldfile, const char *newfile)
Rename a file.
Definition: file.c:1333
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:191
#define _(a)
Definition: message.h:28
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:332
void mutt_update_encoding(struct Body *a)
Update the encoding type.
Definition: sendlib.c:1455
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:95
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
#define PATH_MAX
Definition: mutt.h:51
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:42
int mutt_pipe_attachment(FILE *fp, struct Body *b, const char *path, char *outfile)
Pipe an attachment to a command.
Definition: mutt_attach.c:674

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pipe_attachment ( FILE *  fp,
struct Body b,
struct State state 
)
static

Pipe the attachment to a command.

Parameters
fpFile handle to the attachment (OPTIONAL)
bAttachment
stateFile state for decoding the attachment

Definition at line 803 of file recvattach.c.

804 {
805  if (!state || !state->fp_out)
806  return;
807 
808  if (fp)
809  {
810  state->fp_in = fp;
811  mutt_decode_attachment(b, state);
812  if (C_AttachSep)
813  state_puts(C_AttachSep, state);
814  }
815  else
816  {
817  FILE *fp_in = fopen(b->filename, "r");
818  if (!fp_in)
819  {
820  mutt_perror("fopen");
821  return;
822  }
823  mutt_file_copy_stream(fp_in, state->fp_out);
824  mutt_file_fclose(&fp_in);
825  if (C_AttachSep)
826  state_puts(C_AttachSep, state);
827  }
828 }
void mutt_decode_attachment(struct Body *b, struct State *s)
Decode an email&#39;s attachment.
Definition: handler.c:1790
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#define mutt_perror(...)
Definition: logging.h:85
char * C_AttachSep
Config: Separator to add between saved/printed/piped attachments.
Definition: recvattach.c:75
FILE * fp_out
File to write to.
Definition: state.h:47
FILE * fp_in
File to read from.
Definition: state.h:46
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
#define state_puts(str, state)
Definition: state.h:54
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition: file.c:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pipe_attachment_list ( char *  command,
struct AttachCtx actx,
FILE *  fp,
bool  tag,
struct Body top,
bool  filter,
struct State state 
)
static

Pipe a list of attachments to a command.

Parameters
commandCommand to pipe the attachment to
actxAttachment context
fpFile handle to the attachment (OPTIONAL)
tagIf true, only save the tagged attachments
topFirst Attachment
filterIs this command a filter?
stateFile state for decoding the attachments

Definition at line 840 of file recvattach.c.

842 {
843  for (int i = 0; !tag || (i < actx->idxlen); i++)
844  {
845  if (tag)
846  {
847  fp = actx->idx[i]->fp;
848  top = actx->idx[i]->content;
849  }
850  if (!tag || top->tagged)
851  {
852  if (!filter && !C_AttachSplit)
853  pipe_attachment(fp, top, state);
854  else
855  query_pipe_attachment(command, fp, top, filter);
856  }
857  if (!tag)
858  break;
859  }
860 }
bool C_AttachSplit
Config: Save/print/pipe tagged messages individually.
Definition: recvattach.c:76
short idxlen
Number of attachmentes.
Definition: attach.h:55
bool tagged
This attachment is tagged.
Definition: body.h:70
static void query_pipe_attachment(char *command, FILE *fp, struct Body *body, bool filter)
Ask the user if we should pipe the attachment.
Definition: recvattach.c:761
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
static void pipe_attachment(FILE *fp, struct Body *b, struct State *state)
Pipe the attachment to a command.
Definition: recvattach.c:803
struct Body * content
Attachment.
Definition: attach.h:36
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_pipe_attachment_list ( struct AttachCtx actx,
FILE *  fp,
bool  tag,
struct Body top,
bool  filter 
)

Pipe a list of attachments to a command.

Parameters
actxAttachment context
fpFile handle to the attachment (OPTIONAL)
tagIf true, only save the tagged attachments
topFirst Attachment
filterIs this command a filter?

Definition at line 870 of file recvattach.c.

872 {
873  struct State state = { 0 };
874  char buf[PATH_MAX];
875 
876  if (fp)
877  filter = false; /* sanity check: we can't filter in the recv case yet */
878 
879  buf[0] = '\0';
880  /* perform charset conversion on text attachments when piping */
881  state.flags = MUTT_CHARCONV;
882 
883  if ((mutt_get_field((filter ? _("Filter through: ") : _("Pipe to: ")), buf,
884  sizeof(buf), MUTT_CMD) != 0) ||
885  (buf[0] == '\0'))
886  {
887  return;
888  }
889 
890  mutt_expand_path(buf, sizeof(buf));
891 
892  if (!filter && !C_AttachSplit)
893  {
894  mutt_endwin();
895  pid_t pid = mutt_create_filter(buf, &state.fp_out, NULL, NULL);
896  pipe_attachment_list(buf, actx, fp, tag, top, filter, &state);
897  mutt_file_fclose(&state.fp_out);
898  if ((mutt_wait_filter(pid) != 0) || C_WaitKey)
900  }
901  else
902  pipe_attachment_list(buf, actx, fp, tag, top, filter, &state);
903 }
pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:217
bool C_AttachSplit
Config: Save/print/pipe tagged messages individually.
Definition: recvattach.c:76
static void pipe_attachment_list(char *command, struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, bool filter, struct State *state)
Pipe a list of attachments to a command.
Definition: recvattach.c:840
#define MUTT_CHARCONV
Do character set conversions.
Definition: state.h:36
#define _(a)
Definition: message.h:28
FILE * fp_out
File to write to.
Definition: state.h:47
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:67
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:275
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
#define PATH_MAX
Definition: mutt.h:51
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:544
Keep track when processing files.
Definition: state.h:44
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:228

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool can_print ( struct AttachCtx actx,
struct Body top,
bool  tag 
)
static

Do we know how to print this attachment type?

Parameters
actxAttachment
topBody of email
tagApply to all tagged Attachments
Return values
trueIf (all) the Attachment(s) are printable

Definition at line 912 of file recvattach.c.

913 {
914  char type[256];
915 
916  for (int i = 0; !tag || (i < actx->idxlen); i++)
917  {
918  if (tag)
919  top = actx->idx[i]->content;
920  snprintf(type, sizeof(type), "%s/%s", TYPE(top), top->subtype);
921  if (!tag || top->tagged)
922  {
923  if (!rfc1524_mailcap_lookup(top, type, NULL, MUTT_MC_PRINT))
924  {
925  if ((mutt_str_strcasecmp("text/plain", top->subtype) != 0) &&
926  (mutt_str_strcasecmp("application/postscript", top->subtype) != 0))
927  {
928  if (!mutt_can_decode(top))
929  {
930  /* L10N: s gets replaced by a MIME type, e.g. "text/plain" or
931  application/octet-stream. */
932  mutt_error(_("I don't know how to print %s attachments"), type);
933  return false;
934  }
935  }
936  }
937  }
938  if (!tag)
939  break;
940  }
941  return true;
942 }
bool rfc1524_mailcap_lookup(struct Body *a, char *type, struct Rfc1524MailcapEntry *entry, enum MailcapLookup opt)
Find given type in the list of mailcap files.
Definition: rfc1524.c:465
#define _(a)
Definition: message.h:28
short idxlen
Number of attachmentes.
Definition: attach.h:55
Mailcap print field.
Definition: rfc1524.h:60
bool tagged
This attachment is tagged.
Definition: body.h:70
char * subtype
content-type subtype
Definition: body.h:37
bool mutt_can_decode(struct Body *a)
Will decoding the attachment produce any output.
Definition: handler.c:1749
#define TYPE(body)
Definition: mime.h:83
struct Body * content
Attachment.
Definition: attach.h:36
#define mutt_error(...)
Definition: logging.h:84
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void print_attachment_list ( struct AttachCtx actx,
FILE *  fp,
bool  tag,
struct Body top,
struct State state 
)
static

Print a list of Attachments.

Parameters
actxAttachment context
fpFile handle to the attachment (OPTIONAL)
tagApply to all tagged Attachments
topFirst Attachment
stateFile state for decoding the attachments

Definition at line 952 of file recvattach.c.

954 {
955  char type[256];
956 
957  for (int i = 0; !tag || (i < actx->idxlen); i++)
958  {
959  if (tag)
960  {
961  fp = actx->idx[i]->fp;
962  top = actx->idx[i]->content;
963  }
964  if (!tag || top->tagged)
965  {
966  snprintf(type, sizeof(type), "%s/%s", TYPE(top), top->subtype);
967  if (!C_AttachSplit && !rfc1524_mailcap_lookup(top, type, NULL, MUTT_MC_PRINT))
968  {
969  if ((mutt_str_strcasecmp("text/plain", top->subtype) == 0) ||
970  (mutt_str_strcasecmp("application/postscript", top->subtype) == 0))
971  {
972  pipe_attachment(fp, top, state);
973  }
974  else if (mutt_can_decode(top))
975  {
976  /* decode and print */
977 
978  char newfile[PATH_MAX] = { 0 };
979  FILE *fp_in = NULL;
980 
981  mutt_mktemp(newfile, sizeof(newfile));
982  if (mutt_decode_save_attachment(fp, top, newfile, MUTT_PRINTING,
983  MUTT_SAVE_NO_FLAGS) == 0)
984  {
985  if (!state->fp_out)
986  {
987  mutt_error(
988  "BUG in print_attachment_list(). Please report this. ");
989  return;
990  }
991 
992  fp_in = fopen(newfile, "r");
993  if (fp_in)
994  {
995  mutt_file_copy_stream(fp_in, state->fp_out);
996  mutt_file_fclose(&fp_in);
997  if (C_AttachSep)
998  state_puts(C_AttachSep, state);
999  }
1000  }
1001  mutt_file_unlink(newfile);
1002  }
1003  }
1004  else
1005  mutt_print_attachment(fp, top);
1006  }
1007  if (!tag)
1008  break;
1009  }
1010 }
bool C_AttachSplit
Config: Save/print/pipe tagged messages individually.
Definition: recvattach.c:76
bool rfc1524_mailcap_lookup(struct Body *a, char *type, struct Rfc1524MailcapEntry *entry, enum MailcapLookup opt)
Find given type in the list of mailcap files.
Definition: rfc1524.c:465
No flags set.
Definition: mutt_attach.h:54
char * C_AttachSep
Config: Separator to add between saved/printed/piped attachments.
Definition: recvattach.c:75
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:191
short idxlen
Number of attachmentes.
Definition: attach.h:55
FILE * fp_out
File to write to.
Definition: state.h:47
#define MUTT_PRINTING
Are we printing? - MUTT_DISPLAY "light".
Definition: state.h:37
FILE * fp_in
File to read from.
Definition: state.h:46
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
Mailcap print field.
Definition: rfc1524.h:60
bool tagged
This attachment is tagged.
Definition: body.h:70
char * subtype
content-type subtype
Definition: body.h:37
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
#define PATH_MAX
Definition: mutt.h:51
int mutt_decode_save_attachment(FILE *fp, struct Body *m, const char *path, int displaying, enum SaveAttach opt)
Decode, then save an attachment.
Definition: mutt_attach.c:922
bool mutt_can_decode(struct Body *a)
Will decoding the attachment produce any output.
Definition: handler.c:1749
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
static void pipe_attachment(FILE *fp, struct Body *b, struct State *state)
Pipe the attachment to a command.
Definition: recvattach.c:803
#define TYPE(body)
Definition: mime.h:83
#define state_puts(str, state)
Definition: state.h:54
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition: file.c:267
struct Body * content
Attachment.
Definition: attach.h:36
#define mutt_error(...)
Definition: logging.h:84
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54
int mutt_print_attachment(FILE *fp, struct Body *a)
Print out an attachment.
Definition: mutt_attach.c:1021

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_print_attachment_list ( struct AttachCtx actx,
FILE *  fp,
bool  tag,
struct Body top 
)

Print a list of Attachments.

Parameters
actxAttachment context
fpFile handle to the attachment (OPTIONAL)
tagApply to all tagged Attachments
topFirst Attachment

Definition at line 1019 of file recvattach.c.

1020 {
1021  char prompt[128];
1022  struct State state = { 0 };
1023  int tagmsgcount = 0;
1024 
1025  if (tag)
1026  for (int i = 0; i < actx->idxlen; i++)
1027  if (actx->idx[i]->content->tagged)
1028  tagmsgcount++;
1029 
1030  snprintf(prompt, sizeof(prompt),
1031  /* L10N: Although we now the precise number of tagged messages, we
1032  do not show it to the user. So feel free to use a "generic
1033  plural" as plural translation if your language has one. */
1034  tag ? ngettext("Print tagged attachment?", "Print %d tagged attachments?", tagmsgcount) :
1035  _("Print attachment?"),
1036  tagmsgcount);
1037  if (query_quadoption(C_Print, prompt) != MUTT_YES)
1038  return;
1039 
1040  if (!C_AttachSplit)
1041  {
1042  if (!can_print(actx, top, tag))
1043  return;
1044  mutt_endwin();
1045  pid_t pid = mutt_create_filter(NONULL(C_PrintCommand), &state.fp_out, NULL, NULL);
1046  print_attachment_list(actx, fp, tag, top, &state);
1047  mutt_file_fclose(&state.fp_out);
1048  if ((mutt_wait_filter(pid) != 0) || C_WaitKey)
1050  }
1051  else
1052  print_attachment_list(actx, fp, tag, top, &state);
1053 }
pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:217
bool C_AttachSplit
Config: Save/print/pipe tagged messages individually.
Definition: recvattach.c:76
#define NONULL(x)
Definition: string2.h:37
WHERE unsigned char C_Print
Config: Confirm before printing a message.
Definition: globals.h:194
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3322
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
static void print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, struct State *state)
Print a list of Attachments.
Definition: recvattach.c:952
#define _(a)
Definition: message.h:28
short idxlen
Number of attachmentes.
Definition: attach.h:55
FILE * fp_out
File to write to.
Definition: state.h:47
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
bool tagged
This attachment is tagged.
Definition: body.h:70
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:275
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
static bool can_print(struct AttachCtx *actx, struct Body *top, bool tag)
Do we know how to print this attachment type?
Definition: recvattach.c:912
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:544
struct Body * content
Attachment.
Definition: attach.h:36
WHERE char * C_PrintCommand
Config: External command to print a message.
Definition: globals.h:143
Keep track when processing files.
Definition: state.h:44
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:228
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void recvattach_extract_pgp_keys ( struct AttachCtx actx,
struct Menu menu 
)
static

Extract PGP keys from attachments.

Parameters
actxAttachment context
menuMenu listing attachments

Definition at line 1060 of file recvattach.c.

1061 {
1062  if (!menu->tagprefix)
1064  else
1065  {
1066  for (int i = 0; i < actx->idxlen; i++)
1067  {
1068  if (actx->idx[i]->content->tagged)
1069  {
1070  crypt_pgp_extract_key_from_attachment(actx->idx[i]->fp, actx->idx[i]->content);
1071  }
1072  }
1073  }
1074 }
short idxlen
Number of attachmentes.
Definition: attach.h:55
#define CUR_ATTACH
Definition: recvattach.c:92
bool tagged
This attachment is tagged.
Definition: body.h:70
void crypt_pgp_extract_key_from_attachment(FILE *fp, struct Body *top)
Wrapper for CryptModuleSpecs::pgp_extract_key_from_attachment()
Definition: cryptglue.c:384
bool tagprefix
Definition: mutt_menu.h:93
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
struct Body * content
Attachment.
Definition: attach.h:36
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int recvattach_pgp_check_traditional ( struct AttachCtx actx,
struct Menu menu 
)
static

Is the Attachment inline PGP?

Parameters
actxAttachment to check
menuMenu listing Attachments
Return values
1If the (tagged) Attachment(s) are inline PGP
Note
If the menu->tagprefix is set, all the tagged attachments will be checked.

Definition at line 1084 of file recvattach.c.

1085 {
1086  int rc = 0;
1087 
1088  if (!menu->tagprefix)
1089  rc = crypt_pgp_check_traditional(CUR_ATTACH->fp, CUR_ATTACH->content, true);
1090  else
1091  {
1092  for (int i = 0; i < actx->idxlen; i++)
1093  if (actx->idx[i]->content->tagged)
1094  rc = rc || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->content, true);
1095  }
1096 
1097  return rc;
1098 }
short idxlen
Number of attachmentes.
Definition: attach.h:55
#define CUR_ATTACH
Definition: recvattach.c:92
bool tagged
This attachment is tagged.
Definition: body.h:70
bool tagprefix
Definition: mutt_menu.h:93
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
int crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one)
Wrapper for CryptModuleSpecs::pgp_check_traditional()
Definition: cryptglue.c:273
struct Body * content
Attachment.
Definition: attach.h:36
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Edit the content type of an attachment.

Parameters
actxAttachment context
menuMenu listing Attachments
eEmail

Definition at line 1106 of file recvattach.c.

1108 {
1109  if (!mutt_edit_content_type(e, CUR_ATTACH->content, CUR_ATTACH->fp))
1110  return;
1111 
1112  /* The mutt_update_recvattach_menu() will overwrite any changes
1113  * made to a decrypted CUR_ATTACH->content, so warn the user. */
1114  if (CUR_ATTACH->decrypted)
1115  {
1116  mutt_message(
1117  _("Structural changes to decrypted attachments are not supported"));
1118  mutt_sleep(1);
1119  }
1120  /* Editing the content type can rewrite the body structure. */
1121  for (int i = 0; i < actx->idxlen; i++)
1122  actx->idx[i]->content = NULL;
1123  mutt_actx_free_entries(actx);
1124  mutt_update_recvattach_menu(actx, menu, true);
1125 }
#define mutt_message(...)
Definition: logging.h:83
#define _(a)
Definition: message.h:28
short idxlen
Number of attachmentes.
Definition: attach.h:55
#define CUR_ATTACH
Definition: recvattach.c:92
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1502
void mutt_actx_free_entries(struct AttachCtx *actx)
Free entries in an Attachment Context.
Definition: attach.c:103
static void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1346
struct Body * content
Attachment.
Definition: attach.h:36
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Definition: commands.c:1203
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_attach_display_loop ( struct Menu menu,
int  op,
struct Email e,
struct AttachCtx actx,
bool  recv 
)

Event loop for the Attachment menu.

Parameters
menuMenu listing Attachments
opOperation, e.g. OP_VIEW_ATTACH
eEmail
actxAttachment context
recvtrue if these are received attachments (rather than in compose)
Return values
numOperation performed

Definition at line 1136 of file recvattach.c.

1138 {
1139  do
1140  {
1141  switch (op)
1142  {
1143  case OP_DISPLAY_HEADERS:
1144  bool_str_toggle(Config, "weed", NULL);
1145  /* fallthrough */
1146 
1147  case OP_VIEW_ATTACH:
1148  op = mutt_view_attachment(CUR_ATTACH->fp, CUR_ATTACH->content,
1149  MUTT_VA_REGULAR, e, actx);
1150  break;
1151 
1152  case OP_NEXT_ENTRY:
1153  case OP_MAIN_NEXT_UNDELETED: /* hack */
1154  if (menu->current < menu->max - 1)
1155  {
1156  menu->current++;
1157  op = OP_VIEW_ATTACH;
1158  }
1159  else
1160  op = OP_NULL;
1161  break;
1162  case OP_PREV_ENTRY:
1163  case OP_MAIN_PREV_UNDELETED: /* hack */
1164  if (menu->current > 0)
1165  {
1166  menu->current--;
1167  op = OP_VIEW_ATTACH;
1168  }
1169  else
1170  op = OP_NULL;
1171  break;
1172  case OP_EDIT_TYPE:
1173  /* when we edit the content-type, we should redisplay the attachment
1174  * immediately */
1175  mutt_edit_content_type(e, CUR_ATTACH->content, CUR_ATTACH->fp);
1176  if (recv)
1177  recvattach_edit_content_type(actx, menu, e);
1178  else
1179  mutt_edit_content_type(e, CUR_ATTACH->content, CUR_ATTACH->fp);
1180 
1181  menu->redraw |= REDRAW_INDEX;
1182  op = OP_VIEW_ATTACH;
1183  break;
1184  /* functions which are passed through from the pager */
1185  case OP_CHECK_TRADITIONAL:
1187  {
1188  op = OP_NULL;
1189  break;
1190  }
1191  /* fallthrough */
1192  case OP_ATTACH_COLLAPSE:
1193  if (recv)
1194  return op;
1195  /* fallthrough */
1196  default:
1197  op = OP_NULL;
1198  }
1199  } while (op != OP_NULL);
1200 
1201  return op;
1202 }
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: ncrypt.h:136
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
View using default method.
Definition: mutt_attach.h:41
#define CUR_ATTACH
Definition: recvattach.c:92
static void recvattach_edit_content_type(struct AttachCtx *actx, struct Menu *menu, struct Email *e)
Edit the content type of an attachment.
Definition: recvattach.c:1106
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
int max
the number of entries in the menu
Definition: mutt_menu.h:88
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
int bool_str_toggle(struct ConfigSet *cs, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:240
int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx)
View an attachment.
Definition: mutt_attach.c:386
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Definition: commands.c:1203
int current
current entry
Definition: mutt_menu.h:87
#define WithCrypto
Definition: ncrypt.h:160

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1214 of file recvattach.c.

1217 {
1218  struct Body *m = NULL;
1219  struct Body *new_body = NULL;
1220  FILE *fp_new = NULL;
1222  int need_secured, secured;
1223 
1224  for (m = parts; m; m = m->next)
1225  {
1226  need_secured = 0;
1227  secured = 0;
1228 
1229  if (((WithCrypto & APPLICATION_SMIME) != 0) && (type = mutt_is_application_smime(m)))
1230  {
1231  need_secured = 1;
1232 
1233  if (type & SEC_ENCRYPT)
1234  {
1235  if (!crypt_valid_passphrase(APPLICATION_SMIME))
1236  goto decrypt_failed;
1237 
1238  if (e->env)
1240  }
1241 
1242  secured = !crypt_smime_decrypt_mime(fp, &fp_new, m, &new_body);
1243  /* If the decrypt/verify-opaque doesn't generate mime output, an empty
1244  * text/plain type will still be returned by mutt_read_mime_header().
1245  * We can't distinguish an actual part from a failure, so only use a
1246  * text/plain that results from a single top-level part. */
1247  if (secured && (new_body->type == TYPE_TEXT) &&
1248  (mutt_str_strcasecmp("plain", new_body->subtype) == 0) &&
1249  ((parts != m) || m->next))
1250  {
1251  mutt_body_free(&new_body);
1252  mutt_file_fclose(&fp_new);
1253  goto decrypt_failed;
1254  }
1255 
1256  if (secured && (type & SEC_ENCRYPT))
1257  e->security |= SMIME_ENCRYPT;
1258  }
1259 
1260  if (((WithCrypto & APPLICATION_PGP) != 0) &&
1262  {
1263  need_secured = 1;
1264 
1265  if (!crypt_valid_passphrase(APPLICATION_PGP))
1266  goto decrypt_failed;
1267 
1268  secured = !crypt_pgp_decrypt_mime(fp, &fp_new, m, &new_body);
1269 
1270  if (secured)
1271  e->security |= PGP_ENCRYPT;
1272  }
1273 
1274  if (need_secured && secured)
1275  {
1276  mutt_actx_add_fp(actx, fp_new);
1277  mutt_actx_add_body(actx, new_body);
1278  mutt_generate_recvattach_list(actx, e, new_body, fp_new, parent_type, level, 1);
1279  continue;
1280  }
1281 
1282  decrypt_failed:
1283  /* Fall through and show the original parts if decryption fails */
1284  if (need_secured && !secured)
1285  mutt_error(_("Can't decrypt encrypted message"));
1286 
1287  /* Strip out the top level multipart */
1288  if ((m->type == TYPE_MULTIPART) && m->parts && !need_secured &&
1289  ((parent_type == -1) && mutt_str_strcasecmp("alternative", m->subtype)))
1290  {
1291  mutt_generate_recvattach_list(actx, e, m->parts, fp, m->type, level, decrypted);
1292  }
1293  else
1294  {
1295  struct AttachPtr *ap = mutt_mem_calloc(1, sizeof(struct AttachPtr));
1296  mutt_actx_add_attach(actx, ap);
1297 
1298  ap->content = m;
1299  ap->fp = fp;
1300  m->aptr = ap;
1301  ap->parent_type = parent_type;
1302  ap->level = level;
1303  ap->decrypted = decrypted;
1304 
1305  if (m->type == TYPE_MULTIPART)
1306  mutt_generate_recvattach_list(actx, e, m->parts, fp, m->type, level + 1, decrypted);
1307  else if (mutt_is_message_type(m->type, m->subtype))
1308  {
1309  mutt_generate_recvattach_list(actx, m->email, m->parts, fp, m->type,
1310  level + 1, decrypted);
1311  e->security |= m->email->security;
1312  }
1313  }
1314  }
1315 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
An email to which things will be attached.
Definition: attach.h:34
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1385
void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new)
Save a File handle to the Attachment Context.
Definition: attach.c:62
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:1214
#define _(a)
Definition: message.h:28
struct Body * next
next attachment in the list
Definition: body.h:53
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
Definition: attach.c:40
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
The body of an email.
Definition: body.h:34
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:453
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:38
struct Envelope * env
Envelope information.
Definition: email.h:91
char * subtype
content-type subtype
Definition: body.h:37
bool decrypted
Not part of message as stored in the email->content.
Definition: attach.h:43
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:57
Type: &#39;text/*&#39;.
Definition: mime.h:38
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:455
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:515
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:422
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:619
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
unsigned int type
content-type primary type
Definition: body.h:65
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
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:199
void mutt_body_free(struct Body **p)
Free a Body.
Definition: body.c:57
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
struct Body * content
Attachment.
Definition: attach.h:36
#define SMIME_ENCRYPT
Definition: ncrypt.h:146
#define mutt_error(...)
Definition: logging.h:84
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: ncrypt.h:120
struct Email * email
header information for message/rfc822
Definition: body.h:55
#define WithCrypto
Definition: ncrypt.h:160
int level
Nesting depth of attachment.
Definition: attach.h:40
#define PGP_ENCRYPT
Definition: ncrypt.h:140
void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body)
Add an email box to an Attachment Context.
Definition: attach.c:83
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_attach_init ( struct AttachCtx actx)

Create a new Attachment context.

Parameters
actxAttachment context

Definition at line 1321 of file recvattach.c.

1322 {
1323  /* Collapse the attachments if '$digest_collapse' is set AND if...
1324  * the outer container is of type 'multipart/digest' */
1325  bool digest = (mutt_str_strcasecmp(actx->email->content->subtype, "digest") == 0);
1326 
1327  for (int i = 0; i < actx->idxlen; i++)
1328  {
1329  actx->idx[i]->content->tagged = false;
1330 
1331  /* OR an inner container is of type 'multipart/digest' */
1332  actx->idx[i]->content->collapsed =
1333  (C_DigestCollapse &&
1334  (digest ||
1335  ((actx->idx[i]->content->type == TYPE_MULTIPART) &&
1336  (mutt_str_strcasecmp(actx->idx[i]->content->subtype, "digest") == 0))));
1337  }
1338 }
struct Email * email
Used by recvattach for updating.
Definition: attach.h:51
struct Body * content
List of MIME parts.
Definition: email.h:92
bool C_DigestCollapse
Config: Hide the subparts of a multipart/digest.
Definition: recvattach.c:77
short idxlen
Number of attachmentes.
Definition: attach.h:55
bool tagged
This attachment is tagged.
Definition: body.h:70
bool collapsed
Used by recvattach.
Definition: body.h:88
char * subtype
content-type subtype
Definition: body.h:37
unsigned int type
content-type primary type
Definition: body.h:65
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
struct Body * content
Attachment.
Definition: attach.h:36
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void attach_collapse ( struct AttachCtx actx,
struct Menu menu 
)
static

Close the tree of the current attachment.

Parameters
actxAttachment context
menuMenu listing Attachments

Definition at line 1371 of file recvattach.c.

1372 {
1373  int rindex, curlevel;
1374 
1375  CUR_ATTACH->content->collapsed = !CUR_ATTACH->content->collapsed;
1376  /* When expanding, expand all the children too */
1377  if (CUR_ATTACH->content->collapsed)
1378  return;
1379 
1380  curlevel = CUR_ATTACH->level;
1381  rindex = actx->v2r[menu->current] + 1;
1382 
1383  while ((rindex < actx->idxlen) && (actx->idx[rindex]->level > curlevel))
1384  {
1385  if (C_DigestCollapse && (actx->idx[rindex]->content->type == TYPE_MULTIPART) &&
1386  !mutt_str_strcasecmp(actx->idx[rindex]->content->subtype, "digest"))
1387  {
1388  actx->idx[rindex]->content->collapsed = true;
1389  }
1390  else
1391  {
1392  actx->idx[rindex]->content->collapsed = false;
1393  }
1394  rindex++;
1395  }
1396 }
bool C_DigestCollapse
Config: Hide the subparts of a multipart/digest.
Definition: recvattach.c:77
#define CUR_ATTACH
Definition: recvattach.c:92
bool collapsed
Used by recvattach.
Definition: body.h:88
char * subtype
content-type subtype
Definition: body.h:37
unsigned int type
content-type primary type
Definition: body.h:65
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:58
struct Body * content
Attachment.
Definition: attach.h:36
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
int current
current entry
Definition: mutt_menu.h:87
int level
Nesting depth of attachment.
Definition: attach.h:40
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_view_attachments ( struct Email e)

Show the attachments in a Menu.

Parameters
eEmail

Definition at line 1402 of file recvattach.c.

1403 {
1404  char helpstr[1024];
1405  int op = OP_NULL;
1406 
1407  struct Mailbox *m = Context ? Context->mailbox : NULL;
1408 
1409  /* make sure we have parsed this message */
1411 
1413 
1414  struct Message *msg = mx_msg_open(m, e->msgno);
1415  if (!msg)
1416  return;
1417 
1418  struct Menu *menu = mutt_menu_new(MENU_ATTACH);
1419  menu->title = _("Attachments");
1421  menu->menu_tag = attach_tag;
1422  menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_ATTACH, AttachHelp);
1423  mutt_menu_push_current(menu);
1424 
1425  struct AttachCtx *actx = mutt_mem_calloc(1, sizeof(struct AttachCtx));
1426  actx->email = e;
1427  actx->fp_root = msg->fp;
1428  mutt_update_recvattach_menu(actx, menu, true);
1429 
1430  while (true)
1431  {
1432  if (op == OP_NULL)
1433  op = mutt_menu_loop(menu);
1434  if (!Context)
1435  return;
1436  switch (op)
1437  {
1438  case OP_ATTACH_VIEW_MAILCAP:
1439  mutt_view_attachment(CUR_ATTACH->fp, CUR_ATTACH->content, MUTT_VA_MAILCAP, e, actx);
1440  menu->redraw = REDRAW_FULL;
1441  break;
1442 
1443  case OP_ATTACH_VIEW_TEXT:
1444  mutt_view_attachment(CUR_ATTACH->fp, CUR_ATTACH->content, MUTT_VA_AS_TEXT, e, actx);
1445  menu->redraw = REDRAW_FULL;
1446  break;
1447 
1448  case OP_DISPLAY_HEADERS:
1449  case OP_VIEW_ATTACH:
1450  op = mutt_attach_display_loop(menu, op, e, actx, true);
1451  menu->redraw = REDRAW_FULL;
1452  continue;
1453 
1454  case OP_ATTACH_COLLAPSE:
1455  if (!CUR_ATTACH->content->parts)
1456  {
1457  mutt_error(_("There are no subparts to show"));
1458  break;
1459  }
1460  attach_collapse(actx, menu);
1461  mutt_update_recvattach_menu(actx, menu, false);
1462  break;
1463 
1464  case OP_FORGET_PASSPHRASE:
1466  break;
1467 
1468  case OP_EXTRACT_KEYS:
1470  {
1471  recvattach_extract_pgp_keys(actx, menu);
1472  menu->redraw = REDRAW_FULL;
1473  }
1474  break;
1475 
1476  case OP_CHECK_TRADITIONAL:
1477  if (((WithCrypto & APPLICATION_PGP) != 0) &&
1479  {
1480  e->security = crypt_query(NULL);
1481  menu->redraw = REDRAW_FULL;
1482  }
1483  break;
1484 
1485  case OP_PRINT:
1487  CUR_ATTACH->content);
1488  break;
1489 
1490  case OP_PIPE:
1492  CUR_ATTACH->content, false);
1493  break;
1494 
1495  case OP_SAVE:
1497  CUR_ATTACH->content, e, menu);
1498 
1499  if (!menu->tagprefix && C_Resolve && (menu->current < menu->max - 1))
1500  menu->current++;
1501 
1503  break;
1504 
1505  case OP_DELETE:
1507 
1508 #ifdef USE_POP
1509  if (m->magic == MUTT_POP)
1510  {
1511  mutt_flushinp();
1512  mutt_error(_("Can't delete attachment from POP server"));
1513  break;
1514  }
1515 #endif
1516 
1517 #ifdef USE_NNTP
1518  if (m->magic == MUTT_NNTP)
1519  {
1520  mutt_flushinp();
1521  mutt_error(_("Can't delete attachment from news server"));
1522  break;
1523  }
1524 #endif
1525 
1526  if ((WithCrypto != 0) && (e->security & SEC_ENCRYPT))
1527  {
1528  mutt_message(_("Deletion of attachments from encrypted messages is "
1529  "unsupported"));
1530  break;
1531  }
1532  if ((WithCrypto != 0) && (e->security & (SEC_SIGN | SEC_PARTSIGN)))
1533  {
1534  mutt_message(_("Deletion of attachments from signed messages may "
1535  "invalidate the signature"));
1536  }
1537  if (!menu->tagprefix)
1538  {
1539  if (CUR_ATTACH->parent_type == TYPE_MULTIPART)
1540  {
1541  CUR_ATTACH->content->deleted = true;
1542  if (C_Resolve && (menu->current < menu->max - 1))
1543  {
1544  menu->current++;
1545  menu->redraw = REDRAW_MOTION_RESYNC;
1546  }
1547  else
1548  menu->redraw = REDRAW_CURRENT;
1549  }
1550  else
1551  {
1552  mutt_message(
1553  _("Only deletion of multipart attachments is supported"));
1554  }
1555  }
1556  else
1557  {
1558  for (int i = 0; i < menu->max; i++)
1559  {
1560  if (actx->idx[i]->content->tagged)
1561  {
1562  if (actx->idx[i]->parent_type == TYPE_MULTIPART)
1563  {
1564  actx->idx[i]->content->deleted = true;
1565  menu->redraw = REDRAW_INDEX;
1566  }
1567  else
1568  {
1569  mutt_message(
1570  _("Only deletion of multipart attachments is supported"));
1571  }
1572  }
1573  }
1574  }
1575  break;
1576 
1577  case OP_UNDELETE:
1579  if (!menu->tagprefix)
1580  {
1581  CUR_ATTACH->content->deleted = false;
1582  if (C_Resolve && (menu->current < menu->max - 1))
1583  {
1584  menu->current++;
1585  menu->redraw = REDRAW_MOTION_RESYNC;
1586  }
1587  else
1588  menu->redraw = REDRAW_CURRENT;
1589  }
1590  else
1591  {
1592  for (int i = 0; i < menu->max; i++)
1593  {
1594  if (actx->idx[i]->content->tagged)
1595  {
1596  actx->idx[i]->content->deleted = false;
1597  menu->redraw = REDRAW_INDEX;
1598  }
1599  }
1600  }
1601  break;
1602 
1603  case OP_RESEND:
1604  CHECK_ATTACH;
1605  mutt_attach_resend(CUR_ATTACH->fp, actx,
1606  menu->tagprefix ? NULL : CUR_ATTACH->content);
1607  menu->redraw = REDRAW_FULL;
1608  break;
1609 
1610  case OP_BOUNCE_MESSAGE:
1611  CHECK_ATTACH;
1612  mutt_attach_bounce(m, CUR_ATTACH->fp, actx,
1613  menu->tagprefix ? NULL : CUR_ATTACH->content);
1614  menu->redraw = REDRAW_FULL;
1615  break;
1616 
1617  case OP_FORWARD_MESSAGE:
1618  CHECK_ATTACH;
1619  mutt_attach_forward(CUR_ATTACH->fp, e, actx,
1620  menu->tagprefix ? NULL : CUR_ATTACH->content, SEND_NO_FLAGS);
1621  menu->redraw = REDRAW_FULL;
1622  break;
1623 
1624 #ifdef USE_NNTP
1625  case OP_FORWARD_TO_GROUP:
1626  CHECK_ATTACH;
1627  mutt_attach_forward(CUR_ATTACH->fp, e, actx,
1628  menu->tagprefix ? NULL : CUR_ATTACH->content, SEND_NEWS);
1629  menu->redraw = REDRAW_FULL;
1630  break;
1631 
1632  case OP_FOLLOWUP:
1633  CHECK_ATTACH;
1634 
1635  if (!CUR_ATTACH->content->email->env->followup_to ||
1636  (mutt_str_strcasecmp(CUR_ATTACH->content->email->env->followup_to, "poster") != 0) ||
1638  _("Reply by mail as poster prefers?")) != MUTT_YES))
1639  {
1640  mutt_attach_reply(CUR_ATTACH->fp, e, actx,
1641  menu->tagprefix ? NULL : CUR_ATTACH->content,
1642  SEND_NEWS | SEND_REPLY);
1643  menu->redraw = REDRAW_FULL;
1644  break;
1645  }
1646 #endif
1647  /* fallthrough */
1648  case OP_REPLY:
1649  case OP_GROUP_REPLY:
1650  case OP_GROUP_CHAT_REPLY:
1651  case OP_LIST_REPLY:
1652  {
1653  CHECK_ATTACH;
1654 
1655  SendFlags flags = SEND_REPLY;
1656  if (op == OP_GROUP_REPLY)
1657  flags |= SEND_GROUP_REPLY;
1658  else if (op == OP_GROUP_CHAT_REPLY)
1659  flags |= SEND_GROUP_CHAT_REPLY;
1660  else if (op == OP_LIST_REPLY)
1661  flags |= SEND_LIST_REPLY;
1662 
1663  mutt_attach_reply(CUR_ATTACH->fp, e, actx,
1664  menu->tagprefix ? NULL : CUR_ATTACH->content, flags);
1665  menu->redraw = REDRAW_FULL;
1666  break;
1667  }
1668 
1669  case OP_COMPOSE_TO_SENDER:
1670  CHECK_ATTACH;
1671  mutt_attach_mail_sender(CUR_ATTACH->fp, e, actx,
1672  menu->tagprefix ? NULL : CUR_ATTACH->content);
1673  menu->redraw = REDRAW_FULL;
1674  break;
1675 
1676  case OP_EDIT_TYPE:
1677  recvattach_edit_content_type(actx, menu, e);
1678  menu->redraw |= REDRAW_INDEX;
1679  break;
1680 
1681  case OP_EXIT:
1682  mx_msg_close(m, &msg);
1683 
1684  e->attach_del = false;
1685  for (int i = 0; i < actx->idxlen; i++)
1686  {
1687  if (actx->idx[i]->content && actx->idx[i]->content->deleted)
1688  {
1689  e->attach_del = true;
1690  break;
1691  }
1692  }
1693  if (e->attach_del)
1694  e->changed = true;
1695 
1696  mutt_actx_free(&actx);
1697 
1698  mutt_menu_pop_current(menu);
1699  mutt_menu_free(&menu);
1700  return;
1701  }
1702 
1703  op = OP_NULL;
1704  }
1705 
1706  /* not reached */
1707 }
The "current" mailbox.
Definition: context.h:36
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
static const struct Mapping AttachHelp[]
Definition: recvattach.c:94
GUI selectable list of items.
Definition: mutt_menu.h:82
static void attach_make_entry(char *buf, size_t buflen, struct Menu *menu, int line)
Format a menu item for the attachment list - Implements Menu::menu_make_entry()
Definition: recvattach.c:435
&#39;NNTP&#39; (Usenet) Mailbox type
Definition: mailbox.h:51
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3322
#define mutt_message(...)
Definition: logging.h:83
struct Email * email
Used by recvattach for updating.
Definition: attach.h:51
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
WHERE unsigned char C_FollowupToPoster
Config: (nntp) Reply to the poster if &#39;poster&#39; is in the &#39;Followup-To&#39; header.
Definition: globals.h:201
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:800
bool attach_del
Has an attachment marked for deletion.
Definition: email.h:51
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
Definition: crypt.c:105
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:52
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:48
#define _(a)
Definition: message.h:28
bool changed
Email has been edited.
Definition: email.h:50
short idxlen
Number of attachmentes.
Definition: attach.h:55
Force viewing as text.
Definition: mutt_attach.h:43
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
int menu
menu definition for keymap entries.
Definition: mutt_menu.h:90
uint16_t SendFlags
Flags for ci_send_message(), e.g. SEND_REPLY.
Definition: send.h:85
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: ncrypt.h:126
void(* menu_make_entry)(char *buf, size_t buflen, struct Menu *menu, int line)
Format a item for a menu.
Definition: mutt_menu.h:122
char * mutt_compile_help(char *buf, size_t buflen, int menu, const struct Mapping *items)
Create the text for the help menu.
Definition: help.c:115
#define CUR_ATTACH
Definition: recvattach.c:92
int attach_tag(struct Menu *menu, int sel, int act)
Tag an attachment - Implements Menu::menu_tag()
Definition: recvattach.c:447
#define SEND_NO_FLAGS
No flags are set.
Definition: send.h:86
void mutt_attach_reply(FILE *fp, struct Email *e, struct AttachCtx *actx, struct Body *e_cur, SendFlags flags)
Attach a reply.
Definition: recvcmd.c:897
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1089
struct Mailbox * mailbox
Definition: context.h:50
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:116
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:38
#define SEND_LIST_REPLY
Reply to mailing list.
Definition: send.h:89
bool tagged
This attachment is tagged.
Definition: body.h:70
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:44
void mutt_actx_free(struct AttachCtx **pactx)
Free an Attachment Context.
Definition: attach.c:131
void mutt_attach_bounce(struct Mailbox *m, FILE *fp, struct AttachCtx *actx, struct Body *cur)
Bounce function, from the attachment menu.
Definition: recvcmd.c:168
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
&#39;POP3&#39; Mailbox type
Definition: mailbox.h:54
A local copy of an email.
Definition: mx.h:81
Select an attachment.
Definition: keymap.h:72
A mailbox.
Definition: mailbox.h:92
static void recvattach_edit_content_type(struct AttachCtx *actx, struct Menu *menu, struct Email *e)
Edit the content type of an attachment.
Definition: recvattach.c:1106
int mutt_attach_display_loop(struct Menu *menu, int op, struct Email *e, struct AttachCtx *actx, bool recv)
Event loop for the Attachment menu.
Definition: recvattach.c:1136
bool tagprefix
Definition: mutt_menu.h:93
static void recvattach_extract_pgp_keys(struct AttachCtx *actx, struct Menu *menu)
Extract PGP keys from attachments.
Definition: recvattach.c:1060
WHERE bool C_Resolve
Config: Move to the next email whenever a command modifies an email.
Definition: globals.h:257
static void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1346
#define SEND_NEWS
Reply to a news article.
Definition: send.h:101
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:41
static int recvattach_pgp_check_traditional(struct AttachCtx *actx, struct Menu *menu)
Is the Attachment inline PGP?
Definition: recvattach.c:1084
Force viewing using mailcap entry.
Definition: mutt_attach.h:42
#define SEND_REPLY
Reply to sender.
Definition: send.h:87
#define CHECK_READONLY
Definition: recvattach.c:84
int max
the number of entries in the menu
Definition: mutt_menu.h:88
int(* menu_tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:139
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
void mutt_print_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top)
Print a list of Attachments.
Definition: recvattach.c:1019
MuttRedrawFlags redraw
when to redraw the screen
Definition: mutt_menu.h:89
void mutt_attach_forward(FILE *fp, struct Email *e, struct AttachCtx *actx, struct Body *cur, SendFlags flags)
Forward an Attachment.
Definition: recvcmd.c:749
char * title
the title of this menu
Definition: mutt_menu.h:84
bool deleted
Attachment marked for deletion.
Definition: body.h:71
static void attach_collapse(struct AttachCtx *actx, struct Menu *menu)
Close the tree of the current attachment.
Definition: recvattach.c:1371
#define SEND_GROUP_REPLY
Reply to all.
Definition: send.h:88
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:42
struct Body * content
Attachment.
Definition: attach.h:36
#define mutt_error(...)
Definition: logging.h:84
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
FILE * fp
pointer to the message data
Definition: mx.h:83
void mutt_save_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, struct Email *e, struct Menu *menu)
Save a list of attachments.
Definition: recvattach.c:649
void mutt_attach_mail_sender(FILE *fp, struct Email *e, struct AttachCtx *actx, struct Body *cur)
Compose an email to the sender in the email attachment.
Definition: recvcmd.c:1059
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
#define SEND_GROUP_CHAT_REPLY
Reply to all recipients preserving To/Cc.
Definition: send.h:100
int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx)
View an attachment.
Definition: mutt_attach.c:386
int current
current entry
Definition: mutt_menu.h:87
#define CHECK_ATTACH
Definition: recvattach.c:102
#define WithCrypto
Definition: ncrypt.h:160
A set of attachments.
Definition: attach.h:49
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:54
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:696
void mutt_attach_resend(FILE *fp, struct AttachCtx *actx, struct Body *cur)
resend-message, from the attachment menu
Definition: recvcmd.c:290
char * help
quickref for the current menu
Definition: mutt_menu.h:85
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1041
#define REDRAW_CURRENT
Redraw the current line of the menu.
Definition: mutt_menu.h:45
void mutt_pipe_attachment_list(struct AttachCtx *actx, FILE *fp, bool tag, struct Body *top, bool filter)
Pipe a list of attachments to a command.
Definition: recvattach.c:870
int msgno
Number displayed to the user.
Definition: email.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

char* C_AttachSaveDir

Config: Default directory where attachments are saved.

Definition at line 73 of file recvattach.c.

char* C_AttachSaveWithoutPrompting

Config: If true, then don't prompt to save.

Definition at line 74 of file recvattach.c.

char* C_AttachSep

Config: Separator to add between saved/printed/piped attachments.

Definition at line 75 of file recvattach.c.

bool C_AttachSplit

Config: Save/print/pipe tagged messages individually.

Definition at line 76 of file recvattach.c.

bool C_DigestCollapse

Config: Hide the subparts of a multipart/digest.

Definition at line 77 of file recvattach.c.

char* C_MessageFormat

Config: printf-like format string for listing attached messages.

Definition at line 78 of file recvattach.c.

const char* Mailbox_is_read_only = N_("Mailbox is read-only")
static

Definition at line 82 of file recvattach.c.

const struct Mapping AttachHelp[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT }, { N_("Save"), OP_SAVE }, { N_("Pipe"), OP_PIPE },
{ N_("Print"), OP_PRINT }, { N_("Help"), OP_HELP }, { NULL, 0 },
}
#define N_(a)
Definition: message.h:32

Definition at line 94 of file recvattach.c.

const char* Function_not_permitted
static
Initial value:
=
N_("Function not permitted in attach-message mode")
#define N_(a)
Definition: message.h:32

Definition at line 99 of file recvattach.c.