NeoMutt  2018-07-16 +1360-3df4a2
Teaching an old dog new tricks
DOXYGEN
commands.c File Reference

Manage where the email is piped to external commands. More...

#include "config.h"
#include <errno.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 "conn/conn.h"
#include "mutt.h"
#include "alias.h"
#include "context.h"
#include "copy.h"
#include "curs_lib.h"
#include "filter.h"
#include "format_flags.h"
#include "globals.h"
#include "hdrline.h"
#include "hook.h"
#include "icommands.h"
#include "keymap.h"
#include "mailbox.h"
#include "mutt_curses.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 "options.h"
#include "pager.h"
#include "protos.h"
#include "sendlib.h"
#include "sort.h"
#include "imap/imap.h"
#include "notmuch/mutt_notmuch.h"
#include <libintl.h>
+ Include dependency graph for commands.c:

Go to the source code of this file.

Macros

#define EXTRA_SPACE   (15 + 7 + 2)
 

Functions

static void update_protected_headers (struct Email *cur)
 Get the protected header and update the index. More...
 
int mutt_display_message (struct Email *cur)
 Display a message in the pager. More...
 
void ci_bounce_message (struct Mailbox *m, struct EmailList *el)
 Bounce an email. More...
 
static void pipe_set_flags (bool decode, bool print, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
 Generate flags for copy header/message. More...
 
static void pipe_msg (struct Mailbox *m, struct Email *e, FILE *fp, bool decode, bool print)
 Pipe a message. More...
 
static int pipe_message (struct Mailbox *m, struct EmailList *el, char *cmd, bool decode, bool print, bool split, const char *sep)
 Pipe message to a command. More...
 
void mutt_pipe_message (struct Mailbox *m, struct EmailList *el)
 Pipe a message. More...
 
void mutt_print_message (struct Mailbox *m, struct EmailList *el)
 Print a message. More...
 
int mutt_select_sort (bool reverse)
 Ask the user for a sort method. More...
 
void mutt_shell_escape (void)
 invoke a command in a subshell More...
 
void mutt_enter_command (void)
 enter a neomutt command More...
 
void mutt_display_address (struct Envelope *env)
 Display the address of a message. More...
 
static void set_copy_flags (struct Email *e, bool decode, bool decrypt, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
 Set the flags for a message copy. More...
 
int mutt_save_message_ctx (struct Email *e, bool delete, bool decode, bool decrypt, struct Mailbox *m)
 Save a message to a given mailbox. More...
 
int mutt_save_message (struct Mailbox *m, struct EmailList *el, bool delete, bool decode, bool decrypt)
 Save an email. More...
 
bool mutt_edit_content_type (struct Email *e, struct Body *b, FILE *fp)
 Edit the content type of an attachment. More...
 
static bool check_traditional_pgp (struct Email *e, MuttRedrawFlags *redraw)
 Check for an inline PGP content. More...
 
bool mutt_check_traditional_pgp (struct EmailList *el, MuttRedrawFlags *redraw)
 Check if a message has inline PGP content. More...
 
void mutt_check_stats (void)
 Forcibly update mailbox stats. More...
 

Variables

unsigned char C_CryptVerifySig
 Config: Verify PGP or SMIME signatures. More...
 
char * C_DisplayFilter
 Config: External command to pre-process an email before display. More...
 
bool C_PipeDecode
 Config: Decode the message when piping it. More...
 
char * C_PipeSep
 Config: Separator to add between multiple piped messages. More...
 
bool C_PipeSplit
 Config: Run the pipe command on each message separately. More...
 
bool C_PrintDecode
 Config: Decode message before printing it. More...
 
bool C_PrintSplit
 Config: Print multiple messages separately. More...
 
bool C_PromptAfter
 Config: Pause after running an external pager. More...
 
static const char * ExtPagerProgress = "all"
 
static char LastSaveFolder [PATH_MAX] = ""
 The folder the user last saved to. More...
 

Detailed Description

Manage where the email is piped to external commands.

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

Macro Definition Documentation

#define EXTRA_SPACE   (15 + 7 + 2)

Function Documentation

static void update_protected_headers ( struct Email cur)
static

Get the protected header and update the index.

Parameters
curEmail to update

Definition at line 97 of file commands.c.

98 {
99  struct Envelope *prot_headers = NULL;
100  regmatch_t pmatch[1];
101 
103  return;
104 
105  /* Grab protected headers to update in the index */
106  if (cur->security & SEC_SIGN)
107  {
108  /* Don't update on a bad signature.
109  *
110  * This is a simplification. It's possible the headers are in the
111  * encrypted part of a nested encrypt/signed. But properly handling that
112  * case would require more complexity in the decryption handlers, which
113  * I'm not sure is worth it. */
114  if (!(cur->security & SEC_GOODSIGN))
115  return;
116 
117  if (mutt_is_multipart_signed(cur->content) && cur->content->parts)
118  {
119  prot_headers = cur->content->parts->mime_headers;
120  }
121  else if (((WithCrypto & APPLICATION_SMIME) != 0) && mutt_is_application_smime(cur->content))
122  {
123  prot_headers = cur->content->mime_headers;
124  }
125  }
126  if (!prot_headers && (cur->security & SEC_ENCRYPT))
127  {
128  if (((WithCrypto & APPLICATION_PGP) != 0) &&
131  {
132  prot_headers = cur->content->mime_headers;
133  }
134  else if (((WithCrypto & APPLICATION_SMIME) != 0) && mutt_is_application_smime(cur->content))
135  {
136  prot_headers = cur->content->mime_headers;
137  }
138  }
139 
140  /* Update protected headers in the index and header cache. */
141  if (prot_headers && prot_headers->subject &&
142  mutt_str_strcmp(cur->env->subject, prot_headers->subject))
143  {
144  if (Context->mailbox->subj_hash && cur->env->real_subj)
146 
147  mutt_str_replace(&cur->env->subject, prot_headers->subject);
148  FREE(&cur->env->disp_subj);
149  if (regexec(C_ReplyRegex->regex, cur->env->subject, 1, pmatch, 0) == 0)
150  cur->env->real_subj = cur->env->subject + pmatch[0].rm_eo;
151  else
152  cur->env->real_subj = cur->env->subject;
153 
154  if (Context->mailbox->subj_hash)
156 
158 
159  /* Also persist back to the message headers if this is set */
161  {
163  cur->changed = 1;
164  Context->mailbox->changed = 1;
165  }
166  }
167 }
The "current" mailbox.
Definition: context.h:37
void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data)
Remove an element from a Hash table.
Definition: hash.c:433
struct Envelope * mime_headers
memory hole protected headers
Definition: body.h:68
char * disp_subj
display subject (modified copy of subject)
Definition: envelope.h:52
regex_t * regex
compiled expression
Definition: regex3.h:60
struct Body * content
list of MIME parts
Definition: email.h:93
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:442
char * real_subj
offset of the real subject
Definition: envelope.h:51
bool changed
Definition: email.h:48
int mx_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Wrapper for MxOps::msg_save_hcache()
Definition: mx.c:1574
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:120
#define MUTT_ENV_CHANGED_SUBJECT
Protected header update.
Definition: envelope.h:33
unsigned char changed
Definition: envelope.h:69
struct Mailbox * mailbox
Definition: context.h:51
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:122
struct Envelope * env
envelope information
Definition: email.h:92
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:377
struct Regex * C_ReplyRegex
Config: Regex to match message reply subjects like "re: ".
Definition: email_globals.c:36
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:121
WHERE bool C_CryptProtectedHeadersSave
Config: Save the cleartext Subject with the headers.
Definition: globals.h:277
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:59
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:480
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:584
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
WHERE bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: globals.h:276
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:459
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:129
char * subject
Definition: envelope.h:50
struct Hash * subj_hash
hash table by subject
Definition: mailbox.h:129
#define FREE(x)
Definition: memory.h:40
bool changed
mailbox has been modified
Definition: mailbox.h:115
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:348
#define WithCrypto
Definition: ncrypt.h:155
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611
The header of an email.
Definition: envelope.h:38
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:130

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_display_message ( struct Email cur)

Display a message in the pager.

Parameters
curHeader of current message
Return values
0Success
-1Error

Definition at line 175 of file commands.c.

176 {
177  char tempfile[PATH_MAX], buf[1024];
178  int rc = 0;
179  bool builtin = false;
181  CopyHeaderFlags chflags;
182  pid_t filterpid = -1;
183  int res;
184 
185  snprintf(buf, sizeof(buf), "%s/%s", TYPE(cur->content), cur->content->subtype);
186 
189 
190  /* see if crypto is needed for this message. if so, we should exit curses */
191  if ((WithCrypto != 0) && cur->security)
192  {
193  if (cur->security & SEC_ENCRYPT)
194  {
195  if (cur->security & APPLICATION_SMIME)
196  crypt_smime_getkeys(cur->env);
197  if (!crypt_valid_passphrase(cur->security))
198  return 0;
199 
200  cmflags |= MUTT_CM_VERIFY;
201  }
202  else if (cur->security & SEC_SIGN)
203  {
204  /* find out whether or not the verify signature */
205  /* L10N: Used for the $crypt_verify_sig prompt */
206  if (query_quadoption(C_CryptVerifySig, _("Verify signature?")) == MUTT_YES)
207  {
208  cmflags |= MUTT_CM_VERIFY;
209  }
210  }
211  }
212 
213  if (cmflags & MUTT_CM_VERIFY || cur->security & SEC_ENCRYPT)
214  {
215  if (cur->security & APPLICATION_PGP)
216  {
217  if (cur->env->from)
219 
221  }
222 
223  if (cur->security & APPLICATION_SMIME)
225  }
226 
227  mutt_mktemp(tempfile, sizeof(tempfile));
228  FILE *fp_filter_out = NULL;
229  FILE *fp_out = mutt_file_fopen(tempfile, "w");
230  if (!fp_out)
231  {
232  mutt_error(_("Could not create temporary file"));
233  return 0;
234  }
235 
237  {
238  fp_filter_out = fp_out;
239  fp_out = NULL;
240  filterpid = mutt_create_filter_fd(C_DisplayFilter, &fp_out, NULL, NULL, -1,
241  fileno(fp_filter_out), -1);
242  if (filterpid < 0)
243  {
244  mutt_error(_("Cannot create display filter"));
245  mutt_file_fclose(&fp_filter_out);
246  unlink(tempfile);
247  return 0;
248  }
249  }
250 
251  if (!C_Pager || (mutt_str_strcmp(C_Pager, "builtin") == 0))
252  builtin = true;
253  else
254  {
255  struct HdrFormatInfo hfi;
256  hfi.ctx = Context;
257  hfi.mailbox = Context->mailbox;
258  hfi.pager_progress = ExtPagerProgress;
259  hfi.email = cur;
260  mutt_make_string_info(buf, sizeof(buf), MuttIndexWindow->cols,
261  NONULL(C_PagerFormat), &hfi, 0);
262  fputs(buf, fp_out);
263  fputs("\n\n", fp_out);
264  }
265 
266  chflags = (C_Weed ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM | CH_DISPLAY;
267 #ifdef USE_NOTMUCH
269  chflags |= CH_VIRTUAL;
270 #endif
271  res = mutt_copy_message_ctx(fp_out, Context->mailbox, cur, cmflags, chflags);
272 
273  if (((mutt_file_fclose(&fp_out) != 0) && (errno != EPIPE)) || (res < 0))
274  {
275  mutt_error(_("Could not copy message"));
276  if (fp_filter_out)
277  {
278  mutt_wait_filter(filterpid);
279  mutt_file_fclose(&fp_filter_out);
280  }
281  mutt_file_unlink(tempfile);
282  return 0;
283  }
284 
285  if (fp_filter_out && (mutt_wait_filter(filterpid) != 0))
287 
288  mutt_file_fclose(&fp_filter_out); /* XXX - check result? */
289 
290  if (WithCrypto)
291  {
292  /* update crypto information for this message */
293  cur->security &= ~(SEC_GOODSIGN | SEC_BADSIGN);
294  cur->security |= crypt_query(cur->content);
295 
296  /* Remove color cache for this message, in case there
297  * are color patterns for both ~g and ~V */
298  cur->pair = 0;
299 
300  /* Grab protected headers and update the header and index */
302  }
303 
304  if (builtin)
305  {
306  if ((WithCrypto != 0) && (cur->security & APPLICATION_SMIME) && (cmflags & MUTT_CM_VERIFY))
307  {
308  if (cur->security & SEC_GOODSIGN)
309  {
310  if (crypt_smime_verify_sender(cur) == 0)
311  mutt_message(_("S/MIME signature successfully verified"));
312  else
313  mutt_error(_("S/MIME certificate owner does not match sender"));
314  }
315  else if (cur->security & SEC_PARTSIGN)
316  mutt_message(_("Warning: Part of this message has not been signed"));
317  else if (cur->security & SEC_SIGN || cur->security & SEC_BADSIGN)
318  mutt_error(_("S/MIME signature could NOT be verified"));
319  }
320 
321  if ((WithCrypto != 0) && (cur->security & APPLICATION_PGP) && (cmflags & MUTT_CM_VERIFY))
322  {
323  if (cur->security & SEC_GOODSIGN)
324  mutt_message(_("PGP signature successfully verified"));
325  else if (cur->security & SEC_PARTSIGN)
326  mutt_message(_("Warning: Part of this message has not been signed"));
327  else if (cur->security & SEC_SIGN)
328  mutt_message(_("PGP signature could NOT be verified"));
329  }
330 
331  struct Pager info = { 0 };
332  /* Invoke the builtin pager */
333  info.email = cur;
334  info.ctx = Context;
335  rc = mutt_pager(NULL, tempfile, MUTT_PAGER_MESSAGE, &info);
336  }
337  else
338  {
339  int r;
340 
341  char cmd[STR_COMMAND];
342  mutt_endwin();
343  snprintf(cmd, sizeof(cmd), "%s %s", NONULL(C_Pager), tempfile);
344  r = mutt_system(cmd);
345  if (r == -1)
346  mutt_error(_("Error running \"%s\""), cmd);
347  unlink(tempfile);
348  if (!OptNoCurses)
349  keypad(stdscr, true);
350  if (r != -1)
351  mutt_set_flag(Context->mailbox, cur, MUTT_READ, true);
352  if ((r != -1) && C_PromptAfter)
353  {
354  mutt_unget_event(mutt_any_key_to_continue(_("Command: ")), 0);
355  rc = km_dokey(MENU_PAGER);
356  }
357  else
358  rc = 0;
359  }
360 
361  return rc;
362 }
struct Context * ctx
Definition: hdrline.h:45
The "current" mailbox.
Definition: context.h:37
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: magic.h:43
#define NONULL(x)
Definition: string2.h:36
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:68
int km_dokey(int menu)
Determine what a keypress should do.
Definition: keymap.c:569
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
static void update_protected_headers(struct Email *cur)
Get the protected header and update the index.
Definition: commands.c:97
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3369
#define mutt_message(...)
Definition: logging.h:87
#define MUTT_PAGER_MESSAGE
Definition: pager.h:58
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
struct Body * content
list of MIME parts
Definition: email.h:93
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:191
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:668
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
#define _(a)
Definition: message.h:28
static const char * ExtPagerProgress
Definition: commands.c:88
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:45
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:51
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
An email being displayed.
Definition: pager.h:65
unsigned char C_CryptVerifySig
Config: Verify PGP or SMIME signatures.
Definition: commands.c:79
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:120
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: ncrypt.h:124
#define SEC_BADSIGN
Email has a bad signature.
Definition: ncrypt.h:123
Pager pager (email viewer)
Definition: keymap.h:75
int crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:144
struct Mailbox * mailbox
Definition: context.h:51
#define MUTT_CM_DISPLAY
Output is displayed to the user.
Definition: copy.h:38
Data passed to index_format_str()
Definition: hdrline.h:43
int mutt_copy_message_ctx(FILE *fp_out, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Context.
Definition: copy.c:799
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:122
enum MailboxType magic
mailbox type
Definition: mailbox.h:106
#define CH_WEED
Weed the headers?
Definition: copy.h:52
struct Envelope * env
envelope information
Definition: email.h:92
#define CH_VIRTUAL
Write virtual header lines too.
Definition: copy.h:72
struct Address * from
Definition: envelope.h:41
char * subtype
content-type subtype
Definition: body.h:37
void mutt_make_string_info(char *buf, size_t buflen, int cols, const char *s, struct HdrFormatInfo *hfi, MuttFormatFlags flags)
Create pager status bar string.
Definition: hdrline.c:1489
void crypt_invoke_message(SecurityFlags type)
Display an informative message.
Definition: cryptglue.c:137
struct Context * ctx
current mailbox
Definition: pager.h:67
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:72
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:121
WHERE struct Context * Context
Definition: globals.h:41
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:497
#define PATH_MAX
Definition: mutt.h:48
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:39
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define CH_REORDER
Re-order output of headers (specified by &#39;hdr_order&#39;)
Definition: copy.h:58
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:405
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
pid_t mutt_create_filter_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr)
Run a command on a pipe (optionally connect stdin/stdout)
Definition: filter.c:64
void crypt_pgp_invoke_getkeys(struct Address *addr)
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()
Definition: cryptglue.c:228
#define CH_DISPLAY
Display result to user.
Definition: copy.h:69
Messages that have been read.
Definition: mutt.h:98
int crypt_smime_verify_sender(struct Email *e)
Wrapper for CryptModuleSpecs::smime_verify_sender()
Definition: cryptglue.c:414
#define MUTT_CM_VERIFY
Do signature verification.
Definition: copy.h:46
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:129
#define STR_COMMAND
Enough space for a long command line.
Definition: string2.h:34
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:546
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:530
bool C_PromptAfter
Config: Pause after running an external pager.
Definition: commands.c:86
#define TYPE(body)
Definition: mime.h:83
struct Email * email
current message
Definition: pager.h:68
char * C_DisplayFilter
Config: External command to pre-process an email before display.
Definition: commands.c:80
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
#define mutt_error(...)
Definition: logging.h:88
WHERE char * C_Pager
Config: External command for viewing messages, or &#39;builtin&#39; to use NeoMutt&#39;s.
Definition: globals.h:138
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:441
int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct Pager *extra)
Display a file, or help, in a window.
Definition: pager.c:2231
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:227
#define WithCrypto
Definition: ncrypt.h:155
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:661
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611
int pair
color-pair to use when displaying in the index
Definition: email.h:82
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:50
WHERE char * C_PagerFormat
Config: printf-like format string for the pager&#39;s status bar.
Definition: globals.h:139
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:39
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:130

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ci_bounce_message ( struct Mailbox m,
struct EmailList *  el 
)

Bounce an email.

Parameters
mMailbox
elList of Emails to bounce

Definition at line 369 of file commands.c.

370 {
371  if (!m || !el || STAILQ_EMPTY(el))
372  return;
373 
374  char prompt[128];
375  char scratch[128];
376  char buf[8192] = { 0 };
377  struct Address *addr = NULL;
378  char *err = NULL;
379  int rc;
380  int msg_count = 0;
381 
382  struct EmailNode *en = NULL;
383  STAILQ_FOREACH(en, el, entries)
384  {
385  /* RFC5322 mandates a From: header,
386  * so warn before bouncing messages without one */
387  if (!en->email->env->from)
388  mutt_error(_("Warning: message contains no From: header"));
389 
390  msg_count++;
391  }
392 
393  if (msg_count == 1)
394  mutt_str_strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
395  else
396  mutt_str_strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
397 
398  rc = mutt_get_field(prompt, buf, sizeof(buf), MUTT_ALIAS);
399  if (rc || !buf[0])
400  return;
401 
402  addr = mutt_addr_parse_list2(addr, buf);
403  if (!addr)
404  {
405  mutt_error(_("Error parsing address"));
406  return;
407  }
408 
409  addr = mutt_expand_aliases(addr);
410 
411  if (mutt_addrlist_to_intl(addr, &err) < 0)
412  {
413  mutt_error(_("Bad IDN: '%s'"), err);
414  FREE(&err);
415  mutt_addr_free(&addr);
416  return;
417  }
418 
419  buf[0] = '\0';
420  mutt_addr_write(buf, sizeof(buf), addr, true);
421 
422 #define EXTRA_SPACE (15 + 7 + 2)
423  snprintf(scratch, sizeof(scratch),
424  ngettext("Bounce message to %s", "Bounce messages to %s", msg_count), buf);
425 
427  {
428  mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - EXTRA_SPACE,
429  FMT_LEFT, 0, scratch, sizeof(scratch), 0);
430  mutt_str_strcat(prompt, sizeof(prompt), "...?");
431  }
432  else
433  snprintf(prompt, sizeof(prompt), "%s?", scratch);
434 
435  if (query_quadoption(C_Bounce, prompt) != MUTT_YES)
436  {
437  mutt_addr_free(&addr);
439  mutt_message(ngettext("Message not bounced", "Messages not bounced", msg_count));
440  return;
441  }
442 
444 
445  struct Message *msg = NULL;
446  STAILQ_FOREACH(en, el, entries)
447  {
448  msg = mx_msg_open(m, en->email->msgno);
449  if (!msg)
450  {
451  rc = -1;
452  break;
453  }
454 
455  rc = mutt_bounce_message(msg->fp, en->email, addr);
456  mx_msg_close(m, &msg);
457 
458  if (rc < 0)
459  break;
460  }
461 
462  mutt_addr_free(&addr);
463  /* If no error, or background, display message. */
464  if ((rc == 0) || (rc == S_BKG))
465  mutt_message(ngettext("Message bounced", "Messages bounced", msg_count));
466 }
WHERE unsigned char C_Bounce
Config: Confirm before bouncing a message.
Definition: globals.h:188
struct Address * mutt_addr_parse_list2(struct Address *p, const char *s)
Parse a list of email addresses.
Definition: address.c:630
int mutt_bounce_message(FILE *fp, struct Email *e, struct Address *to)
Bounce an email message.
Definition: sendlib.c:3002
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, int justify, char pad_char, const char *s, size_t n, int arboreal)
Format a string, like snprintf()
Definition: curs_lib.c:911
#define MUTT_ALIAS
Do alias "completion" by calling up the alias-menu.
Definition: mutt.h:61
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3369
#define mutt_message(...)
Definition: logging.h:87
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
#define FMT_LEFT
Definition: curs_lib.h:42
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:32
#define S_BKG
Definition: string2.h:42
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:77
int mutt_addrlist_to_intl(struct Address *a, char **err)
Convert an Address list to Punycode.
Definition: address.c:1208
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
Write an Address to a buffer.
Definition: address.c:1146
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1058
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:69
struct Envelope * env
envelope information
Definition: email.h:92
struct Address * from
Definition: envelope.h:41
A local copy of an email.
Definition: mx.h:81
int mutt_strwidth(const char *s)
Measure a string&#39;s width in screen cells.
Definition: curs_lib.c:1176
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:741
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * mutt_str_strcat(char *buf, size_t buflen, const char *s)
Concatenate two strings.
Definition: string.c:401
struct Address * mutt_expand_aliases(struct Address *a)
Expand aliases in a List of Addresses.
Definition: alias.c:297
struct Email * email
Definition: email.h:123
#define mutt_error(...)
Definition: logging.h:88
FILE * fp
pointer to the message data
Definition: mx.h:83
#define FREE(x)
Definition: memory.h:40
#define STAILQ_EMPTY(head)
Definition: queue.h:346
List of Emails.
Definition: email.h:121
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:41
#define EXTRA_SPACE
void mutt_addr_free(struct Address **p)
Free a list of Addresses.
Definition: address.c:446
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1010
int msgno
number displayed to the user
Definition: email.h:89

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void pipe_set_flags ( bool  decode,
bool  print,
CopyMessageFlags cmflags,
CopyHeaderFlags chflags 
)
static

Generate flags for copy header/message.

Parameters
[in]decodeIf true decode the message
[in]printIf true, mark the message for printing
[out]cmflagsFlags, see CopyMessageFlags
[out]chflagsFlags, see CopyHeaderFlags

Definition at line 475 of file commands.c.

477 {
478  if (decode)
479  {
480  *cmflags |= MUTT_CM_DECODE | MUTT_CM_CHARCONV;
481  *chflags |= CH_DECODE | CH_REORDER;
482 
483  if (C_Weed)
484  {
485  *chflags |= CH_WEED;
486  *cmflags |= MUTT_CM_WEED;
487  }
488  }
489 
490  if (print)
491  *cmflags |= MUTT_CM_PRINTING;
492 }
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
#define MUTT_CM_PRINTING
Printing the message - display light.
Definition: copy.h:42
#define CH_WEED
Weed the headers?
Definition: copy.h:52
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define CH_REORDER
Re-order output of headers (specified by &#39;hdr_order&#39;)
Definition: copy.h:58
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:39

+ Here is the caller graph for this function:

static void pipe_msg ( struct Mailbox m,
struct Email e,
FILE *  fp,
bool  decode,
bool  print 
)
static

Pipe a message.

Parameters
mMailbox
eEmail to pipe
fpFile to write to
decodeIf true, decode the message
printIf true, message is for printing

Definition at line 502 of file commands.c.

503 {
505  CopyHeaderFlags chflags = CH_FROM;
506 
507  pipe_set_flags(decode, print, &cmflags, &chflags);
508 
509  if ((WithCrypto != 0) && decode && e->security & SEC_ENCRYPT)
510  {
512  return;
513  endwin();
514  }
515 
516  if (decode)
518 
519  mutt_copy_message_ctx(fp, m, e, cmflags, chflags);
520 }
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:120
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
int crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:144
int mutt_copy_message_ctx(FILE *fp_out, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Context.
Definition: copy.c:799
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
FILE * fp
pointer to the message data
Definition: mx.h:83
#define WithCrypto
Definition: ncrypt.h:155
static void pipe_set_flags(bool decode, bool print, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
Generate flags for copy header/message.
Definition: commands.c:475

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int pipe_message ( struct Mailbox m,
struct EmailList *  el,
char *  cmd,
bool  decode,
bool  print,
bool  split,
const char *  sep 
)
static

Pipe message to a command.

Parameters
mMailbox
elList of Emails to pipe
cmdCommand to pipe to
decodeShould the message be decrypted
printTrue if this is a print job
splitShould a separator be sent between messages?
sepSeparator string
Return values
0Success
1Error

The following code is shared between printing and piping.

Definition at line 536 of file commands.c.

538 {
539  if (!m || !el)
540  return 1;
541 
542  struct EmailNode *en = STAILQ_FIRST(el);
543  if (!en)
544  return 1;
545 
546  int rc = 0;
547  pid_t pid;
548  FILE *fp_out = NULL;
549 
550  if (!STAILQ_NEXT(en, entries))
551  {
552  /* handle a single message */
554 
555  if ((WithCrypto != 0) && decode)
556  {
558  if ((en->email->security & SEC_ENCRYPT) &&
560  return 1;
561  }
562  mutt_endwin();
563 
564  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
565  if (pid < 0)
566  {
567  mutt_perror(_("Can't create filter process"));
568  return 1;
569  }
570 
571  OptKeepQuiet = true;
572  pipe_msg(m, en->email, fp_out, decode, print);
573  mutt_file_fclose(&fp_out);
574  rc = mutt_wait_filter(pid);
575  OptKeepQuiet = false;
576  }
577  else
578  {
579  /* handle tagged messages */
580  if ((WithCrypto != 0) && decode)
581  {
582  STAILQ_FOREACH(en, el, entries)
583  {
586  if ((en->email->security & SEC_ENCRYPT) &&
588  {
589  return 1;
590  }
591  }
592  }
593 
594  if (split)
595  {
596  STAILQ_FOREACH(en, el, entries)
597  {
599  mutt_endwin();
600  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
601  if (pid < 0)
602  {
603  mutt_perror(_("Can't create filter process"));
604  return 1;
605  }
606  OptKeepQuiet = true;
607  pipe_msg(m, en->email, fp_out, decode, print);
608  /* add the message separator */
609  if (sep)
610  fputs(sep, fp_out);
611  mutt_file_fclose(&fp_out);
612  if (mutt_wait_filter(pid) != 0)
613  rc = 1;
614  OptKeepQuiet = false;
615  }
616  }
617  else
618  {
619  mutt_endwin();
620  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
621  if (pid < 0)
622  {
623  mutt_perror(_("Can't create filter process"));
624  return 1;
625  }
626  OptKeepQuiet = true;
627  STAILQ_FOREACH(en, el, entries)
628  {
630  pipe_msg(m, en->email, fp_out, decode, print);
631  /* add the message separator */
632  if (sep)
633  fputs(sep, fp_out);
634  }
635  mutt_file_fclose(&fp_out);
636  if (mutt_wait_filter(pid) != 0)
637  rc = 1;
638  OptKeepQuiet = false;
639  }
640  }
641 
642  if ((rc != 0) || C_WaitKey)
644  return rc;
645 }
pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
Set up filter program.
Definition: filter.c:216
#define mutt_perror(...)
Definition: logging.h:89
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
#define _(a)
Definition: message.h:28
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:51
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:120
static void pipe_msg(struct Mailbox *m, struct Email *e, FILE *fp, bool decode, bool print)
Pipe a message.
Definition: commands.c:502
int crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:144
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:266
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:497
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:530
struct Email * email
Definition: email.h:123
List of Emails.
Definition: email.h:121
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:441
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:227
WHERE bool OptKeepQuiet
(pseudo) shut up the message and refresh functions while we are executing an external program...
Definition: options.h:36
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:155

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_pipe_message ( struct Mailbox m,
struct EmailList *  el 
)

Pipe a message.

Parameters
mMailbox
elList of Emails to pipe

Definition at line 652 of file commands.c.

653 {
654  if (!m || !el)
655  return;
656 
657  char buf[1024] = { 0 };
658 
659  if ((mutt_get_field(_("Pipe to command: "), buf, sizeof(buf), MUTT_CMD) != 0) ||
660  (buf[0] == '\0'))
661  {
662  return;
663  }
664 
665  mutt_expand_path(buf, sizeof(buf));
666  pipe_message(m, el, buf, C_PipeDecode, false, C_PipeSplit, C_PipeSep);
667 }
#define _(a)
Definition: message.h:28
char * C_PipeSep
Config: Separator to add between multiple piped messages.
Definition: commands.c:82
bool C_PipeDecode
Config: Decode the message when piping it.
Definition: commands.c:81
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:77
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
bool C_PipeSplit
Config: Run the pipe command on each message separately.
Definition: commands.c:83
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:64
static int pipe_message(struct Mailbox *m, struct EmailList *el, char *cmd, bool decode, bool print, bool split, const char *sep)
Pipe message to a command.
Definition: commands.c:536

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_print_message ( struct Mailbox m,
struct EmailList *  el 
)

Print a message.

Parameters
mMailbox
elList of Emails to print

Definition at line 674 of file commands.c.

675 {
676  if (!m || !el)
677  return;
678 
679  if (C_Print && (!C_PrintCommand || !*C_PrintCommand))
680  {
681  mutt_message(_("No printing command has been defined"));
682  return;
683  }
684 
685  int msg_count = 0;
686  struct EmailNode *en = NULL;
687  STAILQ_FOREACH(en, el, entries)
688  {
689  msg_count++;
690  }
691 
692  if (query_quadoption(C_Print, (msg_count == 1) ?
693  _("Print message?") :
694  _("Print tagged messages?")) != MUTT_YES)
695  {
696  return;
697  }
698 
699  if (pipe_message(m, el, C_PrintCommand, C_PrintDecode, true, C_PrintSplit, "\f") == 0)
700  mutt_message(ngettext("Message printed", "Messages printed", msg_count));
701  else
702  {
703  mutt_message(ngettext("Message could not be printed",
704  "Messages could not be printed", msg_count));
705  }
706 }
WHERE unsigned char C_Print
Config: Confirm before printing a message.
Definition: globals.h:192
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3369
#define mutt_message(...)
Definition: logging.h:87
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
bool C_PrintSplit
Config: Print multiple messages separately.
Definition: commands.c:85
#define _(a)
Definition: message.h:28
bool C_PrintDecode
Config: Decode message before printing it.
Definition: commands.c:84
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
WHERE char * C_PrintCommand
Config: External command to print a message.
Definition: globals.h:142
List of Emails.
Definition: email.h:121
static int pipe_message(struct Mailbox *m, struct EmailList *el, char *cmd, bool decode, bool print, bool split, const char *sep)
Pipe message to a command.
Definition: commands.c:536

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_select_sort ( bool  reverse)

Ask the user for a sort method.

Parameters
reverseIf true make it a reverse sort
Return values
numSort type, see SortType

Definition at line 713 of file commands.c.

714 {
715  enum SortType method = C_Sort; /* save the current method in case of abort */
716  enum SortType new_sort = C_Sort;
717 
718  switch (mutt_multi_choice(reverse ?
719  /* L10N: The highlighted letters must match the "Sort" options */
720  _("Rev-Sort "
721  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
722  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?: ") :
723  /* L10N: The highlighted letters must match the "Rev-Sort" options */
724  _("Sort "
725  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
726  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?: "),
727  /* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
728  _("dfrsotuzcpl")))
729  {
730  case -1: /* abort - don't resort */
731  return -1;
732 
733  case 1: /* (d)ate */
734  new_sort = SORT_DATE;
735  break;
736 
737  case 2: /* (f)rm */
738  new_sort = SORT_FROM;
739  break;
740 
741  case 3: /* (r)ecv */
742  new_sort = SORT_RECEIVED;
743  break;
744 
745  case 4: /* (s)ubj */
746  new_sort = SORT_SUBJECT;
747  break;
748 
749  case 5: /* t(o) */
750  new_sort = SORT_TO;
751  break;
752 
753  case 6: /* (t)hread */
754  new_sort = SORT_THREADS;
755  break;
756 
757  case 7: /* (u)nsort */
758  new_sort = SORT_ORDER;
759  break;
760 
761  case 8: /* si(z)e */
762  new_sort = SORT_SIZE;
763  break;
764 
765  case 9: /* s(c)ore */
766  new_sort = SORT_SCORE;
767  break;
768 
769  case 10: /* s(p)am */
770  new_sort = SORT_SPAM;
771  break;
772 
773  case 11: /* (l)abel */
774  new_sort = SORT_LABEL;
775  break;
776  }
777  if (reverse)
778  new_sort |= SORT_REVERSE;
779 
780  cs_str_native_set(Config, "sort", new_sort, NULL);
781  return (C_Sort != method) ? 0 : -1; /* no need to resort if it's the same */
782 }
Sort by the date the email was sent.
Definition: sort.h:50
#define _(a)
Definition: message.h:28
WHERE struct ConfigSet * Config
Wrapper around the user&#39;s config settings.
Definition: globals.h:39
Sort by the email&#39;s subject.
Definition: sort.h:53
Sort by the email&#39;s spam score.
Definition: sort.h:64
WHERE short C_Sort
Config: Sort method for the index.
Definition: sort.h:58
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
Definition: curs_lib.c:792
Sort by the email&#39;s To field.
Definition: sort.h:58
Sort by the emails label.
Definition: sort.h:69
Sort by the email&#39;s From field.
Definition: sort.h:54
Sort by the size of the email.
Definition: sort.h:51
SortType
Methods for sorting.
Definition: sort.h:48
Sort by when the message were delivered locally.
Definition: sort.h:57
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort.h:86
Sort by email threads.
Definition: sort.h:56
Sort by the order the messages appear in the mailbox.
Definition: sort.h:55
Sort by the email&#39;s score.
Definition: sort.h:59
int cs_str_native_set(const struct ConfigSet *cs, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: set.c:798

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_shell_escape ( void  )

invoke a command in a subshell

Definition at line 787 of file commands.c.

788 {
789  char buf[1024];
790 
791  buf[0] = '\0';
792  if (mutt_get_field(_("Shell command: "), buf, sizeof(buf), MUTT_CMD) != 0)
793  return;
794 
795  if (!buf[0] && C_Shell)
796  mutt_str_strfcpy(buf, C_Shell, sizeof(buf));
797  if (!buf[0])
798  return;
799 
801  mutt_endwin();
802  fflush(stdout);
803  int rc = mutt_system(buf);
804  if (rc == -1)
805  mutt_debug(LL_DEBUG1, "Error running \"%s\"!", buf);
806 
807  if ((rc != 0) || C_WaitKey)
810 }
The "current" mailbox.
Definition: context.h:37
#define _(a)
Definition: message.h:28
WHERE char * C_Shell
Config: External command to run subshells in.
Definition: globals.h:145
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:77
struct Mailbox * mailbox
Definition: context.h:51
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:69
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all AllMailboxes for new mail.
Definition: mailbox.c:336
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:64
WHERE bool C_WaitKey
Config: Prompt to press a key after running external commands.
Definition: globals.h:266
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:497
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:741
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mailbox.h:170
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:530
Log at debug level 1.
Definition: logging.h:56
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:41
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_enter_command ( void  )

enter a neomutt command

Definition at line 815 of file commands.c.

816 {
817  char buf[1024] = { 0 };
818 
819  /* if enter is pressed after : with no command, just return */
820  if ((mutt_get_field(":", buf, sizeof(buf), MUTT_COMMAND) != 0) || !buf[0])
821  return;
822 
823  struct Buffer *err = mutt_buffer_alloc(256);
824  struct Buffer *token = mutt_buffer_alloc(256);
825 
826  /* check if buf is a valid icommand, else fall back quietly to parse_rc_lines */
827  enum CommandResult rc = mutt_parse_icommand(buf, err);
828  if (!mutt_buffer_is_empty(err))
829  {
830  /* since errbuf could potentially contain printf() sequences in it,
831  * we must call mutt_error() in this fashion so that vsprintf()
832  * doesn't expect more arguments that we passed */
833  if (rc == MUTT_CMD_ERROR)
834  mutt_error("%s", err->data);
835  else
836  mutt_warning("%s", err->data);
837  }
838  else if (rc != MUTT_CMD_SUCCESS)
839  {
840  rc = mutt_parse_rc_line(buf, token, err);
841  if (!mutt_buffer_is_empty(err))
842  {
843  if (rc == MUTT_CMD_SUCCESS) /* command succeeded with message */
844  mutt_message("%s", err->data);
845  else /* error executing command */
846  mutt_error("%s", err->data);
847  }
848  }
849  /* else successful command */
850 
851  mutt_buffer_free(&token);
852  mutt_buffer_free(&err);
853 }
#define mutt_warning(...)
Definition: logging.h:86
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:31
Error: Can&#39;t help the user.
Definition: mutt_commands.h:33
#define mutt_message(...)
Definition: logging.h:87
String manipulation buffer.
Definition: buffer.h:33
enum CommandResult mutt_parse_icommand(char *line, struct Buffer *err)
Parse an informational command.
Definition: icommands.c:67
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:77
struct Buffer * mutt_buffer_alloc(size_t size)
Create a new Buffer.
Definition: buffer.c:298
#define MUTT_COMMAND
Do command completion.
Definition: mutt.h:67
void mutt_buffer_free(struct Buffer **p)
Release a Buffer and its contents.
Definition: buffer.c:138
char * data
pointer to data
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:35
#define mutt_error(...)
Definition: logging.h:88
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:285
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3259

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_display_address ( struct Envelope env)

Display the address of a message.

Parameters
envEnvelope containing address

Definition at line 859 of file commands.c.

860 {
861  const char *pfx = NULL;
862  char buf[128];
863 
864  struct Address *addr = mutt_get_address(env, &pfx);
865  if (!addr)
866  return;
867 
868  /* Note: We don't convert IDNA to local representation this time.
869  * That is intentional, so the user has an opportunity to copy &
870  * paste the on-the-wire form of the address to other, IDN-unable
871  * software. */
872  buf[0] = '\0';
873  mutt_addr_write(buf, sizeof(buf), addr, false);
874  mutt_message("%s: %s", pfx, buf);
875 }
struct Address * mutt_get_address(struct Envelope *env, const char **pfxp)
Get an Address from an Envelope.
Definition: alias.c:328
#define mutt_message(...)
Definition: logging.h:87
An email address.
Definition: address.h:32
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
Write an Address to a buffer.
Definition: address.c:1146

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void set_copy_flags ( struct Email e,
bool  decode,
bool  decrypt,
CopyMessageFlags cmflags,
CopyHeaderFlags chflags 
)
static

Set the flags for a message copy.

Parameters
[in]eEmail
[in]decodeIf true, decode the message
[in]decryptIf true, decrypt the message
[out]cmflagsFlags, see CopyMessageFlags
[out]chflagsFlags, see CopyHeaderFlags

Definition at line 885 of file commands.c.

887 {
888  *cmflags = MUTT_CM_NO_FLAGS;
889  *chflags = CH_UPDATE_LEN;
890 
891  if ((WithCrypto != 0) && !decode && decrypt && (e->security & SEC_ENCRYPT))
892  {
894  {
895  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
896  *cmflags = MUTT_CM_DECODE_PGP;
897  }
898  else if (((WithCrypto & APPLICATION_PGP) != 0) &&
900  {
901  decode = 1;
902  }
903  else if (((WithCrypto & APPLICATION_SMIME) != 0) &&
905  {
906  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
907  *cmflags = MUTT_CM_DECODE_SMIME;
908  }
909  }
910 
911  if (decode)
912  {
913  *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
914  *cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV;
915 
916  if (!decrypt) /* If decode doesn't kick in for decrypt, */
917  {
918  *chflags |= CH_DECODE; /* then decode RFC2047 headers, */
919 
920  if (C_Weed)
921  {
922  *chflags |= CH_WEED; /* and respect $weed. */
923  *cmflags |= MUTT_CM_WEED;
924  }
925  }
926  }
927 }
#define CH_MIME
Ignore MIME fields.
Definition: copy.h:60
struct Body * content
list of MIME parts
Definition: email.h:93
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:120
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:418
#define CH_WEED
Weed the headers?
Definition: copy.h:52
#define CH_TXTPLAIN
Generate text/plain MIME headers.
Definition: copy.h:62
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:525
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:53
#define CH_XMIT
Transmitting this message? (Ignore Lines: and Content-Length:)
Definition: copy.h:54
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
Definition: copy.h:61
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:584
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:129
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
Definition: copy.h:45
#define MUTT_CM_DECODE_PGP
Used for decoding PGP messages.
Definition: copy.h:44
#define WithCrypto
Definition: ncrypt.h:155
#define CH_NONEWLINE
Don&#39;t output terminating newline after the header.
Definition: copy.h:59
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:39
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:130

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_save_message_ctx ( struct Email e,
bool  delete,
bool  decode,
bool  decrypt,
struct Mailbox m 
)

Save a message to a given mailbox.

Parameters
eEmail
deleteIf true, delete the original
decodeIf true, decode the message
decryptIf true, decrypt the message
mMailbox to save to
Return values
0Success
-1Error

Definition at line 939 of file commands.c.

941 {
943  CopyHeaderFlags chflags = CH_NO_FLAGS;
944  int rc;
945 
946  set_copy_flags(e, decode, decrypt, &cmflags, &chflags);
947 
948  if (decode || decrypt)
950 
951  rc = mutt_append_message(m, Context->mailbox, e, cmflags, chflags);
952  if (rc != 0)
953  return rc;
954 
955  if (delete)
956  {
959  if (C_DeleteUntag)
960  mutt_set_flag(Context->mailbox, e, MUTT_TAG, false);
961  }
962 
963  return 0;
964 }
The "current" mailbox.
Definition: context.h:37
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:68
static void set_copy_flags(struct Email *e, bool decode, bool decrypt, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
Set the flags for a message copy.
Definition: commands.c:885
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
Messages to be purged (bypass trash)
Definition: mutt.h:102
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
struct Mailbox * mailbox
Definition: context.h:51
Messages to be deleted.
Definition: mutt.h:100
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
Tagged messages.
Definition: mutt.h:105
WHERE bool C_DeleteUntag
Config: Untag messages when they are marked for deletion.
Definition: globals.h:215
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Append a message.
Definition: copy.c:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mutt_save_message ( struct Mailbox m,
struct EmailList *  el,
bool  delete,
bool  decode,
bool  decrypt 
)

Save an email.

Parameters
mMailbox
elList of Emails to save
deleteIf true, delete the original (save)
decodeIf true, decode the message
decryptIf true, decrypt the message
Return values
0Copy/save was successful
-1Error/abort

Definition at line 976 of file commands.c.

978 {
979  if (!el || STAILQ_EMPTY(el))
980  return -1;
981 
982  bool need_passphrase = false;
983  int app = 0;
984  char buf[PATH_MAX];
985  const char *prompt = NULL;
986  struct Context *savectx = NULL;
987  struct stat st;
988  struct EmailNode *en = STAILQ_FIRST(el);
989  bool single = !STAILQ_NEXT(en, entries);
990 
991  if (delete)
992  {
993  if (decode)
994  prompt = single ? _("Decode-save to mailbox") : _("Decode-save tagged to mailbox");
995  else if (decrypt)
996  prompt = single ? _("Decrypt-save to mailbox") : _("Decrypt-save tagged to mailbox");
997  else
998  prompt = single ? _("Save to mailbox") : _("Save tagged to mailbox");
999  }
1000  else
1001  {
1002  if (decode)
1003  prompt = single ? _("Decode-copy to mailbox") : _("Decode-copy tagged to mailbox");
1004  else if (decrypt)
1005  prompt = single ? _("Decrypt-copy to mailbox") : _("Decrypt-copy tagged to mailbox");
1006  else
1007  prompt = single ? _("Copy to mailbox") : _("Copy tagged to mailbox");
1008  }
1009 
1010  if (WithCrypto)
1011  {
1012  need_passphrase = (en->email->security & SEC_ENCRYPT);
1013  app = en->email->security;
1014  }
1016  mutt_default_save(buf, sizeof(buf), en->email);
1017 
1018  mutt_pretty_mailbox(buf, sizeof(buf));
1019  if (mutt_enter_fname(prompt, buf, sizeof(buf), 0) == -1)
1020  return -1;
1021 
1022  size_t pathlen = strlen(buf);
1023  if (pathlen == 0)
1024  return -1;
1025 
1026  /* Trim any trailing '/' */
1027  if (buf[pathlen - 1] == '/')
1028  buf[pathlen - 1] = '\0';
1029 
1030  /* This is an undocumented feature of ELM pointed out to me by Felix von
1031  * Leitner <leitner@prz.fu-berlin.de> */
1032  if (mutt_str_strcmp(buf, ".") == 0)
1033  mutt_str_strfcpy(buf, LastSaveFolder, sizeof(buf));
1034  else
1036 
1037  mutt_expand_path(buf, sizeof(buf));
1038 
1039  /* check to make sure that this file is really the one the user wants */
1040  if (mutt_save_confirm(buf, &st) != 0)
1041  return -1;
1042 
1043  if ((WithCrypto != 0) && need_passphrase && (decode || decrypt) &&
1044  !crypt_valid_passphrase(app))
1045  {
1046  return -1;
1047  }
1048 
1049  mutt_message(_("Copying to %s..."), buf);
1050 
1051 #ifdef USE_IMAP
1052  if ((m->magic == MUTT_IMAP) && !(decode || decrypt) &&
1053  (imap_path_probe(buf, NULL) == MUTT_IMAP))
1054  {
1055  switch (imap_copy_messages(m, el, buf, delete))
1056  {
1057  /* success */
1058  case 0:
1059  mutt_clear_error();
1060  return 0;
1061  /* non-fatal error: continue to fetch/append */
1062  case 1:
1063  break;
1064  /* fatal error, abort */
1065  case -1:
1066  return -1;
1067  }
1068  }
1069 #endif
1070 
1071  struct Mailbox *m_save = mx_path_resolve(buf);
1072  savectx = mx_mbox_open(m_save, MUTT_APPEND);
1073  if (!savectx)
1074  {
1075  mailbox_free(&m_save);
1076  return -1;
1077  }
1078 
1079 #ifdef USE_COMPRESSED
1080  /* If we're saving to a compressed mailbox, the stats won't be updated
1081  * until the next open. Until then, improvise. */
1082  struct Mailbox *m_comp = NULL;
1083  if (savectx->mailbox->compress_info)
1084  {
1085  m_comp = mutt_find_mailbox(savectx->mailbox->realpath);
1086  }
1087  /* We probably haven't been opened yet */
1088  if (m_comp && (m_comp->msg_count == 0))
1089  m_comp = NULL;
1090 #endif
1091  if (single)
1092  {
1093  if (mutt_save_message_ctx(en->email, delete, decode, decrypt, savectx->mailbox) != 0)
1094  {
1095  mx_mbox_close(&savectx);
1096  return -1;
1097  }
1098 #ifdef USE_COMPRESSED
1099  if (m_comp)
1100  {
1101  m_comp->msg_count++;
1102  if (!en->email->read)
1103  {
1104  m_comp->msg_unread++;
1105  if (!en->email->old)
1106  m_comp->msg_new++;
1107  }
1108  if (en->email->flagged)
1109  m_comp->msg_flagged++;
1110  }
1111 #endif
1112  }
1113  else
1114  {
1115  int rc = 0;
1116 
1117 #ifdef USE_NOTMUCH
1118  if (m->magic == MUTT_NOTMUCH)
1119  nm_db_longrun_init(m, true);
1120 #endif
1121  STAILQ_FOREACH(en, el, entries)
1122  {
1124  rc = mutt_save_message_ctx(en->email, delete, decode, decrypt, savectx->mailbox);
1125  if (rc != 0)
1126  break;
1127 #ifdef USE_COMPRESSED
1128  if (m_comp)
1129  {
1130  struct Email *e2 = en->email;
1131  m_comp->msg_count++;
1132  if (!e2->read)
1133  {
1134  m_comp->msg_unread++;
1135  if (!e2->old)
1136  m_comp->msg_new++;
1137  }
1138  if (e2->flagged)
1139  m_comp->msg_flagged++;
1140  }
1141 #endif
1142  }
1143 #ifdef USE_NOTMUCH
1144  if (m->magic == MUTT_NOTMUCH)
1145  nm_db_longrun_done(m);
1146 #endif
1147  if (rc != 0)
1148  {
1149  mx_mbox_close(&savectx);
1150  return -1;
1151  }
1152  }
1153 
1154  const bool need_mailbox_cleanup = ((savectx->mailbox->magic == MUTT_MBOX) ||
1155  (savectx->mailbox->magic == MUTT_MMDF));
1156 
1157  mx_mbox_close(&savectx);
1158 
1159  if (need_mailbox_cleanup)
1160  mutt_mailbox_cleanup(buf, &st);
1161 
1162  mutt_clear_error();
1163  return 0;
1164 }
#define MUTT_APPEND
Open mailbox for appending messages.
Definition: mx.h:52
The "current" mailbox.
Definition: context.h:37
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: magic.h:43
int msg_count
total number of messages
Definition: mailbox.h:93
struct Mailbox * mutt_find_mailbox(const char *path)
Find the mailbox with a given path.
Definition: mailbox.c:262
The envelope/body of an email.
Definition: email.h:37
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2454
int msg_unread
number of unread messages
Definition: mailbox.h:94
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:529
void mutt_pretty_mailbox(char *s, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:605
#define mutt_message(...)
Definition: logging.h:87
int msg_flagged
number of flagged messages
Definition: mailbox.h:95
&#39;mmdf&#39; Mailbox type
Definition: magic.h:38
void mutt_mailbox_cleanup(const char *path, struct stat *st)
Restore the timestamp of a mailbox.
Definition: mailbox.c:211
#define _(a)
Definition: message.h:28
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:246
&#39;IMAP&#39; Mailbox type
Definition: magic.h:42
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:51
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:120
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
Definition: hook.c:525
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
Definition: muttlib.c:1377
int crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:144
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
bool read
Definition: email.h:51
struct Mailbox * mailbox
Definition: context.h:51
bool old
Definition: email.h:50
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:103
enum MailboxType magic
mailbox type
Definition: mailbox.h:106
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:141
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition: nm_db.c:307
&#39;mbox&#39; Mailbox type
Definition: magic.h:37
A mailbox.
Definition: mailbox.h:83
#define PATH_MAX
Definition: mutt.h:48
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:741
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
bool flagged
marked important?
Definition: email.h:43
int msg_new
number of new messages
Definition: mailbox.h:96
struct Email * email
Definition: email.h:123
void * compress_info
compressed mbox module private data
Definition: mailbox.h:125
#define mutt_enter_fname(prompt, buf, buflen, mailbox)
Definition: curs_lib.h:76
int mutt_save_message_ctx(struct Email *e, bool delete, bool decode, bool decrypt, struct Mailbox *m)
Save a message to a given mailbox.
Definition: commands.c:939
struct Mailbox * mx_path_resolve(const char *path)
XXX.
Definition: mx.c:1506
int imap_copy_messages(struct Mailbox *m, struct EmailList *el, char *dest, bool delete)
Server COPY messages to another folder.
Definition: message.c:1535
#define STAILQ_EMPTY(head)
Definition: queue.h:346
List of Emails.
Definition: email.h:121
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition: nm_db.c:292
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:86
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:441
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:155
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:611
static char LastSaveFolder[PATH_MAX]
The folder the user last saved to.
Definition: commands.c:91

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool mutt_edit_content_type ( struct Email e,
struct Body b,
FILE *  fp 
)

Edit the content type of an attachment.

Parameters
eEmail
bAttachment
fpFile handle to the attachment
Return values
booltrue if a structural change is made

recvattach requires the return code to know when to regenerate the actx.

Definition at line 1175 of file commands.c.

1176 {
1177  char buf[1024];
1178  char obuf[1024];
1179  char tmp[256];
1180  char charset[256];
1181 
1182  bool charset_changed = false;
1183  bool type_changed = false;
1184  bool structure_changed = false;
1185 
1186  char *cp = mutt_param_get(&b->parameter, "charset");
1187  mutt_str_strfcpy(charset, cp, sizeof(charset));
1188 
1189  snprintf(buf, sizeof(buf), "%s/%s", TYPE(b), b->subtype);
1190  mutt_str_strfcpy(obuf, buf, sizeof(obuf));
1191  if (!TAILQ_EMPTY(&b->parameter))
1192  {
1193  size_t l = strlen(buf);
1194  struct Parameter *np = NULL;
1195  TAILQ_FOREACH(np, &b->parameter, entries)
1196  {
1197  mutt_addr_cat(tmp, sizeof(tmp), np->value, MimeSpecials);
1198  l += snprintf(buf + l, sizeof(buf) - l, "; %s=%s", np->attribute, tmp);
1199  }
1200  }
1201 
1202  if ((mutt_get_field("Content-Type: ", buf, sizeof(buf), 0) != 0) || (buf[0] == '\0'))
1203  return false;
1204 
1205  /* clean up previous junk */
1207  FREE(&b->subtype);
1208 
1209  mutt_parse_content_type(buf, b);
1210 
1211  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1212  type_changed = (mutt_str_strcasecmp(tmp, obuf) != 0);
1213  charset_changed =
1214  (mutt_str_strcasecmp(charset, mutt_param_get(&b->parameter, "charset")) != 0);
1215 
1216  /* if in send mode, check for conversion - current setting is default. */
1217 
1218  if (!e && (b->type == TYPE_TEXT) && charset_changed)
1219  {
1220  snprintf(tmp, sizeof(tmp), _("Convert to %s upon sending?"),
1221  mutt_param_get(&b->parameter, "charset"));
1222  int ans = mutt_yesorno(tmp, b->noconv ? MUTT_NO : MUTT_YES);
1223  if (ans != MUTT_ABORT)
1224  b->noconv = (ans == MUTT_NO);
1225  }
1226 
1227  /* inform the user */
1228 
1229  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1230  if (type_changed)
1231  mutt_message(_("Content-Type changed to %s"), tmp);
1232  if ((b->type == TYPE_TEXT) && charset_changed)
1233  {
1234  if (type_changed)
1235  mutt_sleep(1);
1236  mutt_message(b->noconv ? _("Character set changed to %s; not converting") :
1237  _("Character set changed to %s; converting"),
1238  mutt_param_get(&b->parameter, "charset"));
1239  }
1240 
1241  b->force_charset |= charset_changed;
1242 
1243  if (!is_multipart(b) && b->parts)
1244  {
1245  structure_changed = true;
1246  mutt_body_free(&b->parts);
1247  }
1248  if (!mutt_is_message_type(b->type, b->subtype) && b->email)
1249  {
1250  structure_changed = true;
1251  b->email->content = NULL;
1252  mutt_email_free(&b->email);
1253  }
1254 
1255  if (fp && !b->parts && (is_multipart(b) || mutt_is_message_type(b->type, b->subtype)))
1256  {
1257  structure_changed = true;
1258  mutt_parse_part(fp, b);
1259  }
1260 
1261  if ((WithCrypto != 0) && e)
1262  {
1263  if (e->content == b)
1264  e->security = SEC_NO_FLAGS;
1265 
1266  e->security |= crypt_query(b);
1267  }
1268 
1269  return structure_changed;
1270 }
char * attribute
Definition: parameter.h:39
#define NONULL(x)
Definition: string2.h:36
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1255
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
#define is_multipart(body)
Definition: mime.h:77
User aborted the question (with Ctrl-G)
Definition: quad.h:37
#define mutt_message(...)
Definition: logging.h:87
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:119
struct Body * content
list of MIME parts
Definition: email.h:93
bool noconv
don&#39;t do character set conversion
Definition: body.h:80
#define _(a)
Definition: message.h:28
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:77
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1471
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:330
bool force_charset
send mode: don&#39;t adjust the character set when in send-mode.
Definition: body.h:81
char * subtype
content-type subtype
Definition: body.h:37
void mutt_param_free(struct ParameterList *p)
Free a ParameterList.
Definition: parameter.c:59
void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials)
Copy a string and escape the specified characters.
Definition: address.c:681
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
Type: &#39;text/*&#39;.
Definition: mime.h:38
const char MimeSpecials[]
Characters that need special treatment in MIME.
Definition: mime.c:67
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:59
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:741
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
void mutt_email_free(struct Email **e)
Free an Email.
Definition: email.c:41
unsigned int type
content-type primary type
Definition: body.h:70
#define TYPE(body)
Definition: mime.h:83
void mutt_parse_content_type(const char *s, struct Body *ct)
Parse a content type.
Definition: parse.c:432
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1270
char * mutt_param_get(const struct ParameterList *p, const char *s)
Find a matching Parameter.
Definition: parameter.c:81
void mutt_body_free(struct Body **p)
Free a Body.
Definition: body.c:57
char * value
Definition: parameter.h:40
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:624
Attribute associated with a MIME part.
Definition: parameter.h:37
#define FREE(x)
Definition: memory.h:40
#define TAILQ_EMPTY(head)
Definition: queue.h:715
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
struct Email * email
header information for message/rfc822
Definition: body.h:60
#define WithCrypto
Definition: ncrypt.h:155
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:661

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool check_traditional_pgp ( struct Email e,
MuttRedrawFlags redraw 
)
static

Check for an inline PGP content.

Parameters
[in]eHeader of message to check
[out]redrawFlags if the screen needs redrawing, see MuttRedrawFlags
Return values
trueIf message contains inline PGP content

Definition at line 1278 of file commands.c.

1279 {
1280  bool rc = false;
1281 
1283 
1285  struct Message *msg = mx_msg_open(Context->mailbox, e->msgno);
1286  if (!msg)
1287  return 0;
1288  if (crypt_pgp_check_traditional(msg->fp, e->content, false))
1289  {
1290  e->security = crypt_query(e->content);
1291  *redraw |= REDRAW_FULL;
1292  rc = true;
1293  }
1294 
1296  mx_msg_close(Context->mailbox, &msg);
1297  return rc;
1298 }
The "current" mailbox.
Definition: context.h:37
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
struct Body * content
list of MIME parts
Definition: email.h:93
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:50
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: ncrypt.h:131
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1058
struct Mailbox * mailbox
Definition: context.h:51
A local copy of an email.
Definition: mx.h:81
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
int crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one)
Wrapper for CryptModuleSpecs::pgp_check_traditional()
Definition: cryptglue.c:237
FILE * fp
pointer to the message data
Definition: mx.h:83
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:661
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1010
int msgno
number displayed to the user
Definition: email.h:89

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool mutt_check_traditional_pgp ( struct EmailList *  el,
MuttRedrawFlags redraw 
)

Check if a message has inline PGP content.

Parameters
[in]elList of Emails to check
[out]redrawFlags if the screen needs redrawing, see MuttRedrawFlags
Return values
trueIf message contains inline PGP content

Definition at line 1306 of file commands.c.

1307 {
1308  bool rc = false;
1309  struct EmailNode *en = NULL;
1310  STAILQ_FOREACH(en, el, entries)
1311  {
1312  if (!(en->email->security & PGP_TRADITIONAL_CHECKED))
1313  rc = check_traditional_pgp(en->email, redraw) || rc;
1314  }
1315 
1316  return rc;
1317 }
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: ncrypt.h:131
static bool check_traditional_pgp(struct Email *e, MuttRedrawFlags *redraw)
Check for an inline PGP content.
Definition: commands.c:1278
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
SecurityFlags security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:39
struct Email * email
Definition: email.h:123
List of Emails.
Definition: email.h:121

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mutt_check_stats ( void  )

Forcibly update mailbox stats.

Definition at line 1322 of file commands.c.

1323 {
1325 }
The "current" mailbox.
Definition: context.h:37
#define MUTT_MAILBOX_CHECK_FORCE_STATS
Definition: mailbox.h:171
struct Mailbox * mailbox
Definition: context.h:51
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all AllMailboxes for new mail.
Definition: mailbox.c:336
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mailbox.h:170

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

unsigned char C_CryptVerifySig

Config: Verify PGP or SMIME signatures.

Definition at line 79 of file commands.c.

char* C_DisplayFilter

Config: External command to pre-process an email before display.

Definition at line 80 of file commands.c.

bool C_PipeDecode

Config: Decode the message when piping it.

Definition at line 81 of file commands.c.

char* C_PipeSep

Config: Separator to add between multiple piped messages.

Definition at line 82 of file commands.c.

bool C_PipeSplit

Config: Run the pipe command on each message separately.

Definition at line 83 of file commands.c.

bool C_PrintDecode

Config: Decode message before printing it.

Definition at line 84 of file commands.c.

bool C_PrintSplit

Config: Print multiple messages separately.

Definition at line 85 of file commands.c.

bool C_PromptAfter

Config: Pause after running an external pager.

Definition at line 86 of file commands.c.

const char* ExtPagerProgress = "all"
static

Definition at line 88 of file commands.c.

char LastSaveFolder[PATH_MAX] = ""
static

The folder the user last saved to.

Used by ci_save_message()

Definition at line 91 of file commands.c.