snprintf(buf, sizeof(buf), "%s/%s", TYPE(cur->content), cur->content->subtype);
- mutt_parse_mime_message(Context, cur);
+ mutt_parse_mime_message(Context->mailbox, cur);
mutt_message_hook(Context, cur, MUTT_MESSAGE_HOOK);
/* see if crypto is needed for this message. if so, we should exit curses */
if (!OptNoCurses)
keypad(stdscr, true);
if (r != -1)
- mutt_set_flag(Context, cur, MUTT_READ, 1);
+ mutt_set_flag(Context->mailbox, cur, MUTT_READ, 1);
if (r != -1 && PromptAfter)
{
mutt_unget_event(mutt_any_key_to_continue(_("Command: ")), 0);
}
if (decode)
- mutt_parse_mime_message(Context, e);
+ mutt_parse_mime_message(Context->mailbox, e);
mutt_copy_message_ctx(fp, Context, e, cmflags, chflags);
}
if ((WithCrypto != 0) && decode)
{
- mutt_parse_mime_message(Context, e);
+ mutt_parse_mime_message(Context->mailbox, e);
if (e->security & ENCRYPT && !crypt_valid_passphrase(e->security))
return 1;
}
continue;
mutt_message_hook(Context, Context->mailbox->hdrs[i], MUTT_MESSAGE_HOOK);
- mutt_parse_mime_message(Context, Context->mailbox->hdrs[i]);
+ 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))
{
set_copy_flags(e, decode, decrypt, &cmflags, &chflags);
if (decode || decrypt)
- mutt_parse_mime_message(Context, e);
+ mutt_parse_mime_message(Context->mailbox, e);
rc = mutt_append_message(ctx, Context, e, cmflags, chflags);
if (rc != 0)
if (delete)
{
- mutt_set_flag(Context, e, MUTT_DELETE, 1);
- mutt_set_flag(Context, e, MUTT_PURGE, 1);
+ mutt_set_flag(Context->mailbox, e, MUTT_DELETE, 1);
+ mutt_set_flag(Context->mailbox, e, MUTT_PURGE, 1);
if (DeleteUntag)
- mutt_set_flag(Context, e, MUTT_TAG, 0);
+ mutt_set_flag(Context->mailbox, e, MUTT_TAG, 0);
}
return 0;
e->security |= PGP_TRADITIONAL_CHECKED;
- mutt_parse_mime_message(Context, e);
- struct Message *msg = mx_msg_open(Context, e->msgno);
+ mutt_parse_mime_message(Context->mailbox, e);
+ struct Message *msg = mx_msg_open(Context->mailbox, e->msgno);
if (!msg)
return 0;
if (crypt_pgp_check_traditional(msg->fp, e->content, false))
}
e->security |= PGP_TRADITIONAL_CHECKED;
- mx_msg_close(Context, &msg);
+ mx_msg_close(Context->mailbox, &msg);
return rc;
}
/**
* comp_msg_open - Implements MxOps::msg_open()
*/
-static int comp_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+static int comp_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox || !ctx->mailbox->compress_info)
+ if (!m || !m->compress_info)
return -1;
- struct CompressInfo *ci = ctx->mailbox->compress_info;
+ struct CompressInfo *ci = m->compress_info;
const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
/* Delegate */
- return ops->msg_open(ctx, msg, msgno);
+ return ops->msg_open(m, msg, msgno);
}
/**
* comp_msg_open_new - Implements MxOps::msg_open_new()
*/
-static int comp_msg_open_new(struct Context *ctx, struct Message *msg, struct Email *e)
+static int comp_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e)
{
- if (!ctx || !ctx->mailbox || !ctx->mailbox->compress_info)
+ if (!m || !m->compress_info)
return -1;
- struct CompressInfo *ci = ctx->mailbox->compress_info;
+ struct CompressInfo *ci = m->compress_info;
const struct MxOps *ops = ci->child_ops;
if (!ops)
return -1;
/* Delegate */
- return ops->msg_open_new(ctx, msg, e);
+ return ops->msg_open_new(m, msg, e);
}
/**
int mutt_copy_message_ctx(FILE *fpout, struct Context *src, struct Email *e,
int flags, int chflags)
{
- struct Message *msg = mx_msg_open(src, e->msgno);
+ struct Message *msg = mx_msg_open(src->mailbox, e->msgno);
if (!msg)
return -1;
if (!e->content)
mutt_debug(1, "failed to detect EOF!\n");
r = -1;
}
- mx_msg_close(src, &msg);
+ mx_msg_close(src->mailbox, &msg);
return r;
}
if (!fgets(buf, sizeof(buf), fpin))
return -1;
- msg = mx_msg_open_new(dest, e, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
+ msg = mx_msg_open_new(dest->mailbox, e, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
if (!msg)
return -1;
if (dest->mailbox->magic == MUTT_MBOX || dest->mailbox->magic == MUTT_MMDF)
nm_update_filename(src->mailbox, NULL, msg->committed_path, e);
#endif
- mx_msg_close(dest, &msg);
+ mx_msg_close(dest->mailbox, &msg);
return r;
}
int mutt_append_message(struct Context *dest, struct Context *src,
struct Email *e, int cmflags, int chflags)
{
- struct Message *msg = mx_msg_open(src, e->msgno);
+ struct Message *msg = mx_msg_open(src->mailbox, e->msgno);
if (!msg)
return -1;
int r = append_message(dest, msg->fp, src, e, cmflags, chflags);
- mx_msg_close(src, &msg);
+ mx_msg_close(src->mailbox, &msg);
return r;
}
o_old = cur->old;
cur->read = false;
cur->old = false;
- msg = mx_msg_open_new(tmpctx, cur, of);
+ msg = mx_msg_open_new(tmpctx->mailbox, cur, of);
cur->read = o_read;
cur->old = o_old;
}
rc = mx_msg_commit(tmpctx, msg);
- mx_msg_close(tmpctx, &msg);
+ mx_msg_close(tmpctx->mailbox, &msg);
mx_mbox_close(&tmpctx, NULL);
if (rc == 0)
{
- mutt_set_flag(Context, cur, MUTT_DELETE, 1);
- mutt_set_flag(Context, cur, MUTT_PURGE, 1);
- mutt_set_flag(Context, cur, MUTT_READ, 1);
+ mutt_set_flag(Context->mailbox, cur, MUTT_DELETE, 1);
+ mutt_set_flag(Context->mailbox, cur, MUTT_PURGE, 1);
+ mutt_set_flag(Context->mailbox, cur, MUTT_READ, 1);
if (DeleteUntag)
- mutt_set_flag(Context, cur, MUTT_TAG, 0);
+ mutt_set_flag(Context->mailbox, cur, MUTT_TAG, 0);
}
else if (rc == -1)
mutt_message(_("Error. Preserving temporary file: %s"), tmp);
/**
* mutt_set_flag_update - Set a flag on an email
- * @param ctx Mailbox Context
+ * @param m Mailbox
* @param e Email
* @param flag Flag to set, e.g. #MUTT_DELETE
* @param bf true: set the flag; false: clear the flag
* @param upd_ctx true: update the Context
*/
-void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool bf, bool upd_ctx)
+void mutt_set_flag_update(struct Mailbox *m, struct Email *e, int flag, bool bf, bool upd_ctx)
{
- if (!ctx || !ctx->mailbox || !e)
+ if (!m || !e)
return;
- struct Mailbox *m = ctx->mailbox;
-
bool changed = e->changed;
int deleted = m->msg_deleted;
int tagged = m->msg_tagged;
#ifdef USE_IMAP
/* deleted messages aren't treated as changed elsewhere so that the
* purge-on-sync option works correctly. This isn't applicable here */
- if (ctx && m->magic == MUTT_IMAP)
+ if (m->magic == MUTT_IMAP)
{
e->changed = true;
if (upd_ctx)
if (update)
{
- mutt_set_header_color(ctx, e);
+ mutt_set_header_color(m, e);
#ifdef USE_SIDEBAR
mutt_menu_set_current_redraw(REDRAW_SIDEBAR);
#endif
{
for (int i = 0; i < Context->mailbox->msg_count; i++)
if (message_is_tagged(Context, i))
- mutt_set_flag(Context, Context->mailbox->hdrs[i], flag, bf);
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[i], flag, bf);
}
/**
start = cur;
if (cur->message && cur != e->thread)
- mutt_set_flag(Context, cur->message, flag, bf);
+ mutt_set_flag(Context->mailbox, cur->message, flag, bf);
cur = cur->child;
if (!cur)
while (true)
{
if (cur->message && cur != e->thread)
- mutt_set_flag(Context, cur->message, flag, bf);
+ mutt_set_flag(Context->mailbox, cur->message, flag, bf);
if (cur->child)
cur = cur->child;
done:
cur = e->thread;
if (cur->message)
- mutt_set_flag(Context, cur->message, flag, bf);
+ mutt_set_flag(Context->mailbox, cur->message, flag, bf);
return 0;
}
if (!bf)
{
if (e)
- mutt_set_flag(Context, e, MUTT_PURGE, bf);
+ mutt_set_flag(Context->mailbox, e, MUTT_PURGE, bf);
else
mutt_tag_set_flag(MUTT_PURGE, bf);
}
case 'o':
case 'O':
if (e)
- mutt_set_flag(Context, e, MUTT_READ, !bf);
+ mutt_set_flag(Context->mailbox, e, MUTT_READ, !bf);
else
mutt_tag_set_flag(MUTT_READ, !bf);
flag = MUTT_OLD;
}
if (e)
- mutt_set_flag(Context, e, flag, bf);
+ mutt_set_flag(Context->mailbox, e, flag, bf);
else
mutt_tag_set_flag(flag, bf);
case 'X':
{
- int count = mutt_count_body_parts(ctx, e);
+ int count = mutt_count_body_parts(ctx->mailbox, e);
/* The recursion allows messages without depth to return 0. */
if (optional)
#include <unistd.h>
#include "mutt/mutt.h"
#include "email/lib.h"
+#include "context.h"
#include "mutt.h"
#include "hook.h"
#include "alias.h"
if (hook->type & type)
{
- if ((mutt_pattern_exec(hook->pattern, 0, ctx, e, &cache) > 0) ^
+ if ((mutt_pattern_exec(hook->pattern, 0, ctx->mailbox, e, &cache) > 0) ^
hook->regex.not)
{
if (mutt_parse_rc_line(hook->command, &token, &err) == -1)
if (hook->type & type)
{
- if ((mutt_pattern_exec(hook->pattern, 0, ctx, e, &cache) > 0) ^
+ if ((mutt_pattern_exec(hook->pattern, 0, ctx->mailbox, e, &cache) > 0) ^
hook->regex.not)
{
mutt_make_string_flags(path, pathlen, hook->command, ctx, e, MUTT_FORMAT_PLAIN);
/**
* imap_msg_open_new - Implements MxOps::msg_open_new()
*/
-static int imap_msg_open_new(struct Context *ctx, struct Message *msg, struct Email *e)
+static int imap_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e)
{
char tmp[PATH_MAX];
int imap_cache_clean(struct ImapAccountData *adata);
int imap_append_message(struct Mailbox *m, struct Message *msg);
-int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno);
+int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno);
int imap_msg_close(struct Mailbox *m, struct Message *msg);
int imap_msg_commit(struct Mailbox *m, struct Message *msg);
* case of local_changes, if a change to a flag _would_ have been
* made.
*/
-static void set_changed_flag(struct Context *ctx, struct Email *e,
+static void set_changed_flag(struct Mailbox *m, struct Email *e,
int local_changes, int *server_changes, int flag_name,
int old_hd_flag, int new_hd_flag, int h_flag)
{
/* Local changes have priority */
if (!local_changes)
- mutt_set_flag(ctx, e, flag_name, new_hd_flag);
+ mutt_set_flag(m, e, flag_name, new_hd_flag);
}
#ifdef USE_HCACHE
if (!message_is_tagged(ctx, i))
continue;
- mutt_set_flag(ctx, m->hdrs[i], MUTT_DELETE, 1);
- mutt_set_flag(ctx, m->hdrs[i], MUTT_PURGE, 1);
+ mutt_set_flag(m, m->hdrs[i], MUTT_DELETE, 1);
+ mutt_set_flag(m, m->hdrs[i], MUTT_PURGE, 1);
if (DeleteUntag)
- mutt_set_flag(ctx, m->hdrs[i], MUTT_TAG, 0);
+ mutt_set_flag(m, m->hdrs[i], MUTT_TAG, 0);
}
}
else
{
- mutt_set_flag(ctx, e, MUTT_DELETE, 1);
- mutt_set_flag(ctx, e, MUTT_PURGE, 1);
+ mutt_set_flag(m, e, MUTT_DELETE, 1);
+ mutt_set_flag(m, e, MUTT_PURGE, 1);
if (DeleteUntag)
- mutt_set_flag(ctx, e, MUTT_TAG, 0);
+ mutt_set_flag(m, e, MUTT_TAG, 0);
}
}
/* This is redundant with the following two checks. Removing:
* mutt_set_flag (adata->ctx, e, MUTT_NEW, !(edata->read || edata->old));
*/
- set_changed_flag(adata->ctx, e, local_changes, server_changes, MUTT_OLD,
+ set_changed_flag(m, e, local_changes, server_changes, MUTT_OLD,
old_edata.old, edata->old, e->old);
- set_changed_flag(adata->ctx, e, local_changes, server_changes, MUTT_READ,
+ set_changed_flag(m, e, local_changes, server_changes, MUTT_READ,
old_edata.read, edata->read, e->read);
- set_changed_flag(adata->ctx, e, local_changes, server_changes, MUTT_DELETE,
+ set_changed_flag(m, e, local_changes, server_changes, MUTT_DELETE,
old_edata.deleted, edata->deleted, e->deleted);
- set_changed_flag(adata->ctx, e, local_changes, server_changes, MUTT_FLAG,
+ set_changed_flag(m, e, local_changes, server_changes, MUTT_FLAG,
old_edata.flagged, edata->flagged, e->flagged);
- set_changed_flag(adata->ctx, e, local_changes, server_changes, MUTT_REPLIED,
+ set_changed_flag(m, e, local_changes, server_changes, MUTT_REPLIED,
old_edata.replied, edata->replied, e->replied);
/* this message is now definitively *not* changed (mutt_set_flag
/**
* imap_msg_open - Implements MxOps::msg_open()
*/
-int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox || !msg)
+ if (!m || !msg)
return -1;
struct Envelope *newenv = NULL;
bool fetched = false;
int output_progress;
- struct Mailbox *m = ctx->mailbox;
-
struct ImapAccountData *adata = imap_adata_get(m);
struct ImapMboxData *mdata = m->mdata;
struct Email *e = m->hdrs[msgno];
if (read != e->read)
{
e->read = read;
- mutt_set_flag(ctx, e, MUTT_NEW, read);
+ mutt_set_flag(m, e, MUTT_NEW, read);
}
e->lines = 0;
else
e = ctx->mailbox->hdrs[i];
- if (mutt_pattern_exec(ctx->limit_pattern, MUTT_MATCH_FULL_ADDRESS, ctx, e, NULL))
+ if (mutt_pattern_exec(ctx->limit_pattern, MUTT_MATCH_FULL_ADDRESS, ctx->mailbox, e, NULL))
{
/* virtual will get properly set by mutt_set_virtual(), which
* is called by mutt_sort_headers() just below. */
ctx->vsize = 0;
}
- if (mutt_pattern_exec(ctx->limit_pattern, MUTT_MATCH_FULL_ADDRESS, ctx,
+ if (mutt_pattern_exec(ctx->limit_pattern, MUTT_MATCH_FULL_ADDRESS, ctx->mailbox,
ctx->mailbox->hdrs[i], NULL))
{
assert(ctx->mailbox->vcount < ctx->mailbox->msg_count);
if (e && e->pair)
return e->pair;
- mutt_set_header_color(Context, e);
+ mutt_set_header_color(Context->mailbox, e);
if (e)
return e->pair;
{
for (j = 0; j < Context->mailbox->msg_count; j++)
if (message_is_visible(Context, j))
- mutt_set_flag(Context, Context->mailbox->hdrs[j], MUTT_TAG, 0);
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[j], MUTT_TAG, 0);
menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
}
else
{
- mutt_set_flag(Context, CURHDR, MUTT_TAG, !CURHDR->tagged);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_TAG, !CURHDR->tagged);
Context->last_tag = CURHDR->tagged ?
CURHDR :
{
if (message_is_tagged(Context, j))
{
- mutt_set_flag(Context, Context->mailbox->hdrs[j], MUTT_FLAG,
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[j], MUTT_FLAG,
!Context->mailbox->hdrs[j]->flagged);
}
}
}
else
{
- mutt_set_flag(Context, CURHDR, MUTT_FLAG, !CURHDR->flagged);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_FLAG, !CURHDR->flagged);
if (Resolve)
{
menu->current = ci_next_undeleted(menu->current);
continue;
if (Context->mailbox->hdrs[j]->read || Context->mailbox->hdrs[j]->old)
- mutt_set_flag(Context, Context->mailbox->hdrs[j], MUTT_NEW, 1);
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[j], MUTT_NEW, 1);
else
- mutt_set_flag(Context, Context->mailbox->hdrs[j], MUTT_READ, 1);
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[j], MUTT_READ, 1);
}
menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
}
else
{
if (CURHDR->read || CURHDR->old)
- mutt_set_flag(Context, CURHDR, MUTT_NEW, 1);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_NEW, 1);
else
- mutt_set_flag(Context, CURHDR, MUTT_READ, 1);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_READ, 1);
if (Resolve)
{
}
else
{
- mutt_set_flag(Context, CURHDR, MUTT_DELETE, 1);
- mutt_set_flag(Context, CURHDR, MUTT_PURGE, (op == OP_PURGE_MESSAGE));
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_DELETE, 1);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_PURGE, (op == OP_PURGE_MESSAGE));
if (DeleteUntag)
- mutt_set_flag(Context, CURHDR, MUTT_TAG, 0);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_TAG, 0);
if (Resolve)
{
menu->current = ci_next_undeleted(menu->current);
}
else
{
- mutt_set_flag(Context, CURHDR, MUTT_DELETE, 0);
- mutt_set_flag(Context, CURHDR, MUTT_PURGE, 0);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_DELETE, 0);
+ mutt_set_flag(Context->mailbox, CURHDR, MUTT_PURGE, 0);
if (Resolve && menu->current < Context->mailbox->vcount - 1)
{
menu->current++;
/**
* mutt_set_header_color - Select a colour for a message
- * @param ctx Mailbox
+ * @param m Mailbox
* @param curhdr Header of message
*/
-void mutt_set_header_color(struct Context *ctx, struct Email *curhdr)
+void mutt_set_header_color(struct Mailbox *m, struct Email *curhdr)
{
struct ColorLine *color = NULL;
struct PatternCache cache = { 0 };
STAILQ_FOREACH(color, &ColorIndexList, entries)
{
- if (mutt_pattern_exec(color->color_pattern, MUTT_MATCH_FULL_ADDRESS, ctx, curhdr, &cache))
+ if (mutt_pattern_exec(color->color_pattern, MUTT_MATCH_FULL_ADDRESS, m, curhdr, &cache))
{
curhdr->pair = color->pair;
return;
struct Context;
struct Email;
+struct Mailbox;
struct Menu;
/* These Config Variables are only used in index.c */
void index_make_entry(char *buf, size_t buflen, struct Menu *menu, int line);
void mutt_draw_statusline(int cols, const char *buf, size_t buflen);
int mutt_index_menu(void);
-void mutt_set_header_color(struct Context *ctx, struct Email *curhdr);
+void mutt_set_header_color(struct Mailbox *m, struct Email *curhdr);
void update_index(struct Menu *menu, struct Context *ctx, int check, int oldcount, int index_hint);
#endif /* MUTT_INDEX_H */
long old_body_length = e->content->length;
long old_hdr_lines = e->lines;
- struct Message *dest = mx_msg_open_new(ctx, e, 0);
+ struct Message *dest = mx_msg_open_new(m, e, 0);
if (!dest)
return -1;
else
rc = mh_commit_msg(m, dest, e, false);
- mx_msg_close(ctx, &dest);
+ mx_msg_close(ctx->mailbox, &dest);
if (rc == 0)
{
}
}
else
- mx_msg_close(ctx, &dest);
+ mx_msg_close(ctx->mailbox, &dest);
if (rc == -1 && restore)
{
* bits are already properly set, but it is still faster not to pass
* through it */
if (o->flagged != n->flagged)
- mutt_set_flag(ctx, o, MUTT_FLAG, n->flagged);
+ mutt_set_flag(m, o, MUTT_FLAG, n->flagged);
if (o->replied != n->replied)
- mutt_set_flag(ctx, o, MUTT_REPLIED, n->replied);
+ mutt_set_flag(m, o, MUTT_REPLIED, n->replied);
if (o->read != n->read)
- mutt_set_flag(ctx, o, MUTT_READ, n->read);
+ mutt_set_flag(m, o, MUTT_READ, n->read);
if (o->old != n->old)
- mutt_set_flag(ctx, o, MUTT_OLD, n->old);
+ mutt_set_flag(m, o, MUTT_OLD, n->old);
/* mutt_set_flag() will set this, but we don't need to
* sync the changes we made because we just updated the
/**
* maildir_msg_open - Implements MxOps::msg_open()
*/
-static int maildir_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+static int maildir_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return -1;
-
- struct Mailbox *m = ctx->mailbox;
-
return maildir_mh_open_message(m, msg, msgno, true);
}
* @note This uses _almost_ the maildir file name format,
* but with a {cur,new} prefix.
*/
-static int maildir_msg_open_new(struct Context *ctx, struct Message *msg, struct Email *e)
+static int maildir_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return -1;
- struct Mailbox *m = ctx->mailbox;
-
int fd;
char path[PATH_MAX];
char suffix[16];
/**
* mh_msg_open - Implements MxOps::msg_open()
*/
-static int mh_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+static int mh_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return -1;
-
- struct Mailbox *m = ctx->mailbox;
-
return maildir_mh_open_message(m, msg, msgno, false);
}
*
* Open a new (temporary) message in an MH folder.
*/
-static int mh_msg_open_new(struct Context *ctx, struct Message *msg, struct Email *e)
+static int mh_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e)
{
- if (!ctx || !ctx->mailbox || !msg)
+ if (!m|| !msg)
return -1;
-
- struct Mailbox *m = ctx->mailbox;
-
return mh_mkstemp(m, &msg->fp, &msg->path);
}
* otherwise, the header may have been modified externally,
* and we don't want to lose _those_ changes
*/
- mutt_set_flag(ctx, m->hdrs[i], MUTT_FLAG, old_hdrs[j]->flagged);
- mutt_set_flag(ctx, m->hdrs[i], MUTT_REPLIED, old_hdrs[j]->replied);
- mutt_set_flag(ctx, m->hdrs[i], MUTT_OLD, old_hdrs[j]->old);
- mutt_set_flag(ctx, m->hdrs[i], MUTT_READ, old_hdrs[j]->read);
+ mutt_set_flag(m, m->hdrs[i], MUTT_FLAG, old_hdrs[j]->flagged);
+ mutt_set_flag(m, m->hdrs[i], MUTT_REPLIED, old_hdrs[j]->replied);
+ mutt_set_flag(m, m->hdrs[i], MUTT_OLD, old_hdrs[j]->old);
+ mutt_set_flag(m, m->hdrs[i], MUTT_READ, old_hdrs[j]->read);
}
- mutt_set_flag(ctx, m->hdrs[i], MUTT_DELETE, old_hdrs[j]->deleted);
- mutt_set_flag(ctx, m->hdrs[i], MUTT_PURGE, old_hdrs[j]->purge);
- mutt_set_flag(ctx, m->hdrs[i], MUTT_TAG, old_hdrs[j]->tagged);
+ mutt_set_flag(m, m->hdrs[i], MUTT_DELETE, old_hdrs[j]->deleted);
+ mutt_set_flag(m, m->hdrs[i], MUTT_PURGE, old_hdrs[j]->purge);
+ mutt_set_flag(m, m->hdrs[i], MUTT_TAG, old_hdrs[j]->tagged);
/* we don't need this header any more */
mutt_email_free(&(old_hdrs[j]));
/**
* mbox_msg_open - Implements MxOps::msg_open()
*/
-static int mbox_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+static int mbox_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return -1;
- struct Mailbox *m = ctx->mailbox;
-
struct MboxAccountData *adata = mbox_adata_get(m);
if (!adata)
return -1;
/**
* mbox_msg_open_new - Implements MxOps::msg_open_new()
*/
-static int mbox_msg_open_new(struct Context *ctx, struct Message *msg, struct Email *e)
+static int mbox_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return -1;
- struct Mailbox *m = ctx->mailbox;
-
struct MboxAccountData *adata = mbox_adata_get(m);
if (!adata)
return -1;
STAILQ_FOREACH(np, color, entries)
{
- if (mutt_pattern_exec(np->color_pattern, MUTT_MATCH_FULL_ADDRESS, Context, e, NULL))
+ if (mutt_pattern_exec(np->color_pattern, MUTT_MATCH_FULL_ADDRESS, Context->mailbox, e, NULL))
return np->pair;
}
struct Context *ctx = mx_mbox_open(NULL, path, MUTT_APPEND | MUTT_QUIET);
if (!ctx)
return -1;
- msg = mx_msg_open_new(ctx, en, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
+ msg = mx_msg_open_new(ctx->mailbox, en, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
if (!msg)
{
mx_mbox_close(&ctx, NULL);
r = -1;
}
- mx_msg_close(ctx, &msg);
+ mx_msg_close(ctx->mailbox, &msg);
mx_mbox_close(&ctx, NULL);
return r;
}
if (label_message(Context->mailbox, e, new))
{
changed++;
- mutt_set_header_color(Context, e);
+ mutt_set_header_color(Context->mailbox, e);
}
}
else
if (label_message(Context->mailbox, e2, new))
{
changed++;
- mutt_set_flag(Context, e2, MUTT_TAG, 0);
+ mutt_set_flag(Context->mailbox, e2, MUTT_TAG, 0);
/* mutt_set_flag re-evals the header color */
}
}
/**
* mutt_parse_mime_message - Parse a MIME email
- * @param ctx Mailbox
+ * @param m Mailbox
* @param cur Email
*/
-void mutt_parse_mime_message(struct Context *ctx, struct Email *cur)
+void mutt_parse_mime_message(struct Mailbox *m, struct Email *cur)
{
struct Message *msg = NULL;
if (cur->content->parts)
break; /* The message was parsed earlier. */
- msg = mx_msg_open(ctx, cur->msgno);
+ msg = mx_msg_open(m, cur->msgno);
if (msg)
{
mutt_parse_part(msg->fp, cur->content);
if (WithCrypto)
cur->security = crypt_query(cur->content);
- mx_msg_close(ctx, &msg);
+ mx_msg_close(m, &msg);
}
} while (false);
* @param e Email
* @retval num Number of MIME Body parts
*/
-int mutt_count_body_parts(struct Context *ctx, struct Email *e)
+int mutt_count_body_parts(struct Mailbox *m, struct Email *e)
{
bool keep_parts = false;
if (e->content->parts)
keep_parts = true;
else
- mutt_parse_mime_message(ctx, e);
+ mutt_parse_mime_message(m, e);
if (!STAILQ_EMPTY(&AttachAllow) || !STAILQ_EMPTY(&AttachExclude) ||
!STAILQ_EMPTY(&InlineAllow) || !STAILQ_EMPTY(&InlineExclude))
struct Context;
struct Email;
+struct Mailbox;
-int mutt_count_body_parts(struct Context *ctx, struct Email *e);
-void mutt_parse_mime_message(struct Context *ctx, struct Email *cur);
+int mutt_count_body_parts(struct Mailbox *m, struct Email *e);
+void mutt_parse_mime_message(struct Mailbox *m, struct Email *cur);
#endif /* MUTT_MUTT_PARSE_H */
mutt_break_thread(child);
mutt_list_insert_head(&child->env->in_reply_to, mutt_str_strdup(parent->env->message_id));
- mutt_set_flag(ctx, child, MUTT_TAG, 0);
+ mutt_set_flag(ctx->mailbox, child, MUTT_TAG, 0);
child->env->irt_changed = true;
child->changed = true;
for (i = 0; i < m->msg_count; i++)
{
if (!m->hdrs[i]->deleted && !m->hdrs[i]->old && !m->hdrs[i]->read)
- mutt_set_flag(ctx, m->hdrs[i], MUTT_OLD, 1);
+ mutt_set_flag(m, m->hdrs[i], MUTT_OLD, 1);
}
}
{
if (mutt_append_message(f, ctx, m->hdrs[i], 0, CH_UPDATE_LEN) == 0)
{
- mutt_set_flag(ctx, m->hdrs[i], MUTT_DELETE, 1);
- mutt_set_flag(ctx, m->hdrs[i], MUTT_PURGE, 1);
+ mutt_set_flag(m, m->hdrs[i], MUTT_DELETE, 1);
+ mutt_set_flag(m, m->hdrs[i], MUTT_PURGE, 1);
}
else
{
* @param flags Flags, e.g. #MUTT_SET_DRAFT
* @retval ptr New Message
*/
-struct Message *mx_msg_open_new(struct Context *ctx, struct Email *e, int flags)
+struct Message *mx_msg_open_new(struct Mailbox *m, struct Email *e, int flags)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return NULL;
- struct Mailbox *m = ctx->mailbox;
-
struct Address *p = NULL;
struct Message *msg = NULL;
if (msg->received == 0)
time(&msg->received);
- if (m->mx_ops->msg_open_new(ctx, msg, e) == 0)
+ if (m->mx_ops->msg_open_new(m, msg, e) == 0)
{
if (m->magic == MUTT_MMDF)
fputs(MMDF_SEP, msg->fp);
/**
* mx_msg_open - return a stream pointer for a message
- * @param ctx Mailbox
+ * @param m Mailbox
* @param msgno Message number
* @retval ptr Message
* @retval NULL Error
*/
-struct Message *mx_msg_open(struct Context *ctx, int msgno)
+struct Message *mx_msg_open(struct Mailbox *m, int msgno)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return NULL;
- struct Mailbox *m = ctx->mailbox;
-
struct Message *msg = NULL;
if (!m->mx_ops || !m->mx_ops->msg_open)
}
msg = mutt_mem_calloc(1, sizeof(struct Message));
- if (m->mx_ops->msg_open(ctx, msg, msgno) < 0)
+ if (m->mx_ops->msg_open(m, msg, msgno) < 0)
FREE(&msg);
return msg;
/**
* mx_msg_close - Close a message
- * @param ctx Mailbox
+ * @param m Mailbox
* @param msg Message to close
* @retval 0 Success
* @retval -1 Failure
*/
-int mx_msg_close(struct Context *ctx, struct Message **msg)
+int mx_msg_close(struct Mailbox *m, struct Message **msg)
{
- if (!ctx || !ctx->mailbox || !msg || !*msg)
+ if (!m || !msg || !*msg)
return 0;
- struct Mailbox *m = ctx->mailbox;
-
int r = 0;
if (m->mx_ops && m->mx_ops->msg_close)
int (*mbox_close) (struct Context *ctx);
/**
* msg_open - Open an email message in mailbox
- * @param ctx Mailbox
+ * @param m Mailbox
* @param msg Message to open
* @param msgno Index of message to open
* @retval 0 Success
* @retval -1 Error
*/
- int (*msg_open) (struct Context *ctx, struct Message *msg, int msgno);
+ int (*msg_open) (struct Mailbox *m, struct Message *msg, int msgno);
/**
* msg_open_new - Open a new message in a mailbox
- * @param ctx Mailbox
+ * @param m Mailbox
* @param msg Message to open
* @param e Email
* @retval 0 Success
* @retval -1 Failure
*/
- int (*msg_open_new) (struct Context *ctx, struct Message *msg, struct Email *e);
+ int (*msg_open_new) (struct Mailbox *m, struct Message *msg, struct Email *e);
/**
* msg_commit - Save changes to an email
* @param m Mailbox
int mx_mbox_close (struct Context **pctx, int *index_hint);
struct Context *mx_mbox_open (struct Mailbox *m, const char *path, int flags);
int mx_mbox_sync (struct Context *ctx, int *index_hint);
-int mx_msg_close (struct Context *ctx, struct Message **msg);
+int mx_msg_close (struct Mailbox *m, struct Message **msg);
int mx_msg_commit (struct Context *ctx, struct Message *msg);
-struct Message *mx_msg_open_new (struct Context *ctx, struct Email *e, int flags);
-struct Message *mx_msg_open (struct Context *ctx, int msgno);
+struct Message *mx_msg_open_new (struct Mailbox *m, struct Email *e, int flags);
+struct Message *mx_msg_open (struct Mailbox *m, int msgno);
int mx_msg_padding_size(struct Context *ctx);
int mx_path_canon (char *buf, size_t buflen, const char *folder, int *magic);
int mx_path_canon2 (struct Mailbox *m, const char *folder);
struct Email *ei = Context->mailbox->hdrs[i];
- mutt_parse_mime_message(Context, ei);
+ mutt_parse_mime_message(Context->mailbox, ei);
if (ei->security & ENCRYPT && !crypt_valid_passphrase(ei->security))
{
mutt_file_fclose(&fpout);
}
else
{
- mutt_parse_mime_message(Context, e);
+ mutt_parse_mime_message(Context->mailbox, e);
if (!(e->security & ENCRYPT && !crypt_valid_passphrase(e->security)))
{
if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
if (m && (m->mdata == mdata))
{
for (unsigned int i = 0; i < m->msg_count; i++)
- mutt_set_flag(ctx, m->hdrs[i], MUTT_READ, 1);
+ mutt_set_flag(m, m->hdrs[i], MUTT_READ, 1);
}
return mdata;
}
{
mdata->unread = m->msg_count;
for (unsigned int i = 0; i < m->msg_count; i++)
- mutt_set_flag(ctx, m->hdrs[i], MUTT_READ, 0);
+ mutt_set_flag(m, m->hdrs[i], MUTT_READ, 0);
}
else
{
/* header marked as deleted, removing from context */
if (deleted)
{
- mutt_set_flag(ctx, m->hdrs[i], MUTT_TAG, 0);
+ mutt_set_flag(m, m->hdrs[i], MUTT_TAG, 0);
mutt_email_free(&m->hdrs[i]);
continue;
}
/**
* nntp_msg_open - Implements MxOps::msg_open()
*/
-static int nntp_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+static int nntp_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox || !ctx->mailbox->hdrs || !msg)
+ if (!m || !m->hdrs || !msg)
return -1;
- struct Mailbox *m = ctx->mailbox;
-
struct NntpMboxData *mdata = m->mdata;
struct Email *e = m->hdrs[msgno];
char article[16];
* which is probably wrong, but we just call it again here to handle
* the problem instead of fixing it */
nntp_edata_get(e)->parsed = true;
- mutt_parse_mime_message(ctx, e);
+ mutt_parse_mime_message(m, e);
/* these would normally be updated in mx_update_context(), but the
* full headers aren't parsed with overview, so the information wasn't
{
tag = tag + 1;
if (strcmp(tag, NmUnreadTag) == 0)
- mutt_set_flag(ctx, e, MUTT_READ, 1);
+ mutt_set_flag(ctx->mailbox, e, MUTT_READ, 1);
else if (strcmp(tag, NmRepliedTag) == 0)
- mutt_set_flag(ctx, e, MUTT_REPLIED, 0);
+ mutt_set_flag(ctx->mailbox, e, MUTT_REPLIED, 0);
else if (strcmp(tag, NmFlaggedTag) == 0)
- mutt_set_flag(ctx, e, MUTT_FLAG, 0);
+ mutt_set_flag(ctx->mailbox, e, MUTT_FLAG, 0);
}
else
{
tag = (*tag == '+') ? tag + 1 : tag;
if (strcmp(tag, NmUnreadTag) == 0)
- mutt_set_flag(ctx, e, MUTT_READ, 0);
+ mutt_set_flag(ctx->mailbox, e, MUTT_READ, 0);
else if (strcmp(tag, NmRepliedTag) == 0)
- mutt_set_flag(ctx, e, MUTT_REPLIED, 1);
+ mutt_set_flag(ctx->mailbox, e, MUTT_REPLIED, 1);
else if (strcmp(tag, NmFlaggedTag) == 0)
- mutt_set_flag(ctx, e, MUTT_FLAG, 1);
+ mutt_set_flag(ctx->mailbox, e, MUTT_FLAG, 1);
}
end = NULL;
tag = NULL;
/**
* nm_msg_open - Implements MxOps::msg_open()
*/
-static int nm_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+static int nm_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox || !ctx->mailbox->hdrs || !msg)
+ if (!m || !m->hdrs || !msg)
return -1;
- struct Mailbox *m = ctx->mailbox;
-
struct Email *e = m->hdrs[msgno];
char path[PATH_MAX];
char *folder = nm_email_get_folder(e);
update_tags(msg, buf);
update_email_flags(ctx, e, buf);
update_email_tags(e, msg);
- mutt_set_header_color(ctx, e);
+ mutt_set_header_color(m, e);
rc = 0;
e->changed = true;
if (Context && IsHeader(extra) && !extra->email->read)
{
Context->msgnotreadyet = extra->email->msgno;
- mutt_set_flag(Context, extra->email, MUTT_READ, 1);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_READ, 1);
}
rd.max_line = LINES; /* number of lines on screen, from curses */
/* L10N: CHECK_ACL */
CHECK_ACL(MUTT_ACL_DELETE, _("Cannot delete message"));
- mutt_set_flag(Context, extra->email, MUTT_DELETE, 1);
- mutt_set_flag(Context, extra->email, MUTT_PURGE, (ch == OP_PURGE_MESSAGE));
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_DELETE, 1);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_PURGE, (ch == OP_PURGE_MESSAGE));
if (DeleteUntag)
- mutt_set_flag(Context, extra->email, MUTT_TAG, 0);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_TAG, 0);
pager_menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
if (Resolve)
{
/* L10N: CHECK_ACL */
CHECK_ACL(MUTT_ACL_WRITE, "Cannot flag message");
- mutt_set_flag(Context, extra->email, MUTT_FLAG, !extra->email->flagged);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_FLAG, !extra->email->flagged);
pager_menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
if (Resolve)
{
CHECK_MODE(IsHeader(extra));
if (Context)
{
- mutt_set_flag(Context, extra->email, MUTT_TAG, !extra->email->tagged);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_TAG, !extra->email->tagged);
Context->last_tag =
extra->email->tagged ?
CHECK_ACL(MUTT_ACL_SEEN, _("Cannot toggle new"));
if (extra->email->read || extra->email->old)
- mutt_set_flag(Context, extra->email, MUTT_NEW, 1);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_NEW, 1);
else if (!first)
- mutt_set_flag(Context, extra->email, MUTT_READ, 1);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_READ, 1);
first = 0;
Context->msgnotreadyet = -1;
pager_menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
/* L10N: CHECK_ACL */
CHECK_ACL(MUTT_ACL_DELETE, _("Cannot undelete message"));
- mutt_set_flag(Context, extra->email, MUTT_DELETE, 0);
- mutt_set_flag(Context, extra->email, MUTT_PURGE, 0);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_DELETE, 0);
+ mutt_set_flag(Context->mailbox, extra->email, MUTT_PURGE, 0);
pager_menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
if (Resolve)
{
/**
* msg_search - Search an email
- * @param ctx Mailbox
+ * @param m Mailbox
* @param pat Pattern to find
* @param msgno Message to search
* @retval true Pattern found
* @retval false Error or pattern not found
*/
-static bool msg_search(struct Context *ctx, struct Pattern *pat, int msgno)
+static bool msg_search(struct Mailbox *m, struct Pattern *pat, int msgno)
{
bool match = false;
- struct Message *msg = mx_msg_open(ctx, msgno);
+ struct Message *msg = mx_msg_open(m, msgno);
if (!msg)
{
return match;
FILE *fp = NULL;
long lng = 0;
- struct Email *e = ctx->mailbox->hdrs[msgno];
+ struct Email *e = m->hdrs[msgno];
#ifdef USE_FMEMOPEN
char *temp = NULL;
size_t tempsize;
if (pat->op != MUTT_HEADER)
{
- mutt_parse_mime_message(ctx, e);
+ mutt_parse_mime_message(m, e);
if ((WithCrypto != 0) && (e->security & ENCRYPT) && !crypt_valid_passphrase(e->security))
{
- mx_msg_close(ctx, &msg);
+ mx_msg_close(m, &msg);
if (s.fpout)
{
mutt_file_fclose(&s.fpout);
FREE(&buf);
- mx_msg_close(ctx, &msg);
+ mx_msg_close(m, &msg);
if (ThoroughSearch)
{
* perform_and - Perform a logical AND on a set of Patterns
* @param pat Patterns to test
* @param flags Optional flags, e.g. #MUTT_MATCH_FULL_ADDRESS
- * @param ctx Mailbox
+ * @param m Mailbox
* @param e Email
* @param cache Cached Patterns
* @retval true If ALL of the Patterns evaluates to true
*/
static bool perform_and(struct Pattern *pat, enum PatternExecFlag flags,
- struct Context *ctx, struct Email *e, struct PatternCache *cache)
+ struct Mailbox *m, struct Email *e, struct PatternCache *cache)
{
for (; pat; pat = pat->next)
- if (mutt_pattern_exec(pat, flags, ctx, e, cache) <= 0)
+ if (mutt_pattern_exec(pat, flags, m, e, cache) <= 0)
return false;
return true;
}
* perform_or - Perform a logical OR on a set of Patterns
* @param pat Patterns to test
* @param flags Optional flags, e.g. #MUTT_MATCH_FULL_ADDRESS
- * @param ctx Mailbox
+ * @param m Mailbox
* @param e Email
* @param cache Cached Patterns
* @retval true If ONE (or more) of the Patterns evaluates to true
*/
static int perform_or(struct Pattern *pat, enum PatternExecFlag flags,
- struct Context *ctx, struct Email *e, struct PatternCache *cache)
+ struct Mailbox *m, struct Email *e, struct PatternCache *cache)
{
for (; pat; pat = pat->next)
- if (mutt_pattern_exec(pat, flags, ctx, e, cache) > 0)
+ if (mutt_pattern_exec(pat, flags, m, e, cache) > 0)
return true;
return false;
}
* match_threadcomplete - Match a Pattern against an email thread
* @param pat Pattern to match
* @param flags Flags, e.g. #MUTT_MATCH_FULL_ADDRESS
- * @param ctx Mailbox
+ * @param m Mailbox
* @param t Email thread
* @param left Navigate to the previous email
* @param up Navigate to the email's parent
* @retval 0 No match
*/
static int match_threadcomplete(struct Pattern *pat, enum PatternExecFlag flags,
- struct Context *ctx, struct MuttThread *t,
+ struct Mailbox *m, struct MuttThread *t,
int left, int up, int right, int down)
{
int a;
return 0;
e = t->message;
if (e)
- if (mutt_pattern_exec(pat, flags, ctx, e, NULL))
+ if (mutt_pattern_exec(pat, flags, m, e, NULL))
return 1;
- if (up && (a = match_threadcomplete(pat, flags, ctx, t->parent, 1, 1, 1, 0)))
+ if (up && (a = match_threadcomplete(pat, flags, m, t->parent, 1, 1, 1, 0)))
return a;
if (right && t->parent &&
- (a = match_threadcomplete(pat, flags, ctx, t->next, 0, 0, 1, 1)))
+ (a = match_threadcomplete(pat, flags, m, t->next, 0, 0, 1, 1)))
{
return a;
}
if (left && t->parent &&
- (a = match_threadcomplete(pat, flags, ctx, t->prev, 1, 0, 0, 1)))
+ (a = match_threadcomplete(pat, flags, m, t->prev, 1, 0, 0, 1)))
{
return a;
}
- if (down && (a = match_threadcomplete(pat, flags, ctx, t->child, 1, 0, 1, 1)))
+ if (down && (a = match_threadcomplete(pat, flags, m, t->child, 1, 0, 1, 1)))
return a;
return 0;
}
* match_threadparent - Match Pattern against an email's parent
* @param pat Pattern to match
* @param flags Flags, e.g. #MUTT_MATCH_FULL_ADDRESS
- * @param ctx Mailbox
+ * @param m Mailbox
* @param t Thread of email
* @retval 1 Success, pattern matched
* @retval 0 Pattern did not match
* @retval -1 Error
*/
static int match_threadparent(struct Pattern *pat, enum PatternExecFlag flags,
- struct Context *ctx, struct MuttThread *t)
+ struct Mailbox *m, struct MuttThread *t)
{
if (!t || !t->parent || !t->parent->message)
return 0;
- return mutt_pattern_exec(pat, flags, ctx, t->parent->message, NULL);
+ return mutt_pattern_exec(pat, flags, m, t->parent->message, NULL);
}
/**
* match_threadchildren - Match Pattern against an email's children
* @param pat Pattern to match
* @param flags Flags, e.g. #MUTT_MATCH_FULL_ADDRESS
- * @param ctx Mailbox
+ * @param m Mailbox
* @param t Thread of email
* @retval 1 Success, pattern matched
* @retval 0 Pattern did not match
* @retval -1 Error
*/
static int match_threadchildren(struct Pattern *pat, enum PatternExecFlag flags,
- struct Context *ctx, struct MuttThread *t)
+ struct Mailbox *m, struct MuttThread *t)
{
if (!t || !t->child)
return 0;
for (t = t->child; t; t = t->next)
- if (t->message && mutt_pattern_exec(pat, flags, ctx, t->message, NULL))
+ if (t->message && mutt_pattern_exec(pat, flags, m, t->message, NULL))
return 1;
return 0;
/**
* match_mime_content_type - Match a Pattern against an email's Content-Type
* @param pat Pattern to match
- * @param ctx Mailbox
+ * @param m Mailbox
* @param e Email
* @retval 1 Success, pattern matched
* @retval 0 Pattern did not match
*/
static int match_mime_content_type(const struct Pattern *pat,
- struct Context *ctx, struct Email *e)
+ struct Mailbox *m, struct Email *e)
{
- mutt_parse_mime_message(ctx, e);
+ mutt_parse_mime_message(m, e);
return match_content_type(pat, e->content);
}
* mutt_pattern_exec - Match a pattern against an email header
* @param pat Pattern to match
* @param flags Flags, e.g. #MUTT_MATCH_FULL_ADDRESS
- * @param ctx Mailbox
+ * @param m Mailbox
* @param e Email
* @param cache Cache for common Patterns
* @retval 1 Success, pattern matched
* store some of the cacheable pattern matches in this structure.
*/
int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags,
- struct Context *ctx, struct Email *e, struct PatternCache *cache)
+ struct Mailbox *m, struct Email *e, struct PatternCache *cache)
{
int result;
int *cache_entry = NULL;
switch (pat->op)
{
case MUTT_AND:
- return pat->not^(perform_and(pat->child, flags, ctx, e, cache) > 0);
+ return pat->not^(perform_and(pat->child, flags, m, e, cache) > 0);
case MUTT_OR:
- return pat->not^(perform_or(pat->child, flags, ctx, e, cache) > 0);
+ return pat->not^(perform_or(pat->child, flags, m, e, cache) > 0);
case MUTT_THREAD:
- return pat->not^match_threadcomplete(pat->child, flags, ctx, e->thread, 1, 1, 1, 1);
+ return pat->not^match_threadcomplete(pat->child, flags, m, e->thread, 1, 1, 1, 1);
case MUTT_PARENT:
- return pat->not^match_threadparent(pat->child, flags, ctx, e->thread);
+ return pat->not^match_threadparent(pat->child, flags, m, e->thread);
case MUTT_CHILDREN:
- return pat->not^match_threadchildren(pat->child, flags, ctx, e->thread);
+ return pat->not^match_threadchildren(pat->child, flags, m, e->thread);
case MUTT_ALL:
return !pat->not;
case MUTT_EXPIRED:
case MUTT_BODY:
case MUTT_HEADER:
case MUTT_WHOLE_MSG:
- /* ctx can be NULL in certain cases, such as when replying to a message
+ /* m can be NULL in certain cases, such as when replying to a message
* from the attachment menu and the user has a reply-hook using "~e" (bug
* #2190).
* This is also the case when message scoring.
*/
- if (!ctx)
+ if (!m)
return 0;
#ifdef USE_IMAP
/* IMAP search sets e->matched at search compile time */
- if (ctx->mailbox->magic == MUTT_IMAP && pat->stringmatch)
+ if (m->magic == MUTT_IMAP && pat->stringmatch)
return e->matched;
#endif
- return pat->not^msg_search(ctx, pat, e->msgno);
+ return pat->not^msg_search(m, pat, e->msgno);
case MUTT_SERVERSEARCH:
#ifdef USE_IMAP
- if (!ctx)
+ if (!m)
return 0;
- if (ctx->mailbox->magic == MUTT_IMAP)
+ if (m->magic == MUTT_IMAP)
{
if (pat->stringmatch)
return e->matched;
case MUTT_DUPLICATED:
return pat->not^(e->thread && e->thread->duplicate_thread);
case MUTT_MIMEATTACH:
- if (!ctx)
+ if (!m)
return 0;
{
- int count = mutt_count_body_parts(ctx, e);
+ int count = mutt_count_body_parts(m, e);
return pat->not^(count >= pat->min &&
(pat->max == MUTT_MAXRANGE || count <= pat->max));
}
case MUTT_MIMETYPE:
- if (!ctx)
+ if (!m)
return 0;
- return pat->not^match_mime_content_type(pat, ctx, e);
+ return pat->not^match_mime_content_type(pat, m, e);
case MUTT_UNREFERENCED:
return pat->not^(e->thread && !e->thread->child);
case MUTT_BROKEN:
Context->mailbox->hdrs[i]->limited = false;
Context->mailbox->hdrs[i]->collapsed = false;
Context->mailbox->hdrs[i]->num_hidden = 0;
- if (mutt_pattern_exec(pat, MUTT_MATCH_FULL_ADDRESS, Context,
+ if (mutt_pattern_exec(pat, MUTT_MATCH_FULL_ADDRESS, Context->mailbox,
Context->mailbox->hdrs[i], NULL))
{
Context->mailbox->hdrs[i]->virtual = Context->mailbox->vcount;
for (int i = 0; i < Context->mailbox->vcount; i++)
{
mutt_progress_update(&progress, i, -1);
- if (mutt_pattern_exec(pat, MUTT_MATCH_FULL_ADDRESS, Context,
+ if (mutt_pattern_exec(pat, MUTT_MATCH_FULL_ADDRESS, Context->mailbox,
Context->mailbox->hdrs[Context->mailbox->v2r[i]], NULL))
{
switch (op)
{
case MUTT_UNDELETE:
- mutt_set_flag(Context, Context->mailbox->hdrs[Context->mailbox->v2r[i]],
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[Context->mailbox->v2r[i]],
MUTT_PURGE, 0);
/* fallthrough */
case MUTT_DELETE:
- mutt_set_flag(Context, Context->mailbox->hdrs[Context->mailbox->v2r[i]],
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[Context->mailbox->v2r[i]],
MUTT_DELETE, (op == MUTT_DELETE));
break;
case MUTT_TAG:
case MUTT_UNTAG:
- mutt_set_flag(Context, Context->mailbox->hdrs[Context->mailbox->v2r[i]],
+ mutt_set_flag(Context->mailbox, Context->mailbox->hdrs[Context->mailbox->v2r[i]],
MUTT_TAG, (op == MUTT_TAG));
break;
}
/* remember that we've already searched this message */
e->searched = true;
e->matched =
- mutt_pattern_exec(SearchPattern, MUTT_MATCH_FULL_ADDRESS, Context, e, NULL);
+ mutt_pattern_exec(SearchPattern, MUTT_MATCH_FULL_ADDRESS, Context->mailbox, e, NULL);
if (e->matched > 0)
{
mutt_clear_error();
struct Address;
struct Buffer;
struct Email;
-struct Context;
+struct Mailbox;
/* These Config Variables are only used in pattern.c */
extern bool ThoroughSearch;
struct Pattern *mutt_pattern_new(void);
int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags,
- struct Context *ctx, struct Email *e, struct PatternCache *cache);
+ struct Mailbox *m, struct Email *e, struct PatternCache *cache);
struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer *err);
void mutt_check_simple(char *s, size_t len, const char *simple);
void mutt_pattern_free(struct Pattern **pat);
for (int i = last + 1; i <= msgs; i++)
{
- struct Message *msg = mx_msg_open_new(ctx, NULL, MUTT_ADD_FROM);
+ struct Message *msg = mx_msg_open_new(ctx->mailbox, NULL, MUTT_ADD_FROM);
if (!msg)
ret = -3;
else
ret = -3;
}
- mx_msg_close(ctx, &msg);
+ mx_msg_close(ctx->mailbox, &msg);
}
if ((ret == 0) && (delanswer == MUTT_YES))
/**
* pop_msg_open - Implements MxOps::msg_open()
*/
-static int pop_msg_open(struct Context *ctx, struct Message *msg, int msgno)
+static int pop_msg_open(struct Mailbox *m, struct Message *msg, int msgno)
{
- if (!ctx || !ctx->mailbox)
+ if (!m)
return -1;
- struct Mailbox *m = ctx->mailbox;
-
char buf[LONG_STRING];
char path[PATH_MAX];
struct Progress progressbar;
case OP_DELETE:
case OP_UNDELETE:
/* should deleted draft messages be saved in the trash folder? */
- mutt_set_flag(PostContext, PostContext->mailbox->hdrs[menu->current],
+ mutt_set_flag(PostContext->mailbox, PostContext->mailbox->hdrs[menu->current],
MUTT_DELETE, (i == OP_DELETE) ? 1 : 0);
PostCount = PostContext->mailbox->msg_count - PostContext->mailbox->msg_deleted;
if (Resolve && menu->current < menu->max - 1)
}
/* finished with this message, so delete it. */
- mutt_set_flag(PostContext, e, MUTT_DELETE, 1);
- mutt_set_flag(PostContext, e, MUTT_PURGE, 1);
+ mutt_set_flag(PostContext->mailbox, e, MUTT_DELETE, 1);
+ mutt_set_flag(PostContext->mailbox, e, MUTT_PURGE, 1);
/* update the count for the status display */
PostCount = PostContext->mailbox->msg_count - PostContext->mailbox->msg_deleted;
struct State s = { 0 };
int sec_type;
- if (!fp && !(msg = mx_msg_open(ctx, e->msgno)))
+ if (!fp && !(msg = mx_msg_open(ctx->mailbox, e->msgno)))
return -1;
if (!fp)
if (bfp != fp)
mutt_file_fclose(&bfp);
if (msg)
- mx_msg_close(ctx, &msg);
+ mx_msg_close(ctx->mailbox, &msg);
if (rc == -1)
{
struct EnterState;
struct Envelope;
struct Email;
+struct Mailbox;
/**
* enum XdgType - XDG variable types
int mutt_set_xdg_path(enum XdgType type, char *buf, size_t bufsize);
void mutt_help(int menu);
void mutt_make_help(char *d, size_t dlen, const char *txt, int menu, int op);
-void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool bf, bool upd_ctx);
+void mutt_set_flag_update(struct Mailbox *m, struct Email *e, int flag, bool bf, bool upd_ctx);
#define mutt_set_flag(a, b, c, d) mutt_set_flag_update(a, b, c, d, true)
void mutt_signal_init(void);
void mutt_tag_set_flag(int flag, int bf);
int op = OP_NULL;
/* make sure we have parsed this message */
- mutt_parse_mime_message(Context, e);
+ mutt_parse_mime_message(Context->mailbox, e);
mutt_message_hook(Context, e, MUTT_MESSAGE_HOOK);
- struct Message *msg = mx_msg_open(Context, e->msgno);
+ struct Message *msg = mx_msg_open(Context->mailbox, e->msgno);
if (!msg)
return;
break;
case OP_EXIT:
- mx_msg_close(Context, &msg);
+ mx_msg_close(Context->mailbox, &msg);
e->attach_del = false;
for (int i = 0; i < actx->idxlen; i++)
#include "config/lib.h"
#include "email/lib.h"
#include "mutt.h"
+#include "context.h"
#include "alias.h"
#include "copy.h"
#include "curs_lib.h"
if (ci_send_message(flags, tmphdr, tmpbody, NULL,
parent_hdr ? parent_hdr : (cur ? cur->email : NULL)) == 0)
{
- mutt_set_flag(Context, e, MUTT_REPLIED, 1);
+ mutt_set_flag(Context->mailbox, e, MUTT_REPLIED, 1);
}
}
e->score = 0;
if (e->score <= ScoreThresholdDelete)
- mutt_set_flag_update(ctx, e, MUTT_DELETE, true, upd_ctx);
+ mutt_set_flag_update(ctx->mailbox, e, MUTT_DELETE, true, upd_ctx);
if (e->score <= ScoreThresholdRead)
- mutt_set_flag_update(ctx, e, MUTT_READ, true, upd_ctx);
+ mutt_set_flag_update(ctx->mailbox, e, MUTT_READ, true, upd_ctx);
if (e->score >= ScoreThresholdFlag)
- mutt_set_flag_update(ctx, e, MUTT_FLAG, true, upd_ctx);
+ mutt_set_flag_update(ctx->mailbox, e, MUTT_FLAG, true, upd_ctx);
}
/**
{
int chflags = CH_DECODE, cmflags = 0;
- mutt_parse_mime_message(ctx, cur);
+ mutt_parse_mime_message(ctx->mailbox, cur);
mutt_message_hook(ctx, cur, MUTT_MESSAGE_HOOK);
if ((WithCrypto != 0) && (cur->security & ENCRYPT) && ForwardDecode)
return -1;
}
- mutt_parse_mime_message(ctx, cur);
+ mutt_parse_mime_message(ctx->mailbox, cur);
mutt_message_hook(ctx, cur, MUTT_MESSAGE_HOOK);
mutt_make_attribution(ctx, cur, out);
if (flags & SEND_REPLY)
{
if (cur && ctx)
- mutt_set_flag(ctx, cur, MUTT_REPLIED, is_reply(cur, msg));
+ mutt_set_flag(ctx->mailbox, cur, MUTT_REPLIED, is_reply(cur, msg));
else if (!(flags & SEND_POSTPONED) && ctx && ctx->mailbox &&
ctx->mailbox->msg_tagged)
{
{
if (message_is_tagged(ctx, i))
{
- mutt_set_flag(ctx, ctx->mailbox->hdrs[i], MUTT_REPLIED,
+ mutt_set_flag(ctx->mailbox, ctx->mailbox->hdrs[i], MUTT_REPLIED,
is_reply(ctx->mailbox->hdrs[i], msg));
}
}
body->disposition = DISP_INLINE;
body->noconv = true;
- mutt_parse_mime_message(ctx, e);
+ mutt_parse_mime_message(ctx->mailbox, e);
chflags = CH_XMIT;
cmflags = 0;
}
/* If we failed to open a message, return with error */
- if (!fp && !(msg = mx_msg_open(Context, e->msgno)))
+ if (!fp && !(msg = mx_msg_open(Context->mailbox, e->msgno)))
return -1;
if (!fp)
}
if (msg)
- mx_msg_close(Context, &msg);
+ mx_msg_close(Context->mailbox, &msg);
return rc;
}
onm_flags = MUTT_ADD_FROM;
if (post)
onm_flags |= MUTT_SET_DRAFT;
- msg = mx_msg_open_new(f, e, onm_flags);
+ msg = mx_msg_open_new(f->mailbox, e, onm_flags);
if (!msg)
{
mutt_file_fclose(&tempfp);
mutt_file_fclose(&tempfp);
unlink(tempfile);
mx_msg_commit(f, msg); /* XXX really? */
- mx_msg_close(f, &msg);
+ mx_msg_close(f->mailbox, &msg);
mx_mbox_close(&f, NULL);
goto done;
}
rc = -1;
else if (finalpath)
*finalpath = mutt_str_strdup(msg->committed_path);
- mx_msg_close(f, &msg);
+ mx_msg_close(f->mailbox, &msg);
mx_mbox_close(&f, NULL);
if (!post && need_mailbox_cleanup)