From f957099cd2740652e1848a794052f03affa7878f Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Thu, 6 Sep 2018 23:51:41 +0100 Subject: [PATCH] eliminate Context from backends --- browser.c | 4 ++-- compose.c | 2 +- compress.c | 2 +- curs_main.c | 4 ++-- imap/imap.c | 4 ++-- imap/message.c | 6 +++--- imap/util.c | 4 ++-- maildir/mh.c | 6 +++--- main.c | 2 +- mx.c | 2 +- nntp/newsrc.c | 29 +++++++++++++++++------------ nntp/nntp.c | 14 +++++++------- nntp/nntp.h | 8 ++++---- notmuch/mutt_notmuch.h | 2 +- pop/pop.c | 16 ++++++++-------- sendlib.c | 2 +- 16 files changed, 56 insertions(+), 51 deletions(-) diff --git a/browser.c b/browser.c index c5fed1b8e..26150e113 100644 --- a/browser.c +++ b/browser.c @@ -2158,9 +2158,9 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int break; if (i == OP_CATCHUP) - nntp_data = mutt_newsgroup_catchup(CurrentNewsSrv, ff->name); + nntp_data = mutt_newsgroup_catchup(Context, CurrentNewsSrv, ff->name); else - nntp_data = mutt_newsgroup_uncatchup(CurrentNewsSrv, ff->name); + nntp_data = mutt_newsgroup_uncatchup(Context, CurrentNewsSrv, ff->name); if (nntp_data) { diff --git a/compose.c b/compose.c index 3029106f8..415d67445 100644 --- a/compose.c +++ b/compose.c @@ -1408,7 +1408,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen, OptNews = false; if (op == OP_COMPOSE_ATTACH_NEWS_MESSAGE) { - CurrentNewsSrv = nntp_select_server(NewsServer, false); + CurrentNewsSrv = nntp_select_server(Context, NewsServer, false); if (!CurrentNewsSrv) break; diff --git a/compress.c b/compress.c index 4af95ab6c..d41376fdc 100644 --- a/compress.c +++ b/compress.c @@ -59,7 +59,7 @@ struct Header; /** * struct CompressInfo - Private data for compress * - * This object gets attached to the mailbox's Context. + * This object gets attached to the Mailbox. */ struct CompressInfo { diff --git a/curs_main.c b/curs_main.c index 5ed63927f..c4fb790ae 100644 --- a/curs_main.c +++ b/curs_main.c @@ -2210,7 +2210,7 @@ int mutt_index_menu(void) if (op == OP_MAIN_CHANGE_GROUP || op == OP_MAIN_CHANGE_GROUP_READONLY) { OptNews = true; - CurrentNewsSrv = nntp_select_server(NewsServer, false); + CurrentNewsSrv = nntp_select_server(Context, NewsServer, false); if (!CurrentNewsSrv) break; if (flags) @@ -3010,7 +3010,7 @@ int mutt_index_menu(void) if (Context && Context->mailbox->magic == MUTT_NNTP) { struct NntpData *nntp_data = Context->mailbox->data; - if (mutt_newsgroup_catchup(nntp_data->nserv, nntp_data->group)) + if (mutt_newsgroup_catchup(Context, nntp_data->nserv, nntp_data->group)) menu->redraw = REDRAW_INDEX | REDRAW_STATUS; } break; diff --git a/imap/imap.c b/imap/imap.c index ddc9b1232..fe4302ddf 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -2372,7 +2372,7 @@ static int imap_msg_open_new(struct Context *ctx, struct Message *msg, struct He /** * imap_mbox_check - Implements MxOps::mbox_check() - * @param ctx Context + * @param ctx Mailbox * @param index_hint Remember our place in the index * @retval >0 Success, e.g. #MUTT_REOPENED * @retval -1 Failure @@ -2391,7 +2391,7 @@ static int imap_mbox_check(struct Context *ctx, int *index_hint) /** * imap_sync_mailbox - Sync all the changes to the server - * @param ctx Context + * @param ctx Mailbox * @param expunge if true do expunge * @retval 0 Success * @retval -1 Error diff --git a/imap/message.c b/imap/message.c index 7daf19a0b..7c855487b 100644 --- a/imap/message.c +++ b/imap/message.c @@ -601,7 +601,7 @@ static void imap_fetch_msn_seqset(struct Buffer *b, struct ImapData *idata, /** * set_changed_flag - Have the flags of an email changed - * @param[in] ctx Context + * @param[in] ctx Mailbox * @param[in] h Email Header * @param[in] local_changes Has the local mailbox been changed? * @param[out] server_changes Set to 1 if the flag has changed @@ -1587,7 +1587,7 @@ int imap_msg_commit(struct Context *ctx, struct Message *msg) /** * imap_append_message - Write an email back to the server - * @param ctx Context + * @param ctx Mailbox * @param msg Message to save * @retval 0 Success * @retval -1 Failure @@ -1722,7 +1722,7 @@ fail: /** * imap_copy_messages - Server COPY messages to another folder - * @param ctx Context + * @param ctx Mailbox * @param h Header of the email * @param dest Destination folder * @param delete Delete the original? diff --git a/imap/util.c b/imap/util.c index 04b2855a9..801a7dfe4 100644 --- a/imap/util.c +++ b/imap/util.c @@ -1103,7 +1103,7 @@ int imap_wait_keepalive(pid_t pid) /** * imap_allow_reopen - Allow re-opening a folder upon expunge - * @param ctx Context + * @param ctx Mailbox */ void imap_allow_reopen(struct Context *ctx) { @@ -1118,7 +1118,7 @@ void imap_allow_reopen(struct Context *ctx) /** * imap_disallow_reopen - Disallow re-opening a folder upon expunge - * @param ctx Context + * @param ctx Mailbox */ void imap_disallow_reopen(struct Context *ctx) { diff --git a/maildir/mh.c b/maildir/mh.c index 81e194260..8183dfcfc 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -1022,7 +1022,7 @@ static int maildir_parse_dir(struct Mailbox *mailbox, struct Maildir ***last, } /** - * maildir_add_to_context - Add the Maildir list to the Context + * maildir_add_to_context - Add the Maildir list to the Mailbox * @param ctx Mailbox * @param md Maildir list to copy * @retval true If there's new mail @@ -1063,7 +1063,7 @@ static bool maildir_add_to_context(struct Context *ctx, struct Maildir *md) } /** - * maildir_move_to_context - Copy the Maildir list to the Context + * maildir_move_to_context - Copy the Maildir list to the Mailbox * @param ctx Mailbox * @param md Maildir list to copy, then free * @retval 1 If there's new mail @@ -2276,7 +2276,7 @@ static char *maildir_canon_filename(const char *src, char *buf, size_t buflen) } /** - * maildir_update_tables - Update the Context Header tables + * maildir_update_tables - Update the Header tables * @param ctx Mailbox * @param index_hint Current email in index */ diff --git a/main.c b/main.c index 45cd5f051..b7a3fd997 100644 --- a/main.c +++ b/main.c @@ -1144,7 +1144,7 @@ int main(int argc, char *argv[], char *envp[]) if (flags & MUTT_NEWS) { OptNews = true; - CurrentNewsSrv = nntp_select_server(NewsServer, false); + CurrentNewsSrv = nntp_select_server(Context, NewsServer, false); if (!CurrentNewsSrv) goto main_curses; // TEST38: neomutt -G (unset news_server) } diff --git a/mx.c b/mx.c index 93ac1bb48..ab5053f04 100644 --- a/mx.c +++ b/mx.c @@ -527,7 +527,7 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) return -1; } else if (rc == MUTT_YES) - mutt_newsgroup_catchup(nntp_data->nserv, nntp_data->group); + mutt_newsgroup_catchup(Context, nntp_data->nserv, nntp_data->group); } } #endif diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 324b81df5..86c318081 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -999,6 +999,7 @@ const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char /** * nntp_select_server - Open a connection to an NNTP server + * @param ctx Mailbox * @param server Server URI * @param leave_lock Leave the server locked? * @retval ptr NNTP server @@ -1009,7 +1010,7 @@ const char *nntp_format_str(char *buf, size_t buflen, size_t col, int cols, char * system has broken mtimes, this might mean the file is reloaded every time, * which we'd have to fix. */ -struct NntpServer *nntp_select_server(char *server, bool leave_lock) +struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock) { char file[PATH_MAX]; #ifdef USE_HCACHE @@ -1072,7 +1073,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock) return NULL; /* check for new newsgroups */ - if (!leave_lock && nntp_check_new_groups(Context->mailbox, nserv) < 0) + if (!leave_lock && nntp_check_new_groups(ctx->mailbox, nserv) < 0) rc = -1; /* .newsrc has been externally modified */ @@ -1118,7 +1119,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock) { /* try to load list of newsgroups from cache */ if (nserv->cacheable && active_get_cache(nserv) == 0) - rc = nntp_check_new_groups(Context->mailbox, nserv); + rc = nntp_check_new_groups(ctx->mailbox, nserv); /* load list of newsgroups from server */ else @@ -1300,12 +1301,14 @@ struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *grou /** * mutt_newsgroup_catchup - Catchup newsgroup + * @param ctx Mailbox * @param nserv NNTP server * @param group Newsgroup * @retval ptr NNTP data * @retval NULL Error */ -struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group) +struct NntpData *mutt_newsgroup_catchup(struct Context *ctx, + struct NntpServer *nserv, char *group) { struct NntpData *nntp_data = NULL; @@ -1324,22 +1327,24 @@ struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group) nntp_data->newsrc_ent[0].last = nntp_data->last_message; } nntp_data->unread = 0; - if (Context && Context->mailbox->data == nntp_data) + if (ctx && ctx->mailbox->data == nntp_data) { - for (unsigned int i = 0; i < Context->mailbox->msg_count; i++) - mutt_set_flag(Context, Context->mailbox->hdrs[i], MUTT_READ, 1); + for (unsigned int i = 0; i < ctx->mailbox->msg_count; i++) + mutt_set_flag(ctx, ctx->mailbox->hdrs[i], MUTT_READ, 1); } return nntp_data; } /** * mutt_newsgroup_uncatchup - Uncatchup newsgroup + * @param ctx Mailbox * @param nserv NNTP server * @param group Newsgroup * @retval ptr NNTP data * @retval NULL Error */ -struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group) +struct NntpData *mutt_newsgroup_uncatchup(struct Context *ctx, + struct NntpServer *nserv, char *group) { struct NntpData *nntp_data = NULL; @@ -1357,11 +1362,11 @@ struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group) nntp_data->newsrc_ent[0].first = 1; nntp_data->newsrc_ent[0].last = nntp_data->first_message - 1; } - if (Context && Context->mailbox->data == nntp_data) + if (ctx && ctx->mailbox->data == nntp_data) { - nntp_data->unread = Context->mailbox->msg_count; - for (unsigned int i = 0; i < Context->mailbox->msg_count; i++) - mutt_set_flag(Context, Context->mailbox->hdrs[i], MUTT_READ, 0); + nntp_data->unread = ctx->mailbox->msg_count; + for (unsigned int i = 0; i < ctx->mailbox->msg_count; i++) + mutt_set_flag(ctx, ctx->mailbox->hdrs[i], MUTT_READ, 0); } else { diff --git a/nntp/nntp.c b/nntp/nntp.c index 73b263843..e24487bd7 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -1531,7 +1531,7 @@ static int nntp_mbox_open(struct Context *ctx) group = url.path; url.path = strchr(url.path, '\0'); url_tostring(&url, server, sizeof(server), 0); - nserv = nntp_select_server(server, true); + nserv = nntp_select_server(ctx, server, true); url_free(&url); if (!nserv) return -1; @@ -1775,22 +1775,22 @@ static int nntp_msg_close(struct Context *ctx, struct Message *msg) /** * nntp_post - Post article - * @param mailbox Mailbox - * @param msg Message to post + * @param ctx Mailbox + * @param msg Message to post * @retval 0 Success * @retval -1 Failure */ -int nntp_post(struct Mailbox *mailbox, const char *msg) +int nntp_post(struct Context *ctx, const char *msg) { struct NntpData *nntp_data = NULL; struct NntpData nntp_tmp = { 0 }; char buf[LONG_STRING]; - if (mailbox && (mailbox->magic == MUTT_NNTP)) - nntp_data = mailbox->data; + if (ctx && (ctx->mailbox->magic == MUTT_NNTP)) + nntp_data = ctx->mailbox->data; else { - CurrentNewsSrv = nntp_select_server(NewsServer, false); + CurrentNewsSrv = nntp_select_server(ctx, NewsServer, false); if (!CurrentNewsSrv) return -1; diff --git a/nntp/nntp.h b/nntp/nntp.h index cedee4fe3..18f20ea55 100644 --- a/nntp/nntp.h +++ b/nntp/nntp.h @@ -150,14 +150,14 @@ struct NntpData struct BodyCache *bcache; }; -struct NntpServer *nntp_select_server(char *server, bool leave_lock); +struct NntpServer *nntp_select_server(struct Context *ctx, char *server, bool leave_lock); struct NntpData *mutt_newsgroup_subscribe(struct NntpServer *nserv, char *group); struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *group); -struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group); -struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group); +struct NntpData *mutt_newsgroup_catchup(struct Context *ctx, struct NntpServer *nserv, char *group); +struct NntpData *mutt_newsgroup_uncatchup(struct Context *ctx, struct NntpServer *nserv, char *group); int nntp_active_fetch(struct NntpServer *nserv, bool new); int nntp_newsrc_update(struct NntpServer *nserv); -int nntp_post(struct Mailbox *mailbox, const char *msg); +int nntp_post(struct Context *ctx, const char *msg); int nntp_check_msgid(struct Context *ctx, const char *msgid); int nntp_check_children(struct Context *ctx, const char *msgid); int nntp_newsrc_parse(struct NntpServer *nserv); diff --git a/notmuch/mutt_notmuch.h b/notmuch/mutt_notmuch.h index 0e52b6325..bf804e4bd 100644 --- a/notmuch/mutt_notmuch.h +++ b/notmuch/mutt_notmuch.h @@ -74,7 +74,7 @@ void nm_debug_check(struct Mailbox *mailbox); int nm_get_all_tags(struct Mailbox *mailbox, char **tag_list, int *tag_count); /* - * functions usable outside notmuch Context + * functions usable outside of notmuch */ int nm_nonctx_get_count(char *path, int *all, int *new); int nm_path_probe(const char *path, const struct stat *st); diff --git a/pop/pop.c b/pop/pop.c index e2db60627..392b028e6 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -195,7 +195,7 @@ static int pop_read_header(struct PopData *pop_data, struct Header *h) /** * fetch_uidl - parse UIDL * @param line String to parse - * @param data Mailbox Context + * @param data Mailbox * @retval 0 Success * @retval -1 Failure */ @@ -305,7 +305,7 @@ static header_cache_t *pop_hcache_open(struct PopData *pop_data, const char *pat /** * pop_fetch_headers - Read headers - * @param ctx Context + * @param ctx Mailbox * @retval 0 Success * @retval -1 Connection lost * @retval -2 Invalid command or execution error @@ -477,7 +477,7 @@ static int pop_fetch_headers(struct Context *ctx) /** * pop_mbox_open - open POP mailbox, fetch only headers - * @param ctx Mailbox Context + * @param ctx Mailbox * @retval 0 Success * @retval -1 Failure */ @@ -571,7 +571,7 @@ static void pop_clear_cache(struct PopData *pop_data) /** * pop_mbox_close - close POP mailbox - * @param ctx Mailbox Context + * @param ctx Mailbox * @retval 0 Always */ static int pop_mbox_close(struct Context *ctx) @@ -601,7 +601,7 @@ static int pop_mbox_close(struct Context *ctx) /** * pop_msg_open - fetch message from POP server - * @param ctx Mailbox Context + * @param ctx Mailbox * @param msg Message * @param msgno Message number * @retval 0 Success @@ -752,7 +752,7 @@ static int pop_msg_open(struct Context *ctx, struct Message *msg, int msgno) /** * pop_msg_close - Close POP Message - * @param ctx Mailbox Context + * @param ctx Mailbox * @param msg Message * @retval 0 Success * @retval EOF Error, see errno @@ -764,7 +764,7 @@ static int pop_msg_close(struct Context *ctx, struct Message *msg) /** * pop_mbox_sync - update POP mailbox, delete messages from server - * @param ctx Mailbox Context + * @param ctx Mailbox * @param index_hint Current Message * @retval 0 Success * @retval -1 Failure @@ -849,7 +849,7 @@ static int pop_mbox_sync(struct Context *ctx, int *index_hint) /** * pop_mbox_check - Check for new messages and fetch headers - * @param ctx Mailbox Context + * @param ctx Mailbox * @param index_hint Current Message * @retval 0 Success * @retval -1 Failure diff --git a/sendlib.c b/sendlib.c index fb3769c49..27f01f9df 100644 --- a/sendlib.c +++ b/sendlib.c @@ -2716,7 +2716,7 @@ int mutt_invoke_sendmail(struct Address *from, struct Address *to, struct Addres NONULL(Inews), nntp_format_str, 0, 0); if (!*cmd) { - i = nntp_post(Context->mailbox, msg); + i = nntp_post(Context, msg); unlink(msg); return i; } -- 2.40.0