NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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 <sys/types.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 "lib.h"
#include "attach/lib.h"
#include "expando/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "question/lib.h"
#include "copy.h"
#include "globals.h"
#include "hdrline.h"
#include "hook.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.
 
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.
 
int external_pager (struct MailboxView *mv, struct Email *e, const char *command)
 Display a message in an external program.
 
static void notify_crypto (struct Email *e, struct Message *msg, CopyMessageFlags cmflags)
 Notify the user about the crypto status of the Email.
 
static void squash_index_panel (struct Mailbox *m, struct MuttWindow *win_index, struct MuttWindow *win_pager)
 Shrink or hide the Index Panel.
 
static void expand_index_panel (struct MuttWindow *win_index, struct MuttWindow *win_pager)
 Restore the Index Panel.
 
int mutt_display_message (struct MuttWindow *win_index, struct IndexSharedData *shared)
 Display a message in the pager.
 

Variables

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

Detailed Description

Process a message for display in the pager.

Authors
  • Richard Russon
  • 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 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 69 of file message.c.

70{
71 struct Envelope *prot_headers = NULL;
72
73 const bool c_crypt_protected_headers_read = cs_subset_bool(NeoMutt->sub, "crypt_protected_headers_read");
74#ifdef USE_AUTOCRYPT
75 const bool c_autocrypt = cs_subset_bool(NeoMutt->sub, "autocrypt");
76 if (!c_crypt_protected_headers_read && !c_autocrypt)
77 return;
78#else
79 if (!c_crypt_protected_headers_read)
80 return;
81#endif
82
83 /* Grab protected headers to update in the index */
84 if (e->security & SEC_SIGN)
85 {
86 /* Don't update on a bad signature.
87 *
88 * This is a simplification. It's possible the headers are in the
89 * encrypted part of a nested encrypt/signed. But properly handling that
90 * case would require more complexity in the decryption handlers, which
91 * I'm not sure is worth it. */
92 if (!(e->security & SEC_GOODSIGN))
93 return;
94
96 {
97 prot_headers = e->body->parts->mime_headers;
98 }
100 {
101 prot_headers = e->body->mime_headers;
102 }
103 }
104 if (!prot_headers && (e->security & SEC_ENCRYPT))
105 {
106 if (((WithCrypto & APPLICATION_PGP) != 0) &&
109 {
110 prot_headers = e->body->mime_headers;
111 }
113 {
114 prot_headers = e->body->mime_headers;
115 }
116 }
117
118 /* Update protected headers in the index and header cache. */
119 if (c_crypt_protected_headers_read && prot_headers && prot_headers->subject &&
120 !mutt_str_equal(e->env->subject, prot_headers->subject))
121 {
122 if (m->subj_hash && e->env->real_subj)
124
125 mutt_env_set_subject(e->env, prot_headers->subject);
126 FREE(&e->env->disp_subj);
127
128 if (m->subj_hash)
130
131 mx_save_hcache(m, e);
132
133 /* Also persist back to the message headers if this is set */
134 const bool c_crypt_protected_headers_save = cs_subset_bool(NeoMutt->sub, "crypt_protected_headers_save");
135 if (c_crypt_protected_headers_save)
136 {
138 e->changed = true;
139 m->changed = true;
140 }
141 }
142
143#ifdef USE_AUTOCRYPT
144 if (c_autocrypt && (e->security & SEC_ENCRYPT) && prot_headers && prot_headers->autocrypt_gossip)
145 {
147 }
148#endif
149}
int mutt_autocrypt_process_gossip_header(struct Email *e, struct Envelope *prot_headers)
Parse an Autocrypt email gossip header.
Definition: autocrypt.c:404
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:408
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
Definition: crypt.c:609
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:467
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:504
void mutt_env_set_subject(struct Envelope *env, const char *subj)
Set both subject and real_subj to subj.
Definition: envelope.c:69
#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:45
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
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:1783
#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:73
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:76
struct Envelope * env
Envelope information.
Definition: email.h:68
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:43
struct Body * body
List of MIME parts.
Definition: email.h:69
bool changed
Email has been edited.
Definition: email.h:77
The header of an Email.
Definition: envelope.h:57
char *const subject
Email's subject.
Definition: envelope.h:70
unsigned char changed
Changed fields, e.g. MUTT_ENV_CHANGED_SUBJECT.
Definition: envelope.h:90
struct AutocryptHeader * autocrypt_gossip
Autocrypt Gossip header.
Definition: envelope.h:88
char *const 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:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
+ 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 165 of file message.c.

168{
169 int rc = 0;
170 pid_t filterpid = -1;
171
174
175 char columns[16] = { 0 };
176 // win_pager might not be visible and have a size yet, so use win_index
177 snprintf(columns, sizeof(columns), "%d", wrap_len);
178 envlist_set(&EnvList, "COLUMNS", columns, true);
179
180 /* see if crypto is needed for this message. if so, we should exit curses */
181 if ((WithCrypto != 0) && e->security)
182 {
183 if (e->security & SEC_ENCRYPT)
184 {
188 goto cleanup;
189
190 *cmflags |= MUTT_CM_VERIFY;
191 }
192 else if (e->security & SEC_SIGN)
193 {
194 /* find out whether or not the verify signature */
195 /* L10N: Used for the $crypt_verify_sig prompt */
196 if (query_quadoption(_("Verify signature?"), NeoMutt->sub, "crypt_verify_sig") == MUTT_YES)
197 {
198 *cmflags |= MUTT_CM_VERIFY;
199 }
200 }
201 }
202
203 if (*cmflags & MUTT_CM_VERIFY || e->security & SEC_ENCRYPT)
204 {
205 if (e->security & APPLICATION_PGP)
206 {
207 if (!TAILQ_EMPTY(&e->env->from))
209
211 }
212
215 }
216
217 FILE *fp_filter_out = NULL;
218 buf_mktemp(tempfile);
219 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
220 if (!fp_out)
221 {
222 mutt_error(_("Could not create temporary file"));
223 goto cleanup;
224 }
225
226 const char *const c_display_filter = cs_subset_string(NeoMutt->sub, "display_filter");
227 if (c_display_filter)
228 {
229 fp_filter_out = fp_out;
230 fp_out = NULL;
231 filterpid = filter_create_fd(c_display_filter, &fp_out, NULL, NULL, -1,
232 fileno(fp_filter_out), -1, EnvList);
233 if (filterpid < 0)
234 {
235 mutt_error(_("Can't create display filter"));
236 mutt_file_fclose(&fp_filter_out);
237 unlink(buf_string(tempfile));
238 goto cleanup;
239 }
240 }
241
242 if (header)
243 {
244 fputs(header, fp_out);
245 fputs("\n\n", fp_out);
246 }
247
248 const bool c_weed = cs_subset_bool(NeoMutt->sub, "weed");
249 CopyHeaderFlags chflags = (c_weed ? (CH_WEED | CH_REORDER) : CH_NO_FLAGS) |
251#ifdef USE_NOTMUCH
252 if (m->type == MUTT_NOTMUCH)
253 chflags |= CH_VIRTUAL;
254#endif
255 rc = mutt_copy_message(fp_out, e, msg, *cmflags, chflags, wrap_len);
256
257 if (((mutt_file_fclose(&fp_out) != 0) && (errno != EPIPE)) || (rc < 0))
258 {
259 mutt_error(_("Could not copy message"));
260 if (fp_filter_out)
261 {
262 filter_wait(filterpid);
263 mutt_file_fclose(&fp_filter_out);
264 }
265 mutt_file_unlink(buf_string(tempfile));
266 goto cleanup;
267 }
268
269 if (fp_filter_out && (filter_wait(filterpid) != 0))
271
272 mutt_file_fclose(&fp_filter_out); /* XXX - check result? */
273
274 if (WithCrypto)
275 {
276 /* update crypto information for this message */
278 e->security |= crypt_query(e->body);
279
280 /* Remove color cache for this message, in case there
281 * are color patterns for both ~g and ~V */
282 e->attr_color = NULL;
283
284 /* Process protected headers and autocrypt gossip headers */
286 }
287
288cleanup:
289 envlist_unset(&EnvList, "COLUMNS");
290 return rc;
291}
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:597
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
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:907
#define CH_DECODE
Do RFC2047 header decoding.
Definition: copy.h:56
#define MUTT_CM_VERIFY
Do signature verification.
Definition: copy.h:49
#define CH_FROM
Retain the "From " message separator?
Definition: copy.h:58
#define CH_WEED
Weed the headers?
Definition: copy.h:55
#define CH_REORDER
Re-order output of headers (specified by 'hdr_order')
Definition: copy.h:61
#define CH_DISPLAY
Display result to user.
Definition: copy.h:72
uint32_t CopyHeaderFlags
Flags for mutt_copy_header(), e.g. CH_UPDATE.
Definition: copy.h:52
#define CH_VIRTUAL
Write virtual header lines too.
Definition: copy.h:75
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:53
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:51
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:132
SecurityFlags crypt_query(struct Body *b)
Check out the type of encryption used.
Definition: crypt.c:687
void crypt_invoke_message(SecurityFlags type)
Display an informative message.
Definition: cryptglue.c:156
void crypt_smime_getkeys(struct Envelope *env)
Wrapper for CryptModuleSpecs::smime_getkeys()
Definition: cryptglue.c:454
void crypt_pgp_invoke_getkeys(struct Address *addr)
Wrapper for CryptModuleSpecs::pgp_invoke_getkeys()
Definition: cryptglue.c:273
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition: curs_lib.c:173
bool envlist_set(char ***envp, const char *name, const char *value, bool overwrite)
Set an environment variable.
Definition: envlist.c:88
bool envlist_unset(char ***envp, const char *name)
Unset an environment variable.
Definition: envlist.c:136
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:221
#define mutt_file_fclose(FP)
Definition: file.h:138
#define mutt_file_fopen(PATH, MODE)
Definition: file.h:137
char ** EnvList
Private copy of the environment variables.
Definition: globals.c:75
#define mutt_error(...)
Definition: logging2.h:92
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:700
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:44
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:220
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr, char **envlist)
Run a command on a pipe (optionally connect stdin/stdout)
Definition: filter.c:62
#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:69
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:39
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
Definition: question.c:379
#define TAILQ_FIRST(head)
Definition: queue.h:723
#define TAILQ_EMPTY(head)
Definition: queue.h:721
const struct AttrColor * attr_color
Color-pair to use when displaying in the index.
Definition: email.h:112
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: message.h:35
#define buf_mktemp(buf)
Definition: tmp.h:33
+ 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 301 of file message.c.

