From c3ad7186d385faa99dd15f3b15aee17861706248 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 6 Sep 2018 11:03:46 +0100 Subject: [PATCH] mbox: use Mailbox, not Context --- mbox/mbox.c | 24 ++++++++++++------------ mbox/mbox.h | 4 ++-- mx.c | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mbox/mbox.c b/mbox/mbox.c index 03af4746f..c78b5fe2b 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -931,35 +931,35 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint) /** * mbox_has_new - Does the mailbox have new mail - * @param ctx Context + * @param mailbox Mailbox * @retval true if the mailbox has at least 1 new messages (not old) * @retval false otherwise */ -static bool mbox_has_new(struct Context *ctx) +static bool mbox_has_new(struct Mailbox *mailbox) { - for (int i = 0; i < ctx->mailbox->msg_count; i++) - if (!ctx->mailbox->hdrs[i]->deleted && !ctx->mailbox->hdrs[i]->read && - !ctx->mailbox->hdrs[i]->old) + for (int i = 0; i < mailbox->msg_count; i++) + if (!mailbox->hdrs[i]->deleted && !mailbox->hdrs[i]->read && + !mailbox->hdrs[i]->old) return true; return false; } /** * mbox_reset_atime - Reset the access time on the mailbox file - * @param ctx Mailbox - * @param st Timestamp + * @param mailbox Mailbox + * @param st Timestamp * * if mailbox has at least 1 new message, sets mtime > atime of mailbox so * mailbox check reports new mail */ -void mbox_reset_atime(struct Context *ctx, struct stat *st) +void mbox_reset_atime(struct Mailbox *mailbox, struct stat *st) { struct utimbuf utimebuf; struct stat st2; if (!st) { - if (stat(ctx->mailbox->path, &st2) < 0) + if (stat(mailbox->path, &st2) < 0) return; st = &st2; } @@ -970,12 +970,12 @@ void mbox_reset_atime(struct Context *ctx, struct stat *st) /* When $mbox_check_recent is set, existing new mail is ignored, so do not * reset the atime to mtime-1 to signal new mail. */ - if (!MailCheckRecent && utimebuf.actime >= utimebuf.modtime && mbox_has_new(ctx)) + if (!MailCheckRecent && utimebuf.actime >= utimebuf.modtime && mbox_has_new(mailbox)) { utimebuf.actime = utimebuf.modtime - 1; } - utime(ctx->mailbox->path, &utimebuf); + utime(mailbox->path, &utimebuf); } /** @@ -1268,7 +1268,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) } /* Restore the previous access/modification times */ - mbox_reset_atime(ctx, &statbuf); + mbox_reset_atime(ctx->mailbox, &statbuf); /* reopen the mailbox in read-only mode */ ctx->fp = fopen(ctx->mailbox->path, "r"); diff --git a/mbox/mbox.h b/mbox/mbox.h index 02ab76d4e..fdc566977 100644 --- a/mbox/mbox.h +++ b/mbox/mbox.h @@ -33,7 +33,7 @@ #ifndef MUTT_MBOX_MBOX_H #define MUTT_MBOX_MBOX_H -struct Context; +struct Mailbox; struct stat; extern struct MxOps mx_mbox_ops; @@ -41,7 +41,7 @@ extern struct MxOps mx_mmdf_ops; #define MMDF_SEP "\001\001\001\001\n" -void mbox_reset_atime(struct Context *ctx, struct stat *st); +void mbox_reset_atime(struct Mailbox *mailbox, struct stat *st); int mbox_path_probe(const char *path, const struct stat *st); #endif /* MUTT_MBOX_MBOX_H */ diff --git a/mx.c b/mx.c index 707ae7778..74943dcb9 100644 --- a/mx.c +++ b/mx.c @@ -697,7 +697,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) if (!ctx->mailbox->quiet) mutt_message(_("Mailbox is unchanged")); if (ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) - mbox_reset_atime(ctx, NULL); + mbox_reset_atime(ctx->mailbox, NULL); mx_fastclose_mailbox(ctx); FREE(pctx); return 0; -- 2.40.0