NeoMutt  2018-07-16 +2388-bcedc8
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 <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/mutt.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.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 "mutt_commands.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
#include "mutt_mailbox.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 "autocrypt/autocrypt.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 process_protected_headers (struct Email *e)
 Get the protected header and update the index. More...
 
int mutt_display_message (struct Mailbox *m, struct Email *e)
 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_original, 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_original, 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
  • Pietro Cerutti

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 process_protected_headers ( struct Email e)
static

Get the protected header and update the index.

Parameters
eEmail to update

Definition at line 104 of file commands.c.

105 {
106  struct Envelope *prot_headers = NULL;
107  regmatch_t pmatch[1];
108 
109 #ifdef USE_AUTOCRYPT
111  return;
112 #else
114  return;
115 #endif
116 
117  /* Grab protected headers to update in the index */
118  if (e->security & SEC_SIGN)
119  {
120  /* Don't update on a bad signature.
121  *
122  * This is a simplification. It's possible the headers are in the
123  * encrypted part of a nested encrypt/signed. But properly handling that
124  * case would require more complexity in the decryption handlers, which
125  * I'm not sure is worth it. */
126  if (!(e->security & SEC_GOODSIGN))
127  return;
128 
130  {
131  prot_headers = e->content->parts->mime_headers;
132  }
134  {
135  prot_headers = e->content->mime_headers;
136  }
137  }
138  if (!prot_headers && (e->security & SEC_ENCRYPT))
139  {
140  if (((WithCrypto & APPLICATION_PGP) != 0) &&
143  {
144  prot_headers = e->content->mime_headers;
145  }
146  else if (((WithCrypto & APPLICATION_SMIME) != 0) && mutt_is_application_smime(e->content))
147  {
148  prot_headers = e->content->mime_headers;
149  }
150  }
151 
152  /* Update protected headers in the index and header cache. */
153  if (C_CryptProtectedHeadersRead && prot_headers && prot_headers->subject &&
154  mutt_str_strcmp(e->env->subject, prot_headers->subject))
155  {
156  if (Context->mailbox->subj_hash && e->env->real_subj)
158 
159  mutt_str_replace(&e->env->subject, prot_headers->subject);
160  FREE(&e->env->disp_subj);
161  if (mutt_regex_capture(C_ReplyRegex, e->env->subject, 1, pmatch))
162  e->env->real_subj = e->env->subject + pmatch[0].rm_eo;
163  else
164  e->env->real_subj = e->env->subject;
165 
166  if (Context->mailbox->subj_hash)
168 
170 
171  /* Also persist back to the message headers if this is set */
173  {
175  e->changed = 1;
176  Context->mailbox->changed = 1;
177  }
178  }
179 
180 #ifdef USE_AUTOCRYPT
181  if (C_Autocrypt && (e->security & SEC_ENCRYPT) && prot_headers && prot_headers->autocrypt_gossip)
182  {
183  mutt_autocrypt_process_gossip_header(e, prot_headers);
184  }
185 #endif
186 }
The "current" mailbox.
Definition: context.h:36
void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data)
Remove an element from a Hash table.
Definition: hash.c:444
WHERE bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: globals.h:209
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
struct AutocryptHeader * autocrypt_gossip
Definition: envelope.h:86
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:68
struct Body * content
List of MIME parts.
Definition: email.h:92
int mutt_autocrypt_process_gossip_header(struct Email *e, struct Envelope *prot_headers)
Parse an Autocrypt email gossip header.
Definition: autocrypt.c:410
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:477
char * real_subj
Offset of the real subject.
Definition: envelope.h:67
bool changed
Email has been edited.
Definition: email.h:50
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:1610
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define MUTT_ENV_CHANGED_SUBJECT
Protected header update.
Definition: envelope.h:35
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
Definition: envelope.h:88
struct Mailbox * mailbox
Definition: context.h:50
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:124
struct Envelope * env
Envelope information.
Definition: email.h:91
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:412
struct Regex * C_ReplyRegex
Config: Regex to match message reply subjects like "re: ".
Definition: email_globals.c:37
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
WHERE bool C_CryptProtectedHeadersSave
Config: Save the cleartext Subject with the headers.
Definition: globals.h:286
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:515
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
WHERE bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: globals.h:285
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
bool mutt_regex_capture(const struct Regex *regex, const char *str, size_t nmatch, regmatch_t matches[])
match a regex against a string, with provided options
Definition: regex.c:594
char * subject
Email&#39;s subject.
Definition: envelope.h:66
struct Hash * subj_hash
Hash table by subject.
Definition: mailbox.h:139
#define FREE(x)
Definition: memory.h:40
bool changed
Mailbox has been modified.
Definition: mailbox.h:125
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:352
#define WithCrypto
Definition: ncrypt.h:160
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
The header of an Email.
Definition: envelope.h:54
#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:

int mutt_display_message ( struct Mailbox m,
struct Email e 
)

Display a message in the pager.

Parameters
mMailbox
eEmail to display
Return values
0Success
-1Error

Definition at line 195 of file commands.c.

