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);
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))
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++)
#endif
}
#ifdef USE_NOTMUCH
- if (Context->magic == MUTT_NOTMUCH)
+ if (Context->mailbox->magic == MUTT_NOTMUCH)
nm_longrun_done(Context);
#endif
if (rc != 0)
}
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);
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));
*/
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);
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;
}
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;
}
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? */
#include "globals.h"
#include "handler.h"
#include "hdrline.h"
+#include "mailbox.h"
#include "mutt_window.h"
#include "muttlib.h"
#include "mx.h"
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
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;
CHECK_IN_MAILBOX;
CHECK_READONLY;
CHECK_ATTACH;
- if (Context->magic == MUTT_NNTP)
+ if (Context->mailbox->magic == MUTT_NNTP)
{
struct Header *hdr = NULL;
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;
#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)
#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;
}
#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++)
{
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;
}
}
#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;
{
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;
#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));
/* 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
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))
/* 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;
}
/* 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;
}
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;
}
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;
}
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
#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)
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)
* 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;
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;
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;
#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)
{
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)
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;
}
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)
*/
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);
ret = 0;
}
- if (ctx->magic == MUTT_MH)
+ if (ctx->mailbox->magic == MUTT_MH)
{
key = p->h->path;
keylen = strlen(key);
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);
}
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)
{
}
#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)
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);
* 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);
{
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);
#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 != ',')
}
}
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;
{
const char *key = NULL;
size_t keylen;
- if (ctx->magic == MUTT_MH)
+ if (ctx->mailbox->magic == MUTT_MH)
{
key = h->path;
keylen = strlen(key);
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);
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
}
#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? */
{
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++;
}
}
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;
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;
ctx->subj_hash = NULL;
mutt_make_label_hash(ctx);
- switch (ctx->magic)
+ switch (ctx->mailbox->magic)
{
case MUTT_MBOX:
case MUTT_MMDF:
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:
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);
/* 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 */
{
j++;
- if (ctx->magic == MUTT_MMDF)
+ if (ctx->mailbox->magic == MUTT_MMDF)
{
if (fputs(MMDF_SEP, fp) == EOF)
{
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)
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);
}
else if (Context)
{
- info->magic = Context->magic;
+ info->magic = Context->mailbox->magic;
info->path = Context->mailbox->realpath;
}
else
#include "filter.h"
#include "globals.h"
#include "handler.h"
+#include "mailbox.h"
#include "muttlib.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
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))
{
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
{
}
}
- if (ctx->magic == MUTT_MAILBOX_ERROR)
+ if (ctx->mailbox->magic == MUTT_MAILBOX_ERROR)
{
if (stat(ctx->mailbox->path, &sb) == -1)
{
{
#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
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;
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);
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;
}
#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;
}
#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;
#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
/* 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),
/* 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++)
{
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);
#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)
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);
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)
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++;
}
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);
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++)
{
}
#ifdef USE_IMAP
- if (ctx->magic == MUTT_IMAP)
+ if (ctx->mailbox->magic == MUTT_IMAP)
rc = imap_sync_mailbox(ctx, purge);
else
#endif
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"));
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);
* 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 */
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;
}
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)
{
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;
}
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;
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
{
}
}
/* 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)
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;
*/
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)
*/
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;
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);
*/
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++)
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;
}
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);
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);
}
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);
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;
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;
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;
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);
#ifdef USE_IMAP
if (!ctx)
return 0;
- if (ctx->magic == MUTT_IMAP)
+ if (ctx->mailbox->magic == MUTT_IMAP)
{
if (pat->stringmatch)
return h->matched;
}
#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
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;
#include "hdrline.h"
#include "hook.h"
#include "keymap.h"
+#include "mailbox.h"
#include "menu.h"
#include "mutt_attach.h"
#include "mutt_logging.h"
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"));
#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"));
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
/* 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+");
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
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
{
#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
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);
}