]> granicus.if.org Git - neomutt/commitdiff
change check_stats() to return number of new emails 1859/head
authorRichard Russon <rich@flatcap.org>
Tue, 1 Oct 2019 10:09:42 +0000 (11:09 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 1 Oct 2019 10:12:25 +0000 (11:12 +0100)
imap/imap.c
maildir/maildir.c
mbox/mbox.c
mutt_mailbox.c
mx.h

index 3ec35140ded43f7639741146f7d2e81997db727a..fa9a19241a8e9b4c5c0f1267e037275a2b1a3c88 100644 (file)
@@ -1293,10 +1293,7 @@ static int imap_status(struct ImapAccountData *adata, struct ImapMboxData *mdata
  */
 int imap_mbox_check_stats(struct Mailbox *m, int flags)
 {
-  int rc = imap_mailbox_status(m, true);
-  if (rc > 0)
-    rc = 1;
-  return rc;
+  return imap_mailbox_status(m, true);
 }
 
 /**
@@ -1326,7 +1323,8 @@ int imap_path_status(const char *path, bool queue)
  * imap_mailbox_status - Refresh the number of total and new messages
  * @param m      Mailbox
  * @param queue  Queue the STATUS command
- * @retval num   Total number of messages
+ * @retval num Total number of messages
+ * @retval -1  Error
  *
  * @note Prepare the mailbox if we are not connected
  */
index 3db24cabbf242694be3a76795d903f32b3756a79..d4bfa33b0735ef80fe91de7b87d19726211845c4 100644 (file)
@@ -549,7 +549,7 @@ static int maildir_mbox_check_stats(struct Mailbox *m, int flags)
   if (check_new || check_stats)
     maildir_check_dir(m, "cur", check_new, check_stats);
 
-  return (m->msg_new > 0);
+  return m->msg_new;
 }
 
 /**
index a1472e701f4f22a133b4db14b92cec5a9c8abbc4..7f1021b3b81ca179d7a6e5a28bdd55d9bc62cab4 100644 (file)
@@ -1784,7 +1784,7 @@ static int mbox_mbox_check_stats(struct Mailbox *m, int flags)
   if (m->msg_new == 0)
     m->has_new = false;
 
-  return (m->msg_new > 0);
+  return m->msg_new;
 }
 
 // clang-format off
index fa904a679514b8d4541c5c953ef2682e526ff8ed..4aed7355518901381f86c03abdd96ab0e986e59f 100644 (file)
@@ -89,7 +89,7 @@ static void mailbox_check(struct Mailbox *m_cur, struct Mailbox *m_check,
       case MUTT_MAILDIR:
       case MUTT_MH:
       case MUTT_NOTMUCH:
-        if ((mx_mbox_check_stats(m_check, check_stats) == 1) && m_check->has_new)
+        if ((mx_mbox_check_stats(m_check, check_stats) > 0) && m_check->has_new)
           MailboxCount++;
         break;
       default:; /* do nothing */
diff --git a/mx.h b/mx.h
index 2e53e53ebc513d58d372efda6c2e213efe689346..897913caf1f0d67dde81afef6f9400c2fa472774 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -150,7 +150,7 @@ struct MxOps
    * @param m     Mailbox to check
    * @param flags Function flags
    * @retval  0 Success, no new mail
-   * @retval  1 Success, some new mail
+   * @retval >0 Success, number of new emails
    * @retval -1 Failure
    */
   int (*mbox_check_stats)(struct Mailbox *m, int flags);