196 {
197  char tempfile[PATH_MAX], buf[1024];
198  int rc = 0;
199  bool builtin = false;
201  CopyHeaderFlags chflags;
202  pid_t filterpid = -1;
203  int res;
204 
205  snprintf(buf, sizeof(buf), "%s/%s", TYPE(e->content), e->content->subtype);
206 
209 
210  /* see if crypto is needed for this message. if so, we should exit curses */
211  if ((WithCrypto != 0) && e->security)
212  {
213  if (e->security & SEC_ENCRYPT)
214  {
215  if (e->security & APPLICATION_SMIME)
218  return 0;
219 
220  cmflags |= MUTT_CM_VERIFY;
221  }
222  else if (e->security & SEC_SIGN)
223  {
224  /* find out whether or not the verify signature */
225  /* L10N: Used for the $crypt_verify_sig prompt */
226  if (query_quadoption(C_CryptVerifySig, _("Verify signature?")) == MUTT_YES)
227  {
228  cmflags |= MUTT_CM_VERIFY;
229  }
230  }
231  }
232 
233  if (cmflags & MUTT_CM_VERIFY || e->security & SEC_ENCRYPT)
234  {
235  if (e->security & APPLICATION_PGP)
236  {
237  if (!TAILQ_EMPTY(&e->env->from))
239 
241  }
242 
243  if (e->security & APPLICATION_SMIME)
245  }
246 
247  mutt_mktemp(tempfile, sizeof(tempfile));
248  FILE *fp_filter_out = NULL;
249  FILE *fp_out = mutt_file_fopen(tempfile, "w");
250  if (!fp_out)
251  {
252  mutt_error(_("Could not create temporary file"));
253  return 0;
254  }
255 
256  if (C_DisplayFilter)
257  {
258  fp_filter_out = fp_out;
259  fp_out = NULL;
260  filterpid = mutt_create_filter_fd(C_DisplayFilter, &fp_out, NULL, NULL, -1,
261  fileno(fp_filter_out), -1);
262  if (filterpid < 0)
263  {
264  mutt_error(_("Can't create display filter"));
265  mutt_file_fclose(&fp_filter_out);
266  unlink(tempfile);
267  return 0;
268  }
269  }
270 
271  if (!C_Pager || (mutt_str_strcmp(C_Pager, "builtin") == 0))
272  builtin = true;
273  else
274  {
275  struct HdrFormatInfo hfi;
276  hfi.ctx = Context;
277  hfi.mailbox = m;
278  hfi.pager_progress = ExtPagerProgress;
279  hfi.email = e;
280  mutt_make_string_info(buf, sizeof(buf), MuttIndexWindow->cols,
282  fputs(buf, fp_out);
283  fputs("\n\n", fp_out);
284  }
285 
286  chflags = (C_Weed ? (CH_WEED | CH_REORDER) : CH_NO_FLAGS) | CH_DECODE | CH_FROM | CH_DISPLAY;
287 #ifdef USE_NOTMUCH
288  if (m->magic == MUTT_NOTMUCH)
289  chflags |= CH_VIRTUAL;
290 #endif
291  res = mutt_copy_message(fp_out, m, e, cmflags, chflags);
292 
293  if (((mutt_file_fclose(&fp_out) != 0) && (errno != EPIPE)) || (res < 0))
294  {
295  mutt_error(_("Could not copy message"));
296  if (fp_filter_out)
297  {
298  mutt_wait_filter(filterpid);
299  mutt_file_fclose(&fp_filter_out);
300  }
301  mutt_file_unlink(tempfile);
302  return 0;
303  }
304 
305  if (fp_filter_out && (mutt_wait_filter(filterpid) != 0))
307 
308  mutt_file_fclose(&fp_filter_out); /* XXX - check result? */
309 
310  if (WithCrypto)
311  {
312  /* update crypto information for this message */
313  e->security &= ~(SEC_GOODSIGN | SEC_BADSIGN);
314  e->security |= crypt_query(e->content);
315 
316  /* Remove color cache for this message, in case there
317  * are color patterns for both ~g and ~V */
318  e->pair = 0;
319 
320  /* Process protected headers and autocrypt gossip headers */
322  }
323 
324  if (builtin)
325  {
326  if ((WithCrypto != 0) && (e->security & APPLICATION_SMIME) && (cmflags & MUTT_CM_VERIFY))
327  {
328  if (e->security & SEC_GOODSIGN)
329  {
330  if (crypt_smime_verify_sender(m, e) == 0)
331  mutt_message(_("S/MIME signature successfully verified"));
332  else
333  mutt_error(_("S/MIME certificate owner does not match sender"));
334  }
335  else if (e->security & SEC_PARTSIGN)
336  mutt_message(_("Warning: Part of this message has not been signed"));
337  else if (e->security & SEC_SIGN || e->security & SEC_BADSIGN)
338  mutt_error(_("S/MIME signature could NOT be verified"));
339  }
340 
341  if ((WithCrypto != 0) && (e->security & APPLICATION_PGP) && (cmflags & MUTT_CM_VERIFY))
342  {
343  if (e->security & SEC_GOODSIGN)
344  mutt_message(_("PGP signature successfully verified"));
345  else if (e->security & SEC_PARTSIGN)
346  mutt_message(_("Warning: Part of this message has not been signed"));
347  else if (e->security & SEC_SIGN)
348  mutt_message(_("PGP signature could NOT be verified"));
349  }
350 
351  struct Pager info = { 0 };
352  /* Invoke the builtin pager */
353  info.email = e;
354  info.ctx = Context;
355  rc = mutt_pager(NULL, tempfile, MUTT_PAGER_MESSAGE, &info);
356  }
357  else
358  {
359  int r;
360 
361  char cmd[STR_COMMAND];
362  mutt_endwin();
363  snprintf(cmd, sizeof(cmd), "%s %s", NONULL(C_Pager), tempfile);
364  r = mutt_system(cmd);
365  if (r == -1)
366  mutt_error(_("Error running \"%s\""), cmd);
367  unlink(tempfile);
368  if (!OptNoCurses)
369  keypad(stdscr, true);
370  if (r != -1)
371  mutt_set_flag(m, e, MUTT_READ, true);
372  if ((r != -1) && C_PromptAfter)
373  {
374  mutt_unget_event(mutt_any_key_to_continue(_("Command: ")), 0);
375  rc = km_dokey(MENU_PAGER);
376  }
377  else
378  rc = 0;
379  }
380 
381  return rc;
382 }
struct Context * ctx
Definition: hdrline.h:47
#define NONULL(x)
Definition: string2.h:37
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:68
#define TAILQ_FIRST(head)
Definition: queue.h:717
int km_dokey(int menu)
Determine what a keypress should do.
Definition: keymap.c:570
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
#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:92
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:48
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:715
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Mailbox.
Definition: copy.c:806
#define _(a)
Definition: message.h:28
static const char * ExtPagerProgress
Definition: commands.c:95
WHERE bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:46
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:31
int crypt_smime_verify_sender(struct Mailbox *m, struct Email *e)
Wrapper for CryptModuleSpecs::smime_verify_sender()
Definition: cryptglue.c:464
An email being displayed.
Definition: pager.h:65
unsigned char C_CryptVerifySig
Config: Verify PGP or SMIME signatures.
Definition: commands.c:86
#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
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
#define SEC_BADSIGN
Email has a bad signature.
Definition: ncrypt.h:125
Pager pager (email viewer)
Definition: keymap.h:78
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
struct Mailbox * mailbox
Definition: context.h:50
#define MUTT_CM_DISPLAY
Output is displayed to the user.
Definition: copy.h:38
Data passed to index_format_str()
Definition: hdrline.h:45
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:124
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:116
#define CH_WEED
Weed the headers?
Definition: copy.h:52
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
struct Envelope * env
Envelope information.
Definition: email.h:91
#define CH_VIRTUAL
Write virtual header lines too.
Definition: copy.h:72
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:1523
void crypt_invoke_message(SecurityFlags type)
Display an informative message.
Definition: cryptglue.c:145
struct Context * ctx
Current mailbox.
Definition: pager.h:67
#define mutt_mktemp(buf, buflen)
Definition: muttlib.h:76
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
WHERE struct Context * Context
Definition: globals.h:41
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:499
#define PATH_MAX
Definition: mutt.h:51
struct MuttWindow * MuttIndexWindow
Index Window.
Definition: mutt_window.c:40
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
#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:455
#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:65
void crypt_pgp_invoke_getkeys(struct Address *addr)
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()
Definition: cryptglue.c:264
#define CH_DISPLAY
Display result to user.
Definition: copy.h:69
Messages that have been read.
Definition: mutt.h:101
#define MUTT_CM_VERIFY
Do signature verification.
Definition: copy.h:46
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
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:53
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#define STR_COMMAND
Enough space for a long command line.
Definition: string2.h:35
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
bool C_PromptAfter
Config: Pause after running an external pager.
Definition: commands.c:93
#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:87
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:49
#define mutt_error(...)
Definition: logging.h:84
static void process_protected_headers(struct Email *e)
Get the protected header and update the index.
Definition: commands.c:104
WHERE char * C_Pager
Config: External command for viewing messages, or &#39;builtin&#39; to use NeoMutt&#39;s.
Definition: globals.h:139
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
#define TAILQ_EMPTY(head)
Definition: queue.h:715
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:2242
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:584
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:228
#define WithCrypto
Definition: ncrypt.h:160
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:696
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
int pair
Color-pair to use when displaying in the index.
Definition: email.h:81
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51
WHERE char * C_PagerFormat
Config: printf-like format string for the pager&#39;s status bar.
Definition: globals.h:140
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
#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 ci_bounce_message ( struct Mailbox m,
struct EmailList *  el 
)

