From: Mehdi Abaakouk Date: Wed, 21 Nov 2018 08:51:04 +0000 (+0100) Subject: Use Mailbox instead of Context X-Git-Tag: 2019-10-25~501 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81862ae3ba5f5c2256ab2f4ddb4cd90243e3f944;p=neomutt Use Mailbox instead of Context This aims to remove Context from mutt_set_flag, to do so other function signature have been changed too. * mutt_set_flag_update * mx_msg_open * mx_msg_open_new * mx_msg_close * mutt_pattern_exec * mutt_parse_mime_message * mutt_set_header_color * mutt_count_body_parts --- diff --git a/commands.c b/commands.c index da364a8a3..ec4cacc54 100644 --- a/commands.c +++ b/commands.c @@ -103,7 +103,7 @@ int mutt_display_message(struct Email *cur) 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 */ @@ -262,7 +262,7 @@ int mutt_display_message(struct Email *cur) 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); @@ -424,7 +424,7 @@ static void pipe_msg(struct Email *e, FILE *fp, bool decode, bool print) } if (decode) - mutt_parse_mime_message(Context, e); + mutt_parse_mime_message(Context->mailbox, e); mutt_copy_message_ctx(fp, Context, e, cmflags, chflags); } @@ -455,7 +455,7 @@ static int pipe_message(struct Email *e, char *cmd, bool decode, bool print, 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; } @@ -485,7 +485,7 @@ static int pipe_message(struct Email *e, char *cmd, bool decode, bool print, 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)) { @@ -844,7 +844,7 @@ int mutt_save_message_ctx(struct Email *e, bool delete, bool decode, 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) @@ -852,10 +852,10 @@ int mutt_save_message_ctx(struct Email *e, bool delete, bool decode, 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; @@ -1203,8 +1203,8 @@ static bool check_traditional_pgp(struct Email *e, int *redraw) 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)) @@ -1215,7 +1215,7 @@ static bool check_traditional_pgp(struct Email *e, int *redraw) } e->security |= PGP_TRADITIONAL_CHECKED; - mx_msg_close(Context, &msg); + mx_msg_close(Context->mailbox, &msg); return rc; } diff --git a/compress.c b/compress.c index 0300b098f..b5a07ef5f 100644 --- a/compress.c +++ b/compress.c @@ -801,37 +801,37 @@ static int comp_mbox_close(struct Context *ctx) /** * 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); } /** diff --git a/copy.c b/copy.c index 9888f7404..4b37f7f0e 100644 --- a/copy.c +++ b/copy.c @@ -792,7 +792,7 @@ int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, int flags, in 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) @@ -803,7 +803,7 @@ int mutt_copy_message_ctx(FILE *fpout, struct Context *src, struct Email *e, mutt_debug(1, "failed to detect EOF!\n"); r = -1; } - mx_msg_close(src, &msg); + mx_msg_close(src->mailbox, &msg); return r; } @@ -830,7 +830,7 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src, 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) @@ -846,7 +846,7 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src, nm_update_filename(src->mailbox, NULL, msg->committed_path, e); #endif - mx_msg_close(dest, &msg); + mx_msg_close(dest->mailbox, &msg); return r; } @@ -863,11 +863,11 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src, 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; } diff --git a/editmsg.c b/editmsg.c index 8c11f74cd..9037250eb 100644 --- a/editmsg.c +++ b/editmsg.c @@ -215,7 +215,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Email 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; @@ -234,7 +234,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Email } rc = mx_msg_commit(tmpctx, msg); - mx_msg_close(tmpctx, &msg); + mx_msg_close(tmpctx->mailbox, &msg); mx_mbox_close(&tmpctx, NULL); @@ -247,12 +247,12 @@ bail: 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); diff --git a/flags.c b/flags.c index ec2b81dff..0d2fe371e 100644 --- a/flags.c +++ b/flags.c @@ -47,19 +47,17 @@ /** * 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; @@ -87,7 +85,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool b #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) @@ -332,7 +330,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool b 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 @@ -358,7 +356,7 @@ void mutt_tag_set_flag(int flag, int bf) { 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); } /** @@ -386,7 +384,7 @@ int mutt_thread_set_flag(struct Email *e, int flag, int bf, int subthread) 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) @@ -395,7 +393,7 @@ int mutt_thread_set_flag(struct Email *e, int flag, int bf, int subthread) 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; @@ -415,7 +413,7 @@ int mutt_thread_set_flag(struct Email *e, int flag, int bf, int subthread) 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; } @@ -456,7 +454,7 @@ int mutt_change_flag(struct Email *e, int bf) 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); } @@ -471,7 +469,7 @@ int mutt_change_flag(struct Email *e, int 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; @@ -496,7 +494,7 @@ int mutt_change_flag(struct Email *e, int bf) } if (e) - mutt_set_flag(Context, e, flag, bf); + mutt_set_flag(Context->mailbox, e, flag, bf); else mutt_tag_set_flag(flag, bf); diff --git a/hdrline.c b/hdrline.c index 311b2cd1c..1482e6135 100644 --- a/hdrline.c +++ b/hdrline.c @@ -1222,7 +1222,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co 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) diff --git a/hook.c b/hook.c index e0fe93790..666c25ea4 100644 --- a/hook.c +++ b/hook.c @@ -35,6 +35,7 @@ #include #include "mutt/mutt.h" #include "email/lib.h" +#include "context.h" #include "mutt.h" #include "hook.h" #include "alias.h" @@ -453,7 +454,7 @@ void mutt_message_hook(struct Context *ctx, struct Email *e, int type) 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) @@ -501,7 +502,7 @@ static int addr_hook(char *path, size_t pathlen, int type, struct Context *ctx, 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); diff --git a/imap/imap.c b/imap/imap.c index bad33888f..a68585fa0 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -2317,7 +2317,7 @@ static int imap_mbox_close(struct Context *ctx) /** * 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]; diff --git a/imap/imap_private.h b/imap/imap_private.h index a94762fc6..0666eb3c7 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -319,7 +319,7 @@ int imap_cache_del(struct ImapAccountData *adata, struct Email *e); 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); diff --git a/imap/message.c b/imap/message.c index 14e912f53..9c943a641 100644 --- a/imap/message.c +++ b/imap/message.c @@ -655,7 +655,7 @@ static void imap_fetch_msn_seqset(struct Buffer *b, struct ImapAccountData *adat * 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) { @@ -675,7 +675,7 @@ static void set_changed_flag(struct Context *ctx, struct Email *e, /* 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 @@ -1674,18 +1674,18 @@ int imap_copy_messages(struct Context *ctx, struct Email *e, char *dest, bool de 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); } } @@ -1787,15 +1787,15 @@ char *imap_set_flags(struct ImapAccountData *adata, struct Email *e, char *s, in /* 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 @@ -1811,9 +1811,9 @@ char *imap_set_flags(struct ImapAccountData *adata, struct Email *e, char *s, in /** * 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; @@ -1834,8 +1834,6 @@ int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno) 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]; @@ -2003,7 +2001,7 @@ parsemsg: 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; diff --git a/index.c b/index.c index 5ca93fbb1..1dc760f21 100644 --- a/index.c +++ b/index.c @@ -404,7 +404,7 @@ static void update_index_threaded(struct Context *ctx, int check, int oldcount) 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. */ @@ -470,7 +470,7 @@ static void update_index_unthreaded(struct Context *ctx, int check, int oldcount 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); @@ -730,7 +730,7 @@ int index_color(int line) 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; @@ -1714,12 +1714,12 @@ int mutt_index_menu(void) { 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 : @@ -2667,7 +2667,7 @@ int mutt_index_menu(void) { 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); } } @@ -2676,7 +2676,7 @@ int mutt_index_menu(void) } 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); @@ -2710,18 +2710,18 @@ int mutt_index_menu(void) 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) { @@ -2925,10 +2925,10 @@ int mutt_index_menu(void) } 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); @@ -3383,8 +3383,8 @@ int mutt_index_menu(void) } 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++; @@ -3498,10 +3498,10 @@ int mutt_index_menu(void) /** * 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 }; @@ -3511,7 +3511,7 @@ void mutt_set_header_color(struct Context *ctx, struct Email *curhdr) 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; diff --git a/index.h b/index.h index 8aca52a73..ad4e9973a 100644 --- a/index.h +++ b/index.h @@ -28,6 +28,7 @@ struct Context; struct Email; +struct Mailbox; struct Menu; /* These Config Variables are only used in index.c */ @@ -44,7 +45,7 @@ int index_color(int line); 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 */ diff --git a/maildir/mh.c b/maildir/mh.c index b35d7dac4..31bf277a0 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -1556,7 +1556,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno) 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; @@ -1573,7 +1573,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno) else rc = mh_commit_msg(m, dest, e, false); - mx_msg_close(ctx, &dest); + mx_msg_close(ctx->mailbox, &dest); if (rc == 0) { @@ -1605,7 +1605,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno) } } else - mx_msg_close(ctx, &dest); + mx_msg_close(ctx->mailbox, &dest); if (rc == -1 && restore) { @@ -2205,13 +2205,13 @@ bool maildir_update_flags(struct Context *ctx, struct Email *o, struct Email *n) * 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 @@ -2626,13 +2626,10 @@ static int maildir_mbox_check(struct Context *ctx, int *index_hint) /** * 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); } @@ -2644,13 +2641,11 @@ static int maildir_msg_open(struct Context *ctx, struct Message *msg, int msgno) * @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]; @@ -3068,13 +3063,10 @@ static int mh_mbox_close(struct Context *ctx) /** * 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); } @@ -3083,13 +3075,10 @@ static int mh_msg_open(struct Context *ctx, struct Message *msg, int msgno) * * 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); } diff --git a/mbox/mbox.c b/mbox/mbox.c index 0638c7ffa..db5c7d0c2 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -720,14 +720,14 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint) * 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])); @@ -1571,13 +1571,11 @@ static int mbox_mbox_close(struct Context *ctx) /** * 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; @@ -1590,13 +1588,11 @@ static int mbox_msg_open(struct Context *ctx, struct Message *msg, int msgno) /** * 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; diff --git a/menu.c b/menu.c index 82abd7db9..825a0611c 100644 --- a/menu.c +++ b/menu.c @@ -112,7 +112,7 @@ static int get_color(int index, unsigned char *s) 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; } diff --git a/mutt_attach.c b/mutt_attach.c index fcf32f43c..ba63a5906 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -812,7 +812,7 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct 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); @@ -831,7 +831,7 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct r = -1; } - mx_msg_close(ctx, &msg); + mx_msg_close(ctx->mailbox, &msg); mx_mbox_close(&ctx, NULL); return r; } diff --git a/mutt_header.c b/mutt_header.c index 6cc79172f..322ef53cc 100644 --- a/mutt_header.c +++ b/mutt_header.c @@ -146,7 +146,7 @@ int mutt_label_message(struct Email *e) if (label_message(Context->mailbox, e, new)) { changed++; - mutt_set_header_color(Context, e); + mutt_set_header_color(Context->mailbox, e); } } else @@ -160,7 +160,7 @@ int mutt_label_message(struct Email *e) 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 */ } } diff --git a/mutt_parse.c b/mutt_parse.c index 755fbaa4f..a66c32d2e 100644 --- a/mutt_parse.c +++ b/mutt_parse.c @@ -38,10 +38,10 @@ struct Context; /** * 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; @@ -53,7 +53,7 @@ void mutt_parse_mime_message(struct Context *ctx, struct Email *cur) 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); @@ -61,7 +61,7 @@ void mutt_parse_mime_message(struct Context *ctx, struct Email *cur) if (WithCrypto) cur->security = crypt_query(cur->content); - mx_msg_close(ctx, &msg); + mx_msg_close(m, &msg); } } while (false); @@ -211,7 +211,7 @@ static int count_body_parts(struct Body *body, int flags) * @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; @@ -221,7 +221,7 @@ int mutt_count_body_parts(struct Context *ctx, struct Email *e) 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)) diff --git a/mutt_parse.h b/mutt_parse.h index 24cee8fa1..c7f4e94bf 100644 --- a/mutt_parse.h +++ b/mutt_parse.h @@ -25,8 +25,9 @@ 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 */ diff --git a/mutt_thread.c b/mutt_thread.c index b7da8363c..e81d7b06d 100644 --- a/mutt_thread.c +++ b/mutt_thread.c @@ -1466,7 +1466,7 @@ static bool link_threads(struct Email *parent, struct Email *child, struct Conte 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; diff --git a/mx.c b/mx.c index 2cdbff0a6..1430dfb45 100644 --- a/mx.c +++ b/mx.c @@ -658,7 +658,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) 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); } } @@ -706,8 +706,8 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) { 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 { @@ -1042,13 +1042,11 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) * @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; @@ -1073,7 +1071,7 @@ struct Message *mx_msg_open_new(struct Context *ctx, struct Email *e, int flags) 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); @@ -1120,18 +1118,16 @@ int mx_mbox_check(struct Context *ctx, int *index_hint) /** * 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) @@ -1141,7 +1137,7 @@ struct Message *mx_msg_open(struct Context *ctx, int msgno) } 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; @@ -1172,18 +1168,16 @@ int mx_msg_commit(struct Context *ctx, struct Message *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) diff --git a/mx.h b/mx.h index 56b8f853b..3cbe52534 100644 --- a/mx.h +++ b/mx.h @@ -158,22 +158,22 @@ struct MxOps 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 @@ -255,10 +255,10 @@ int mx_mbox_check (struct Context *ctx, int *index_hint); 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); diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index afaf039a4..7e9ada17b 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -834,7 +834,7 @@ void crypt_extract_keys_from_messages(struct Email *e) 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); @@ -882,7 +882,7 @@ void crypt_extract_keys_from_messages(struct Email *e) } 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)) diff --git a/nntp/newsrc.c b/nntp/newsrc.c index f38b8a883..7ae605eaa 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -1307,7 +1307,7 @@ struct NntpMboxData *mutt_newsgroup_catchup(struct Context *ctx, 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; } @@ -1344,7 +1344,7 @@ struct NntpMboxData *mutt_newsgroup_uncatchup(struct Context *ctx, { 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 { diff --git a/nntp/nntp.c b/nntp/nntp.c index 71ba7bc5c..a5ec656aa 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -1625,7 +1625,7 @@ static int check_mailbox(struct Context *ctx) /* 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; } @@ -2721,13 +2721,11 @@ static int nntp_mbox_close(struct Context *ctx) /** * 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]; @@ -2835,7 +2833,7 @@ static int nntp_msg_open(struct Context *ctx, struct Message *msg, int msgno) * 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 diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index fbb29b67a..1ac8221d9 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -1290,21 +1290,21 @@ static int update_email_flags(struct Context *ctx, struct Email *e, const char * { 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; @@ -2424,13 +2424,11 @@ static int nm_mbox_close(struct Context *ctx) /** * 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); @@ -2508,7 +2506,7 @@ static int nm_tags_commit(struct Context *ctx, struct Email *e, char *buf) 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; diff --git a/pager.c b/pager.c index 1ff3f34a5..69dd9ea44 100644 --- a/pager.c +++ b/pager.c @@ -2250,7 +2250,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e 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 */ @@ -2942,10 +2942,10 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e /* 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) { @@ -3050,7 +3050,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e /* 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) { @@ -3250,7 +3250,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e 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 ? @@ -3275,9 +3275,9 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e 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; @@ -3294,8 +3294,8 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e /* 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) { diff --git a/pattern.c b/pattern.c index da4aa7046..b4b8759e0 100644 --- a/pattern.c +++ b/pattern.c @@ -964,16 +964,16 @@ static int patmatch(const struct Pattern *pat, const char *buf) /** * 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; @@ -981,7 +981,7 @@ static bool msg_search(struct Context *ctx, struct Pattern *pat, int msgno) 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; @@ -1016,11 +1016,11 @@ static bool msg_search(struct Context *ctx, struct Pattern *pat, int msgno) 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); @@ -1106,7 +1106,7 @@ static bool msg_search(struct Context *ctx, struct Pattern *pat, int msgno) FREE(&buf); - mx_msg_close(ctx, &msg); + mx_msg_close(m, &msg); if (ThoroughSearch) { @@ -1497,16 +1497,16 @@ struct Pattern *mutt_pattern_comp(/* const */ char *s, int flags, struct Buffer * 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; } @@ -1515,16 +1515,16 @@ static bool perform_and(struct Pattern *pat, enum PatternExecFlag flags, * 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; } @@ -1641,7 +1641,7 @@ static int match_user(int alladdr, struct Address *a1, struct Address *a2) * 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 @@ -1651,7 +1651,7 @@ static int match_user(int alladdr, struct Address *a1, struct Address *a2) * @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; @@ -1661,22 +1661,22 @@ static int match_threadcomplete(struct Pattern *pat, enum PatternExecFlag flags, 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; } @@ -1685,39 +1685,39 @@ static int match_threadcomplete(struct Pattern *pat, enum PatternExecFlag flags, * 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; @@ -1750,15 +1750,15 @@ static int match_content_type(const struct Pattern *pat, struct Body *b) /** * 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); } @@ -1799,7 +1799,7 @@ static int is_pattern_cache_set(int cache_entry) * 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 @@ -1811,7 +1811,7 @@ static int is_pattern_cache_set(int cache_entry) * 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; @@ -1819,15 +1819,15 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, 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: @@ -1859,24 +1859,24 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, 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; @@ -2037,17 +2037,17 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, 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: @@ -2265,7 +2265,7 @@ int mutt_pattern_func(int op, char *prompt) 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; @@ -2282,22 +2282,22 @@ int mutt_pattern_func(int op, char *prompt) 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; } @@ -2460,7 +2460,7 @@ int mutt_search_command(int cur, int op) /* 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(); diff --git a/pattern.h b/pattern.h index 05739b84c..285e5ccf4 100644 --- a/pattern.h +++ b/pattern.h @@ -30,7 +30,7 @@ struct Address; struct Buffer; struct Email; -struct Context; +struct Mailbox; /* These Config Variables are only used in pattern.c */ extern bool ThoroughSearch; @@ -91,7 +91,7 @@ struct PatternCache 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); diff --git a/pop/pop.c b/pop/pop.c index 57ea571d7..ed92076d2 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -674,7 +674,7 @@ void pop_fetch_mail(void) 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 @@ -690,7 +690,7 @@ void pop_fetch_mail(void) ret = -3; } - mx_msg_close(ctx, &msg); + mx_msg_close(ctx->mailbox, &msg); } if ((ret == 0) && (delanswer == MUTT_YES)) @@ -1072,13 +1072,11 @@ static int pop_mbox_close(struct Context *ctx) /** * 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; diff --git a/postpone.c b/postpone.c index dac17de3b..264e7b891 100644 --- a/postpone.c +++ b/postpone.c @@ -229,7 +229,7 @@ static struct Email *select_msg(void) 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) @@ -322,8 +322,8 @@ int mutt_get_postponed(struct Context *ctx, struct Email *hdr, } /* 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; @@ -563,7 +563,7 @@ int mutt_prepare_template(FILE *fp, struct Context *ctx, struct Email *newhdr, 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) @@ -773,7 +773,7 @@ bail: if (bfp != fp) mutt_file_fclose(&bfp); if (msg) - mx_msg_close(ctx, &msg); + mx_msg_close(ctx->mailbox, &msg); if (rc == -1) { diff --git a/protos.h b/protos.h index 7494f05a4..ce1389ee6 100644 --- a/protos.h +++ b/protos.h @@ -34,6 +34,7 @@ struct Context; struct EnterState; struct Envelope; struct Email; +struct Mailbox; /** * enum XdgType - XDG variable types @@ -49,7 +50,7 @@ int mutt_system(const char *cmd); 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); diff --git a/recvattach.c b/recvattach.c index 178f61b80..b0ee39953 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1307,11 +1307,11 @@ void mutt_view_attachments(struct Email *e) 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; @@ -1571,7 +1571,7 @@ void mutt_view_attachments(struct Email *e) 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++) diff --git a/recvcmd.c b/recvcmd.c index e547d43a9..602f6cd10 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -29,6 +29,7 @@ #include "config/lib.h" #include "email/lib.h" #include "mutt.h" +#include "context.h" #include "alias.h" #include "copy.h" #include "curs_lib.h" @@ -1032,7 +1033,7 @@ void mutt_attach_reply(FILE *fp, struct Email *e, struct AttachCtx *actx, 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); } } diff --git a/score.c b/score.c index db6adbfa6..8f1ec493f 100644 --- a/score.c +++ b/score.c @@ -184,11 +184,11 @@ void mutt_score_message(struct Context *ctx, struct Email *e, bool upd_ctx) 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); } /** diff --git a/send.c b/send.c index 75445ff8d..6d302f7bb 100644 --- a/send.c +++ b/send.c @@ -537,7 +537,7 @@ static int include_forward(struct Context *ctx, struct Email *cur, FILE *out) { 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) @@ -626,7 +626,7 @@ static int include_reply(struct Context *ctx, struct Email *cur, FILE *out) 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); @@ -2415,7 +2415,7 @@ int ci_send_message(int flags, struct Email *msg, char *tempfile, 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) { @@ -2423,7 +2423,7 @@ int ci_send_message(int flags, struct Email *msg, char *tempfile, { 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)); } } diff --git a/sendlib.c b/sendlib.c index 7644993a5..52bdaf172 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1482,7 +1482,7 @@ struct Body *mutt_make_message_attach(struct Context *ctx, struct Email *e, bool 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; @@ -2974,7 +2974,7 @@ static int bounce_message(FILE *fp, struct Email *e, struct Address *to, } /* 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) @@ -3018,7 +3018,7 @@ static int bounce_message(FILE *fp, struct Email *e, struct Address *to, } if (msg) - mx_msg_close(Context, &msg); + mx_msg_close(Context->mailbox, &msg); return rc; } @@ -3206,7 +3206,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, 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); @@ -3327,7 +3327,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, 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; } @@ -3358,7 +3358,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, 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)