From 1ef3d4d794b94f3612cbc8b5da191cb93b7591ea Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 13 Nov 2018 01:40:26 +0000 Subject: [PATCH] msg_commit: remove Context --- compress.c | 8 ++------ imap/imap_private.h | 4 ++-- imap/message.c | 18 +++++++----------- maildir/mh.c | 12 ++---------- mbox/mbox.c | 4 ++-- mx.c | 2 +- mx.h | 4 ++-- notmuch/mutt_notmuch.c | 2 +- 8 files changed, 19 insertions(+), 35 deletions(-) diff --git a/compress.c b/compress.c index 456d1081c..b49295552 100644 --- a/compress.c +++ b/compress.c @@ -837,12 +837,8 @@ static int comp_msg_open_new(struct Context *ctx, struct Message *msg, struct Em /** * comp_msg_commit - Implements MxOps::msg_commit() */ -static int comp_msg_commit(struct Context *ctx, struct Message *msg) +static int comp_msg_commit(struct Mailbox *m, struct Message *msg) { - if (!ctx) - return -1; - - struct Mailbox *m = ctx->mailbox; if (!m) return -1; @@ -855,7 +851,7 @@ static int comp_msg_commit(struct Context *ctx, struct Message *msg) return -1; /* Delegate */ - return ops->msg_commit(ctx, msg); + return ops->msg_commit(m, msg); } /** diff --git a/imap/imap_private.h b/imap/imap_private.h index f45025ccc..4b939c593 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -327,11 +327,11 @@ int imap_read_headers(struct ImapAccountData *adata, unsigned int msn_begin, uns char *imap_set_flags(struct ImapAccountData *adata, struct Email *e, char *s, int *server_changes); int imap_cache_del(struct ImapAccountData *adata, struct Email *e); int imap_cache_clean(struct ImapAccountData *adata); -int imap_append_message(struct Context *ctx, struct Message *msg); +int imap_append_message(struct Mailbox *m, struct Message *msg); int imap_msg_open(struct Context *ctx, struct Message *msg, int msgno); int imap_msg_close(struct Mailbox *m, struct Message *msg); -int imap_msg_commit(struct Context *ctx, struct Message *msg); +int imap_msg_commit(struct Mailbox *m, struct Message *msg); /* util.c */ struct ImapAccountData *imap_adata_get(struct Mailbox *m); diff --git a/imap/message.c b/imap/message.c index 12a1d425f..2177335cd 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1370,13 +1370,16 @@ bail: /** * imap_append_message - Write an email back to the server - * @param ctx Mailbox + * @param m Mailbox * @param msg Message to save * @retval 0 Success * @retval -1 Failure */ -int imap_append_message(struct Context *ctx, struct Message *msg) +int imap_append_message(struct Mailbox *m, struct Message *msg) { + if (!m || !msg) + return -1; + FILE *fp = NULL; char buf[LONG_STRING * 2]; char mbox[LONG_STRING]; @@ -1390,13 +1393,6 @@ int imap_append_message(struct Context *ctx, struct Message *msg) struct ImapMbox mx; int rc; - if (!ctx) - return -1; - - struct Mailbox *m = ctx->mailbox; - if (!m) - return -1; - struct ImapAccountData *adata = imap_adata_get(m); if (imap_parse_path(m->path, &mx)) @@ -2048,13 +2044,13 @@ bail: * * @note May also return EOF Failure, see errno */ -int imap_msg_commit(struct Context *ctx, struct Message *msg) +int imap_msg_commit(struct Mailbox *m, struct Message *msg) { int r = mutt_file_fclose(&msg->fp); if (r != 0) return r; - return imap_append_message(ctx, msg); + return imap_append_message(m, msg); } /** diff --git a/maildir/mh.c b/maildir/mh.c index 803d39f36..02dcb0435 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -2715,12 +2715,8 @@ static int maildir_msg_open_new(struct Context *ctx, struct Message *msg, struct /** * maildir_msg_commit - Implements MxOps::msg_commit() */ -static int maildir_msg_commit(struct Context *ctx, struct Message *msg) +static int maildir_msg_commit(struct Mailbox *m, struct Message *msg) { - if (!ctx) - return -1; - - struct Mailbox *m = ctx->mailbox; if (!m) return -1; @@ -3109,12 +3105,8 @@ static int mh_msg_open_new(struct Context *ctx, struct Message *msg, struct Emai /** * mh_msg_commit - Implements MxOps::msg_commit() */ -static int mh_msg_commit(struct Context *ctx, struct Message *msg) +static int mh_msg_commit(struct Mailbox *m, struct Message *msg) { - if (!ctx) - return -1; - - struct Mailbox *m = ctx->mailbox; if (!m) return -1; diff --git a/mbox/mbox.c b/mbox/mbox.c index 8baa594d2..9feb636d1 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -1607,7 +1607,7 @@ static int mbox_msg_open_new(struct Context *ctx, struct Message *msg, struct Em /** * mbox_msg_commit - Implements MxOps::msg_commit() */ -static int mbox_msg_commit(struct Context *ctx, struct Message *msg) +static int mbox_msg_commit(struct Mailbox *m, struct Message *msg) { if (!msg) return -1; @@ -1772,7 +1772,7 @@ int mbox_path_parent(char *buf, size_t buflen) /** * mmdf_msg_commit - Implements MxOps::msg_commit() */ -static int mmdf_msg_commit(struct Context *ctx, struct Message *msg) +static int mmdf_msg_commit(struct Mailbox *m, struct Message *msg) { if (fputs(MMDF_SEP, msg->fp) == EOF) return -1; diff --git a/mx.c b/mx.c index 7c58a68e5..b7803e062 100644 --- a/mx.c +++ b/mx.c @@ -1167,7 +1167,7 @@ int mx_msg_commit(struct Context *ctx, struct Message *msg) return -1; } - return m->mx_ops->msg_commit(ctx, msg); + return m->mx_ops->msg_commit(m, msg); } /** diff --git a/mx.h b/mx.h index 615be26e1..b7b89bafb 100644 --- a/mx.h +++ b/mx.h @@ -176,12 +176,12 @@ struct MxOps int (*msg_open_new) (struct Context *ctx, struct Message *msg, struct Email *e); /** * msg_commit - Save changes to an email - * @param ctx Mailbox + * @param m Mailbox * @param msg Message to commit * @retval 0 Success * @retval -1 Failure */ - int (*msg_commit) (struct Context *ctx, struct Message *msg); + int (*msg_commit) (struct Mailbox *m, struct Message *msg); /** * msg_close - Close an email * @param m Mailbox diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 640515ee9..ca2377dd7 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -2457,7 +2457,7 @@ static int nm_msg_open(struct Context *ctx, struct Message *msg, int msgno) * nm_msg_commit - Implements MxOps::msg_commit() * @retval -1 Always */ -static int nm_msg_commit(struct Context *ctx, struct Message *msg) +static int nm_msg_commit(struct Mailbox *m, struct Message *msg) { mutt_error(_("Can't write to virtual folder")); return -1; -- 2.40.0