From: Richard Russon Date: Wed, 26 Dec 2018 18:14:46 +0000 (+0000) Subject: mbox_sync: factor out Context X-Git-Tag: 2019-10-25~399^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f9a43c888d3f9c54fcb7f7c06eb6b2ee3994b9a;p=neomutt mbox_sync: factor out Context --- diff --git a/compress.c b/compress.c index 638f0e3f0..861884631 100644 --- a/compress.c +++ b/compress.c @@ -639,12 +639,11 @@ static int comp_mbox_check(struct Mailbox *m, int *index_hint) * Changes in NeoMutt only affect the tmp file. * Calling comp_mbox_sync() will commit them to the compressed file. */ -static int comp_mbox_sync(struct Context *ctx, int *index_hint) +static int comp_mbox_sync(struct Mailbox *m, int *index_hint) { - if (!ctx || !ctx->mailbox || !ctx->mailbox->compress_info) + if (!m || !m->compress_info) return -1; - struct Mailbox *m = ctx->mailbox; struct CompressInfo *ci = m->compress_info; if (!ci->close) @@ -667,7 +666,7 @@ static int comp_mbox_sync(struct Context *ctx, int *index_hint) if (rc != 0) goto sync_cleanup; - rc = ops->mbox_sync(ctx, index_hint); + rc = ops->mbox_sync(m, index_hint); if (rc != 0) goto sync_cleanup; diff --git a/maildir/maildir_private.h b/maildir/maildir_private.h index d304f1d3c..5efcb9ec9 100644 --- a/maildir/maildir_private.h +++ b/maildir/maildir_private.h @@ -80,7 +80,7 @@ int maildir_path_parent(char *buf, size_t buflen); int maildir_path_pretty(char *buf, size_t buflen, const char *folder); int mh_mbox_check (struct Mailbox *m, int *index_hint); int mh_mbox_close (struct Mailbox *m); -int mh_mbox_sync (struct Context *ctx, int *index_hint); +int mh_mbox_sync (struct Mailbox *m, int *index_hint); int mh_msg_close (struct Mailbox *m, struct Message *msg); /* Maildir/MH shared functions */ diff --git a/maildir/shared.c b/maildir/shared.c index e042a6bb9..d2248e129 100644 --- a/maildir/shared.c +++ b/maildir/shared.c @@ -1757,13 +1757,11 @@ int maildir_path_parent(char *buf, size_t buflen) /** * mh_mbox_sync - Implements MxOps::mbox_sync() */ -int mh_mbox_sync(struct Context *ctx, int *index_hint) +int mh_mbox_sync(struct Mailbox *m, int *index_hint) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; - struct Mailbox *m = ctx->mailbox; - int i, j; #ifdef USE_HCACHE header_cache_t *hc = NULL; diff --git a/mbox/mbox.c b/mbox/mbox.c index f865df460..e31e05438 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -1128,13 +1128,11 @@ static int mbox_mbox_check(struct Mailbox *m, int *index_hint) /** * mbox_mbox_sync - Implements MxOps::mbox_sync() */ -static int mbox_mbox_sync(struct Context *ctx, int *index_hint) +static int mbox_mbox_sync(struct Mailbox *m, int *index_hint) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; - struct Mailbox *m = ctx->mailbox; - struct MboxAccountData *adata = mbox_adata_get(m); if (!adata) return -1; @@ -1288,7 +1286,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) */ new_offset[i - first].hdr = ftello(fp) + offset; - if (mutt_copy_message_ctx(fp, ctx->mailbox, m->emails[i], MUTT_CM_UPDATE, + if (mutt_copy_message_ctx(fp, m, m->emails[i], MUTT_CM_UPDATE, CH_FROM | CH_UPDATE | CH_UPDATE_LEN) != 0) { mutt_perror(tempfile); diff --git a/mx.c b/mx.c index 563717faf..023016bbb 100644 --- a/mx.c +++ b/mx.c @@ -481,7 +481,7 @@ static int sync_mailbox(struct Context *ctx, int *index_hint) mutt_message(_("Writing %s..."), m->path); } - int rc = m->mx_ops->mbox_sync(ctx, index_hint); + int rc = m->mx_ops->mbox_sync(m, index_hint); if ((rc != 0) && !m->quiet) { /* L10N: Displayed if a mailbox sync fails */ diff --git a/mx.h b/mx.h index 5796bf7b7..08260b785 100644 --- a/mx.h +++ b/mx.h @@ -152,12 +152,12 @@ struct MxOps int (*mbox_check_stats)(struct Mailbox *m, int flags); /** * mbox_sync - Save changes to the mailbox - * @param ctx Mailbox to sync + * @param m Mailbox to sync * @param index_hint Remember our place in the index * @retval 0 Success * @retval -1 Failure */ - int (*mbox_sync) (struct Context *ctx, int *index_hint); + int (*mbox_sync) (struct Mailbox *m, int *index_hint); /** * mbox_close - Close a mailbox * @param m Mailbox to close diff --git a/nntp/nntp.c b/nntp/nntp.c index 29ad5aab1..ba9f59edb 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -2606,13 +2606,11 @@ static int nntp_mbox_check(struct Mailbox *m, int *index_hint) * * @note May also return values from check_mailbox() */ -static int nntp_mbox_sync(struct Context *ctx, int *index_hint) +static int nntp_mbox_sync(struct Mailbox *m, int *index_hint) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; - struct Mailbox *m = ctx->mailbox; - struct NntpMboxData *mdata = m->mdata; int rc; #ifdef USE_HCACHE @@ -2662,7 +2660,7 @@ static int nntp_mbox_sync(struct Context *ctx, int *index_hint) #endif /* save .newsrc entries */ - nntp_newsrc_gen_entries(ctx->mailbox); + nntp_newsrc_gen_entries(m); nntp_newsrc_update(mdata->adata); nntp_newsrc_close(mdata->adata); return 0; diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index bea00dec8..424a60837 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -2296,13 +2296,11 @@ done: /** * nm_mbox_sync - Implements MxOps::mbox_sync() */ -static int nm_mbox_sync(struct Context *ctx, int *index_hint) +static int nm_mbox_sync(struct Mailbox *m, int *index_hint) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; - struct Mailbox *m = ctx->mailbox; - struct NmMboxData *mdata = nm_mdata_get(m); if (!mdata) return -1; diff --git a/pop/pop.c b/pop/pop.c index 92d494e50..71acc00f9 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -931,13 +931,11 @@ static int pop_mbox_check(struct Mailbox *m, int *index_hint) * * Update POP mailbox, delete messages from server */ -static int pop_mbox_sync(struct Context *ctx, int *index_hint) +static int pop_mbox_sync(struct Mailbox *m, int *index_hint) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; - struct Mailbox *m = ctx->mailbox; - int i, j, ret = 0; char buf[LONG_STRING]; struct PopAccountData *adata = pop_get_adata(m);