-
- snprintf (path, sizeof (path), "%s/new", tmp->path);
- if ((dirp = opendir (path)) == NULL)
- {
- tmp->magic = 0;
- break;
- }
- tmp->msgcount = 0;
- tmp->msg_unread = 0;
- while ((de = readdir (dirp)) != NULL)
- {
- char *p;
- if (*de->d_name != '.' &&
- (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
- {
- /* one new and undeleted message is enough */
- BuffyCount++;
- tmp->has_new = tmp->new = 1;
- tmp->msgcount++;
- tmp->msg_unread++;
- }
- }
- closedir (dirp);
-#if 0
- /* I commented this out because it led to an infite "New mail in ..." loop,
- * and when looking at the code, the check seems to be overly eager.
- * -- ak
- */
- snprintf (path, sizeof (path), "%s/cur", tmp->path);
- if ((dirp = opendir (path)) == NULL)
- {
- tmp->magic = 0;
- break;
- }
- while ((de = readdir (dirp)) != NULL)
- {
- char *p;
- if (*de->d_name != '.' &&
- (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
- {
- /* one new and undeleted message is enough */
- BuffyCount++;
- tmp->has_new = tmp->new = 1;
- tmp->msgcount++;
- }
- }
- closedir (dirp);
-#endif
- break;
+ /* only check on force or $mail_check reached */
+ if (force != 0 || (now - last1 >= BuffyTimeout)) {
+ snprintf (path, sizeof (path), "%s/new", tmp->path);
+ if ((dirp = opendir (path)) == NULL)
+ {
+ tmp->magic = 0;
+ break;
+ }
+ tmp->new = 0;
+ tmp->msg_unread = 0;
+ tmp->msgcount = 0;
+ while ((de = readdir (dirp)) != NULL)
+ {
+ char *p;
+ if (*de->d_name != '.' &&
+ (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')))
+ {
+ /* one new and undeleted message is enough */
+ if (tmp->new == 0)
+ {
+ BuffyCount++;
+ tmp->new = 1;
+ if (SidebarWidth == 0 || !option (OPTMBOXPANE))
+ /* if sidebar invisible -> done */
+ break;
+ }
+ tmp->msgcount++;
+ tmp->msg_unread++;
+ tmp->new++;
+ }
+ }
+ closedir (dirp);
+
+ if (SidebarWidth > 0 && option (OPTMBOXPANE))
+ {
+ /* only count total mail if sidebar visible */
+ snprintf (path, sizeof (path), "%s/cur", tmp->path);
+ if ((dirp = opendir (path)) == NULL)
+ {
+ tmp->magic = 0;
+ break;
+ }
+ tmp->msg_flagged = 0;
+ while ((de = readdir (dirp)) != NULL)
+ {
+ char *p;
+ if (*de->d_name != '.' && (p = strstr (de->d_name, ":2,")) != NULL) {
+ if (!strchr (p + 3, 'T'))
+ tmp->msgcount++;
+ if (strchr (p + 3, 'F'))
+ tmp->msg_flagged++;
+ }
+ }
+ closedir (dirp);
+ }
+ } else if (tmp->new > 0)
+ /* keep current stats if !force and !$mail_check reached */
+ BuffyCount++;
+ break;