Commit ac7e2890 authored by Anton Lindqvist's avatar Anton Lindqvist Committed by Kevin J. McCarthy

Add check-stats function to calculate mailbox statistics.

This allows the statistics to be updated without setting
$mail_check_stats or before $mail_check_stats_interval has passed.
parent 0e34a489
Pipeline #24801674 passed with stages
in 14 minutes and 43 seconds
......@@ -181,6 +181,7 @@ OP_VERSION "show the Mutt version number and date"
OP_VIEW_ATTACH "view attachment using mailcap entry if necessary"
OP_VIEW_ATTACHMENTS "show MIME attachments"
OP_WHAT_KEY "display the keycode for a key press"
OP_CHECK_STATS "calculate message statistics for all mailboxes"
OP_MAIN_SHOW_LIMIT "show currently active limit pattern"
OP_MAIN_COLLAPSE_THREAD "collapse/uncollapse current thread"
OP_MAIN_COLLAPSE_ALL "collapse/uncollapse all threads"
......@@ -505,7 +505,9 @@ static int buffy_mbox_check (BUFFY* mailbox, struct stat *sb, int check_stats)
}
/* Check all Incoming for new mail and total/new/flagged messages
* force: if true, ignore BuffyTimeout and check for new mail anyway
* The force argument may be any combination of the following values:
* MUTT_BUFFY_CHECK_FORCE ignore BuffyTimeout and check for new mail
* MUTT_BUFFY_CHECK_FORCE_STATS ignore BuffyTimeout and calculate statistics
*/
int mutt_buffy_check (int force)
{
......@@ -525,7 +527,7 @@ int mutt_buffy_check (int force)
#ifdef USE_IMAP
/* update postponed count as well, on force */
if (force)
if (force & MUTT_BUFFY_CHECK_FORCE)
mutt_update_num_postponed ();
#endif
......@@ -536,8 +538,9 @@ int mutt_buffy_check (int force)
if (!force && (t - BuffyTime < BuffyTimeout))
return BuffyCount;
if (option (OPTMAILCHECKSTATS) &&
(t - BuffyStatsTime >= BuffyCheckStatsInterval))
if ((force & MUTT_BUFFY_CHECK_FORCE_STATS) ||
(option (OPTMAILCHECKSTATS) &&
(t - BuffyStatsTime >= BuffyCheckStatsInterval)))
{
check_stats = 1;
BuffyStatsTime = t;
......@@ -744,7 +747,8 @@ void mutt_buffy (char *s, size_t slen)
found = 1;
}
mutt_buffy_check (1); /* buffy was wrong - resync things */
mutt_buffy_check (MUTT_BUFFY_CHECK_FORCE); /* buffy was wrong - resync
things */
}
/* no folders with new mail */
......
......@@ -63,4 +63,8 @@ void mutt_buffy_setnotified (const char *path);
int mh_buffy (BUFFY *, int);
/* force flags passed to mutt_buffy_check() */
#define MUTT_BUFFY_CHECK_FORCE 1
#define MUTT_BUFFY_CHECK_FORCE_STATS (1<<1)
#endif /* _BUFFY_H */
......@@ -1028,4 +1028,7 @@ int mutt_check_traditional_pgp (HEADER *h, int *redraw)
return rv;
}
void mutt_check_stats (void)
{
mutt_buffy_check (MUTT_BUFFY_CHECK_FORCE | MUTT_BUFFY_CHECK_FORCE_STATS);
}
......@@ -579,8 +579,10 @@ int mutt_index_menu (void)
menu->custom_menu_redraw = index_menu_redraw;
mutt_push_current_menu (menu);
if (!attach_msg)
mutt_buffy_check(1); /* force the buffy check after we enter the folder */
if (!attach_msg) {
mutt_buffy_check(MUTT_BUFFY_CHECK_FORCE); /* force the buffy check after we
enter the folder */
}
#ifdef USE_INOTIFY
mutt_monitor_add (NULL);
#endif
......@@ -1339,8 +1341,9 @@ int mutt_index_menu (void)
#endif
mutt_clear_error ();
mutt_buffy_check(1); /* force the buffy check after we have changed
the folder */
mutt_buffy_check(MUTT_BUFFY_CHECK_FORCE); /* force the buffy check after
we have changed the
folder */
menu->redraw = REDRAW_FULL;
set_option (OPTSEARCHINVALID);
break;
......@@ -2467,6 +2470,10 @@ int mutt_index_menu (void)
mutt_what_key();
break;
case OP_CHECK_STATS:
mutt_check_stats();
break;
#ifdef USE_SIDEBAR
case OP_SIDEBAR_NEXT:
case OP_SIDEBAR_NEXT_NEW:
......
......@@ -953,6 +953,20 @@ In addition, the <emphasis>index</emphasis> and
<variablelist>
<varlistentry>
<term>
<literal>&lt;check-stats&gt;</literal><anchor id="check-stats"/>
</term>
<listitem>
<para>
Calculate statistics for all monitored mailboxes declared using the
<command>mailboxes</command> command.
It will calculate statistics despite
<link linkend="mail-check-stats">$mail_check_stats</link> being unset.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>&lt;create-alias&gt;</literal><anchor id="create-alias"/>
......
......@@ -80,6 +80,7 @@ const struct binding_t OpGeneric[] = { /* map: generic */
{ "current-bottom", OP_CURRENT_BOTTOM, NULL },
{ "error-history", OP_ERROR_HISTORY, NULL },
{ "what-key", OP_WHAT_KEY, NULL },
{ "check-stats", OP_CHECK_STATS, NULL },
{ NULL, 0, NULL }
};
......@@ -290,6 +291,7 @@ const struct binding_t OpPager[] = { /* map: pager */
{ "decrypt-save", OP_DECRYPT_SAVE, NULL },
{ "what-key", OP_WHAT_KEY, NULL },
{ "check-stats", OP_CHECK_STATS, NULL },
#ifdef USE_SIDEBAR
{ "sidebar-next", OP_SIDEBAR_NEXT, NULL },
......
......@@ -1546,6 +1546,10 @@ struct option_t MuttVars[] = {
** this operation is more performance intensive, it defaults to
** \fIunset\fP, and has a separate option, $$mail_check_stats_interval, to
** control how often to update these counts.
** .pp
** Message statistics can also be explicitly calculated by invoking the
** \fC<check-stats>\fP
** function.
*/
{ "mail_check_stats_interval", DT_NUM, R_NONE, UL &BuffyCheckStatsInterval, 60 },
/*
......
......@@ -1195,6 +1195,10 @@ int mutt_menuLoop (MUTTMENU *menu)
mutt_what_key ();
break;
case OP_CHECK_STATS:
mutt_check_stats ();
break;
case OP_REDRAW:
clearok (stdscr, TRUE);
menu->redraw = REDRAW_FULL;
......
......@@ -2884,6 +2884,10 @@ search_next:
mutt_what_key ();
break;
case OP_CHECK_STATS:
mutt_check_stats ();
break;
#ifdef USE_SIDEBAR
case OP_SIDEBAR_NEXT:
case OP_SIDEBAR_NEXT_NEW:
......
......@@ -178,6 +178,7 @@ void mutt_break_thread (HEADER *);
void mutt_buffy (char *, size_t);
int mutt_buffy_list (void);
void mutt_canonical_charset (char *, size_t, const char *);
void mutt_check_stats(void);
int mutt_count_body_parts (CONTEXT *, HEADER *);
void mutt_check_rescore (CONTEXT *);
void mutt_clear_error (void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment