NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
DOXYGEN
message.c File Reference

Process a message for display in the pager. More...

#include "config.h"
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "attach/lib.h"
#include "index/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "pager/lib.h"
#include "question/lib.h"
#include "copy.h"
#include "format_flags.h"
#include "globals.h"
#include "hdrline.h"
#include "hook.h"
#include "keymap.h"
#include "mview.h"
#include "mx.h"
#include "protos.h"
#include "autocrypt/lib.h"
+ Include dependency graph for message.c:

Go to the source code of this file.

Functions

static void process_protected_headers (struct Mailbox *m, struct Email *e)
 Get the protected header and update the index. More...
 
static int email_to_file (struct Message *msg, struct Buffer *tempfile, struct Mailbox *m, struct Email *e, const char *header, int wrap_len, CopyMessageFlags *cmflags)
 Decrypt, decode and weed an Email into a file. More...
 
int external_pager (struct MailboxView *mv, struct Email *e, const char *command)
 Display a message in an external program. More...
 
static void notify_crypto (struct Email *e, struct Message *msg, CopyMessageFlags cmflags)
 Notify the user about the crypto status of the Email. More...
 
static void squash_index_panel (struct Mailbox *m, struct MuttWindow *win_index, struct MuttWindow *win_pager)
 Shrink or hide the Index Panel. More...
 
static void expand_index_panel (struct MuttWindow *win_index, struct MuttWindow *win_pager)
 Restore the Index Panel. More...
 
int mutt_display_message (struct MuttWindow *win_index, struct IndexSharedData *shared)
 Display a message in the pager. More...
 

Variables

static const char * ExtPagerProgress = N_("all")
 Status bar message when entire message is visible in the Pager. More...
 

Detailed Description

Process a message for display in the pager.

Authors
  • Richard Russon

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

Function Documentation

◆ process_protected_headers()

static void process_protected_headers ( struct Mailbox m,
struct Email e 
)
static

Get the protected header and update the index.

Parameters
mMailbox
eEmail to update

Definition at line 67 of file message.c.