Bounce an email.

Parameters
mMailbox
elList of Emails to bounce

Definition at line 389 of file commands.c.

390 {
391  if (!m || !el || STAILQ_EMPTY(el))
392  return;
393 
394  char prompt[129];
395  char scratch[128];
396  char buf[8192] = { 0 };
397  struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
398  char *err = NULL;
399  int rc;
400  int msg_count = 0;
401 
402  struct EmailNode *en = NULL;
403  STAILQ_FOREACH(en, el, entries)
404  {
405  /* RFC5322 mandates a From: header,
406  * so warn before bouncing messages without one */
407  if (!TAILQ_EMPTY(&en->email->env->from))
408  mutt_error(_("Warning: message contains no From: header"));
409 
410  msg_count++;
411  }
412 
413  if (msg_count == 1)
414  mutt_str_strfcpy(prompt, _("Bounce message to: "), sizeof(prompt));
415  else
416  mutt_str_strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt));
417 
418  rc = mutt_get_field(prompt, buf, sizeof(buf), MUTT_ALIAS);
419  if (rc || !buf[0])
420  return;
421 
422  mutt_addrlist_parse2(&al, buf);
423  if (TAILQ_EMPTY(&al))
424  {
425  mutt_error(_("Error parsing address"));
426  return;
427  }
428 
429  mutt_expand_aliases(&al);
430 
431  if (mutt_addrlist_to_intl(&al, &err) < 0)
432  {
433  mutt_error(_("Bad IDN: '%s'"), err);
434  FREE(&err);
435  mutt_addrlist_clear(&al);
436  return;
437  }
438 
439  buf[0] = '\0';
440  mutt_addrlist_write(buf, sizeof(buf), &al, true);
441 
442 #define EXTRA_SPACE (15 + 7 + 2)
443  snprintf(scratch, sizeof(scratch),
444  ngettext("Bounce message to %s?", "Bounce messages to %s?", msg_count), buf);
445 
447  {
448  mutt_simple_format(prompt, sizeof(prompt), 0, MuttMessageWindow->cols - EXTRA_SPACE,
449  JUSTIFY_LEFT, 0, scratch, sizeof(scratch), false);
450  mutt_str_strcat(prompt, sizeof(prompt), "...?");
451  }
452  else
453  snprintf(prompt, sizeof(prompt), "%s?", scratch);
454 
455  if (query_quadoption(C_Bounce, prompt) != MUTT_YES)
456  {
457  mutt_addrlist_clear(&al);
459  mutt_message(ngettext("Message not bounced", "Messages not bounced", msg_count));
460  return;
461  }
462 
464 
465  struct Message *msg = NULL;
466  STAILQ_FOREACH(en, el, entries)
467  {
468  msg = mx_msg_open(m, en->email->msgno);
469  if (!msg)
470  {
471  rc = -1;
472  break;
473  }
474 
475  rc = mutt_bounce_message(msg->fp, en->email, &al);
476  mx_msg_close(m, &msg);
477 
478  if (rc < 0)
479  break;
480  }
481 
482  mutt_addrlist_clear(&al);
483  /* If no error, or background, display message. */
484  if ((rc == 0) || (rc == S_BKG))
485  mutt_message(ngettext("Message bounced", "Messages bounced", msg_count));
486 }
WHERE unsigned char C_Bounce
Config: Confirm before bouncing a message.
Definition: globals.h:189
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:289
Left justify the text.
Definition: curs_lib.h:46
#define MUTT_ALIAS
Do alias "completion" by calling up the alias-menu.
Definition: mutt.h:64
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
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1378
#define _(a)
Definition: message.h:28
#define S_BKG
Definition: string2.h:43
size_t mutt_addrlist_write(char *buf, size_t buflen, const struct AddressList *al, bool display)
Write an Address to a buffer.
Definition: address.c:1134
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition: address.c:603
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1089
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:95
struct Envelope * env
Envelope information.
Definition: email.h:91
int mutt_bounce_message(FILE *fp, struct Email *e, struct AddressList *to)
Bounce an email message.
Definition: sendlib.c:3057
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:1262
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 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:395
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1213
struct Email * email
Email in the list.
Definition: email.h:122
#define mutt_error(...)
Definition: logging.h:84
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:120
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:42
#define TAILQ_EMPTY(head)
Definition: queue.h:715
#define EXTRA_SPACE
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:631
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1041
int msgno
Number displayed to the user.
Definition: email.h:88
void mutt_simple_format(char *buf, size_t buflen, int min_width, int max_width, enum FormatJustify justify, char pad_char, const char *s, size_t n, bool arboreal)
Format a string, like snprintf()
Definition: curs_lib.c:996

+ 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 495 of file commands.c.

497 {
498  if (decode)
499  {
500  *cmflags |= MUTT_CM_DECODE | MUTT_CM_CHARCONV;
501  *chflags |= CH_DECODE | CH_REORDER;
502 
503  if (C_Weed)
504  {
505  *chflags |= CH_WEED;
506  *cmflags |= MUTT_CM_WEED;
507  }
508  }
509 
510  if (print)
511  *cmflags |= MUTT_CM_PRINTING;
512 }
#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:40

+ 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 522 of file commands.c.

