snprintf(buf, sizeof(buf), "%s/%s", TYPE(cur->content), cur->content->subtype);
mutt_parse_mime_message(Context->mailbox, cur);
- mutt_message_hook(Context, cur, MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, cur, MUTT_MESSAGE_HOOK);
/* see if crypto is needed for this message. if so, we should exit curses */
if ((WithCrypto != 0) && cur->security)
static int pipe_message(struct Email *e, char *cmd, bool decode, bool print,
bool split, const char *sep)
{
+ if (!Context)
+ return 1;
+
int rc = 0;
pid_t thepid;
FILE *fpout = NULL;
if (e)
{
- mutt_message_hook(Context, e, MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, e, MUTT_MESSAGE_HOOK);
if ((WithCrypto != 0) && decode)
{
if (!message_is_tagged(Context, i))
continue;
- mutt_message_hook(Context, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
mutt_parse_mime_message(Context->mailbox, Context->mailbox->hdrs[i]);
if (Context->mailbox->hdrs[i]->security & ENCRYPT &&
!crypt_valid_passphrase(Context->mailbox->hdrs[i]->security))
if (!message_is_tagged(Context, i))
continue;
- mutt_message_hook(Context, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
mutt_endwin();
thepid = mutt_create_filter(cmd, &fpout, NULL, NULL);
if (thepid < 0)
if (!message_is_tagged(Context, i))
continue;
- mutt_message_hook(Context, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
pipe_msg(Context->mailbox->hdrs[i], fpout, decode, print);
/* add the message separator */
if (sep)
need_passphrase = (e->security & ENCRYPT);
app = e->security;
}
- mutt_message_hook(Context, e, MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, e, MUTT_MESSAGE_HOOK);
mutt_default_save(buf, sizeof(buf), e);
}
else
if (e)
{
- mutt_message_hook(Context, e, MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, e, MUTT_MESSAGE_HOOK);
mutt_default_save(buf, sizeof(buf), e);
if (WithCrypto)
{
if (!message_is_tagged(Context, i))
continue;
- mutt_message_hook(Context, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
+ mutt_message_hook(Context->mailbox, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
rc = mutt_save_message_ctx(Context->mailbox->hdrs[i], delete, decode,
decrypt, savectx->mailbox);
if (rc != 0)
/**
* mutt_message_hook - Perform a message hook
- * @param ctx Mailbox Context
+ * @param m Mailbox Context
* @param e Email
* @param type Hook type, e.g. #MUTT_MESSAGE_HOOK
*/
-void mutt_message_hook(struct Context *ctx, struct Email *e, int type)
+void mutt_message_hook(struct Mailbox *m, struct Email *e, int type)
{
struct Buffer err, token;
struct Hook *hook = NULL;
if (hook->type & type)
{
- if ((mutt_pattern_exec(hook->pattern, 0, ctx->mailbox, e, &cache) > 0) ^
+ if ((mutt_pattern_exec(hook->pattern, 0, m, e, &cache) > 0) ^
hook->regex.not)
{
if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
struct Address;
struct Buffer;
-struct Context;
struct Email;
struct ListHead;
+struct Mailbox;
/* These Config Variables are only used in hook.c */
extern char *DefaultHook;
void mutt_delete_hooks(int type);
char *mutt_find_hook(int type, const char *pat);
void mutt_folder_hook(const char *path);
-void mutt_message_hook(struct Context *ctx, struct Email *e, int type);
+void mutt_message_hook(struct Mailbox *m, struct Email *e, int type);
int mutt_parse_hook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
int mutt_parse_unhook(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err);
void mutt_select_fcc(char *path, size_t pathlen, struct Email *e);
static const char *Mailbox_is_read_only = N_("Mailbox is read-only");
#define CHECK_READONLY \
- if (Context->mailbox->readonly) \
+ if (!Context || !Context->mailbox || Context->mailbox->readonly) \
{ \
mutt_flushinp(); \
mutt_error(_(Mailbox_is_read_only)); \
int flags = 0;
int op = OP_NULL;
+ struct Mailbox *m = Context ? Context->mailbox : NULL;
+
/* make sure we have parsed this message */
- mutt_parse_mime_message(Context->mailbox, e);
+ mutt_parse_mime_message(m, e);
- mutt_message_hook(Context, e, MUTT_MESSAGE_HOOK);
+ mutt_message_hook(m, e, MUTT_MESSAGE_HOOK);
- struct Message *msg = mx_msg_open(Context->mailbox, e->msgno);
+ struct Message *msg = mx_msg_open(m, e->msgno);
if (!msg)
return;
CHECK_READONLY;
#ifdef USE_POP
- if (Context->mailbox->magic == MUTT_POP)
+ if (m->magic == MUTT_POP)
{
mutt_flushinp();
mutt_error(_("Can't delete attachment from POP server"));
#endif
#ifdef USE_NNTP
- if (Context->mailbox->magic == MUTT_NNTP)
+ if (m->magic == MUTT_NNTP)
{
mutt_flushinp();
mutt_error(_("Can't delete attachment from news server"));
break;
case OP_EXIT:
- mx_msg_close(Context->mailbox, &msg);
+ mx_msg_close(m, &msg);
e->attach_del = false;
for (int i = 0; i < actx->idxlen; i++)
int chflags = CH_DECODE, cmflags = 0;
mutt_parse_mime_message(ctx->mailbox, cur);
- mutt_message_hook(ctx, cur, MUTT_MESSAGE_HOOK);
+ mutt_message_hook(ctx->mailbox, cur, MUTT_MESSAGE_HOOK);
if ((WithCrypto != 0) && (cur->security & ENCRYPT) && ForwardDecode)
{
}
mutt_parse_mime_message(ctx->mailbox, cur);
- mutt_message_hook(ctx, cur, MUTT_MESSAGE_HOOK);
+ mutt_message_hook(ctx->mailbox, cur, MUTT_MESSAGE_HOOK);
mutt_make_attribution(ctx, cur, out);
if ((flags & SEND_REPLY) && cur)
{
/* change setting based upon message we are replying to */
- mutt_message_hook(ctx, cur, MUTT_REPLY_HOOK);
+ mutt_message_hook(ctx->mailbox, cur, MUTT_REPLY_HOOK);
/* set the replied flag for the message we are generating so that the
* user can use ~Q in a send-hook to know when reply-hook's are also