From: Richard Russon Date: Sat, 15 Sep 2018 14:52:14 +0000 (+0100) Subject: sidebar: drop unnec fn: mutt_sb_set_mailbox_stats X-Git-Tag: 2019-10-25~646 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fcd5fc1b1a11faae7be492bf28dc31d42f57edd;p=neomutt sidebar: drop unnec fn: mutt_sb_set_mailbox_stats This used to copy stats from the Context to the Mailbox. Now, the Context points to the Mailbox. --- diff --git a/curs_main.c b/curs_main.c index ad90c1732..90cba585e 100644 --- a/curs_main.c +++ b/curs_main.c @@ -914,10 +914,7 @@ static void index_menu_redraw(struct Menu *menu) #ifdef USE_SIDEBAR if (menu->redraw & REDRAW_SIDEBAR) - { - mutt_sb_set_mailbox_stats(Context); menu_redraw_sidebar(menu); - } #endif if (Context && Context->mailbox->hdrs && !(menu->current >= Context->mailbox->vcount)) diff --git a/imap/imap.c b/imap/imap.c index e6d02f55a..798dbc91e 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -177,8 +177,8 @@ static void set_flag(struct ImapMboxData *mdata, int aclbit, int flag, * @note Headers must be in SORT_ORDER. See imap_exec_msgset() for args. * Pos is an opaque pointer a la strtok(). It should be 0 at first call. */ -static int make_msg_set(struct ImapMboxData *mdata, struct Buffer *buf, int flag, - bool changed, bool invert, int *pos) +static int make_msg_set(struct ImapMboxData *mdata, struct Buffer *buf, + int flag, bool changed, bool invert, int *pos) { int count = 0; /* number of messages in message set */ unsigned int setstart = 0; /* start of current message range */ @@ -1186,8 +1186,8 @@ bool imap_has_flag(struct ListHead *flag_list, const char *flag) * Prepares commands for all messages matching conditions * (must be flushed with imap_exec) */ -int imap_exec_msgset(struct ImapMboxData *mdata, const char *pre, const char *post, - int flag, bool changed, bool invert) +int imap_exec_msgset(struct ImapMboxData *mdata, const char *pre, + const char *post, int flag, bool changed, bool invert) { struct Email **emails = NULL; short oldsort; diff --git a/mx.c b/mx.c index a96d26eb4..fde6e2ee4 100644 --- a/mx.c +++ b/mx.c @@ -757,8 +757,6 @@ int mx_mbox_close(struct Context **pctx, int *index_hint) if (ctx->mailbox->hdrs[i]->deleted && ctx->mailbox->hdrs[i]->flagged) ctx->mailbox->msg_flagged--; } - ctx->mailbox->msg_count -= ctx->deleted; - mutt_sb_set_mailbox_stats(ctx); ctx->mailbox->msg_count = orig_msgcount; } #endif diff --git a/nntp/newsrc.c b/nntp/newsrc.c index 0e9fc38d9..7b09a9d93 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -486,8 +486,7 @@ int nntp_newsrc_update(struct NntpServer *nserv) buflen *= 2; mutt_mem_realloc(&buf, buflen); } - snprintf(buf + off, buflen - off, "%s%c ", mdata->group, - mdata->subscribed ? ':' : '!'); + snprintf(buf + off, buflen - off, "%s%c ", mdata->group, mdata->subscribed ? ':' : '!'); off += strlen(buf + off); /* write entries */ @@ -504,8 +503,8 @@ int nntp_newsrc_update(struct NntpServer *nserv) snprintf(buf + off, buflen - off, "%u", mdata->newsrc_ent[j].first); else if (mdata->newsrc_ent[j].first < mdata->newsrc_ent[j].last) { - snprintf(buf + off, buflen - off, "%u-%u", - mdata->newsrc_ent[j].first, mdata->newsrc_ent[j].last); + snprintf(buf + off, buflen - off, "%u-%u", mdata->newsrc_ent[j].first, + mdata->newsrc_ent[j].last); } off += strlen(buf + off); } @@ -693,9 +692,8 @@ int nntp_active_save_cache(struct NntpServer *nserv) mutt_mem_realloc(&buf, buflen); } snprintf(buf + off, buflen - off, "%s %u %u %c%s%s\n", mdata->group, - mdata->last_message, mdata->first_message, - mdata->allowed ? 'y' : 'n', mdata->desc ? " " : "", - mdata->desc ? mdata->desc : ""); + mdata->last_message, mdata->first_message, mdata->allowed ? 'y' : 'n', + mdata->desc ? " " : "", mdata->desc ? mdata->desc : ""); off += strlen(buf + off); } @@ -737,9 +735,8 @@ header_cache_t *nntp_hcache_open(struct NntpMboxData *mdata) struct Url url; char file[PATH_MAX]; - if (!mdata->nserv || !mdata->nserv->cacheable || - !mdata->nserv->conn || !mdata->group || - !(mdata->newsrc_ent || mdata->subscribed || SaveUnsubscribed)) + if (!mdata->nserv || !mdata->nserv->cacheable || !mdata->nserv->conn || + !mdata->group || !(mdata->newsrc_ent || mdata->subscribed || SaveUnsubscribed)) { return NULL; } @@ -1226,8 +1223,7 @@ void nntp_article_status(struct Mailbox *mailbox, struct Email *e, char *group, for (unsigned int i = 0; i < mdata->newsrc_len; i++) { - if ((anum >= mdata->newsrc_ent[i].first) && - (anum <= mdata->newsrc_ent[i].last)) + if ((anum >= mdata->newsrc_ent[i].first) && (anum <= mdata->newsrc_ent[i].last)) { /* can't use mutt_set_flag() because mx_update_context() didn't get called yet */ @@ -1307,7 +1303,7 @@ struct NntpMboxData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char * * @retval NULL Error */ struct NntpMboxData *mutt_newsgroup_catchup(struct Context *ctx, - struct NntpServer *nserv, char *group) + struct NntpServer *nserv, char *group) { struct NntpMboxData *mdata = NULL; @@ -1343,7 +1339,7 @@ struct NntpMboxData *mutt_newsgroup_catchup(struct Context *ctx, * @retval NULL Error */ struct NntpMboxData *mutt_newsgroup_uncatchup(struct Context *ctx, - struct NntpServer *nserv, char *group) + struct NntpServer *nserv, char *group) { struct NntpMboxData *mdata = NULL; diff --git a/nntp/nntp.c b/nntp/nntp.c index b466da2c1..275f08676 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -791,8 +791,7 @@ static int nntp_fetch_lines(struct NntpMboxData *mdata, char *query, size_t qlen while (true) { char *p = NULL; - int chunk = mutt_socket_readln_d(buf, sizeof(buf), mdata->nserv->conn, - MUTT_SOCK_LOG_HDR); + int chunk = mutt_socket_readln_d(buf, sizeof(buf), mdata->nserv->conn, MUTT_SOCK_LOG_HDR); if (chunk < 0) { mdata->nserv->status = NNTP_NONE; @@ -1924,8 +1923,8 @@ int nntp_post(struct Mailbox *mailbox, const char *msg) len++; buf[len] = '\0'; } - if (mutt_socket_send_d(mdata->nserv->conn, - buf[1] == '.' ? buf : buf + 1, MUTT_SOCK_LOG_HDR) < 0) + if (mutt_socket_send_d(mdata->nserv->conn, buf[1] == '.' ? buf : buf + 1, + MUTT_SOCK_LOG_HDR) < 0) { mutt_file_fclose(&fp); return nntp_connect_error(mdata->nserv); @@ -2577,8 +2576,8 @@ static int nntp_msg_open(struct Context *ctx, struct Message *msg, int msgno) /* fetch message to cache file */ snprintf(buf, sizeof(buf), "ARTICLE %s\r\n", NNTP_EDATA(e)->article_num ? article : e->env->message_id); - const int rc = nntp_fetch_lines(mdata, buf, sizeof(buf), fetch_msg, - fetch_tempfile, msg->fp); + const int rc = + nntp_fetch_lines(mdata, buf, sizeof(buf), fetch_msg, fetch_tempfile, msg->fp); if (rc) { mutt_file_fclose(&msg->fp); diff --git a/pop/pop.c b/pop/pop.c index 5a452b546..87f0c468e 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -291,7 +291,6 @@ static int fetch_uidl(char *line, void *data) mailbox->hdrs[i]->data = new_emaildata(line); mailbox->hdrs[i]->free_data = free_emaildata; - } else if (mailbox->hdrs[i]->index != index - 1) mdata->clear_cache = true; @@ -494,7 +493,8 @@ static int pop_fetch_headers(struct Context *ctx) * - if we also have a body: read * - if we don't have a body: new */ - const bool bcached = (mutt_bcache_exists(mdata->bcache, cache_id(edata->uid)) == 0); + const bool bcached = + (mutt_bcache_exists(mdata->bcache, cache_id(edata->uid)) == 0); ctx->mailbox->hdrs[i]->old = false; ctx->mailbox->hdrs[i]->read = false; if (hcached) diff --git a/pop/pop_lib.c b/pop/pop_lib.c index 2b76c970f..2abeb0e69 100644 --- a/pop/pop_lib.c +++ b/pop/pop_lib.c @@ -523,8 +523,7 @@ int pop_fetch_data(struct PopMboxData *mdata, const char *query, while (true) { - const int chunk = - mutt_socket_readln_d(buf, sizeof(buf), mdata->conn, MUTT_SOCK_LOG_HDR); + const int chunk = mutt_socket_readln_d(buf, sizeof(buf), mdata->conn, MUTT_SOCK_LOG_HDR); if (chunk < 0) { mdata->status = POP_DISCONNECTED; diff --git a/sidebar.c b/sidebar.c index d82502efc..1746b7d7e 100644 --- a/sidebar.c +++ b/sidebar.c @@ -1061,32 +1061,6 @@ void mutt_sb_change_mailbox(int op) mutt_menu_set_current_redraw(REDRAW_SIDEBAR); } -/** - * mutt_sb_set_mailbox_stats - Update the Mailbox's message counts from the Context - * @param ctx A mailbox Context - * - * Given a mailbox Context, find a matching mailbox Mailbox and copy the message - * counts into it. - */ -void mutt_sb_set_mailbox_stats(const struct Context *ctx) -{ - if (!ctx) - return; - - /* Even if the sidebar's hidden, we should take note of the new data. */ - struct MailboxNode *np = NULL; - STAILQ_FOREACH(np, &AllMailboxes, entries) - { - if (mutt_str_strcmp(np->m->realpath, ctx->mailbox->realpath) == 0) - { - np->m->msg_unread = ctx->mailbox->msg_unread; - np->m->msg_count = ctx->mailbox->msg_count; - np->m->msg_flagged = ctx->mailbox->msg_flagged; - break; - } - } -} - /** * mutt_sb_get_highlight - Get the Mailbox that's highlighted in the sidebar * @retval ptr Mailbox path diff --git a/sidebar.h b/sidebar.h index 747c40155..6fc24d6e3 100644 --- a/sidebar.h +++ b/sidebar.h @@ -46,7 +46,6 @@ void mutt_sb_change_mailbox(int op); void mutt_sb_draw(void); const char *mutt_sb_get_highlight(void); void mutt_sb_notify_mailbox(struct Mailbox *m, bool created); -void mutt_sb_set_mailbox_stats(const struct Context *ctx); void mutt_sb_set_open_mailbox(void); void mutt_sb_toggle_virtual(void);