From: Richard Russon Date: Mon, 24 Dec 2018 11:23:23 +0000 (+0000) Subject: mbox_open: factor out Context X-Git-Tag: 2019-10-25~399^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2acd0cf42e6ef290d5a692b20693038d8ad77e1e;p=neomutt mbox_open: factor out Context --- diff --git a/compress.c b/compress.c index 32d0f660d..c1f9af83b 100644 --- a/compress.c +++ b/compress.c @@ -456,9 +456,9 @@ int comp_ac_add(struct Account *a, struct Mailbox *m) * Then determine the type of the mailbox so we can delegate the handling of * messages. */ -static int comp_mbox_open(struct Mailbox *m, struct Context *ctx) +static int comp_mbox_open(struct Mailbox *m) { - if (!ctx || !ctx->mailbox || (ctx->mailbox->magic != MUTT_COMPRESSED)) + if (!m || (m->magic != MUTT_COMPRESSED)) return -1; struct CompressInfo *ci = set_compress_info(m); @@ -500,7 +500,7 @@ static int comp_mbox_open(struct Mailbox *m, struct Context *ctx) } m->account->magic = m->magic; - return ci->child_ops->mbox_open(m, ctx); + return ci->child_ops->mbox_open(m); cmo_fail: /* remove the partial uncompressed file */ diff --git a/imap/imap.c b/imap/imap.c index 86fae0bef..28f10e892 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1947,7 +1947,7 @@ int imap_login(struct ImapAccountData *adata) /** * imap_mbox_open - Implements MxOps::mbox_open() */ -static int imap_mbox_open(struct Mailbox *m, struct Context *ctx) +static int imap_mbox_open(struct Mailbox *m) { if (!m || !m->account || !m->mdata) return -1; diff --git a/maildir/maildir.c b/maildir/maildir.c index cbe354646..65003edf7 100644 --- a/maildir/maildir.c +++ b/maildir/maildir.c @@ -292,7 +292,7 @@ cleanup: /** * maildir_mbox_open - Implements MxOps::mbox_open() */ -static int maildir_mbox_open(struct Mailbox *m, struct Context *ctx) +static int maildir_mbox_open(struct Mailbox *m) { return maildir_read_dir(m); } diff --git a/maildir/mh.c b/maildir/mh.c index ac20e5e03..72aba93b3 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -541,7 +541,7 @@ int mh_sync_message(struct Mailbox *m, int msgno) /** * mh_mbox_open - Implements MxOps::mbox_open() */ -static int mh_mbox_open(struct Mailbox *m, struct Context *ctx) +static int mh_mbox_open(struct Mailbox *m) { return mh_read_dir(m, NULL); } diff --git a/mbox/mbox.c b/mbox/mbox.c index 3f1f74995..bd133d96d 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -923,7 +923,7 @@ int mbox_ac_add(struct Account *a, struct Mailbox *m) /** * mbox_mbox_open - Implements MxOps::mbox_open() */ -static int mbox_mbox_open(struct Mailbox *m, struct Context *ctx) +static int mbox_mbox_open(struct Mailbox *m) { if (init_mailbox(m) != 0) return -1; @@ -1016,7 +1016,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint) if (!adata->fp) { - if (mbox_mbox_open(m, NULL) < 0) + if (mbox_mbox_open(m) < 0) return -1; mx_update_context(ctx); } diff --git a/mx.c b/mx.c index f5d559421..522a2b599 100644 --- a/mx.c +++ b/mx.c @@ -395,7 +395,7 @@ struct Context *mx_mbox_open(struct Mailbox *m, const char *path, int flags) if (!m->quiet) mutt_message(_("Reading %s..."), m->path); - int rc = m->mx_ops->mbox_open(ctx->mailbox, ctx); + int rc = m->mx_ops->mbox_open(ctx->mailbox); m->opened++; if (rc == 0) mx_update_context(ctx); diff --git a/mx.h b/mx.h index 2224767c7..a9a860722 100644 --- a/mx.h +++ b/mx.h @@ -120,13 +120,12 @@ struct MxOps int (*ac_add) (struct Account *a, struct Mailbox *m); /** * mbox_open - Open a mailbox - * @param m Mailbox to open - * @param ctx Mailbox to open + * @param m Mailbox to open * @retval 0 Success * @retval -1 Error * @retval -2 Aborted */ - int (*mbox_open) (struct Mailbox *m, struct Context *ctx); + int (*mbox_open) (struct Mailbox *m); /** * mbox_open_append - Open a mailbox for appending * @param m Mailbox to open diff --git a/nntp/nntp.c b/nntp/nntp.c index af8b50566..bced2fe51 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -2427,7 +2427,7 @@ int nntp_ac_add(struct Account *a, struct Mailbox *m) /** * nntp_mbox_open - Implements MxOps::mbox_open() */ -static int nntp_mbox_open(struct Mailbox *m, struct Context *ctx) +static int nntp_mbox_open(struct Mailbox *m) { if (!m || !m->account) return -1; diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 29d836d40..4f2a7b7ea 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -2110,7 +2110,7 @@ int nm_ac_add(struct Account *a, struct Mailbox *m) /** * nm_mbox_open - Implements MxOps::mbox_open() */ -static int nm_mbox_open(struct Mailbox *m, struct Context *ctx) +static int nm_mbox_open(struct Mailbox *m) { if (init_mailbox(m) != 0) return -1; diff --git a/pop/pop.c b/pop/pop.c index 594c81d3a..3ec37eeeb 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -371,19 +371,17 @@ static header_cache_t *pop_hcache_open(struct PopAccountData *adata, const char /** * pop_fetch_headers - Read headers - * @param ctx Mailbox + * @param m Mailbox * @retval 0 Success * @retval -1 Connection lost * @retval -2 Invalid command or execution error * @retval -3 Error writing to tempfile */ -static int pop_fetch_headers(struct Context *ctx) +static int pop_fetch_headers(struct Mailbox *m) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; - struct Mailbox *m = ctx->mailbox; - struct PopAccountData *adata = pop_get_adata(m); struct Progress progress; @@ -813,7 +811,7 @@ int pop_ac_add(struct Account *a, struct Mailbox *m) * * Fetch only headers */ -static int pop_mbox_open(struct Mailbox *m, struct Context *ctx) +static int pop_mbox_open(struct Mailbox *m) { if (!m || !m->account) return -1; @@ -879,7 +877,7 @@ static int pop_mbox_open(struct Mailbox *m, struct Context *ctx) mutt_message(_("Fetching list of messages...")); - const int ret = pop_fetch_headers(ctx); + const int ret = pop_fetch_headers(m); if (ret >= 0) return 0; @@ -916,7 +914,7 @@ static int pop_mbox_check(struct Context *ctx, int *index_hint) mutt_message(_("Checking for new messages...")); int old_msg_count = m->msg_count; - int ret = pop_fetch_headers(ctx); + int ret = pop_fetch_headers(m); pop_clear_cache(adata); if (m->msg_count > old_msg_count) mx_update_context(ctx);