NeoMutt  2023-03-22
Teaching an old dog new tricks
dlg_attach.c File Reference

Attachment Selection Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "menu/lib.h"
#include "attach.h"
#include "attachments.h"
#include "format_flags.h"
#include "functions.h"
#include "hdrline.h"
#include "hook.h"
#include "keymap.h"
#include "menu/type.h"
#include "mutt_logging.h"
#include "muttlib.h"
#include "opcodes.h"
#include "private_data.h"
#include "recvattach.h"
+ Include dependency graph for dlg_attach.c:

Go to the source code of this file.


static int attach_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -. More...
const char * attach_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
 Format a string for the attachment menu - Implements format_t -. More...
static void attach_make_entry (struct Menu *menu, char *buf, size_t buflen, int line)
 Format a menu item for the attachment list - Implements Menu::make_entry() -. More...
static int attach_tag (struct Menu *menu, int sel, int act)
 Tag an attachment - Implements Menu::tag() -. More...
static int attach_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -. More...
void dlg_select_attachment (struct ConfigSubset *sub, struct Mailbox *m, struct Email *e, FILE *fp)
 Show the attachments in a Menu. More...


static const struct Mapping AttachHelp []
 Help Bar for the Attachment selection dialog. More...

Detailed Description

Attachment Selection Dialog.

  • Michael R. Elkins
  • Thomas Roessler

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

Definition in file dlg_attach.c.

Function Documentation

◆ dlg_select_attachment()

void dlg_select_attachment ( struct ConfigSubset sub,
struct Mailbox m,
struct Email e,
FILE *  fp 

Show the attachments in a Menu.

subConfig Subset
fpFile with the content of the email, or NULL

Definition at line 449 of file dlg_attach.c.

452 if (!m || !e || !fp)
453 return;
455 /* make sure we have parsed this message */
460 struct Menu *menu = dlg->wdata;
462 menu->tag = attach_tag;
464 struct AttachCtx *actx = mutt_actx_new();
465 actx->email = e;
466 actx->fp_root = fp;
467 mutt_update_recvattach_menu(actx, menu, true);
470 priv->menu = menu;
471 priv->actx = actx;
472 priv->sub = sub;
473 priv->mailbox = m;
474 menu->mdata = priv;
477 // NT_COLOR is handled by the SimpleDialog
481 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
482 sbar_set_title(sbar, _("Attachments"));
484 // ---------------------------------------------------------------------------
485 // Event Loop
486 int rc = 0;
487 int op = OP_NULL;
488 do
489 {
490 menu_tagging_dispatcher(menu->win, op);
491 window_redraw(NULL);
493 op = km_dokey(MENU_ATTACH);
494 mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", opcodes_get_name(op), op);
495 if (op < 0)
496 continue;
497 if (op == OP_NULL)
498 {
500 continue;
501 }
504 rc = attach_function_dispatcher(dlg, op);
505 if (rc == FR_UNKNOWN)
506 rc = menu_function_dispatcher(menu->win, op);
507 if (rc == FR_UNKNOWN)
508 rc = global_function_dispatcher(NULL, op);
510 if (rc == FR_CONTINUE)
511 {
512 op = priv->op;
513 }
515 } while (rc != FR_DONE);
516 // ---------------------------------------------------------------------------
518 simple_dialog_free(&dlg);
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:52
void mutt_parse_mime_message(struct Email *e, FILE *fp)
Parse a MIME email.
Definition: attachments.c:590
Exit the Dialog.
Definition: dispatcher.h:35
Unknown function.
Definition: dispatcher.h:33
Remain in the Dialog.
Definition: dispatcher.h:34
static const struct Mapping AttachHelp[]
Help Bar for the Attachment selection dialog.
Definition: dlg_attach.c:94
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
Definition: tagging.c:223
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
Definition: global.c:164
int attach_function_dispatcher(struct MuttWindow *win, int op)
Perform a Attach function - Implements function_dispatcher_t -.
Definition: functions.c:641
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
Definition: functions.c:320
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
static void attach_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the attachment list - Implements Menu::make_entry() -.
Definition: dlg_attach.c:386
void attach_private_data_free(struct Menu *menu, void **ptr)
Free 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:400
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition: dlg_attach.c:110
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition: dlg_attach.c:419
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: simple.c:166
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
Definition: simple.c:129
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition: hook.c:656
message-hook: run before displaying a message
Definition: hook.h:45
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
Definition: keymap.c:796
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1062
Log at debug level 1.
Definition: logging.h:40
#define _(a)
Definition: message.h:28
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:189
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:73
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:603
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:521
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:78
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
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:46
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1187
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition: sbar.c:224
A set of attachments.
Definition: attach.h:51
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:53
struct Email * email
Used by recvattach for updating.
Definition: attach.h:52
Private state data for Attachments.
Definition: private_data.h:34
int op
Op returned from the Pager, e.g. OP_NEXT_ENTRY.
Definition: private_data.h:39
struct Menu * menu
Current Menu.
Definition: private_data.h:35
struct ConfigSubset * sub
Config subset.
Definition: private_data.h:37
struct AttachCtx * actx
List of all Attachments.
Definition: private_data.h:36
struct Mailbox * mailbox
Current Mailbox.
Definition: private_data.h:38
Definition: lib.h:70
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:77
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:97
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:122
void * mdata
Private data.
Definition: lib.h:138
void * wdata
Private data.
Definition: mutt_window.h:145
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Definition: mutt_window.h:138
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
Select an attachment.
Definition: type.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AttachHelp

const struct Mapping AttachHelp[]
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Pipe"), OP_PIPE },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
#define N_(a)
Definition: message.h:32

Help Bar for the Attachment selection dialog.

Definition at line 94 of file dlg_attach.c.