NeoMutt  2024-10-02-34-g9dd811
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_attach.c
Go to the documentation of this file.
1
70#include "config.h"
71#include <stdbool.h>
72#include <stdio.h>
73#include "mutt/lib.h"
74#include "config/lib.h"
75#include "email/lib.h"
76#include "core/lib.h"
77#include "gui/lib.h"
78#include "lib.h"
79#include "color/lib.h"
80#include "expando/lib.h"
81#include "key/lib.h"
82#include "menu/lib.h"
83#include "attach.h"
84#include "attachments.h"
85#include "functions.h"
86#include "hdrline.h"
87#include "hook.h"
88#include "mutt_logging.h"
89#include "muttlib.h"
90#include "mview.h"
91#include "private_data.h"
92#include "recvattach.h"
93
94void attach_F(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
95 struct Buffer *buf);
96
98static const struct Mapping AttachmentHelp[] = {
99 // clang-format off
100 { N_("Exit"), OP_EXIT },
101 { N_("Save"), OP_ATTACHMENT_SAVE },
102 { N_("Pipe"), OP_PIPE },
103 { N_("Print"), OP_ATTACHMENT_PRINT },
104 { N_("Help"), OP_HELP },
105 { NULL, 0 },
106 // clang-format on
107};
108
115{
116 if (nc->event_type != NT_CONFIG)
117 return 0;
118 if (!nc->global_data || !nc->event_data)
119 return -1;
120
121 struct EventConfig *ev_c = nc->event_data;
122
123 if (!mutt_str_equal(ev_c->name, "attach_format") && !mutt_str_equal(ev_c->name, "message_format"))
124 return 0;
125
126 struct Menu *menu = nc->global_data;
128 mutt_debug(LL_DEBUG5, "config done, request WA_RECALC, MENU_REDRAW_FULL\n");
129
130 return 0;
131}
132
136void attach_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
137 struct Buffer *buf)
138{
139 const struct AttachPtr *aptr = data;
140
141 // NOTE(g0mb4): use $to_chars?
142 const char *s = ((aptr->body->type != TYPE_TEXT) || aptr->body->noconv) ? "n" : "c";
143 buf_strcpy(buf, s);
144}
145
149void attach_C(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
150 struct Buffer *buf)
151{
152 const struct AttachPtr *aptr = data;
153
154 char tmp[128] = { 0 };
155
156 if (mutt_is_text_part(aptr->body) && mutt_body_get_charset(aptr->body, tmp, sizeof(tmp)))
157 {
158 buf_strcpy(buf, tmp);
159 }
160}
161
165void attach_d(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
166 struct Buffer *buf)
167{
168 const struct AttachPtr *aptr = data;
169
170 const struct Expando *c_message_format = cs_subset_expando(NeoMutt->sub, "message_format");
171 if (aptr->body->description)
172 {
173 const char *s = aptr->body->description;
174 buf_strcpy(buf, s);
175 return;
176 }
177
178 if (mutt_is_message_type(aptr->body->type, aptr->body->subtype) &&
179 c_message_format && aptr->body->email)
180 {
181 mutt_make_string(buf, -1, c_message_format, NULL, -1, aptr->body->email,
183
184 return;
185 }
186
187 if (!aptr->body->d_filename && !aptr->body->filename)
188 {
189 const char *s = "<no description>";
190 buf_strcpy(buf, s);
191 return;
192 }
193
194 attach_F(node, data, flags, buf);
195}
196
200long attach_D_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
201{
202 const struct AttachPtr *aptr = data;
203 return aptr->body->deleted;
204}
205
209void attach_D(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
210 struct Buffer *buf)
211{
212 const struct AttachPtr *aptr = data;
213
214 // NOTE(g0mb4): use $to_chars?
215 const char *s = aptr->body->deleted ? "D" : " ";
216 buf_strcpy(buf, s);
217}
218
222void attach_e(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
223 struct Buffer *buf)
224{
225 const struct AttachPtr *aptr = data;
226
227 const char *s = ENCODING(aptr->body->encoding);
228 buf_strcpy(buf, s);
229}
230
234void attach_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
235 struct Buffer *buf)
236{
237 const struct AttachPtr *aptr = data;
238
239 if (aptr->body->filename && (*aptr->body->filename == '/'))
240 {
241 struct Buffer *path = buf_pool_get();
242
243 buf_strcpy(path, aptr->body->filename);
244 buf_pretty_mailbox(path);
245 buf_copy(buf, path);
246 buf_pool_release(&path);
247 }
248 else
249 {
250 const char *s = aptr->body->filename;
251 buf_strcpy(buf, s);
252 }
253}
254
258void attach_F(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
259 struct Buffer *buf)
260{
261 const struct AttachPtr *aptr = data;
262
263 if (aptr->body->d_filename)
264 {
265 const char *s = aptr->body->d_filename;
266 buf_strcpy(buf, s);
267 return;
268 }
269
270 attach_f(node, data, flags, buf);
271}
272
276void attach_I(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
277 struct Buffer *buf)
278{
279 const struct AttachPtr *aptr = data;
280
281 // NOTE(g0mb4): use $to_chars?
282 static const char dispchar[] = { 'I', 'A', 'F', '-' };
283 char ch;
284
285 if (aptr->body->disposition < sizeof(dispchar))
286 {
287 ch = dispchar[aptr->body->disposition];
288 }
289 else
290 {
291 mutt_debug(LL_DEBUG1, "ERROR: invalid content-disposition %d\n", aptr->body->disposition);
292 ch = '!';
293 }
294
295 buf_printf(buf, "%c", ch);
296}
297
301void attach_m(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
302 struct Buffer *buf)
303{
304 const struct AttachPtr *aptr = data;
305
306 const char *s = TYPE(aptr->body);
307 buf_strcpy(buf, s);
308}
309
313void attach_M(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
314 struct Buffer *buf)
315{
316 const struct AttachPtr *aptr = data;
317
318 const char *s = aptr->body->subtype;
319 buf_strcpy(buf, s);
320}
321
325long attach_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
326{
327 const struct AttachPtr *aptr = data;
328
329 return aptr->num + 1;
330}
331
335long attach_Q_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
336{
337 const struct AttachPtr *aptr = data;
338 return aptr->body->attach_qualifies;
339}
340
344void attach_Q(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
345 struct Buffer *buf)
346{
347 const struct AttachPtr *aptr = data;
348
349 // NOTE(g0mb4): use $to_chars?
350 const char *s = aptr->body->attach_qualifies ? "Q" : " ";
351 buf_strcpy(buf, s);
352}
353
357long attach_s_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
358{
359 const struct AttachPtr *aptr = data;
360
361 if (aptr->body->filename && (flags & MUTT_FORMAT_STAT_FILE))
362 return mutt_file_get_size(aptr->body->filename);
363
364 return aptr->body->length;
365}
366
370void attach_s(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
371 struct Buffer *buf)
372{
373 const struct AttachPtr *aptr = data;
374
375 char tmp[128] = { 0 };
376
377 size_t l = 0;
378 if (aptr->body->filename && (flags & MUTT_FORMAT_STAT_FILE))
379 {
380 l = mutt_file_get_size(aptr->body->filename);
381 }
382 else
383 {
384 l = aptr->body->length;
385 }
386
387 mutt_str_pretty_size(tmp, sizeof(tmp), l);
388 buf_strcpy(buf, tmp);
389}
390
394long attach_t_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
395{
396 const struct AttachPtr *aptr = data;
397 return aptr->body->tagged;
398}
399
403void attach_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
404 struct Buffer *buf)
405{
406 const struct AttachPtr *aptr = data;
407
408 // NOTE(g0mb4): use $to_chars?
409 const char *s = aptr->body->tagged ? "*" : " ";
410 buf_strcpy(buf, s);
411}
412
416void attach_T(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
417 struct Buffer *buf)
418{
419 const struct AttachPtr *aptr = data;
420
422 node_expando_set_has_tree(node, true);
423 const char *s = aptr->tree;
424 buf_strcpy(buf, s);
425}
426
430long attach_u_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
431{
432 const struct AttachPtr *aptr = data;
433 return aptr->body->unlink;
434}
435
439void attach_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags,
440 struct Buffer *buf)
441{
442 const struct AttachPtr *aptr = data;
443
444 // NOTE(g0mb4): use $to_chars?
445 const char *s = aptr->body->unlink ? "-" : " ";
446 buf_strcpy(buf, s);
447}
448
452long attach_X_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
453{
454 const struct AttachPtr *aptr = data;
455 const struct Body *body = aptr->body;
456
457 return body->attach_count + body->attach_qualifies;
458}
459
465static int attach_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
466{
467 struct AttachPrivateData *priv = menu->mdata;
468 struct AttachCtx *actx = priv->actx;
469
470 const bool c_arrow_cursor = cs_subset_bool(menu->sub, "arrow_cursor");
471 if (c_arrow_cursor)
472 {
473 const char *const c_arrow_string = cs_subset_string(menu->sub, "arrow_string");
474 max_cols -= (mutt_strwidth(c_arrow_string) + 1);
475 }
476
477 const struct Expando *c_attach_format = cs_subset_expando(NeoMutt->sub, "attach_format");
478 return expando_filter(c_attach_format, AttachRenderData, (actx->idx[actx->v2r[line]]),
479 MUTT_FORMAT_ARROWCURSOR, max_cols, buf);
480}
481
485static int attach_tag(struct Menu *menu, int sel, int act)
486{
487 struct AttachPrivateData *priv = menu->mdata;
488 struct AttachCtx *actx = priv->actx;
489
490 struct Body *cur = actx->idx[actx->v2r[sel]]->body;
491 bool ot = cur->tagged;
492
493 cur->tagged = ((act >= 0) ? act : !cur->tagged);
494 return cur->tagged - ot;
495}
496
505{
506 if (nc->event_type != NT_WINDOW)
507 return 0;
508 if (!nc->global_data || !nc->event_data)
509 return -1;
511 return 0;
512
513 struct MuttWindow *win_menu = nc->global_data;
514 struct EventWindow *ev_w = nc->event_data;
515 if (ev_w->win != win_menu)
516 return 0;
517
518 struct Menu *menu = win_menu->wdata;
519
522
523 mutt_debug(LL_DEBUG5, "window delete done\n");
524 return 0;
525}
526
540 struct Email *e, FILE *fp, bool attach_msg)
541{
542 if (!mv || !mv->mailbox || !e || !fp)
543 return;
544
545 struct Mailbox *m = mv->mailbox;
546
547 /* make sure we have parsed this message */
550
552 struct Menu *menu = dlg->wdata;
554 menu->tag = attach_tag;
555
556 struct AttachCtx *actx = mutt_actx_new();
557 actx->email = e;
558 actx->fp_root = fp;
559 mutt_update_recvattach_menu(actx, menu, true);
560
562 priv->menu = menu;
563 priv->actx = actx;
564 priv->sub = sub;
565 priv->mailbox = m;
566 priv->attach_msg = attach_msg;
567 menu->mdata = priv;
569
570 // NT_COLOR is handled by the SimpleDialog
573
574 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
575 sbar_set_title(sbar, _("Attachments"));
576
577 struct MuttWindow *old_focus = window_set_focus(menu->win);
578 // ---------------------------------------------------------------------------
579 // Event Loop
580 int rc = 0;
581 int op = OP_NULL;
582 do
583 {
584 menu_tagging_dispatcher(menu->win, op);
585 window_redraw(NULL);
586
588 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
589 if (op < 0)
590 continue;
591 if (op == OP_NULL)
592 {
594 continue;
595 }
597
598 rc = attach_function_dispatcher(dlg, op);
599 if (rc == FR_UNKNOWN)
600 rc = menu_function_dispatcher(menu->win, op);
601 if (rc == FR_UNKNOWN)
602 rc = global_function_dispatcher(NULL, op);
603
604 if (rc == FR_CONTINUE)
605 {
606 op = priv->op;
607 }
608
609 } while (rc != FR_DONE);
610 // ---------------------------------------------------------------------------
611
612 window_set_focus(old_focus);
613 simple_dialog_free(&dlg);
614}
615
622 // clang-format off
628 { ED_BODY, ED_BOD_FILE, attach_f, NULL },
637 { ED_ATTACH, ED_ATT_TREE, attach_T, NULL },
640 { -1, -1, NULL, NULL },
641 // clang-format on
642};
struct AttachCtx * mutt_actx_new(void)
Create a new Attachment Context.
Definition: attach.c:189
struct AttachPrivateData * attach_private_data_new(void)
Create new Attach Data.
Definition: private_data.c:50
Handling of email attachments.
@ ED_ATT_NUMBER
AttachPtr.num.
Definition: attach.h:57
@ ED_ATT_TREE
AttachPtr.tree.
Definition: attach.h:58
@ ED_ATT_CHARSET
AttachPtr.body.
Definition: attach.h:56
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:597
Miscellaneous email parsing routines.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition: buffer.c:601
Color and attribute parsing.
@ MT_COLOR_TREE
Index: tree-drawing characters.
Definition: color.h:79
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:291
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:47
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
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition: curs_lib.c:443
@ FR_DONE
Exit the Dialog.
Definition: dispatcher.h:35
@ FR_UNKNOWN
Unknown function.
Definition: dispatcher.h:33
@ FR_CONTINUE
Remain in the Dialog.
Definition: dispatcher.h:34
static const struct Mapping AttachmentHelp[]
Help Bar for the Attachment selection dialog.
Definition: dlg_attach.c:98
const struct ExpandoRenderData AttachRenderData[]
Callbacks for Attachment Expandos.
Definition: dlg_attach.c:621
@ ED_BODY
Body ED_BOD_ ExpandoDataBody.
Definition: domain.h:38
@ ED_ATTACH
Attach ED_ATT_ ExpandoDataAttach.
Definition: domain.h:36
char * mutt_body_get_charset(struct Body *b, char *buf, size_t buflen)
Get a body's character set.
Definition: body.c:133
@ ED_BOD_DESCRIPTION
Body.description.
Definition: body.h:106
@ ED_BOD_CHARSET_CONVERT
Body.type.
Definition: body.h:104
@ ED_BOD_DELETED
Body.deleted.
Definition: body.h:105
@ ED_BOD_UNLINK
Body.unlink.
Definition: body.h:115
@ ED_BOD_FILE_SIZE
Body.filename.
Definition: body.h:110
@ ED_BOD_DISPOSITION
Body.disposition.
Definition: body.h:107
@ ED_BOD_ATTACH_QUALIFIES
Body.attach_qualifies.
Definition: body.h:103
@ ED_BOD_MIME_MAJOR
Body.type, Body.xtype.
Definition: body.h:112
@ ED_BOD_TAGGED
Body.tagged.
Definition: body.h:114
@ ED_BOD_ATTACH_COUNT
Body.attach_count.
Definition: body.h:102
@ ED_BOD_FILE
Body.filename.
Definition: body.h:108
@ ED_BOD_MIME_MINOR
Body.subtype.
Definition: body.h:113
@ ED_BOD_FILE_DISPOSITION
Body.d_filename.
Definition: body.h:109
@ ED_BOD_MIME_ENCODING
Body.encoding.
Definition: body.h:111
Structs that make up an email.
bool mutt_is_message_type(int type, const char *subtype)
Determine if a mime type matches a message or not.
Definition: parse.c:1498
int expando_filter(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition: filter.c:138
Parse Expando string.
long mutt_file_get_size(const char *path)
Get the size of a file.
Definition: file.c:1519
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
Definition: get.c:464
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: get.c:294
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:230
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:172
int attach_function_dispatcher(struct MuttWindow *win, int op)
Perform a Attach function - Implements function_dispatcher_t -.
Definition: functions.c:713
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:318
long attach_s_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Size - Implements ExpandoRenderData::get_number() -.
Definition: dlg_attach.c:357
long attach_u_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Unlink flag - Implements ExpandoRenderData::get_number() -.
Definition: dlg_attach.c:430
long attach_D_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Deleted - Implements ExpandoRenderData::get_number() -.
Definition: dlg_attach.c:200
long attach_Q_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Attachment counting - Implements ExpandoRenderData::get_number() -.
Definition: dlg_attach.c:335
long attach_t_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Is Tagged - Implements ExpandoRenderData::get_number() -.
Definition: dlg_attach.c:394
long attach_X_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Number of MIME parts - Implements ExpandoRenderData::get_number() -.
Definition: dlg_attach.c:452
long attach_n_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Attachment: Index number - Implements ExpandoRenderData::get_number() -.
Definition: dlg_attach.c:325
void attach_C(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Charset - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:149
void attach_d(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Description - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:165
void attach_F(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Filename in header - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:258
void attach_m(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Major MIME type - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:301
void attach_T(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Tree characters - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:416
void attach_u(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Unlink flag - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:439
void attach_s(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Size - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:370
void attach_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Filename - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:234
void attach_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Requires conversion flag - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:136
void attach_Q(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Attachment counting - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:344
void attach_M(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: MIME subtype - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:313
void attach_t(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Is Tagged - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:403
void attach_D(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Deleted - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:209
void attach_I(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: Disposition flag - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:276
void attach_e(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Attachment: MIME type - Implements ExpandoRenderData::get_string() -.
Definition: dlg_attach.c:222
void dlg_attachment(struct ConfigSubset *sub, struct MailboxView *mv, struct Email *e, FILE *fp, bool attach_msg)
Show the attachments in a Menu -.
Definition: dlg_attach.c:539
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int attach_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Attachment for the Menu - Implements Menu::make_entry() -.
Definition: dlg_attach.c:465
void attach_private_data_free(struct Menu *menu, void **ptr)
Free the Attach Data - Implements Menu::mdata_free() -.
Definition: private_data.c:38
static int attach_tag(struct Menu *menu, int sel, int act)
Tag an attachment - Implements Menu::tag() -.
Definition: dlg_attach.c:485
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_attach.c:114
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_attach.c:504
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:168
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:132
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
String processing routines to generate the mail index.
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:700
Parse and execute user-defined hooks.
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition: hook.h:44
Manage keymappings.
#define GETCH_NO_FLAGS
No flags are set.
Definition: lib.h:51
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
GUI present the user with a selectable list.
#define MENU_REDRAW_FULL
Redraw everything.
Definition: lib.h:59
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition: menu.c:184
@ TYPE_TEXT
Type: 'text/*'.
Definition: mime.h:38
#define ENCODING(x)
Definition: mime.h:92
#define TYPE(body)
Definition: mime.h:89
Convenience wrapper for the library headers.
#define N_(a)
Definition: message.h:32
#define _(a)
Definition: message.h:28
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:191
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:74
NeoMutt Logging.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:633
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
Definition: mutt_window.c:683
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_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:101
@ WT_DLG_ATTACHMENT
Attachment Dialog, dlg_attachment()
Definition: mutt_window.h:78
@ NT_WINDOW_DELETE
Window is about to be deleted.
Definition: mutt_window.h:228
bool mutt_is_text_part(const struct Body *b)
Is this part of an email in plain text?
Definition: muttlib.c:407
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:519
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Definition: muttlib.c:1004
Some miscellaneous functions.
View of a Mailbox.
void node_expando_set_color(const struct ExpandoNode *node, int cid)
Set the colour for an Expando.
Definition: node_expando.c:100
void node_expando_set_has_tree(const struct ExpandoNode *node, bool has_tree)
Set the has_tree flag for an Expando.
Definition: node_expando.c:115
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:57
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition: notify_type.h:43
const char * opcodes_get_name(int op)
Get the name of an opcode.
Definition: opcodes.c:48
Private state data for the Pager.
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
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1214
Routines for managing attachments.
#define MUTT_FORMAT_FORCESUBJ
Print the subject even if unchanged.
Definition: render.h:34
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: render.h:37
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: render.h:32
#define MUTT_FORMAT_STAT_FILE
Used by attach_format_str.
Definition: render.h:36
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:227
Sidebar functions.
Key value store.
A set of attachments.
Definition: attach.h:65
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:67
struct Email * email
Used by recvattach for updating.
Definition: attach.h:66
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:69
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:73
Private state data for Attachments.
Definition: private_data.h:36
int op
Op returned from the Pager, e.g. OP_NEXT_ENTRY.
Definition: private_data.h:41
struct Menu * menu
Current Menu.
Definition: private_data.h:37
struct ConfigSubset * sub
Config subset.
Definition: private_data.h:39
struct AttachCtx * actx
List of all Attachments.
Definition: private_data.h:38
bool attach_msg
Are we in "attach message" mode?
Definition: private_data.h:42
struct Mailbox * mailbox
Current Mailbox.
Definition: private_data.h:40
An email to which things will be attached.
Definition: attach.h:37
struct Body * body
Attachment.
Definition: attach.h:38
char * tree
Tree characters to display.
Definition: attach.h:41
int num
Attachment index number.
Definition: attach.h:43
The body of an email.
Definition: body.h:36
char * d_filename
filename to be used for the content-disposition header If NULL, filename is used instead.
Definition: body.h:56
signed short attach_count
Number of attachments.
Definition: body.h:91
bool deleted
Attachment marked for deletion.
Definition: body.h:88
bool noconv
Don't do character set conversion.
Definition: body.h:46
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition: body.h:68
LOFF_T length
length (in bytes) of attachment
Definition: body.h:53
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:75
struct Email * email
header information for message/rfc822
Definition: body.h:74
char * description
content-description
Definition: body.h:55
unsigned int disposition
content-disposition, ContentDisposition
Definition: body.h:42
bool attach_qualifies
This attachment should be counted.
Definition: body.h:87
bool tagged
This attachment is tagged.
Definition: body.h:90
char * subtype
content-type subtype
Definition: body.h:61
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition: body.h:41
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
char * filename
When sending a message, this is the file to which this structure refers.
Definition: body.h:59
String manipulation buffer.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:37
A set of inherited config items.
Definition: subset.h:47
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition: subset.h:52
The envelope/body of an email.
Definition: email.h:39
A config-change event.
Definition: subset.h:71
const char * name
Name of config item that changed.
Definition: subset.h:73
An Event that happened to a Window.
Definition: mutt_window.h:238
struct MuttWindow * win
Window that changed.
Definition: mutt_window.h:239
Basic Expando Node.
Definition: node.h:67
Parsed Expando trees.
Definition: expando.h:41
struct ExpandoNode * node
Parsed tree.
Definition: expando.h:43
View of a Mailbox.
Definition: mview.h:40
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:51
A mailbox.
Definition: mailbox.h:79
Mapping between user-readable string and a constant.
Definition: mapping.h:33
Definition: lib.h:79
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:86
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:161
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:131
int(* make_entry)(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Definition: lib.h:106
struct ConfigSubset * sub
Inherited config items.
Definition: lib.h:87
void * mdata
Private data.
Definition: lib.h:147
void * wdata
Private data.
Definition: mutt_window.h:144
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:137
Container for Accounts, Notifications.
Definition: neomutt.h:42
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
Data passed to a notification function.
Definition: observer.h:34
void * event_data
Data from notify_send()
Definition: observer.h:38
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
Definition: observer.h:37
void * global_data
Data from notify_observer_add()
Definition: observer.h:39
@ MENU_ATTACHMENT
Select an attachment.
Definition: type.h:38