NeoMutt  2022-04-29-215-gc12b98
Teaching an old dog new tricks
DOXYGEN
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.

Functions

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

Variables

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

Detailed Description

Attachment Selection Dialog.

Authors
  • 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 http://www.gnu.org/licenses/.

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.

Parameters
subConfig Subset
mMailbox
eEmail
fpFile with the content of the email, or NULL

Definition at line 449 of file dlg_attach.c.

451{
452 if (!m || !e || !fp)
453 return;
454
455 /* make sure we have parsed this message */
458
460 struct Menu *menu = dlg->wdata;
462 menu->tag = attach_tag;
463
464 struct AttachCtx *actx = mutt_actx_new();
465 actx->email = e;
466 actx->fp_root = fp;
467 mutt_update_recvattach_menu(actx, menu, true);
468
470 priv->menu = menu;
471 priv->actx = actx;
472 priv->sub = sub;
473 priv->mailbox = m;
474 menu->mdata = priv;
476
477 // NT_COLOR is handled by the SimpleDialog
480
481 struct MuttWindow *sbar = window_find_child(dlg, WT_STATUS_BAR);
482 sbar_set_title(sbar, _("Attachments"));
483
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);
492
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 }
503
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);
509
510 if (rc == FR_CONTINUE)
511 {
512 op = priv->op;
513 }
514
515 } while (rc != FR_DONE);
516 // ---------------------------------------------------------------------------
517
518 simple_dialog_free(&dlg);
519}
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:591
@ 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 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:658
#define MUTT_MESSAGE_HOOK
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:795
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
Definition: keymap.c:1061
@ LL_DEBUG1
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:74
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
Definition: mutt_window.c:604
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
Definition: mutt_window.c:522
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
Definition: mutt_window.h:102
@ WT_DLG_ATTACH
Attach Dialog, dlg_select_attachment()
Definition: mutt_window.h:78
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition: notify_type.h:55
@ 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:46
void mutt_update_recvattach_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Update the Attachment Menu.
Definition: recvattach.c:1192
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:69
struct MuttWindow * win
Window holding the Menu.
Definition: lib.h:76
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Definition: lib.h:96
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition: lib.h:152
int(* tag)(struct Menu *menu, int sel, int act)
Definition: lib.h:121
void * mdata
Private data.
Definition: lib.h:137
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
@ MENU_ATTACH
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[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Save"), OP_ATTACHMENT_SAVE },
{ N_("Pipe"), OP_PIPE },
{ N_("Print"), OP_ATTACHMENT_PRINT },
{ 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.