]> granicus.if.org Git - neomutt/commitdiff
sidebar: drop unnec fn: mutt_sb_set_mailbox_stats
authorRichard Russon <rich@flatcap.org>
Sat, 15 Sep 2018 14:52:14 +0000 (15:52 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 16 Sep 2018 16:00:21 +0000 (17:00 +0100)
This used to copy stats from the Context to the Mailbox.
Now, the Context points to the Mailbox.

curs_main.c
imap/imap.c
mx.c
nntp/newsrc.c
nntp/nntp.c
pop/pop.c
pop/pop_lib.c
sidebar.c
sidebar.h

index ad90c17326406aa9b571075a280a855dec831cb3..90cba585e4a55dc435d9824bdbd866393527c7d9 100644 (file)
@@ -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))
index e6d02f55a6e72b2adb314dd7ac9a305f6de58c95..798dbc91e73f47e2c12f08cb19c8a8baeaf706e7 100644 (file)
@@ -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 a96d26eb4010f61f1e36de87efb50fdba6d5c672..fde6e2ee4edc22ca7921e00616d39ff8422d5784 100644 (file)
--- 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
index 0e9fc38d9175eba312f5d95a023158175af55066..7b09a9d9349c3b80891d4bb09056f88210c6a8ca 100644 (file)
@@ -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;
 
index b466da2c19bb63ab8eb04347ec34ad6126ec5c56..275f0867664d992c17484fa28b8fca2322766db3 100644 (file)
@@ -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);
index 5a452b546ae701a991dfe5e5370d8ccfe54c3c07..87f0c468ea47ae796f0783652f6f43caeb2eddcd 100644 (file)
--- 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)
index 2b76c970f8e4ddb4ec32d113d788867169553d4c..2abeb0e6957e224a57be56ef33651951f6055fd8 100644 (file)
@@ -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;
index d82502efcf11394408c1a764362697dc2fa89b4f..1746b7d7e98dcb73506ae2b45ea4fad9b05945bc 100644 (file)
--- 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
index 747c4015599a3b577b3525a76a6c59287f89efe5..6fc24d6e309ad2b7d505a577f08a398379a50e58 100644 (file)
--- 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);