From bfdd5b1f1335ee5c9990ae320533f79e41a90b63 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 1 Oct 2019 11:09:42 +0100 Subject: [PATCH] change check_stats() to return number of new emails --- imap/imap.c | 8 +++----- maildir/maildir.c | 2 +- mbox/mbox.c | 2 +- mutt_mailbox.c | 2 +- mx.h | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/imap/imap.c b/imap/imap.c index 3ec35140d..fa9a19241 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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 */ diff --git a/maildir/maildir.c b/maildir/maildir.c index 3db24cabb..d4bfa33b0 100644 --- a/maildir/maildir.c +++ b/maildir/maildir.c @@ -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; } /** diff --git a/mbox/mbox.c b/mbox/mbox.c index a1472e701..7f1021b3b 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -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 diff --git a/mutt_mailbox.c b/mutt_mailbox.c index fa904a679..4aed73555 100644 --- a/mutt_mailbox.c +++ b/mutt_mailbox.c @@ -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 2e53e53eb..897913caf 100644 --- 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); -- 2.40.0