68{
69 struct Envelope *prot_headers = NULL;
70 regmatch_t pmatch[1];
71
72 const bool c_crypt_protected_headers_read = cs_subset_bool(NeoMutt->sub, "crypt_protected_headers_read");
73#ifdef USE_AUTOCRYPT
74 const bool c_autocrypt = cs_subset_bool(NeoMutt->sub, "autocrypt");
75 if (!c_crypt_protected_headers_read && !c_autocrypt)
76 return;
77#else
78 if (!c_crypt_protected_headers_read)
79 return;
80#endif
81
82 /* Grab protected headers to update in the index */
83 if (e->security & SEC_SIGN)
84 {
85 /* Don't update on a bad signature.
86 *
87 * This is a simplification. It's possible the headers are in the
88 * encrypted part of a nested encrypt/signed. But properly handling that
89 * case would require more complexity in the decryption handlers, which
90 * I'm not sure is worth it. */
91 if (!(e->security & SEC_GOODSIGN))
92 return;
93
95 {
96 prot_headers = e->body->parts->mime_headers;
97 }
99 {
100 prot_headers = e->body->mime_headers;
101 }
102 }
103 if (!prot_headers && (e->security & SEC_ENCRYPT))
104 {
105 if (((WithCrypto & APPLICATION_PGP) != 0) &&
108 {
109 prot_headers = e->body->mime_headers;
110 }
112 {
113 prot_headers = e->body->mime_headers;
114 }
115 }
116
117 /* Update protected headers in the index and header cache. */
118 if (c_crypt_protected_headers_read && prot_headers && prot_headers->subject &&
119 !mutt_str_equal(e->env->subject, prot_headers->subject))
120 {
121 if (m->subj_hash && e->env->real_subj)
123
124 mutt_str_replace(&e->env->subject, prot_headers->subject);
125 FREE(&e->env->disp_subj);
126 const struct Regex *c_reply_regex = cs_subset_regex(NeoMutt->sub, "reply_regex");
127 if (mutt_regex_capture(c_reply_regex, e->env->subject, 1, pmatch))
128 {
129 e->env->real_subj = e->env->subject + pmatch[0].rm_eo;
130 if (e->env->real_subj[0] == '\0')
131 e->env->real_subj = NULL;
132 }
133 else
134 {
135 e->env->real_subj = e->env->subject;
136 }
137
138 if (m->subj_hash)
140
141 mx_save_hcache(m, e);
142
143 /* Also persist back to the message headers if this is set */
144 const bool c_crypt_protected_headers_save = cs_subset_bool(NeoMutt->sub, "crypt_protected_headers_save");
145 if (c_crypt_protected_headers_save)
146 {
148 e->changed = true;
149 m->changed = true;
150 }
151 }
152
153#ifdef USE_AUTOCRYPT
154 if (c_autocrypt && (e->security & SEC_ENCRYPT) && prot_headers && prot_headers->autocrypt_gossip)
155 {
157 }
158#endif
159}
int mutt_autocrypt_process_gossip_header(struct Email *e, struct Envelope *prot_headers)
Parse an Autocrypt email gossip header.
Definition: autocrypt.c:414
const struct Regex * cs_subset_regex(const struct ConfigSubset *sub, const char *name)
Get a regex config item by name.
Definition: helpers.c:243
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:398
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
Definition: crypt.c:599
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:457
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:494
#define MUTT_ENV_CHANGED_SUBJECT
Protected header update.
Definition: envelope.h:37
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition: hash.c:335
void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
Definition: hash.c:427
#define FREE(x)
Definition: memory.h:43
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:618
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:327
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:1845
#define SEC_GOODSIGN
Email has a valid signature.
Definition: lib.h:80
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:91
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:78
#define WithCrypto
Definition: lib.h:116
#define SEC_SIGN
Email is signed.
Definition: lib.h:79
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:72
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:75
struct Envelope * env
Envelope information.
Definition: email.h:66
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:41
struct Body * body
List of MIME parts.
Definition: email.h:67
bool changed
Email has been edited.
Definition: email.h:75
The header of an Email.
Definition: envelope.h:57
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
Definition: envelope.h:92
struct AutocryptHeader * autocrypt_gossip
Autocrypt Gossip header.
Definition: envelope.h:90
char * subject
Email's subject.
Definition: envelope.h:70
char * real_subj
Offset of the real subject.
Definition: envelope.h:71
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:72
bool changed
Mailbox has been modified.
Definition: mailbox.h:110
struct HashTable * subj_hash
Hash Table: "subject" -> Email.
Definition: mailbox.h:124
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
Cached regular expression.
Definition: regex3.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ email_to_file()

static int email_to_file ( struct Message msg,
struct Buffer tempfile,
struct Mailbox m,
struct Email e,
const char *  header,
int  wrap_len,
CopyMessageFlags cmflags 
)
static

Decrypt, decode and weed an Email into a file.

Parameters
msgRaw Email
tempfileTemporary filename for result
mMailbox
eEmail to display
headerHeader to prefix output (OPTIONAL)
wrap_lenWidth to wrap lines
cmflagsMessage flags, e.g. MUTT_CM_DECODE
Return values
0Success
-1Error
Note
Flags may be added to cmflags

Definition at line 175 of file message.c.

178{
179 int rc = 0;
180 pid_t filterpid = -1;
181
184
185 char columns[16] = { 0 };
186 // win_pager might not be visible and have a size yet, so use win_index
187 snprintf(columns, sizeof(columns), "%d", wrap_len);
188 envlist_set(&EnvList, "COLUMNS", columns, true);
189
190 /* see if crypto is needed for this message. if so, we should exit curses */
191 if ((WithCrypto != 0) && e->security)
192 {
193 if (e->security & SEC_ENCRYPT)
194 {
198 goto cleanup;
199
200 *cmflags |= MUTT_CM_VERIFY;
201 }
202 else if (e->security & SEC_SIGN)
203 {
204 /* find out whether or not the verify signature */
205 /* L10N: Used for the $crypt_verify_sig prompt */
206 const enum QuadOption c_crypt_verify_sig = cs_subset_quad(NeoMutt->sub, "crypt_verify_sig");
207 if (query_quadoption(c_crypt_verify_sig, _("Verify signature?")) == MUTT_YES)
208 {
209 *cmflags |= MUTT_CM_VERIFY;
210 }
211 }
212 }
213
214 if (*cmflags & MUTT_CM_VERIFY || e->security & SEC_ENCRYPT)
215 {
216 if (e->security & APPLICATION_PGP)
217 {
218 if (!TAILQ_EMPTY(&e->env->from))
220
222 }
223
226 }
227
228 FILE *fp_filter_out = NULL;
229 buf_mktemp(tempfile);
230 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
231 if (!fp_out)
232 {
233 mutt_error(_("Could not create temporary file"));
234 goto cleanup;
235 }
236
237 const char *const c_display_filter = cs_subset_string(NeoMutt->sub, "display_filter");
238 if (c_display_filter)
239 {
240 fp_filter_out = fp_out;
241 fp_out = NULL;
242 filterpid = filter_create_fd(c_display_filter, &fp_out, NULL, NULL, -1,
243 fileno(fp_filter_out), -1);
244 if (filterpid < 0)
245 {
246 mutt_error(_("Can't create display filter"));
247 mutt_file_fclose(&fp_filter_out);
248 unlink(buf_string(tempfile));
249 goto cleanup;
250 }
251 }
252
253 if (header)
254 {
255 fputs(header, fp_out);
256 fputs("\n\n", fp_out);
257 }
258
259 const bool c_weed = cs_subset_bool(NeoMutt->sub, "weed");
260 CopyHeaderFlags chflags = (c_weed ? (CH_WEED | CH_REORDER) : CH_NO_FLAGS) |
262#ifdef USE_NOTMUCH
263 if (m->type == MUTT_NOTMUCH)
264 chflags |= CH_VIRTUAL;
265#endif
266 rc = mutt_copy_message(fp_out, e, msg, *cmflags, chflags, wrap_len);
267
268 if (((mutt_file_fclose(&fp_out) != 0) && (errno != EPIPE)) || (rc < 0))
269 {
270 mutt_error(_("Could not copy message"));
271 if (fp_filter_out)
272 {
273 filter_wait(filterpid);
274 mutt_file_fclose(&fp_filter_out);
275 }
276 mutt_file_unlink(buf_string(tempfile));
277 goto cleanup;
278 }
279
280 if (fp_filter_out && (filter_wait(filterpid) != 0))
282
283 mutt_file_fclose(&fp_filter_out); /* XXX - check result? */
284
285 if (WithCrypto)
286 {
287 /* update crypto information for this message */
289 e->security |= crypt_query(e->body);
290
291 /* Remove color cache for this message, in case there
292 * are color patterns for both ~g and ~V */
293 e->attr_color = NULL;
294
295 /* Process protected headers and autocrypt gossip headers */
297 }
298
299cleanup:
300 envlist_unset(&EnvList, "COLUMNS");
301 return rc;
302}
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:596
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:90
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
enum QuadOption cs_subset_quad(const struct ConfigSubset *sub, const char *name)
Get a quad-value config item by name.
Definition: helpers.c:218
int mutt_copy_message(FILE *fp_out, struct Email *e, struct Message *msg, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Definition: copy.c:884
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:54
#define MUTT_CM_VERIFY
Do signature verification.
Definition: copy.h:47
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:56
#define CH_WEED
Weed the headers?
Definition: copy.h:53
#define CH_REORDER
Re-order output of headers (specified by 'hdr_order')
Definition: copy.h:59
#define CH_DISPLAY
Display result to user.
Definition: copy.h:70
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:50
#define CH_VIRTUAL
Write virtual header lines too.
Definition: copy.h:73
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:51
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:135
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition: crypt.c:677
void crypt_invoke_message(SecurityFlags type)
Display an informative message.
Definition: cryptglue.c:157
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:455
void crypt_pgp_invoke_getkeys(struct Address *addr)
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()
Definition: cryptglue.c:274
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition: curs_lib.c:388
bool envlist_set(char ***envp, const char *name, const char *value, bool overwrite)
Set an environment variable.
Definition: envlist.c:87
bool envlist_unset(char ***envp, const char *name)
Unset an environment variable.
Definition: envlist.c:135
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:634
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:150
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:194
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
pid_t filter_create_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:61
char ** EnvList
Private copy of the environment variables.
Definition: globals.c:91
#define mutt_error(...)
Definition: logging2.h:90
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:658
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:45
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:51
#define _(a)
Definition: message.h:28
#define SEC_BADSIGN
Email has a bad signature.
Definition: lib.h:81
static void process_protected_headers(struct Mailbox *m, struct Email *e)
Get the protected header and update the index.
Definition: message.c:67
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: question.c:386
#define TAILQ_FIRST(head)
Definition: queue.h:723
#define TAILQ_EMPTY(head)
Definition: queue.h:721
struct AttrColor * attr_color
Color-pair to use when displaying in the index.
Definition: email.h:111
struct AddressList from
Email's 'From' list.
Definition: envelope.h:59
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
FILE * fp
pointer to the message data
Definition: mxapi.h:44
#define buf_mktemp(buf)
Definition: tmp.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ external_pager()

int external_pager ( struct MailboxView mv,
struct Email e,
const char *  command 
)

Display a message in an external program.

Parameters
mvMailbox view
eEmail to display
commandExternal command to run
Return values
0Success
-1Error

Definition at line 312 of file message.c.

313{
314 if (!mv || !mv->mailbox)
315 return -1;
316
317 struct Mailbox *m = mv->mailbox;
318 struct Message *msg = mx_msg_open(m, e);
319 if (!msg)
320 return -1;
321
322 char buf[1024] = { 0 };
323 const char *const c_pager_format = cs_subset_string(NeoMutt->sub, "pager_format");
324 const int screen_width = RootWindow->state.cols;
325 mutt_make_string(buf, sizeof(buf), screen_width, NONULL(c_pager_format), m,
327
328 struct Buffer *tempfile = buf_pool_get();
329
331 int rc = email_to_file(msg, tempfile, m, e, buf, screen_width, &cmflags);
332 if (rc < 0)
333 goto cleanup;
334
335 mutt_endwin();
336
337 struct Buffer *cmd = buf_pool_get();
338 buf_printf(cmd, "%s %s", command, buf_string(tempfile));
339 int r = mutt_system(buf_string(cmd));
340 if (r == -1)
341 mutt_error(_("Error running \"%s\""), buf_string(cmd));
342 unlink(buf_string(tempfile));
343 buf_pool_release(&cmd);
344
345 if (!OptNoCurses)
346 keypad(stdscr, true);
347 if (r != -1)
348 mutt_set_flag(m, e, MUTT_READ, true, true);
349 const bool c_prompt_after = cs_subset_bool(NeoMutt->sub, "prompt_after");
350 if ((r != -1) && c_prompt_after)
351 {
353 rc = km_dokey(MENU_PAGER);
354 }
355 else
356 {
357 rc = 0;
358 }
359
360cleanup:
361 mx_msg_close(m, &msg);
362 buf_pool_release(&tempfile);
363 return rc;
364}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:173
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:38
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:42
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:34
#define MUTT_CM_DISPLAY
Output is displayed to the user.
Definition: copy.h:39
void mutt_endwin(void)
Shutdown curses.
Definition: curs_lib.c:355
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition: curs_lib.c:522
void mutt_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
Set a flag on an email.
Definition: flags.c:52
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
bool OptNoCurses
(pseudo) when sending in batch mode
Definition: globals.c:82
void mutt_make_string(char *buf, size_t buflen, int cols, const char *s, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
Definition: hdrline.c:1489
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:803
@ MUTT_READ
Messages that have been read.
Definition: mutt.h:81
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1210
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
Definition: mx.c:1164
static int email_to_file(struct Message *msg, struct Buffer *tempfile, struct Mailbox *m, struct Email *e, const char *header, int wrap_len, CopyMessageFlags *cmflags)
Decrypt, decode and weed an Email into a file.
Definition: message.c:175
static const char * ExtPagerProgress
Status bar message when entire message is visible in the Pager.
Definition: message.c:60
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
int mutt_system(const char *cmd)
Run an external command.
Definition: system.c:52
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: rootwin.c:104
#define NONULL(x)
Definition: string2.h:37
String manipulation buffer.
Definition: buffer.h:34
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:50
A mailbox.
Definition: mailbox.h:79
A local copy of an email.
Definition: mxapi.h:43
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:127
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:60
@ MENU_PAGER
Pager pager (email viewer)
Definition: type.h:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notify_crypto()

static void notify_crypto ( struct Email e,
struct Message msg,
CopyMessageFlags  cmflags 
)
static

Notify the user about the crypto status of the Email.

Parameters
eEmail to display
msgRaw Email
cmflagsMessage flags, e.g. MUTT_CM_DECODE

Definition at line 372 of file message.c.

373{
374 if ((WithCrypto != 0) && (e->security & APPLICATION_SMIME) && (cmflags & MUTT_CM_VERIFY))
375 {
376 if (e->security & SEC_GOODSIGN)
377 {
378 if (crypt_smime_verify_sender(e, msg) == 0)
379 mutt_message(_("S/MIME signature successfully verified"));
380 else
381 mutt_error(_("S/MIME certificate owner does not match sender"));
382 }
383 else if (e->security & SEC_PARTSIGN)
384 {
385 mutt_message(_("Warning: Part of this message has not been signed"));
386 }
387 else if (e->security & SEC_SIGN || e->security & SEC_BADSIGN)
388 {
389 mutt_error(_("S/MIME signature could NOT be verified"));
390 }
391 }
392
393 if ((WithCrypto != 0) && (e->security & APPLICATION_PGP) && (cmflags & MUTT_CM_VERIFY))
394 {
395 if (e->security & SEC_GOODSIGN)
396 mutt_message(_("PGP signature successfully verified"));
397 else if (e->security & SEC_PARTSIGN)
398 mutt_message(_("Warning: Part of this message has not been signed"));
399 else if (e->security & SEC_SIGN)
400 mutt_message(_("PGP signature could NOT be verified"));
401 }
402}
int crypt_smime_verify_sender(struct Email *e, struct Message *msg)
Wrapper for CryptModuleSpecs::smime_verify_sender()
Definition: cryptglue.c:464
#define mutt_message(...)
Definition: logging2.h:89
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: lib.h:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ squash_index_panel()

static void squash_index_panel ( struct Mailbox m,
struct MuttWindow win_index,
struct MuttWindow win_pager 
)
static

Shrink or hide the Index Panel.

Parameters
mMailbox
win_indexIndex Window
win_pagerPager Window

Definition at line 410 of file message.c.

412{
413 const short c_pager_index_lines = cs_subset_number(NeoMutt->sub, "pager_index_lines");
414 if (c_pager_index_lines > 0)
415 {
416 win_index->size = MUTT_WIN_SIZE_FIXED;
417 win_index->req_rows = c_pager_index_lines;
418 win_index->parent->size = MUTT_WIN_SIZE_MINIMISE;
419 }
420 window_set_visible(win_index->parent, (c_pager_index_lines > 0));
421
422 window_set_visible(win_pager->parent, true);
423
424 struct MuttWindow *dlg = dialog_find(win_index);
426
427 // Force the menu to reframe itself
428 struct Menu *menu = win_index->wdata;
429 menu_set_index(menu, menu_get_index(menu));
430}
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:83
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:155
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:169
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:341
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:163
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition: mutt_window.h:47
@ MUTT_WIN_SIZE_MINIMISE
Window size depends on its children.
Definition: mutt_window.h:49
Definition: lib.h:70
void * wdata
Private data.
Definition: mutt_window.h:145
short req_rows
Number of rows required.
Definition: mutt_window.h:125
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expand_index_panel()

static void expand_index_panel ( struct MuttWindow win_index,
struct MuttWindow win_pager 
)
static

Restore the Index Panel.

Parameters
win_indexIndex Window
win_pagerPager Window

Definition at line 437 of file message.c.

438{
439 win_index->size = MUTT_WIN_SIZE_MAXIMISE;
441 win_index->parent->size = MUTT_WIN_SIZE_MAXIMISE;
443 window_set_visible(win_index->parent, true);
444
445 window_set_visible(win_pager->parent, false);
446
447 struct MuttWindow *dlg = dialog_find(win_index);
449}
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition: mutt_window.h:52
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition: mutt_window.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_display_message()

int mutt_display_message ( struct MuttWindow win_index,
struct IndexSharedData shared 
)

Display a message in the pager.

Parameters
win_indexIndex Window
sharedShared Index data
Return values
0Success
-1Error

Definition at line 458 of file message.c.

459{
460 struct MuttWindow *dlg = dialog_find(win_index);
461 struct MuttWindow *win_pager = window_find_child(dlg, WT_CUSTOM);
462 struct MuttWindow *win_pbar = window_find_child(dlg, WT_STATUS_BAR);
463 struct Buffer *tempfile = buf_pool_get();
464 struct Message *msg = NULL;
465
466 squash_index_panel(shared->mailbox, win_index, win_pager);
467
468 int rc = PAGER_LOOP_QUIT;
469 do
470 {
471 msg = mx_msg_open(shared->mailbox, shared->email);
472 if (!msg)
473 break;
474
476
477 buf_reset(tempfile);
478 // win_pager might not be visible and have a size yet, so use win_index
479 rc = email_to_file(msg, tempfile, shared->mailbox, shared->email, NULL,
480 win_index->state.cols, &cmflags);
481 if (rc < 0)
482 break;
483
484 notify_crypto(shared->email, msg, cmflags);
485
486 /* Invoke the builtin pager */
487 struct PagerData pdata = { 0 };
488 struct PagerView pview = { &pdata };
489
490 pdata.fp = msg->fp;
491 pdata.fname = buf_string(tempfile);
492
493 pview.mode = PAGER_MODE_EMAIL;
494 pview.banner = NULL;
495 pview.flags = MUTT_PAGER_MESSAGE |
496 (shared->email->body->nowrap ? MUTT_PAGER_NOWRAP : 0);
497 pview.win_index = win_index;
498 pview.win_pbar = win_pbar;
499 pview.win_pager = win_pager;
500
501 rc = mutt_pager(&pview);
502 mx_msg_close(shared->mailbox, &msg);
503 } while (rc == PAGER_LOOP_RELOAD);
504
506
507 mx_msg_close(shared->mailbox, &msg);
508 buf_pool_release(&tempfile);
509 return rc;
510}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:88
int mutt_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window.
Definition: dlg_pager.c:225
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:523
@ WT_CUSTOM
Window with a custom drawing function.
Definition: mutt_window.h:95
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
@ PAGER_LOOP_RELOAD
Reload the Pager from scratch.
Definition: lib.h:152
@ PAGER_LOOP_QUIT
Quit the Pager.
Definition: lib.h:151
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition: lib.h:72
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:136
#define MUTT_PAGER_MESSAGE
Definition: lib.h:75
static void expand_index_panel(struct MuttWindow *win_index, struct MuttWindow *win_pager)
Restore the Index Panel.
Definition: message.c:437
static void notify_crypto(struct Email *e, struct Message *msg, CopyMessageFlags cmflags)
Notify the user about the crypto status of the Email.
Definition: message.c:372
static void squash_index_panel(struct Mailbox *m, struct MuttWindow *win_index, struct MuttWindow *win_pager)
Shrink or hide the Index Panel.
Definition: message.c:410
bool nowrap
Do not wrap the output in the pager.
Definition: body.h:88
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
Data to be displayed by PagerView.
Definition: lib.h:159
const char * fname
Name of the file to read.
Definition: lib.h:163
FILE * fp
Source stream.
Definition: lib.h:161
Paged view into some data.
Definition: lib.h:170
struct MuttWindow * win_index
Index Window.
Definition: lib.h:176
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:171
enum PagerMode mode
Pager mode.
Definition: lib.h:172
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:173
const char * banner
Title to display in status bar.
Definition: lib.h:174
struct MuttWindow * win_pbar
Pager Bar Window.
Definition: lib.h:177
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:178
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ ExtPagerProgress

const char* ExtPagerProgress = N_("all")
static

Status bar message when entire message is visible in the Pager.

Definition at line 60 of file message.c.