302{
303 if (!mv || !mv->mailbox)
304 return -1;
305
306 struct Mailbox *m = mv->mailbox;
307 struct Message *msg = mx_msg_open(m, e);
308 if (!msg)
309 return -1;
310
311 struct Buffer *buf = buf_pool_get();
312 const struct Expando *c_pager_format = cs_subset_expando(NeoMutt->sub, "pager_format");
313 const int screen_width = RootWindow->state.cols;
314 mutt_make_string(buf, screen_width, c_pager_format, m, -1, e,
316
317 struct Buffer *tempfile = buf_pool_get();
318
320 int rc = email_to_file(msg, tempfile, m, e, buf_string(buf), screen_width, &cmflags);
321 if (rc < 0)
322 goto cleanup;
323
324 mutt_endwin();
325
326 struct Buffer *cmd = buf_pool_get();
327 buf_printf(cmd, "%s %s", command, buf_string(tempfile));
328 int r = mutt_system(buf_string(cmd));
329 if (r == -1)
330 mutt_error(_("Error running \"%s\""), buf_string(cmd));
331 unlink(buf_string(tempfile));
332 buf_pool_release(&cmd);
333
334 if (!OptNoCurses)
335 keypad(stdscr, true);
336 if (r != -1)
337 mutt_set_flag(m, e, MUTT_READ, true, true);
338 const bool c_prompt_after = cs_subset_bool(NeoMutt->sub, "prompt_after");
339 if ((r != -1) && c_prompt_after)
340 {
343 }
344 else
345 {
346 rc = 0;
347 }
348
349cleanup:
350 buf_pool_release(&buf);
351 mx_msg_close(m, &msg);
352 buf_pool_release(&tempfile);
353 return rc;
354}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando config item by name.
Definition: config_type.c:357
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:40
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:44
uint16_t CopyMessageFlags
Flags for mutt_copy_message(), e.g. MUTT_CM_NOHEADER.
Definition: copy.h:36
#define MUTT_CM_DISPLAY
Output is displayed to the user.
Definition: copy.h:41
void mutt_endwin(void)
Shutdown curses.
Definition: curs_lib.c:151
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition: get.c:115
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:57
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:464
bool OptNoCurses
(pseudo) when sending in batch mode
Definition: globals.c:69
int mutt_make_string(struct Buffer *buf, size_t max_cols, const struct Expando *exp, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
Definition: hdrline.c:1719
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:51
@ MUTT_READ
Messages that have been read.
Definition: mutt.h:73
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
Definition: mx.c:1180
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
Definition: mx.c:1134
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:165
static const char * ExtPagerProgress
Status bar message when entire message is visible in the Pager.
Definition: message.c:62
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
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: render.h:33
struct MuttWindow * RootWindow
Parent of all Windows.
Definition: rootwin.c:106
String manipulation buffer.
Definition: buffer.h:36
Parsed Expando trees.
Definition: expando.h:41
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:51
A mailbox.
Definition: mailbox.h:79
A local copy of an email.
Definition: message.h:34
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:126
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:52
+ 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 362 of file message.c.

363{
364 if ((WithCrypto != 0) && (e->security & APPLICATION_SMIME) && (cmflags & MUTT_CM_VERIFY))
365 {
366 if (e->security & SEC_GOODSIGN)
367 {
368 if (crypt_smime_verify_sender(e, msg) == 0)
369 mutt_message(_("S/MIME signature successfully verified"));
370 else
371 mutt_error(_("S/MIME certificate owner does not match sender"));
372 }
373 else if (e->security & SEC_PARTSIGN)
374 {
375 mutt_message(_("Warning: Part of this message has not been signed"));
376 }
377 else if (e->security & SEC_SIGN || e->security & SEC_BADSIGN)
378 {
379 mutt_error(_("S/MIME signature could NOT be verified"));
380 }
381 }
382
383 if ((WithCrypto != 0) && (e->security & APPLICATION_PGP) && (cmflags & MUTT_CM_VERIFY))
384 {
385 if (e->security & SEC_GOODSIGN)
386 mutt_message(_("PGP signature successfully verified"));
387 else if (e->security & SEC_PARTSIGN)
388 mutt_message(_("Warning: Part of this message has not been signed"));
389 else if (e->security & SEC_SIGN)
390 mutt_message(_("PGP signature could NOT be verified"));
391 }
392}
int crypt_smime_verify_sender(struct Email *e, struct Message *msg)
Wrapper for CryptModuleSpecs::smime_verify_sender()
Definition: cryptglue.c:463
#define mutt_message(...)
Definition: logging2.h:91
#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 400 of file message.c.

402{
403 const short c_pager_index_lines = cs_subset_number(NeoMutt->sub, "pager_index_lines");
404 if (c_pager_index_lines > 0)
405 {
406 win_index->size = MUTT_WIN_SIZE_FIXED;
407 win_index->req_rows = c_pager_index_lines;
408 win_index->parent->size = MUTT_WIN_SIZE_MINIMISE;
409 }
410 window_set_visible(win_index->parent, (c_pager_index_lines > 0));
411
412 window_set_visible(win_pager->parent, true);
413
414 struct MuttWindow *dlg = dialog_find(win_index);
416
417 // Force the menu to reframe itself
418 struct Menu *menu = win_index->wdata;
419 menu_set_index(menu, menu_get_index(menu));
420}
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:143
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:89
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:160
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:174
void mutt_window_reflow(struct MuttWindow *win)
Resize a Window and its children.
Definition: mutt_window.c:343
void window_set_visible(struct MuttWindow *win, bool visible)
Set a Window visible or hidden.
Definition: mutt_window.c:164
@ 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:79
void * wdata
Private data.
Definition: mutt_window.h:144
short req_rows
Number of rows required.
Definition: mutt_window.h:124
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:134
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
Definition: mutt_window.h:130
+ 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 427 of file message.c.

428{
429 win_index->size = MUTT_WIN_SIZE_MAXIMISE;
431 win_index->parent->size = MUTT_WIN_SIZE_MAXIMISE;
433 window_set_visible(win_index->parent, true);
434
435 window_set_visible(win_pager->parent, false);
436
437 struct MuttWindow *dlg = dialog_find(win_index);
439}
#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 448 of file message.c.

449{
450 struct MuttWindow *dlg = dialog_find(win_index);
451 struct MuttWindow *win_pager = window_find_child(dlg, WT_CUSTOM);
452 struct MuttWindow *win_pbar = window_find_child(dlg, WT_STATUS_BAR);
453 struct Buffer *tempfile = buf_pool_get();
454 struct Message *msg = NULL;
455
456 squash_index_panel(shared->mailbox, win_index, win_pager);
457
458 int rc = PAGER_LOOP_QUIT;
459 do
460 {
461 msg = mx_msg_open(shared->mailbox, shared->email);
462 if (!msg)
463 break;
464
466
467 buf_reset(tempfile);
468 // win_pager might not be visible and have a size yet, so use win_index
469 rc = email_to_file(msg, tempfile, shared->mailbox, shared->email, NULL,
470 win_index->state.cols, &cmflags);
471 if (rc < 0)
472 break;
473
474 notify_crypto(shared->email, msg, cmflags);
475
476 /* Invoke the built-in pager */
477 struct PagerData pdata = { 0 };
478 struct PagerView pview = { &pdata };
479
480 pdata.fp = msg->fp;
481 pdata.fname = buf_string(tempfile);
482
483 pview.mode = PAGER_MODE_EMAIL;
484 pview.banner = NULL;
485 pview.flags = MUTT_PAGER_MESSAGE |
486 (shared->email->body->nowrap ? MUTT_PAGER_NOWRAP : 0);
487 pview.win_index = win_index;
488 pview.win_pbar = win_pbar;
489 pview.win_pager = win_pager;
490
491 rc = dlg_pager(&pview);
492 mx_msg_close(shared->mailbox, &msg);
493 } while (rc == PAGER_LOOP_RELOAD);
494
496
497 mx_msg_close(shared->mailbox, &msg);
498 buf_pool_release(&tempfile);
499 return rc;
500}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
int dlg_pager(struct PagerView *pview)
Display an email, attachment, or help, in a window -.
Definition: dlg_pager.c:215
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:532
@ WT_CUSTOM
Window with a custom drawing function.
Definition: mutt_window.h:94
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:101
@ PAGER_LOOP_RELOAD
Reload the Pager from scratch.
Definition: lib.h:154
@ PAGER_LOOP_QUIT
Quit the Pager.
Definition: lib.h:153
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition: lib.h:73
@ PAGER_MODE_EMAIL
Pager is invoked via 1st path. The mime part is selected automatically.
Definition: lib.h:138
#define MUTT_PAGER_MESSAGE
Definition: lib.h:77
static void expand_index_panel(struct MuttWindow *win_index, struct MuttWindow *win_pager)
Restore the Index Panel.
Definition: message.c:427
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:362
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:400
bool nowrap
Do not wrap the output in the pager.
Definition: body.h:89
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:161
const char * fname
Name of the file to read.
Definition: lib.h:165
FILE * fp
Source stream.
Definition: lib.h:163
Paged view into some data.
Definition: lib.h:172
struct MuttWindow * win_index
Index Window.
Definition: lib.h:178
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:173
enum PagerMode mode
Pager mode.
Definition: lib.h:174
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:175
const char * banner
Title to display in status bar.
Definition: lib.h:176
struct MuttWindow * win_pbar
Pager Bar Window.
Definition: lib.h:179
struct MuttWindow * win_pager
Pager Window.
Definition: lib.h:180
+ 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 62 of file message.c.