523 {
525  CopyHeaderFlags chflags = CH_FROM;
526 
527  pipe_set_flags(decode, print, &cmflags, &chflags);
528 
529  if ((WithCrypto != 0) && decode && e->security & SEC_ENCRYPT)
530  {
532  return;
533  endwin();
534  }
535 
536  if (decode)
538 
539  mutt_copy_message(fp, m, e, cmflags, chflags);
540 }
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:48
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:55
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Copy a message from a Mailbox.
Definition: copy.c:806
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:122
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
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
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:160
static void pipe_set_flags(bool decode, bool print, CopyMessageFlags *cmflags, CopyHeaderFlags *chflags)
Generate flags for copy header/message.
Definition: commands.c:495

+ 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 556 of file commands.c.

558 {
559  if (!m || !el)
560  return 1;
561 
562  struct EmailNode *en = STAILQ_FIRST(el);
563  if (!en)
564  return 1;
565 
566  int rc = 0;
567  pid_t pid;
568  FILE *fp_out = NULL;
569 
570  if (!STAILQ_NEXT(en, entries))
571  {
572  /* handle a single message */
574 
575  if ((WithCrypto != 0) && decode)
576  {
578  if ((en->email->security & SEC_ENCRYPT) &&
580  {
581  return 1;
582  }
583  }
584  mutt_endwin();
585 
586  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
587  if (pid < 0)
588  {
589  mutt_perror(_("Can't create filter process"));
590  return 1;
591  }
592 
593  OptKeepQuiet = true;
594  pipe_msg(m, en->email, fp_out, decode, print);
595  mutt_file_fclose(&fp_out);
596  rc = mutt_wait_filter(pid);
597  OptKeepQuiet = false;
598  }
599  else
600  {
601  /* handle tagged messages */
602  if ((WithCrypto != 0) && decode)
603  {
604  STAILQ_FOREACH(en, el, entries)
605  {
608  if ((en->email->security & SEC_ENCRYPT) &&
610  {
611  return 1;
612  }
613  }
614  }
615 
616  if (split)
617  {
618  STAILQ_FOREACH(en, el, entries)
619  {
621  mutt_endwin();
622  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
623  if (pid < 0)
624  {
625  mutt_perror(_("Can't create filter process"));
626  return 1;
627  }
628  OptKeepQuiet = true;
629  pipe_msg(m, en->email, fp_out, decode, print);
630  /* add the message separator */
631  if (sep)
632  fputs(sep, fp_out);
633  mutt_file_fclose(&fp_out);
634  if (mutt_wait_filter(pid) != 0)
635  rc = 1;
636  OptKeepQuiet = false;
637  }
638  }
639  else
640  {
641  mutt_endwin();
642  pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
643  if (pid < 0)
644  {
645  mutt_perror(_("Can't create filter process"));
646  return 1;
647  }
648  OptKeepQuiet = true;
649  STAILQ_FOREACH(en, el, entries)
650  {
652  pipe_msg(m, en->email, fp_out, decode, print);
653  /* add the message separator */
654  if (sep)
655  fputs(sep, fp_out);
656  }
657  mutt_file_fclose(&fp_out);
658  if (mutt_wait_filter(pid) != 0)
659  rc = 1;
660  OptKeepQuiet = false;
661  }
662  }
663 
664  if ((rc != 0) || C_WaitKey)
666  return rc;
667 }
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
#define mutt_perror(...)
Definition: logging.h:85
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
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
static void pipe_msg(struct Mailbox *m, struct Email *e, FILE *fp, bool decode, bool print)
Pipe a message.
Definition: commands.c:522
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:149
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 STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
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 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 Email * email
Email in the list.
Definition: email.h:122
List of Emails.
Definition: email.h:120
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
int mutt_wait_filter(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:228
WHERE bool OptKeepQuiet
(pseudo) shut up the message and refresh functions while we are executing an external program...
Definition: options.h:37
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:160

+ 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 674 of file commands.c.

675 {
676  if (!m || !el)
677  return;
678 
679  char buf[1024] = { 0 };
680 
681  if ((mutt_get_field(_("Pipe to command: "), buf, sizeof(buf), MUTT_CMD) != 0) ||
682  (buf[0] == '\0'))
683  {
684  return;
685  }
686 
687  mutt_expand_path(buf, sizeof(buf));
688  pipe_message(m, el, buf, C_PipeDecode, false, C_PipeSplit, C_PipeSep);
689 }
#define _(a)
Definition: message.h:28
char * C_PipeSep
Config: Separator to add between multiple piped messages.
Definition: commands.c:89
bool C_PipeDecode
Config: Decode the message when piping it.
Definition: commands.c:88
#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
bool C_PipeSplit
Config: Run the pipe command on each message separately.
Definition: commands.c:90
#define MUTT_CMD
Do completion on previous word.
Definition: mutt.h:67
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:556

+ 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 696 of file commands.c.

697 {
698  if (!m || !el)
699  return;
700 
701  if (C_Print && !C_PrintCommand)
702  {
703  mutt_message(_("No printing command has been defined"));
704  return;
705  }
706 
707  int msg_count = 0;
708  struct EmailNode *en = NULL;
709  STAILQ_FOREACH(en, el, entries)
710  {
711  msg_count++;
712  }
713 
714  if (query_quadoption(C_Print, (msg_count == 1) ?
715  _("Print message?") :
716  _("Print tagged messages?")) != MUTT_YES)
717  {
718  return;
719  }
720 
721  if (pipe_message(m, el, C_PrintCommand, C_PrintDecode, true, C_PrintSplit, "\f") == 0)
722  mutt_message(ngettext("Message printed", "Messages printed", msg_count));
723  else
724  {
725  mutt_message(ngettext("Message could not be printed",
726  "Messages could not be printed", msg_count));
727  }
728 }
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
#define mutt_message(...)
Definition: logging.h:83
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:92
#define _(a)
Definition: message.h:28
bool C_PrintDecode
Config: Decode message before printing it.
Definition: commands.c:91
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
WHERE char * C_PrintCommand
Config: External command to print a message.
Definition: globals.h:143
List of Emails.
Definition: email.h:120
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:556

+ 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 735 of file commands.c.

736 {
737  enum SortType method = C_Sort; /* save the current method in case of abort */
738  enum SortType new_sort = C_Sort;
739 
740  switch (mutt_multi_choice(reverse ?
741  /* L10N: The highlighted letters must match the "Sort" options */
742  _("Rev-Sort "
743  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
744  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?") :
745  /* L10N: The highlighted letters must match the "Rev-Sort" options */
746  _("Sort "
747  "(d)ate/(f)rm/(r)ecv/(s)ubj/t(o)/(t)hread/"
748  "(u)nsort/si(z)e/s(c)ore/s(p)am/(l)abel?"),
749  /* L10N: These must match the highlighted letters from "Sort" and "Rev-Sort" */
750  _("dfrsotuzcpl")))
751  {
752  case -1: /* abort - don't resort */
753  return -1;
754 
755  case 1: /* (d)ate */
756  new_sort = SORT_DATE;
757  break;
758 
759  case 2: /* (f)rm */
760  new_sort = SORT_FROM;
761  break;
762 
763  case 3: /* (r)ecv */
764  new_sort = SORT_RECEIVED;
765  break;
766 
767  case 4: /* (s)ubj */
768  new_sort = SORT_SUBJECT;
769  break;
770 
771  case 5: /* t(o) */
772  new_sort = SORT_TO;
773  break;
774 
775  case 6: /* (t)hread */
776  new_sort = SORT_THREADS;
777  break;
778 
779  case 7: /* (u)nsort */
780  new_sort = SORT_ORDER;
781  break;
782 
783  case 8: /* si(z)e */
784  new_sort = SORT_SIZE;
785  break;
786 
787  case 9: /* s(c)ore */
788  new_sort = SORT_SCORE;
789  break;
790 
791  case 10: /* s(p)am */
792  new_sort = SORT_SPAM;
793  break;
794 
795  case 11: /* (l)abel */
796  new_sort = SORT_LABEL;
797  break;
798  }
799  if (reverse)
800  new_sort |= SORT_REVERSE;
801 
802  cs_str_native_set(Config, "sort", new_sort, NULL);
803  return (C_Sort != method) ? 0 : -1; /* no need to resort if it's the same */
804 }
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:839
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:770

+ 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 809 of file commands.c.

810 {
811  char buf[1024];
812 
813  buf[0] = '\0';
814  if (mutt_get_field(_("Shell command: "), buf, sizeof(buf), MUTT_CMD) != 0)
815  return;
816 
817  if ((buf[0] == '\0') && C_Shell)
818  mutt_str_strfcpy(buf, C_Shell, sizeof(buf));
819  if (buf[0] == '\0')
820  return;
821 
823  mutt_endwin();
824  fflush(stdout);
825  int rc = mutt_system(buf);
826  if (rc == -1)
827  mutt_debug(LL_DEBUG1, "Error running \"%s\"", buf);
828 
829  if ((rc != 0) || C_WaitKey)
832 }
The "current" mailbox.
Definition: context.h:36
#define _(a)
Definition: message.h:28
WHERE char * C_Shell
Config: External command to run subshells in.
Definition: globals.h:146
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
struct Mailbox * mailbox
Definition: context.h:50
void mutt_window_clearline(struct MuttWindow *win, int row)
Clear a row of a Window.
Definition: mutt_window.c:95
#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
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:126
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_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:17
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
Log at debug level 1.
Definition: logging.h:56
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:42
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:51

+ 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 837 of file commands.c.

838 {
839  char buf[1024] = { 0 };
840 
841  /* if enter is pressed after : with no command, just return */
842  if ((mutt_get_field(":", buf, sizeof(buf), MUTT_COMMAND) != 0) || !buf[0])
843  return;
844 
845  struct Buffer *err = mutt_buffer_alloc(256);
846  struct Buffer *token = mutt_buffer_alloc(256);
847 
848  /* check if buf is a valid icommand, else fall back quietly to parse_rc_lines */
849  enum CommandResult rc = mutt_parse_icommand(buf, err);
850  if (!mutt_buffer_is_empty(err))
851  {
852  /* since errbuf could potentially contain printf() sequences in it,
853  * we must call mutt_error() in this fashion so that vsprintf()
854  * doesn't expect more arguments that we passed */
855  if (rc == MUTT_CMD_ERROR)
856  mutt_error("%s", err->data);
857  else
858  mutt_warning("%s", err->data);
859  }
860  else if (rc != MUTT_CMD_SUCCESS)
861  {
862  rc = mutt_parse_rc_line(buf, token, err);
863  if (!mutt_buffer_is_empty(err))
864  {
865  if (rc == MUTT_CMD_SUCCESS) /* command succeeded with message */
866  mutt_message("%s", err->data);
867  else /* error executing command */
868  mutt_error("%s", err->data);
869  }
870  }
871  /* else successful command */
872 
873  mutt_buffer_free(&token);
874  mutt_buffer_free(&err);
875 }
#define mutt_warning(...)
Definition: logging.h:82
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:33
Error: Can&#39;t help the user.
Definition: mutt_commands.h:35
#define mutt_message(...)
Definition: logging.h:83
String manipulation buffer.
Definition: buffer.h:33
enum CommandResult mutt_parse_icommand(char *line, struct Buffer *err)
Parse an informational command.
Definition: icommands.c:74
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
struct Buffer * mutt_buffer_alloc(size_t size)
Create a new Buffer.
Definition: buffer.c:296
#define MUTT_COMMAND
Do command completion.
Definition: mutt.h:70
void mutt_buffer_free(struct Buffer **p)
Release a Buffer and its contents.
Definition: buffer.c:134
char * data
Pointer to data.
Definition: buffer.h:35
Success: Command worked.
Definition: mutt_commands.h:37
#define mutt_error(...)
Definition: logging.h:84
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:283
enum CommandResult mutt_parse_rc_line(char *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: init.c:3216

+ 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 881 of file commands.c.

882 {
883  const char *pfx = NULL;
884  char buf[128];
885 
886  struct AddressList *al = mutt_get_address(env, &pfx);
887  if (!al)
888  return;
889 
890  /* Note: We don't convert IDNA to local representation this time.
891  * That is intentional, so the user has an opportunity to copy &
892  * paste the on-the-wire form of the address to other, IDN-unable
893  * software. */
894  buf[0] = '\0';
895  mutt_addrlist_write(buf, sizeof(buf), al, false);
896  mutt_message("%s: %s", pfx, buf);
897 }
#define mutt_message(...)
Definition: logging.h:83
struct AddressList * mutt_get_address(struct Envelope *env, const char **pfxp)
Get an Address from an Envelope.
Definition: alias.c:321
size_t mutt_addrlist_write(char *buf, size_t buflen, const struct AddressList *al, bool display)
Write an Address to a buffer.
Definition: address.c:1134

+ 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 907 of file commands.c.

909 {
910  *cmflags = MUTT_CM_NO_FLAGS;
911  *chflags = CH_UPDATE_LEN;
912 
913  if ((WithCrypto != 0) && !decode && decrypt && (e->security & SEC_ENCRYPT))
914  {
916  {
917  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
918  *cmflags = MUTT_CM_DECODE_PGP;
919  }
920  else if (((WithCrypto & APPLICATION_PGP) != 0) &&
922  {
923  decode = 1;
924  }
925  else if (((WithCrypto & APPLICATION_SMIME) != 0) &&
927  {
928  *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
929  *cmflags = MUTT_CM_DECODE_SMIME;
930  }
931  }
932 
933  if (decode)
934  {
935  *chflags = CH_XMIT | CH_MIME | CH_TXTPLAIN;
936  *cmflags = MUTT_CM_DECODE | MUTT_CM_CHARCONV;
937 
938  if (!decrypt) /* If decode doesn't kick in for decrypt, */
939  {
940  *chflags |= CH_DECODE; /* then decode RFC2047 headers, */
941 
942  if (C_Weed)
943  {
944  *chflags |= CH_WEED; /* and respect $weed. */
945  *cmflags |= MUTT_CM_WEED;
946  }
947  }
948  }
949 }
#define CH_MIME
Ignore MIME fields.
Definition: copy.h:60
struct Body * content
List of MIME parts.
Definition: email.h:92
#define MUTT_CM_WEED
Weed message/rfc822 attachment headers.
Definition: copy.h:40
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#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:453
#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:560
#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: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
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
#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:160
#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:40
#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:

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

Save a message to a given mailbox.

Parameters
eEmail
delete_originalIf 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 961 of file commands.c.

963 {
965  CopyHeaderFlags chflags = CH_NO_FLAGS;
966  int rc;
967 
968  set_copy_flags(e, decode, decrypt, &cmflags, &chflags);
969 
970  if (decode || decrypt)
972 
973  rc = mutt_append_message(m, Context->mailbox, e, cmflags, chflags);
974  if (rc != 0)
975  return rc;
976 
977  if (delete_original)
978  {
981  if (C_DeleteUntag)
982  mutt_set_flag(Context->mailbox, e, MUTT_TAG, false);
983  }
984 
985  return 0;
986 }
The "current" mailbox.
Definition: context.h:36
#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:907
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:48
Messages to be purged (bypass trash)
Definition: mutt.h:105
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:50
Messages to be deleted.
Definition: mutt.h:103
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
Tagged messages.
Definition: mutt.h:108
WHERE bool C_DeleteUntag
Config: Untag messages when they are marked for deletion.
Definition: globals.h:220
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:876

+ 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_original,
bool  decode,
bool  decrypt 
)

Save an email.

Parameters
mMailbox
elList of Emails to save
delete_originalIf 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 998 of file commands.c.

1000 {
1001  if (!el || STAILQ_EMPTY(el))
1002  return -1;
1003 
1004  bool need_passphrase = false;
1005  int app = 0;
1006  char buf[PATH_MAX];
1007  const char *prompt = NULL;
1008  struct stat st;
1009  struct EmailNode *en = STAILQ_FIRST(el);
1010  bool single = !STAILQ_NEXT(en, entries);
1011 
1012  if (delete_original)
1013  {
1014  if (decode)
1015  prompt = single ? _("Decode-save to mailbox") : _("Decode-save tagged to mailbox");
1016  else if (decrypt)
1017  prompt = single ? _("Decrypt-save to mailbox") : _("Decrypt-save tagged to mailbox");
1018  else
1019  prompt = single ? _("Save to mailbox") : _("Save tagged to mailbox");
1020  }
1021  else
1022  {
1023  if (decode)
1024  prompt = single ? _("Decode-copy to mailbox") : _("Decode-copy tagged to mailbox");
1025  else if (decrypt)
1026  prompt = single ? _("Decrypt-copy to mailbox") : _("Decrypt-copy tagged to mailbox");
1027  else
1028  prompt = single ? _("Copy to mailbox") : _("Copy tagged to mailbox");
1029  }
1030 
1031  if (WithCrypto)
1032  {
1033  need_passphrase = (en->email->security & SEC_ENCRYPT);
1034  app = en->email->security;
1035  }
1037  mutt_default_save(buf, sizeof(buf), en->email);
1038 
1039  mutt_pretty_mailbox(buf, sizeof(buf));
1040  if (mutt_enter_fname(prompt, buf, sizeof(buf), false) == -1)
1041  return -1;
1042 
1043  size_t pathlen = strlen(buf);
1044  if (pathlen == 0)
1045  return -1;
1046 
1047  /* Trim any trailing '/' */
1048  if (buf[pathlen - 1] == '/')
1049  buf[pathlen - 1] = '\0';
1050 
1051  /* This is an undocumented feature of ELM pointed out to me by Felix von
1052  * Leitner <leitner@prz.fu-berlin.de> */
1053  if (mutt_str_strcmp(buf, ".") == 0)
1054  mutt_str_strfcpy(buf, LastSaveFolder, sizeof(buf));
1055  else
1057 
1058  mutt_expand_path(buf, sizeof(buf));
1059 
1060  /* check to make sure that this file is really the one the user wants */
1061  if (mutt_save_confirm(buf, &st) != 0)
1062  return -1;
1063 
1064  if ((WithCrypto != 0) && need_passphrase && (decode || decrypt) &&
1065  !crypt_valid_passphrase(app))
1066  {
1067  return -1;
1068  }
1069 
1070  mutt_message(_("Copying to %s..."), buf);
1071 
1072 #ifdef USE_IMAP
1073  if ((m->magic == MUTT_IMAP) && !(decode || decrypt) &&
1074  (imap_path_probe(buf, NULL) == MUTT_IMAP))
1075  {
1076  switch (imap_copy_messages(m, el, buf, delete_original))
1077  {
1078  /* success */
1079  case 0:
1080  mutt_clear_error();
1081  return 0;
1082  /* non-fatal error: continue to fetch/append */
1083  case 1:
1084  break;
1085  /* fatal error, abort */
1086  case -1:
1087  return -1;
1088  }
1089  }
1090 #endif
1091 
1092  struct Mailbox *m_save = mx_path_resolve(buf);
1093  struct Context *ctx_save = mx_mbox_open(m_save, MUTT_NEWFOLDER);
1094  if (!ctx_save)
1095  {
1096  mailbox_free(&m_save);
1097  return -1;
1098  }
1099  bool old_append = m_save->append;
1100  m_save->append = true;
1101 
1102 #ifdef USE_COMPRESSED
1103  /* If we're saving to a compressed mailbox, the stats won't be updated
1104  * until the next open. Until then, improvise. */
1105  struct Mailbox *m_comp = NULL;
1106  if (ctx_save->mailbox->compress_info)
1107  {
1108  m_comp = mailbox_find(ctx_save->mailbox->realpath);
1109  }
1110  /* We probably haven't been opened yet */
1111  if (m_comp && (m_comp->msg_count == 0))
1112  m_comp = NULL;
1113 #endif
1114  if (single)
1115  {
1116  if (mutt_save_message_ctx(en->email, delete_original, decode, decrypt,
1117  ctx_save->mailbox) != 0)
1118  {
1119  m_save->append = old_append;
1120  mx_mbox_close(&ctx_save);
1121  return -1;
1122  }
1123 #ifdef USE_COMPRESSED
1124  if (m_comp)
1125  {
1126  m_comp->msg_count++;
1127  if (!en->email->read)
1128  {
1129  m_comp->msg_unread++;
1130  if (!en->email->old)
1131  m_comp->msg_new++;
1132  }
1133  if (en->email->flagged)
1134  m_comp->msg_flagged++;
1135  }
1136 #endif
1137  }
1138  else
1139  {
1140  int rc = 0;
1141 
1142 #ifdef USE_NOTMUCH
1143  if (m->magic == MUTT_NOTMUCH)
1144  nm_db_longrun_init(m, true);
1145 #endif
1146  STAILQ_FOREACH(en, el, entries)
1147  {
1149  rc = mutt_save_message_ctx(en->email, delete_original, decode, decrypt,
1150  ctx_save->mailbox);
1151  if (rc != 0)
1152  break;
1153 #ifdef USE_COMPRESSED
1154  if (m_comp)
1155  {
1156  struct Email *e2 = en->email;
1157  m_comp->msg_count++;
1158  if (!e2->read)
1159  {
1160  m_comp->msg_unread++;
1161  if (!e2->old)
1162  m_comp->msg_new++;
1163  }
1164  if (e2->flagged)
1165  m_comp->msg_flagged++;
1166  }
1167 #endif
1168  }
1169 #ifdef USE_NOTMUCH
1170  if (m->magic == MUTT_NOTMUCH)
1171  nm_db_longrun_done(m);
1172 #endif
1173  if (rc != 0)
1174  {
1175  m_save->append = old_append;
1176  mx_mbox_close(&ctx_save);
1177  return -1;
1178  }
1179  }
1180 
1181  const bool need_mailbox_cleanup = ((ctx_save->mailbox->magic == MUTT_MBOX) ||
1182  (ctx_save->mailbox->magic == MUTT_MMDF));
1183 
1184  m_save->append = old_append;
1185  mx_mbox_close(&ctx_save);
1186 
1187  if (need_mailbox_cleanup)
1188  mutt_mailbox_cleanup(buf, &st);
1189 
1190  mutt_clear_error();
1191  return 0;
1192 }
int mutt_save_message_ctx(struct Email *e, bool delete_original, bool decode, bool decrypt, struct Mailbox *m)
Save a message to a given mailbox.
Definition: commands.c:961
The "current" mailbox.
Definition: context.h:36
int msg_count
Total number of messages.
Definition: mailbox.h:102
The envelope/body of an email.
Definition: email.h:39
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2430
int msg_unread
Number of unread messages.
Definition: mailbox.h:103
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:558
void mutt_mailbox_cleanup(const char *path, struct stat *st)
Restore the timestamp of a mailbox.
Definition: mutt_mailbox.c:353
#define mutt_message(...)
Definition: logging.h:83
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:104
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
Definition: mailbox.c:79
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:95
#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:254
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:52
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
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
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
bool read
Email is read.
Definition: email.h:53
struct Mailbox * mailbox
Definition: context.h:50
bool old
Email is seen, but unread.
Definition: email.h:52
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:55
enum MailboxType magic
Mailbox type.
Definition: mailbox.h:116
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:143
int imap_copy_messages(struct Mailbox *m, struct EmailList *el, char *dest, bool delete_original)
Server COPY messages to another folder.
Definition: message.c:1579
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition: nm_db.c:305
A mailbox.
Definition: mailbox.h:92
#define PATH_MAX
Definition: mutt.h:51
&#39;mmdf&#39; Mailbox type
Definition: mailbox.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:750
bool append
Mailbox is opened in append mode.
Definition: mailbox.h:124
void mutt_pretty_mailbox(char *buf, size_t buflen)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:612
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
#define STAILQ_NEXT(elm, field)
Definition: queue.h:398
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
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:53
&#39;mbox&#39; Mailbox type
Definition: mailbox.h:47
bool flagged
Marked important?
Definition: email.h:45
int msg_new
Number of new messages.
Definition: mailbox.h:106
struct Email * email
Email in the list.
Definition: email.h:122
void * compress_info
Compressed mbox module private data.
Definition: mailbox.h:135
#define mutt_enter_fname(prompt, buf, buflen, mailbox)
Definition: curs_lib.h:85
struct Mailbox * mx_path_resolve(const char *path)
XXX.
Definition: mx.c:1541
#define STAILQ_EMPTY(head)
Definition: queue.h:346
List of Emails.
Definition: email.h:120
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition: nm_db.c:290
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:579
#define MUTT_NEWFOLDER
Create a new folder - same as MUTT_APPEND,.
Definition: mx.h:55
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:52
#define STAILQ_FIRST(head)
Definition: queue.h:348
#define WithCrypto
Definition: ncrypt.h:160
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:615
static char LastSaveFolder[PATH_MAX]
The folder the user last saved to.
Definition: commands.c:98

+ 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 1203 of file commands.c.

1204 {
1205  char buf[1024];
1206  char obuf[1024];
1207  char tmp[256];
1208  char charset[256];
1209 
1210  bool charset_changed = false;
1211  bool type_changed = false;
1212  bool structure_changed = false;
1213 
1214  char *cp = mutt_param_get(&b->parameter, "charset");
1215  mutt_str_strfcpy(charset, cp, sizeof(charset));
1216 
1217  snprintf(buf, sizeof(buf), "%s/%s", TYPE(b), b->subtype);
1218  mutt_str_strfcpy(obuf, buf, sizeof(obuf));
1219  if (!TAILQ_EMPTY(&b->parameter))
1220  {
1221  size_t l = strlen(buf);
1222  struct Parameter *np = NULL;
1223  TAILQ_FOREACH(np, &b->parameter, entries)
1224  {
1225  mutt_addr_cat(tmp, sizeof(tmp), np->value, MimeSpecials);
1226  l += snprintf(buf + l, sizeof(buf) - l, "; %s=%s", np->attribute, tmp);
1227  if (l >= sizeof(buf))
1228  {
1229  // L10N: e.g. "text/plain; charset=UTF-8; ..."
1230  mutt_error(_("Content type is too long"));
1231  return false;
1232  }
1233  }
1234  }
1235 
1236  if ((mutt_get_field("Content-Type: ", buf, sizeof(buf), 0) != 0) || (buf[0] == '\0'))
1237  return false;
1238 
1239  /* clean up previous junk */
1241  FREE(&b->subtype);
1242 
1243  mutt_parse_content_type(buf, b);
1244 
1245  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1246  type_changed = (mutt_str_strcasecmp(tmp, obuf) != 0);
1247  charset_changed =
1248  (mutt_str_strcasecmp(charset, mutt_param_get(&b->parameter, "charset")) != 0);
1249 
1250  /* if in send mode, check for conversion - current setting is default. */
1251 
1252  if (!e && (b->type == TYPE_TEXT) && charset_changed)
1253  {
1254  snprintf(tmp, sizeof(tmp), _("Convert to %s upon sending?"),
1255  mutt_param_get(&b->parameter, "charset"));
1256  int ans = mutt_yesorno(tmp, b->noconv ? MUTT_NO : MUTT_YES);
1257  if (ans != MUTT_ABORT)
1258  b->noconv = (ans == MUTT_NO);
1259  }
1260 
1261  /* inform the user */
1262 
1263  snprintf(tmp, sizeof(tmp), "%s/%s", TYPE(b), NONULL(b->subtype));
1264  if (type_changed)
1265  mutt_message(_("Content-Type changed to %s"), tmp);
1266  if ((b->type == TYPE_TEXT) && charset_changed)
1267  {
1268  if (type_changed)
1269  mutt_sleep(1);
1270  mutt_message(b->noconv ? _("Character set changed to %s; not converting") :
1271  _("Character set changed to %s; converting"),
1272  mutt_param_get(&b->parameter, "charset"));
1273  }
1274 
1275  b->force_charset |= charset_changed;
1276 
1277  if (!is_multipart(b) && b->parts)
1278  {
1279  structure_changed = true;
1280  mutt_body_free(&b->parts);
1281  }
1282  if (!mutt_is_message_type(b->type, b->subtype) && b->email)
1283  {
1284  structure_changed = true;
1285  b->email->content = NULL;
1286  email_free(&b->email);
1287  }
1288 
1289  if (fp && !b->parts && (is_multipart(b) || mutt_is_message_type(b->type, b->subtype)))
1290  {
1291  structure_changed = true;
1292  mutt_parse_part(fp, b);
1293  }
1294 
1295  if ((WithCrypto != 0) && e)
1296  {
1297  if (e->content == b)
1298  e->security = SEC_NO_FLAGS;
1299 
1300  e->security |= crypt_query(b);
1301  }
1302 
1303  return structure_changed;
1304 }
char * attribute
Parameter name.
Definition: parameter.h:34
#define NONULL(x)
Definition: string2.h:37
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 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:83
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:121
struct Body * content
List of MIME parts.
Definition: email.h:92
bool noconv
Don&#39;t do character set conversion.
Definition: body.h:73
#define _(a)
Definition: message.h:28
#define mutt_get_field(field, buf, buflen, complete)
Definition: curs_lib.h:86
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1502
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:332
bool force_charset
Send mode: don&#39;t adjust the character set when in send-mode.
Definition: body.h:74
void mutt_param_free(struct ParameterList *pl)
Free a ParameterList.
Definition: parameter.c:61
char * subtype
content-type subtype
Definition: body.h:37
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:54
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
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 TYPE(body)
Definition: mime.h:83
void mutt_parse_content_type(const char *s, struct Body *ct)
Parse a content type.
Definition: parse.c:457
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
Definition: parse.c:1400
void mutt_body_free(struct Body **p)
Free a Body.
Definition: body.c:57
char * value
Parameter value.
Definition: parameter.h:35
#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
Attribute associated with a MIME part.
Definition: parameter.h:32
#define FREE(x)
Definition: memory.h:40
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
#define TAILQ_EMPTY(head)
Definition: queue.h:715
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:41
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
struct Email * email
header information for message/rfc822
Definition: body.h:55
#define WithCrypto
Definition: ncrypt.h:160
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:696
void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials)
Copy a string and wrap it in quotes if it contains special characters.
Definition: address.c:668

+ 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]eEmail to check
[out]redrawFlags if the screen needs redrawing, see MuttRedrawFlags
Return values
trueIf message contains inline PGP content

Definition at line 1312 of file commands.c.

1313 {
1314  bool rc = false;
1315 
1317 
1319  struct Message *msg = mx_msg_open(Context->mailbox, e->msgno);
1320  if (!msg)
1321  return 0;
1322  if (crypt_pgp_check_traditional(msg->fp, e->content, false))
1323  {
1324  e->security = crypt_query(e->content);
1325  *redraw |= REDRAW_FULL;
1326  rc = true;
1327  }
1328 
1330  mx_msg_close(Context->mailbox, &msg);
1331  return rc;
1332 }
The "current" mailbox.
Definition: context.h:36
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:47
struct Body * content
List of MIME parts.
Definition: email.h:92
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:48
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: ncrypt.h:136
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1089
struct Mailbox * mailbox
Definition: context.h:50
A local copy of an email.
Definition: mx.h:81
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 crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one)
Wrapper for CryptModuleSpecs::pgp_check_traditional()
Definition: cryptglue.c:273
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:696
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1041
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:

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 1340 of file commands.c.

1341 {
1342  bool rc = false;
1343  struct EmailNode *en = NULL;
1344  STAILQ_FOREACH(en, el, entries)
1345  {
1346  if (!(en->email->security & PGP_TRADITIONAL_CHECKED))
1347  rc = check_traditional_pgp(en->email, redraw) || rc;
1348  }
1349 
1350  return rc;
1351 }
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: ncrypt.h:136
static bool check_traditional_pgp(struct Email *e, MuttRedrawFlags *redraw)
Check for an inline PGP content.
Definition: commands.c:1312
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
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
struct Email * email
Email in the list.
Definition: email.h:122
List of Emails.
Definition: email.h:120

+ 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 1356 of file commands.c.

1357 {
1359 }
The "current" mailbox.
Definition: context.h:36
struct Mailbox * mailbox
Definition: context.h:50
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:126
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:17
#define MUTT_MAILBOX_CHECK_FORCE_STATS
Definition: mutt_mailbox.h:18

+ 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 86 of file commands.c.

char* C_DisplayFilter

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

Definition at line 87 of file commands.c.

bool C_PipeDecode

Config: Decode the message when piping it.

Definition at line 88 of file commands.c.

char* C_PipeSep

Config: Separator to add between multiple piped messages.

Definition at line 89 of file commands.c.

bool C_PipeSplit

Config: Run the pipe command on each message separately.

Definition at line 90 of file commands.c.

bool C_PrintDecode

Config: Decode message before printing it.

Definition at line 91 of file commands.c.

bool C_PrintSplit

Config: Print multiple messages separately.

Definition at line 92 of file commands.c.

bool C_PromptAfter

Config: Pause after running an external pager.

Definition at line 93 of file commands.c.

const char* ExtPagerProgress = "all"
static

Definition at line 95 of file commands.c.

char LastSaveFolder[PATH_MAX] = ""
static

The folder the user last saved to.

Used by ci_save_message()

Definition at line 98 of file commands.c.