From: Richard Russon Date: Thu, 30 Aug 2018 16:19:13 +0000 (+0100) Subject: move magic X-Git-Tag: 2019-10-25~664^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc05261341675f5e10338906187fa9c7db9ec3c6;p=neomutt move magic --- diff --git a/commands.c b/commands.c index 5c4277c25..131b99635 100644 --- a/commands.c +++ b/commands.c @@ -182,7 +182,7 @@ int mutt_display_message(struct Header *cur) chflags = (Weed ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM | CH_DISPLAY; #ifdef USE_NOTMUCH - if (Context->magic == MUTT_NOTMUCH) + if (Context->mailbox->magic == MUTT_NOTMUCH) chflags |= CH_VIRTUAL; #endif res = mutt_copy_message_ctx(fpout, Context, cur, cmflags, chflags); @@ -968,7 +968,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) mutt_message(_("Copying to %s..."), buf); #ifdef USE_IMAP - if ((Context->magic == MUTT_IMAP) && !(decode || decrypt) && + if ((Context->mailbox->magic == MUTT_IMAP) && !(decode || decrypt) && (imap_path_probe(buf, NULL) == MUTT_IMAP)) { switch (imap_copy_messages(Context, h, buf, delete)) @@ -1025,7 +1025,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) int rc = 0; #ifdef USE_NOTMUCH - if (Context->magic == MUTT_NOTMUCH) + if (Context->mailbox->magic == MUTT_NOTMUCH) nm_longrun_init(Context, true); #endif for (int i = 0; i < Context->mailbox->msg_count; i++) @@ -1050,7 +1050,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) #endif } #ifdef USE_NOTMUCH - if (Context->magic == MUTT_NOTMUCH) + if (Context->mailbox->magic == MUTT_NOTMUCH) nm_longrun_done(Context); #endif if (rc != 0) @@ -1061,7 +1061,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) } const bool need_mailbox_cleanup = - ((savectx->magic == MUTT_MBOX) || (savectx->magic == MUTT_MMDF)); + ((savectx->mailbox->magic == MUTT_MBOX) || (savectx->mailbox->magic == MUTT_MMDF)); mx_mbox_close(&savectx, NULL); diff --git a/compose.c b/compose.c index bbe63b0a2..89afa58b0 100644 --- a/compose.c +++ b/compose.c @@ -1419,7 +1419,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, if (Context) #ifdef USE_NNTP - if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->magic == MUTT_NNTP)) + if ((op == OP_COMPOSE_ATTACH_MESSAGE) ^ (Context->mailbox->magic == MUTT_NNTP)) #endif { mutt_str_strfcpy(fname, Context->mailbox->path, sizeof(fname)); diff --git a/compress.c b/compress.c index e527f9894..b1f139c26 100644 --- a/compress.c +++ b/compress.c @@ -445,7 +445,7 @@ static int execute_command(struct Context *ctx, const char *command, const char */ static int comp_mbox_open(struct Context *ctx) { - if (!ctx || (ctx->magic != MUTT_COMPRESSED)) + if (!ctx || (ctx->mailbox->magic != MUTT_COMPRESSED)) return -1; struct CompressInfo *ci = set_compress_info(ctx); @@ -472,17 +472,17 @@ static int comp_mbox_open(struct Context *ctx) unlock_realpath(ctx); - ctx->magic = mx_path_probe(ctx->mailbox->path, NULL); - if (ctx->magic == MUTT_UNKNOWN) + ctx->mailbox->magic = mx_path_probe(ctx->mailbox->path, NULL); + if (ctx->mailbox->magic == MUTT_UNKNOWN) { mutt_error(_("Can't identify the contents of the compressed file")); goto or_fail; } - ci->child_ops = mx_get_ops(ctx->magic); + ci->child_ops = mx_get_ops(ctx->mailbox->magic); if (!ci->child_ops) { - mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->magic); + mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->mailbox->magic); goto or_fail; } @@ -540,22 +540,22 @@ static int comp_mbox_open_append(struct Context *ctx, int flags) mutt_error(_("Compress command failed: %s"), ci->open); goto oa_fail2; } - ctx->magic = mx_path_probe(ctx->mailbox->path, NULL); + ctx->mailbox->magic = mx_path_probe(ctx->mailbox->path, NULL); } else - ctx->magic = MboxType; + ctx->mailbox->magic = MboxType; /* We can only deal with mbox and mmdf mailboxes */ - if ((ctx->magic != MUTT_MBOX) && (ctx->magic != MUTT_MMDF)) + if ((ctx->mailbox->magic != MUTT_MBOX) && (ctx->mailbox->magic != MUTT_MMDF)) { mutt_error(_("Unsupported mailbox type for appending")); goto oa_fail2; } - ci->child_ops = mx_get_ops(ctx->magic); + ci->child_ops = mx_get_ops(ctx->mailbox->magic); if (!ci->child_ops) { - mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->magic); + mutt_error(_("Can't find mailbox ops for mailbox type %d"), ctx->mailbox->magic); goto oa_fail2; } diff --git a/context.h b/context.h index 10d8d788c..8dda5f255 100644 --- a/context.h +++ b/context.h @@ -77,8 +77,6 @@ struct Context struct Menu *menu; /**< needed for pattern compilation */ - enum MailboxType magic; /**< mailbox type */ - unsigned char rights[(RIGHTSMAX + 7) / 8]; /**< ACL bits */ bool locked : 1; /**< is the mailbox locked? */ diff --git a/copy.c b/copy.c index 8b5c1891b..b52b40451 100644 --- a/copy.c +++ b/copy.c @@ -40,6 +40,7 @@ #include "globals.h" #include "handler.h" #include "hdrline.h" +#include "mailbox.h" #include "mutt_window.h" #include "muttlib.h" #include "mx.h" @@ -827,15 +828,15 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src, msg = mx_msg_open_new(dest, hdr, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM); if (!msg) return -1; - if (dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF) + if (dest->mailbox->magic == MUTT_MBOX || dest->mailbox->magic == MUTT_MMDF) chflags |= CH_FROM | CH_FORCE_FROM; - chflags |= (dest->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE); + chflags |= (dest->mailbox->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE); r = mutt_copy_message_fp(msg->fp, fpin, hdr, flags, chflags); if (mx_msg_commit(dest, msg) != 0) r = -1; #ifdef USE_NOTMUCH - if (msg->committed_path && dest->magic == MUTT_MAILDIR && src->magic == MUTT_NOTMUCH) + if (msg->committed_path && dest->mailbox->magic == MUTT_MAILDIR && src->mailbox->magic == MUTT_NOTMUCH) nm_update_filename(src, NULL, msg->committed_path, hdr); #endif diff --git a/curs_main.c b/curs_main.c index 5cc9507ca..720f6ad4f 100644 --- a/curs_main.c +++ b/curs_main.c @@ -986,7 +986,7 @@ int mutt_index_menu(void) menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_MAIN, #ifdef USE_NNTP - (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp : + (Context && (Context->mailbox->magic == MUTT_NNTP)) ? IndexNewsHelp : #endif IndexHelp); menu->custom_menu_redraw = index_menu_redraw; @@ -1307,7 +1307,7 @@ int mutt_index_menu(void) CHECK_IN_MAILBOX; CHECK_READONLY; CHECK_ATTACH; - if (Context->magic == MUTT_NNTP) + if (Context->mailbox->magic == MUTT_NNTP) { struct Header *hdr = NULL; @@ -1375,7 +1375,7 @@ int mutt_index_menu(void) CHECK_VISIBLE; CHECK_READONLY; CHECK_ATTACH; - if (Context->magic == MUTT_NNTP) + if (Context->mailbox->magic == MUTT_NNTP) { int oldmsgcount = Context->mailbox->msg_count; int oldindex = CURHDR->index; @@ -1792,12 +1792,12 @@ int mutt_index_menu(void) #ifdef USE_IMAP case OP_MAIN_IMAP_FETCH: - if (Context && Context->magic == MUTT_IMAP) + if (Context && Context->mailbox->magic == MUTT_IMAP) imap_check_mailbox(Context, true); break; case OP_MAIN_IMAP_LOGOUT_ALL: - if (Context && Context->magic == MUTT_IMAP) + if (Context && Context->mailbox->magic == MUTT_IMAP) { int check = mx_mbox_close(&Context, &index_hint); if (check != 0) @@ -1906,7 +1906,7 @@ int mutt_index_menu(void) #ifdef USE_NOTMUCH case OP_MAIN_ENTIRE_THREAD: { - if (!Context || (Context->magic != MUTT_NOTMUCH)) + if (!Context || (Context->mailbox->magic != MUTT_NOTMUCH)) { mutt_message(_("No virtual folder, aborting")); break; @@ -1980,7 +1980,7 @@ int mutt_index_menu(void) } #ifdef USE_NOTMUCH - if (Context->magic == MUTT_NOTMUCH) + if (Context->mailbox->magic == MUTT_NOTMUCH) nm_longrun_init(Context, true); #endif for (px = 0, j = 0; j < Context->mailbox->msg_count; j++) @@ -1995,7 +1995,7 @@ int mutt_index_menu(void) { bool still_queried = false; #ifdef USE_NOTMUCH - if (Context->magic == MUTT_NOTMUCH) + if (Context->mailbox->magic == MUTT_NOTMUCH) still_queried = nm_message_is_still_queried(Context, Context->hdrs[j]); #endif Context->hdrs[j]->quasi_deleted = !still_queried; @@ -2003,7 +2003,7 @@ int mutt_index_menu(void) } } #ifdef USE_NOTMUCH - if (Context->magic == MUTT_NOTMUCH) + if (Context->mailbox->magic == MUTT_NOTMUCH) nm_longrun_done(Context); #endif menu->redraw = REDRAW_STATUS | REDRAW_INDEX; @@ -2019,7 +2019,7 @@ int mutt_index_menu(void) { bool still_queried = false; #ifdef USE_NOTMUCH - if (Context->magic == MUTT_NOTMUCH) + if (Context->mailbox->magic == MUTT_NOTMUCH) still_queried = nm_message_is_still_queried(Context, CURHDR); #endif CURHDR->quasi_deleted = !still_queried; @@ -2167,7 +2167,7 @@ int mutt_index_menu(void) #ifdef USE_NOTMUCH else if (op == OP_MAIN_CHANGE_VFOLDER) { - if (Context && (Context->magic == MUTT_NOTMUCH)) + if (Context && (Context->mailbox->magic == MUTT_NOTMUCH)) { mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf)); mutt_mailbox_vfolder(buf, sizeof(buf)); @@ -2232,7 +2232,7 @@ int mutt_index_menu(void) /* mutt_mailbox_check() must be done with mail-reader mode! */ menu->help = mutt_compile_help( helpstr, sizeof(helpstr), MENU_MAIN, - (Context && (Context->magic == MUTT_NNTP)) ? IndexNewsHelp : IndexHelp); + (Context && (Context->mailbox->magic == MUTT_NNTP)) ? IndexNewsHelp : IndexHelp); #endif mutt_expand_path(buf, sizeof(buf)); #ifdef USE_SIDEBAR @@ -2988,7 +2988,7 @@ int mutt_index_menu(void) CHECK_MSGCOUNT; CHECK_READONLY; CHECK_ATTACH - if (Context && Context->magic == MUTT_NNTP) + if (Context && Context->mailbox->magic == MUTT_NNTP) { struct NntpData *nntp_data = Context->data; if (mutt_newsgroup_catchup(nntp_data->nserv, nntp_data->group)) @@ -3160,7 +3160,7 @@ int mutt_index_menu(void) /* in an IMAP folder index with imap_peek=no, piping could change * new or old messages status to read. Redraw what's needed. */ - if (Context->magic == MUTT_IMAP && !ImapPeek) + if (Context->mailbox->magic == MUTT_IMAP && !ImapPeek) { menu->redraw |= (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS; } @@ -3178,7 +3178,7 @@ int mutt_index_menu(void) /* in an IMAP folder index with imap_peek=no, printing could change * new or old messages status to read. Redraw what's needed. */ - if (Context->magic == MUTT_IMAP && !ImapPeek) + if (Context->mailbox->magic == MUTT_IMAP && !ImapPeek) { menu->redraw |= (tag ? REDRAW_INDEX : REDRAW_CURRENT) | REDRAW_STATUS; } @@ -3300,7 +3300,7 @@ int mutt_index_menu(void) query_quadoption(FollowupToPoster, _("Reply by mail as poster prefers?")) != MUTT_YES) { - if (Context && Context->magic == MUTT_NNTP && + if (Context && Context->mailbox->magic == MUTT_NNTP && !((struct NntpData *) Context->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES) { break; diff --git a/editmsg.c b/editmsg.c index 88c07774b..2dc269ce5 100644 --- a/editmsg.c +++ b/editmsg.c @@ -95,7 +95,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade } const int chflags = - CH_NOLEN | ((ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS); + CH_NOLEN | ((ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS); rc = mutt_append_message(tmpctx, ctx, cur, 0, chflags); oerrno = errno; @@ -196,11 +196,11 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade } of = 0; - cf = (((tmpctx->magic == MUTT_MBOX) || (tmpctx->magic == MUTT_MMDF)) ? 0 : CH_NOSTATUS); + cf = (((tmpctx->mailbox->magic == MUTT_MBOX) || (tmpctx->mailbox->magic == MUTT_MMDF)) ? 0 : CH_NOSTATUS); if (fgets(buf, sizeof(buf), fp) && is_from(buf, NULL, 0, NULL)) { - if ((tmpctx->magic == MUTT_MBOX) || (tmpctx->magic == MUTT_MMDF)) + if ((tmpctx->mailbox->magic == MUTT_MBOX) || (tmpctx->mailbox->magic == MUTT_MMDF)) cf = CH_FROM | CH_FORCE_FROM; } else diff --git a/flags.c b/flags.c index 4242cf5b2..49384be37 100644 --- a/flags.c +++ b/flags.c @@ -85,7 +85,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Header *h, int flag, bool #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 && ctx->magic == MUTT_IMAP) + if (ctx && ctx->mailbox->magic == MUTT_IMAP) { h->changed = true; if (upd_ctx) @@ -102,7 +102,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Header *h, int flag, bool ctx->deleted--; #ifdef USE_IMAP /* see my comment above */ - if (ctx->magic == MUTT_IMAP) + if (ctx->mailbox->magic == MUTT_IMAP) { h->changed = true; if (upd_ctx) @@ -116,7 +116,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Header *h, int flag, bool * is checked in specific code in the maildir folder * driver. */ - if (ctx->magic == MUTT_MAILDIR && upd_ctx && h->trash) + if (ctx->mailbox->magic == MUTT_MAILDIR && upd_ctx && h->trash) ctx->changed = true; } break; diff --git a/imap/util.c b/imap/util.c index 1205a2e01..78d3deb5d 100644 --- a/imap/util.c +++ b/imap/util.c @@ -1108,7 +1108,7 @@ int imap_wait_keepalive(pid_t pid) void imap_allow_reopen(struct Context *ctx) { struct ImapData *idata = NULL; - if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP) + if (!ctx || !ctx->data || ctx->mailbox->magic != MUTT_IMAP) return; idata = ctx->data; @@ -1123,7 +1123,7 @@ void imap_allow_reopen(struct Context *ctx) void imap_disallow_reopen(struct Context *ctx) { struct ImapData *idata = NULL; - if (!ctx || !ctx->data || ctx->magic != MUTT_IMAP) + if (!ctx || !ctx->data || ctx->mailbox->magic != MUTT_IMAP) return; idata = ctx->data; diff --git a/mailbox.c b/mailbox.c index 9cc45e185..951516d18 100644 --- a/mailbox.c +++ b/mailbox.c @@ -856,9 +856,9 @@ int mutt_mailbox_check(int force) #endif /* check device ID and serial number instead of comparing paths */ - if (!Context || Context->magic == MUTT_IMAP || Context->magic == MUTT_POP + if (!Context || Context->mailbox->magic == MUTT_IMAP || Context->mailbox->magic == MUTT_POP #ifdef USE_NNTP - || Context->magic == MUTT_NNTP + || Context->mailbox->magic == MUTT_NNTP #endif || stat(Context->mailbox->path, &contex_sb) != 0) { diff --git a/maildir/mh.c b/maildir/mh.c index d8d8b7eb9..d5ab2e549 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -852,7 +852,7 @@ static void maildir_update_mtime(struct Context *ctx) struct stat st; struct MhData *data = mh_data(ctx); - if (ctx->magic == MUTT_MAILDIR) + if (ctx->mailbox->magic == MUTT_MAILDIR) { snprintf(buf, sizeof(buf), "%s/%s", ctx->mailbox->path, "cur"); if (stat(buf, &st) == 0) @@ -973,8 +973,8 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last, while (((de = readdir(dirp))) && (SigInt != 1)) { - if ((ctx->magic == MUTT_MH && !mh_valid_message(de->d_name)) || - (ctx->magic == MUTT_MAILDIR && *de->d_name == '.')) + if ((ctx->mailbox->magic == MUTT_MH && !mh_valid_message(de->d_name)) || + (ctx->mailbox->magic == MUTT_MAILDIR && *de->d_name == '.')) { continue; } @@ -984,7 +984,7 @@ static int maildir_parse_dir(struct Context *ctx, struct Maildir ***last, h = mutt_header_new(); h->old = is_old; - if (ctx->magic == MUTT_MAILDIR) + if (ctx->mailbox->magic == MUTT_MAILDIR) maildir_parse_flags(h, de->d_name); if (count) @@ -1262,7 +1262,7 @@ static struct Maildir *maildir_sort(struct Maildir *list, size_t len, */ static void mh_sort_natural(struct Context *ctx, struct Maildir **md) { - if (!ctx || !md || !*md || ctx->magic != MUTT_MH || Sort != SORT_ORDER) + if (!ctx || !md || !*md || ctx->mailbox->magic != MUTT_MH || Sort != SORT_ORDER) return; mutt_debug(4, "maildir: sorting %s into natural order\n", ctx->mailbox->path); *md = maildir_sort(*md, (size_t) -1, md_cmp_path); @@ -1354,7 +1354,7 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md, ret = 0; } - if (ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MH) { key = p->h->path; keylen = strlen(key); @@ -1374,18 +1374,18 @@ static void maildir_delayed_parsing(struct Context *ctx, struct Maildir **md, h->path = mutt_str_strdup(p->h->path); mutt_header_free(&p->h); p->h = h; - if (ctx->magic == MUTT_MAILDIR) + if (ctx->mailbox->magic == MUTT_MAILDIR) maildir_parse_flags(p->h, fn); } else { #endif - if (maildir_parse_message(ctx->magic, fn, p->h->old, p->h)) + if (maildir_parse_message(ctx->mailbox->magic, fn, p->h->old, p->h)) { p->header_parsed = 1; #ifdef USE_HCACHE - if (ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MH) { key = p->h->path; keylen = strlen(key); @@ -1469,7 +1469,7 @@ static int mh_read_dir(struct Context *ctx, const char *subdir) } maildir_delayed_parsing(ctx, &md, &progress); - if (ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MH) { if (mh_read_sequences(&mhs, ctx->mailbox->path) < 0) { @@ -1869,7 +1869,7 @@ static int md_commit_message(struct Context *ctx, struct Message *msg, struct He } #ifdef USE_NOTMUCH - if (ctx->magic == MUTT_NOTMUCH) + if (ctx->mailbox->magic == MUTT_NOTMUCH) nm_update_filename(ctx, hdr->path, full, hdr); #endif if (hdr) @@ -2022,7 +2022,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno) snprintf(oldpath, sizeof(oldpath), "%s/%s", ctx->mailbox->path, h->path); mutt_str_strfcpy(partpath, h->path, sizeof(partpath)); - if (ctx->magic == MUTT_MAILDIR) + if (ctx->mailbox->magic == MUTT_MAILDIR) rc = md_commit_message(ctx, dest, h); else rc = mh_commit_msg(ctx, dest, h, false); @@ -2049,7 +2049,7 @@ static int mh_rewrite_message(struct Context *ctx, int msgno) * lose flag modifications. */ - if (ctx->magic == MUTT_MH && rc == 0) + if (ctx->mailbox->magic == MUTT_MH && rc == 0) { char newpath[PATH_MAX]; snprintf(newpath, sizeof(newpath), "%s/%s", ctx->mailbox->path, h->path); @@ -2177,18 +2177,18 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno) { struct Header *h = ctx->hdrs[msgno]; - if (h->deleted && (ctx->magic != MUTT_MAILDIR || !MaildirTrash)) + if (h->deleted && (ctx->mailbox->magic != MUTT_MAILDIR || !MaildirTrash)) { char path[PATH_MAX]; snprintf(path, sizeof(path), "%s/%s", ctx->mailbox->path, h->path); - if (ctx->magic == MUTT_MAILDIR || (MhPurge && ctx->magic == MUTT_MH)) + if (ctx->mailbox->magic == MUTT_MAILDIR || (MhPurge && ctx->mailbox->magic == MUTT_MH)) { #ifdef USE_HCACHE if (hc) { const char *key = NULL; size_t keylen; - if (ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MH) { key = h->path; keylen = strlen(key); @@ -2203,7 +2203,7 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno) #endif unlink(path); } - else if (ctx->magic == MUTT_MH) + else if (ctx->mailbox->magic == MUTT_MH) { /* MH just moves files out of the way when you delete them */ if (*h->path != ',') @@ -2216,10 +2216,10 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno) } } else if (h->changed || h->attach_del || h->xlabel_changed || - (ctx->magic == MUTT_MAILDIR && (MaildirTrash || h->trash) && + (ctx->mailbox->magic == MUTT_MAILDIR && (MaildirTrash || h->trash) && (h->deleted != h->trash))) { - if (ctx->magic == MUTT_MAILDIR) + if (ctx->mailbox->magic == MUTT_MAILDIR) { if (maildir_sync_message(ctx, msgno) == -1) return -1; @@ -2236,7 +2236,7 @@ int mh_sync_mailbox_message(struct Context *ctx, int msgno) { const char *key = NULL; size_t keylen; - if (ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MH) { key = h->path; keylen = strlen(key); @@ -2619,7 +2619,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) char msgbuf[PATH_MAX + 64]; struct Progress progress; - if (ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MH) i = mh_mbox_check(ctx, index_hint); else i = maildir_mbox_check(ctx, index_hint); @@ -2628,7 +2628,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) return i; #ifdef USE_HCACHE - if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MAILDIR || ctx->mailbox->magic == MUTT_MH) hc = mutt_hcache_open(HeaderCache, ctx->mailbox->path, NULL); #endif @@ -2653,11 +2653,11 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) } #ifdef USE_HCACHE - if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MAILDIR || ctx->mailbox->magic == MUTT_MH) mutt_hcache_close(hc); #endif - if (ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MH) mh_update_sequences(ctx); /* XXX race condition? */ @@ -2670,7 +2670,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) { for (i = 0, j = 0; i < ctx->mailbox->msg_count; i++) { - if (!ctx->hdrs[i]->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash)) + if (!ctx->hdrs[i]->deleted || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash)) ctx->hdrs[i]->index = j++; } } @@ -2679,7 +2679,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) err: #ifdef USE_HCACHE - if (ctx->magic == MUTT_MAILDIR || ctx->magic == MUTT_MH) + if (ctx->mailbox->magic == MUTT_MAILDIR || ctx->mailbox->magic == MUTT_MH) mutt_hcache_close(hc); #endif return -1; diff --git a/mbox/mbox.c b/mbox/mbox.c index 97bb06d67..5b9f09e46 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -480,9 +480,9 @@ static int mbox_mbox_open(struct Context *ctx) return -1; } - if (ctx->magic == MUTT_MBOX) + if (ctx->mailbox->magic == MUTT_MBOX) rc = mbox_parse_mailbox(ctx); - else if (ctx->magic == MUTT_MMDF) + else if (ctx->mailbox->magic == MUTT_MMDF) rc = mmdf_parse_mailbox(ctx); else rc = -1; @@ -697,7 +697,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint) ctx->subj_hash = NULL; mutt_make_label_hash(ctx); - switch (ctx->magic) + switch (ctx->mailbox->magic) { case MUTT_MBOX: case MUTT_MMDF: @@ -707,7 +707,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint) if (!ctx->fp) rc = -1; else - rc = ((ctx->magic == MUTT_MBOX) ? mbox_parse_mailbox : mmdf_parse_mailbox)(ctx); + rc = ((ctx->mailbox->magic == MUTT_MBOX) ? mbox_parse_mailbox : mmdf_parse_mailbox)(ctx); break; default: @@ -869,12 +869,12 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint) mutt_debug(1, "#1 fseek() failed\n"); if (fgets(buffer, sizeof(buffer), ctx->fp)) { - if ((ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buffer, 5) == 0)) || - (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buffer) == 0))) + if ((ctx->mailbox->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buffer, 5) == 0)) || + (ctx->mailbox->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buffer) == 0))) { if (fseeko(ctx->fp, ctx->size, SEEK_SET) != 0) mutt_debug(1, "#2 fseek() failed\n"); - if (ctx->magic == MUTT_MBOX) + if (ctx->mailbox->magic == MUTT_MBOX) mbox_parse_mailbox(ctx); else mmdf_parse_mailbox(ctx); @@ -1082,7 +1082,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) /* the offset stored in the header does not include the MMDF_SEP, so make * sure we seek to the correct location */ - if (ctx->magic == MUTT_MMDF) + if (ctx->mailbox->magic == MUTT_MMDF) offset -= (sizeof(MMDF_SEP) - 1); /* allocate space for the new offsets */ @@ -1113,7 +1113,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) { j++; - if (ctx->magic == MUTT_MMDF) + if (ctx->mailbox->magic == MUTT_MMDF) { if (fputs(MMDF_SEP, fp) == EOF) { @@ -1146,7 +1146,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) new_offset[i - first].body = ftello(fp) - ctx->hdrs[i]->content->length + offset; mutt_body_free(&ctx->hdrs[i]->content->parts); - switch (ctx->magic) + switch (ctx->mailbox->magic) { case MUTT_MMDF: if (fputs(MMDF_SEP, fp) == EOF) @@ -1200,8 +1200,8 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) if (fseeko(ctx->fp, offset, SEEK_SET) != 0 || /* seek the append location */ /* do a sanity check to make sure the mailbox looks ok */ !fgets(buf, sizeof(buf), ctx->fp) || - (ctx->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buf, 5) != 0)) || - (ctx->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buf) != 0))) + (ctx->mailbox->magic == MUTT_MBOX && (mutt_str_strncmp("From ", buf, 5) != 0)) || + (ctx->mailbox->magic == MUTT_MMDF && (mutt_str_strcmp(MMDF_SEP, buf) != 0))) { mutt_debug(1, "message not in expected position.\n"); mutt_debug(1, "\tLINE: %s\n", buf); diff --git a/monitor.c b/monitor.c index 8d1289268..7c8ca865e 100644 --- a/monitor.c +++ b/monitor.c @@ -294,7 +294,7 @@ static int monitor_resolve(struct MonitorInfo *info, struct Mailbox *mailbox) } else if (Context) { - info->magic = Context->magic; + info->magic = Context->mailbox->magic; info->path = Context->mailbox->realpath; } else diff --git a/mutt_attach.c b/mutt_attach.c index 38360fca1..e270b5d01 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -41,6 +41,7 @@ #include "filter.h" #include "globals.h" #include "handler.h" +#include "mailbox.h" #include "muttlib.h" #include "mx.h" #include "ncrypt/ncrypt.h" @@ -812,9 +813,9 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct mx_mbox_close(&ctx, NULL); return -1; } - if ((ctx->magic == MUTT_MBOX) || (ctx->magic == MUTT_MMDF)) + if ((ctx->mailbox->magic == MUTT_MBOX) || (ctx->mailbox->magic == MUTT_MMDF)) chflags = CH_FROM | CH_UPDATE_LEN; - chflags |= (ctx->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE); + chflags |= (ctx->mailbox->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE); if ((mutt_copy_message_fp(msg->fp, fp, hn, 0, chflags) == 0) && (mx_msg_commit(ctx, msg) == 0)) { diff --git a/mx.c b/mx.c index 09335e2d3..f60819e5c 100644 --- a/mx.c +++ b/mx.c @@ -179,12 +179,12 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags) struct stat sb; ctx->append = true; - ctx->magic = mx_path_probe(ctx->mailbox->path, NULL); - if (ctx->magic == MUTT_UNKNOWN) + ctx->mailbox->magic = mx_path_probe(ctx->mailbox->path, NULL); + if (ctx->mailbox->magic == MUTT_UNKNOWN) { if (flags & (MUTT_APPEND | MUTT_NEWFOLDER)) { - ctx->magic = MUTT_MAILBOX_ERROR; + ctx->mailbox->magic = MUTT_MAILBOX_ERROR; } else { @@ -193,7 +193,7 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags) } } - if (ctx->magic == MUTT_MAILBOX_ERROR) + if (ctx->mailbox->magic == MUTT_MAILBOX_ERROR) { if (stat(ctx->mailbox->path, &sb) == -1) { @@ -201,10 +201,10 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags) { #ifdef USE_COMPRESSED if (mutt_comp_can_append(ctx)) - ctx->magic = MUTT_COMPRESSED; + ctx->mailbox->magic = MUTT_COMPRESSED; else #endif - ctx->magic = MboxType; + ctx->mailbox->magic = MboxType; flags |= MUTT_APPENDNEW; } else @@ -217,7 +217,7 @@ static int mx_open_mailbox_append(struct Context *ctx, int flags) return -1; } - ctx->mx_ops = mx_get_ops(ctx->magic); + ctx->mx_ops = mx_get_ops(ctx->mailbox->magic); if (!ctx->mx_ops || !ctx->mx_ops->mbox_open_append) return -1; @@ -283,14 +283,14 @@ struct Context *mx_mbox_open(const char *path, int flags) return ctx; } - ctx->magic = mx_path_probe(path, NULL); - ctx->mx_ops = mx_get_ops(ctx->magic); + ctx->mailbox->magic = mx_path_probe(path, NULL); + ctx->mx_ops = mx_get_ops(ctx->mailbox->magic); - if ((ctx->magic == MUTT_UNKNOWN) || (ctx->magic == MUTT_MAILBOX_ERROR) || !ctx->mx_ops) + if ((ctx->mailbox->magic == MUTT_UNKNOWN) || (ctx->mailbox->magic == MUTT_MAILBOX_ERROR) || !ctx->mx_ops) { - if (ctx->magic == MUTT_MAILBOX_ERROR) + if (ctx->mailbox->magic == MUTT_MAILBOX_ERROR) mutt_perror(path); - else if (ctx->magic == MUTT_UNKNOWN || !ctx->mx_ops) + else if (ctx->mailbox->magic == MUTT_UNKNOWN || !ctx->mx_ops) mutt_error(_("%s is not a mailbox"), path); mx_fastclose_mailbox(ctx); @@ -431,7 +431,7 @@ static int trash_append(struct Context *ctx) struct stat st, stc; int opt_confappend, rc; - if (!Trash || !ctx->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash)) + if (!Trash || !ctx->deleted || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash)) return 0; int delmsgcount = 0; @@ -472,7 +472,7 @@ static int trash_append(struct Context *ctx) } #ifdef USE_IMAP - if (Context->magic == MUTT_IMAP && (imap_path_probe(Trash, NULL) == MUTT_IMAP)) + if (Context->mailbox->magic == MUTT_IMAP && (imap_path_probe(Trash, NULL) == MUTT_IMAP)) { if (imap_fast_trash(Context, Trash) == 0) return 0; @@ -535,7 +535,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) } #ifdef USE_NNTP - if (ctx->mailbox->msg_unread && ctx->magic == MUTT_NNTP) + if (ctx->mailbox->msg_unread && ctx->mailbox->magic == MUTT_NNTP) { struct NntpData *nntp_data = ctx->data; @@ -563,7 +563,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) #ifdef USE_NNTP /* don't need to move articles from newsgroup */ - if (ctx->magic == MUTT_NNTP) + if (ctx->mailbox->magic == MUTT_NNTP) read_msgs = 0; #endif @@ -602,7 +602,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) /* There is no point in asking whether or not to purge if we are * just marking messages as "trash". */ - if (ctx->deleted && !(ctx->magic == MUTT_MAILDIR && MaildirTrash)) + if (ctx->deleted && !(ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash)) { snprintf(buf, sizeof(buf), ngettext("Purge %d deleted message?", "Purge %d deleted messages?", ctx->deleted), @@ -633,7 +633,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) /* try to use server-side copy first */ i = 1; - if ((ctx->magic == MUTT_IMAP) && (imap_path_probe(mbox, NULL) == MUTT_IMAP)) + if ((ctx->mailbox->magic == MUTT_IMAP) && (imap_path_probe(mbox, NULL) == MUTT_IMAP)) { /* tag messages for moving, and clear old tags, if any */ for (i = 0; i < ctx->mailbox->msg_count; i++) @@ -695,7 +695,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) { if (!ctx->quiet) mutt_message(_("Mailbox is unchanged")); - if (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) + if (ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) mbox_reset_atime(ctx, NULL); mx_fastclose_mailbox(ctx); FREE(pctx); @@ -714,7 +714,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) #ifdef USE_IMAP /* allow IMAP to preserve the deleted flag across sessions */ - if (ctx->magic == MUTT_IMAP) + if (ctx->mailbox->magic == MUTT_IMAP) { int check = imap_sync_mailbox(ctx, (purge != MUTT_NO)); if (check != 0) @@ -758,7 +758,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) mutt_message(_("%d kept, %d deleted"), ctx->mailbox->msg_count - ctx->deleted, ctx->deleted); } - if (ctx->mailbox->msg_count == ctx->deleted && (ctx->magic == MUTT_MMDF || ctx->magic == MUTT_MBOX) && + if (ctx->mailbox->msg_count == ctx->deleted && (ctx->mailbox->magic == MUTT_MMDF || ctx->mailbox->magic == MUTT_MBOX) && !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty) { mutt_file_unlink_empty(ctx->mailbox->path); @@ -810,7 +810,7 @@ void mx_update_tables(struct Context *ctx, bool committing) for (i = 0, j = 0; i < ctx->mailbox->msg_count; i++) { if (!ctx->hdrs[i]->quasi_deleted && - ((committing && (!ctx->hdrs[i]->deleted || (ctx->magic == MUTT_MAILDIR && MaildirTrash))) || + ((committing && (!ctx->hdrs[i]->deleted || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash))) || (!committing && ctx->hdrs[i]->active))) { if (i != j) @@ -832,7 +832,7 @@ void mx_update_tables(struct Context *ctx, bool committing) else if (ctx->hdrs[j]->changed) ctx->changed = true; - if (!committing || (ctx->magic == MUTT_MAILDIR && MaildirTrash)) + if (!committing || (ctx->mailbox->magic == MUTT_MAILDIR && MaildirTrash)) { if (ctx->hdrs[j]->deleted) ctx->deleted++; @@ -853,7 +853,7 @@ void mx_update_tables(struct Context *ctx, bool committing) } else { - if (ctx->magic == MUTT_MH || ctx->magic == MUTT_MAILDIR) + if (ctx->mailbox->magic == MUTT_MH || ctx->mailbox->magic == MUTT_MAILDIR) { ctx->size -= (ctx->hdrs[i]->content->length + ctx->hdrs[i]->content->offset - ctx->hdrs[i]->content->hdr_offset); @@ -929,7 +929,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) if (!ctx->changed) return 0; /* nothing to do! */ /* let IMAP servers hold on to D flags */ - if (ctx->magic != MUTT_IMAP) + if (ctx->mailbox->magic != MUTT_IMAP) { for (int i = 0; i < ctx->mailbox->msg_count; i++) { @@ -955,7 +955,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) } #ifdef USE_IMAP - if (ctx->magic == MUTT_IMAP) + if (ctx->mailbox->magic == MUTT_IMAP) rc = imap_sync_mailbox(ctx, purge); else #endif @@ -963,7 +963,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) if (rc == 0) { #ifdef USE_IMAP - if (ctx->magic == MUTT_IMAP && !purge) + if (ctx->mailbox->magic == MUTT_IMAP && !purge) { if (!ctx->quiet) mutt_message(_("Mailbox checkpointed")); @@ -977,7 +977,7 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) mutt_sleep(0); - if (ctx->mailbox->msg_count == ctx->deleted && (ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) && + if (ctx->mailbox->msg_count == ctx->deleted && (ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) && !mutt_is_spool(ctx->mailbox->path) && !SaveEmpty) { unlink(ctx->mailbox->path); @@ -992,10 +992,10 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) * MH and maildir are safe. mbox-style seems to need re-sorting, * at least with the new threading code. */ - if (purge || (ctx->magic != MUTT_MAILDIR && ctx->magic != MUTT_MH)) + if (purge || (ctx->mailbox->magic != MUTT_MAILDIR && ctx->mailbox->magic != MUTT_MH)) { /* IMAP does this automatically after handling EXPUNGE */ - if (ctx->magic != MUTT_IMAP) + if (ctx->mailbox->magic != MUTT_IMAP) { mx_update_tables(ctx, true); mutt_sort_headers(ctx, true); /* rethread from scratch */ @@ -1020,7 +1020,7 @@ struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int fla if (!ctx->mx_ops || !ctx->mx_ops->msg_open_new) { - mutt_debug(1, "function unimplemented for mailbox type %d.\n", ctx->magic); + mutt_debug(1, "function unimplemented for mailbox type %d.\n", ctx->mailbox->magic); return NULL; } @@ -1041,10 +1041,10 @@ struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int fla if (ctx->mx_ops->msg_open_new(ctx, msg, hdr) == 0) { - if (ctx->magic == MUTT_MMDF) + if (ctx->mailbox->magic == MUTT_MMDF) fputs(MMDF_SEP, msg->fp); - if ((ctx->magic == MUTT_MBOX || ctx->magic == MUTT_MMDF) && flags & MUTT_ADD_FROM) + if ((ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) && flags & MUTT_ADD_FROM) { if (hdr) { @@ -1098,7 +1098,7 @@ struct Message *mx_msg_open(struct Context *ctx, int msgno) if (!ctx->mx_ops || !ctx->mx_ops->msg_open) { - mutt_debug(1, "function not implemented for mailbox type %d.\n", ctx->magic); + mutt_debug(1, "function not implemented for mailbox type %d.\n", ctx->mailbox->magic); return NULL; } diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 1937cfc3b..bc9bdb6ce 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -1386,7 +1386,7 @@ void nntp_mailbox(char *buf, size_t buflen) if (!nntp_data || !nntp_data->subscribed || !nntp_data->unread) continue; - if (Context && Context->magic == MUTT_NNTP && + if (Context && Context->mailbox->magic == MUTT_NNTP && (mutt_str_strcmp(nntp_data->group, ((struct NntpData *) Context->data)->group) == 0)) { unsigned int unread = 0; diff --git a/nntp/nntp.c b/nntp/nntp.c index d108c2bb4..8fca93987 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -1784,7 +1784,7 @@ int nntp_post(const char *msg) struct NntpData *nntp_data, nntp_tmp; char buf[LONG_STRING]; - if (Context && Context->magic == MUTT_NNTP) + if (Context && Context->mailbox->magic == MUTT_NNTP) nntp_data = Context->data; else { @@ -2368,7 +2368,7 @@ int nntp_check_new_groups(struct NntpServer *nserv) } } /* select current newsgroup */ - if (Context && Context->magic == MUTT_NNTP) + if (Context && Context->mailbox->magic == MUTT_NNTP) { buf[0] = '\0'; if (nntp_query((struct NntpData *) Context->data, buf, sizeof(buf)) < 0) @@ -2383,7 +2383,7 @@ int nntp_check_new_groups(struct NntpServer *nserv) if (nntp_date(nserv, &now) < 0) return -1; nntp_data.nserv = nserv; - if (Context && Context->magic == MUTT_NNTP) + if (Context && Context->mailbox->magic == MUTT_NNTP) nntp_data.group = ((struct NntpData *) Context->data)->group; else nntp_data.group = NULL; diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 7c01cbdeb..61b232cc0 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -237,7 +237,7 @@ static struct NmCtxData *new_ctxdata(const char *uri) */ static int init_context(struct Context *ctx) { - if (!ctx || (ctx->magic != MUTT_NOTMUCH)) + if (!ctx || (ctx->mailbox->magic != MUTT_NOTMUCH)) return -1; if (ctx->data) @@ -282,7 +282,7 @@ static char *header_get_fullpath(struct Header *h, char *buf, size_t buflen) */ static struct NmCtxData *get_ctxdata(struct Context *ctx) { - if (ctx && (ctx->magic == MUTT_NOTMUCH)) + if (ctx && (ctx->mailbox->magic == MUTT_NOTMUCH)) return ctx->data; return NULL; @@ -1973,7 +1973,7 @@ bool nm_normalize_uri(const char *uri, char *buf, size_t buflen) if (!tmp_ctxdata) return false; - tmp_ctx.magic = MUTT_NOTMUCH; + tmp_ctx.mailbox->magic = MUTT_NOTMUCH; tmp_ctx.data = tmp_ctxdata; mutt_debug(2, "#1 () -> db_query: %s\n", tmp_ctxdata->db_query); @@ -2492,7 +2492,7 @@ static int nm_mbox_open(struct Context *ctx) */ static int nm_mbox_close(struct Context *ctx) { - if (!ctx || (ctx->magic != MUTT_NOTMUCH)) + if (!ctx || (ctx->mailbox->magic != MUTT_NOTMUCH)) return -1; for (int i = 0; i < ctx->mailbox->msg_count; i++) @@ -2684,14 +2684,14 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint) header_get_fullpath(h, old, sizeof(old)); mutt_str_strfcpy(ctx->mailbox->path, hd->folder, sizeof(ctx->mailbox->path)); - ctx->magic = hd->magic; + ctx->mailbox->magic = hd->magic; #ifdef USE_HCACHE rc = mh_sync_mailbox_message(ctx, i, NULL); #else rc = mh_sync_mailbox_message(ctx, i); #endif mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path)); - ctx->magic = MUTT_NOTMUCH; + ctx->mailbox->magic = MUTT_NOTMUCH; if (rc) break; @@ -2711,7 +2711,7 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint) } mutt_str_strfcpy(ctx->mailbox->path, uri, sizeof(ctx->mailbox->path)); - ctx->magic = MUTT_NOTMUCH; + ctx->mailbox->magic = MUTT_NOTMUCH; if (!is_longrun(data)) release_db(data); @@ -2740,7 +2740,7 @@ static int nm_msg_open(struct Context *ctx, struct Message *msg, int msgno) msg->fp = fopen(path, "r"); if (!msg->fp && (errno == ENOENT) && - ((ctx->magic == MUTT_MAILDIR) || (ctx->magic == MUTT_NOTMUCH))) + ((ctx->mailbox->magic == MUTT_MAILDIR) || (ctx->mailbox->magic == MUTT_NOTMUCH))) { msg->fp = maildir_open_find_message(folder, cur->path, NULL); } diff --git a/pager.c b/pager.c index 129894edd..13d3c67cb 100644 --- a/pager.c +++ b/pager.c @@ -2272,7 +2272,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e mutt_str_strfcpy(tmphelp, helpstr, sizeof(tmphelp)); mutt_compile_help(buffer, sizeof(buffer), MENU_PAGER, #ifdef USE_NNTP - (Context && (Context->magic == MUTT_NNTP)) ? PagerNewsHelpExtra : + (Context && (Context->mailbox->magic == MUTT_NNTP)) ? PagerNewsHelpExtra : #endif PagerHelpExtra); snprintf(helpstr, sizeof(helpstr), "%s %s", tmphelp, buffer); @@ -3083,7 +3083,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e case OP_POST: CHECK_MODE(IsHeader(extra) && !IsAttach(extra)); CHECK_ATTACH; - if (extra->ctx && extra->ctx->magic == MUTT_NNTP && + if (extra->ctx && extra->ctx->mailbox->magic == MUTT_NNTP && !((struct NntpData *) extra->ctx->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES) { break; @@ -3095,7 +3095,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e case OP_FORWARD_TO_GROUP: CHECK_MODE(IsHeader(extra) || IsMsgAttach(extra)); CHECK_ATTACH; - if (extra->ctx && extra->ctx->magic == MUTT_NNTP && + if (extra->ctx && extra->ctx->mailbox->magic == MUTT_NNTP && !((struct NntpData *) extra->ctx->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES) { break; @@ -3121,7 +3121,7 @@ int mutt_pager(const char *banner, const char *fname, int flags, struct Pager *e query_quadoption(FollowupToPoster, _("Reply by mail as poster prefers?")) != MUTT_YES) { - if (extra->ctx && extra->ctx->magic == MUTT_NNTP && + if (extra->ctx && extra->ctx->mailbox->magic == MUTT_NNTP && !((struct NntpData *) extra->ctx->data)->allowed && query_quadoption(PostModerated, _("Posting to this group not allowed, may be moderated. Continue?")) != MUTT_YES) { break; diff --git a/pattern.c b/pattern.c index cd2e94a16..7a57bce8d 100644 --- a/pattern.c +++ b/pattern.c @@ -1869,7 +1869,7 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, return 0; #ifdef USE_IMAP /* IMAP search sets h->matched at search compile time */ - if (ctx->magic == MUTT_IMAP && pat->stringmatch) + if (ctx->mailbox->magic == MUTT_IMAP && pat->stringmatch) return h->matched; #endif return pat->not ^ msg_search(ctx, pat, h->msgno); @@ -1877,7 +1877,7 @@ int mutt_pattern_exec(struct Pattern *pat, enum PatternExecFlag flags, #ifdef USE_IMAP if (!ctx) return 0; - if (ctx->magic == MUTT_IMAP) + if (ctx->mailbox->magic == MUTT_IMAP) { if (pat->stringmatch) return h->matched; @@ -2242,7 +2242,7 @@ int mutt_pattern_func(int op, char *prompt) } #ifdef USE_IMAP - if (Context->magic == MUTT_IMAP && imap_search(Context, pat) < 0) + if (Context->mailbox->magic == MUTT_IMAP && imap_search(Context, pat) < 0) goto bail; #endif @@ -2400,7 +2400,7 @@ int mutt_search_command(int cur, int op) for (int i = 0; i < Context->mailbox->msg_count; i++) Context->hdrs[i]->searched = false; #ifdef USE_IMAP - if (Context->magic == MUTT_IMAP && imap_search(Context, SearchPattern) < 0) + if (Context->mailbox->magic == MUTT_IMAP && imap_search(Context, SearchPattern) < 0) return -1; #endif OptSearchInvalid = false; diff --git a/recvattach.c b/recvattach.c index 806d3e929..e1fcc9cad 100644 --- a/recvattach.c +++ b/recvattach.c @@ -43,6 +43,7 @@ #include "hdrline.h" #include "hook.h" #include "keymap.h" +#include "mailbox.h" #include "menu.h" #include "mutt_attach.h" #include "mutt_logging.h" @@ -1415,7 +1416,7 @@ void mutt_view_attachments(struct Header *hdr) CHECK_READONLY; #ifdef USE_POP - if (Context->magic == MUTT_POP) + if (Context->mailbox->magic == MUTT_POP) { mutt_flushinp(); mutt_error(_("Can't delete attachment from POP server")); @@ -1424,7 +1425,7 @@ void mutt_view_attachments(struct Header *hdr) #endif #ifdef USE_NNTP - if (Context->magic == MUTT_NNTP) + if (Context->mailbox->magic == MUTT_NNTP) { mutt_flushinp(); mutt_error(_("Can't delete attachment from news server")); diff --git a/send.c b/send.c index e21e204aa..024ddf90e 100644 --- a/send.c +++ b/send.c @@ -1727,7 +1727,7 @@ int ci_send_message(int flags, struct Header *msg, char *tempfile, mutt_fix_reply_recipients(msg->env); #ifdef USE_NNTP - if ((flags & SEND_NEWS) && ctx && ctx->magic == MUTT_NNTP && !msg->env->newsgroups) + if ((flags & SEND_NEWS) && ctx && ctx->mailbox->magic == MUTT_NNTP && !msg->env->newsgroups) msg->env->newsgroups = mutt_str_strdup(((struct NntpData *) ctx->data)->group); #endif diff --git a/sendlib.c b/sendlib.c index 140c6cfc5..a75eedd6a 100644 --- a/sendlib.c +++ b/sendlib.c @@ -3186,7 +3186,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid, /* We need to add a Content-Length field to avoid problems where a line in * the message body begins with "From " */ - if ((f->magic == MUTT_MMDF) || (f->magic == MUTT_MBOX)) + if ((f->mailbox->magic == MUTT_MMDF) || (f->mailbox->magic == MUTT_MBOX)) { mutt_mktemp(tempfile, sizeof(tempfile)); tempfp = mutt_file_fopen(tempfile, "w+"); @@ -3233,7 +3233,7 @@ int mutt_write_fcc(const char *path, struct Header *hdr, const char *msgid, if (post && fcc) fprintf(msg->fp, "X-Mutt-Fcc: %s\n", fcc); - if ((f->magic == MUTT_MMDF) || (f->magic == MUTT_MBOX)) + if ((f->mailbox->magic == MUTT_MMDF) || (f->mailbox->magic == MUTT_MBOX)) fprintf(msg->fp, "Status: RO\n"); /* mutt_rfc822_write_header() only writes out a Date: header with diff --git a/sort.c b/sort.c index 452bad34c..363b800d5 100644 --- a/sort.c +++ b/sort.c @@ -321,7 +321,7 @@ sort_t *mutt_get_sort_func(int method) return compare_label; case SORT_ORDER: #ifdef USE_NNTP - if (Context && (Context->magic == MUTT_NNTP)) + if (Context && (Context->mailbox->magic == MUTT_NNTP)) return nntp_compare_order; else #endif diff --git a/status.c b/status.c index 88d5d9e0b..03605912f 100644 --- a/status.c +++ b/status.c @@ -125,7 +125,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c { #ifdef USE_NOTMUCH char *p = NULL; - if (Context && Context->magic == MUTT_NOTMUCH && (p = nm_get_description(Context))) + if (Context && Context->mailbox->magic == MUTT_NOTMUCH && (p = nm_get_description(Context))) mutt_str_strfcpy(tmp, p, sizeof(tmp)); else #endif @@ -269,7 +269,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c 2 : (Context->changed || /* deleted doesn't necessarily mean changed in IMAP */ - (Context->magic != MUTT_IMAP && Context->deleted)) ? + (Context->mailbox->magic != MUTT_IMAP && Context->deleted)) ? 1 : 0); }