NeoMutt  2020-06-26-30-g76c339
Teaching an old dog new tricks
DOXYGEN
mutt_mailbox.c File Reference

Mailbox helper functions. More...

#include "config.h"
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <utime.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt_mailbox.h"
#include "globals.h"
#include "mutt_menu.h"
#include "muttlib.h"
#include "mx.h"
#include "protos.h"
+ Include dependency graph for mutt_mailbox.c:

Go to the source code of this file.

Functions

static void mailbox_check (struct Mailbox *m_cur, struct Mailbox *m_check, struct stat *ctx_sb, bool check_stats)
 Check a mailbox for new mail. More...
 
int mutt_mailbox_check (struct Mailbox *m_cur, int force)
 Check all all Mailboxes for new mail. More...
 
bool mutt_mailbox_notify (struct Mailbox *m_cur)
 Notify the user if there's new mail. More...
 
bool mutt_mailbox_list (void)
 List the mailboxes with new mail. More...
 
void mutt_mailbox_set_notified (struct Mailbox *m)
 Note when the user was last notified of new mail. More...
 
struct Mailboxmutt_mailbox_next (struct Mailbox *m_cur, struct Buffer *s)
 incoming folders completion routine More...
 
void mutt_mailbox_cleanup (const char *path, struct stat *st)
 Restore the timestamp of a mailbox. More...
 

Variables

static time_t MailboxTime = 0
 last time we started checking for mail More...
 
static time_t MailboxStatsTime = 0
 last time we check performed mail_check_stats More...
 
static short MailboxCount = 0
 how many boxes with new mail More...
 
static short MailboxNotify = 0
 

of unnotified new boxes

More...
 
short C_MailCheck
 Config: Number of seconds before NeoMutt checks for new mail. More...
 
bool C_MailCheckStats
 Config: Periodically check for new mail. More...
 
short C_MailCheckStatsInterval
 Config: How often to check for new mail. More...
 

Detailed Description

Mailbox helper functions.

  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file mutt_mailbox.c.

Function Documentation

◆ mailbox_check()

static void mailbox_check ( struct Mailbox m_cur,
struct Mailbox m_check,
struct stat *  ctx_sb,
bool  check_stats 
)
static

Check a mailbox for new mail.

Parameters
m_curCurrent Mailbox
m_checkMailbox to check
ctx_sbstat() info for the current Mailbox
check_statsIf true, also count the total, new and flagged messages

Definition at line 61 of file mutt_mailbox.c.

63 {
64  struct stat sb = { 0 };
65 
66 #ifdef USE_SIDEBAR
67  short orig_new = m_check->has_new;
68  int orig_count = m_check->msg_count;
69  int orig_unread = m_check->msg_unread;
70  int orig_flagged = m_check->msg_flagged;
71 #endif
72 
73  enum MailboxType mb_type = mx_path_probe(mailbox_path(m_check));
74 
75  if ((m_cur == m_check) && C_MailCheckRecent)
76  m_check->has_new = false;
77 
78  switch (mb_type)
79  {
80  case MUTT_POP:
81  case MUTT_NNTP:
82  case MUTT_NOTMUCH:
83  case MUTT_IMAP:
84  m_check->type = mb_type;
85  break;
86  default:
87  if ((stat(mailbox_path(m_check), &sb) != 0) ||
88  ((m_check->type == MUTT_UNKNOWN) && S_ISREG(sb.st_mode) && (sb.st_size == 0)) ||
89  ((m_check->type == MUTT_UNKNOWN) &&
90  ((m_check->type = mx_path_probe(mailbox_path(m_check))) <= 0)))
91  {
92  /* if the mailbox still doesn't exist, set the newly created flag to be
93  * ready for when it does. */
94  m_check->newly_created = true;
95  m_check->type = MUTT_UNKNOWN;
96  m_check->size = 0;
97  return;
98  }
99  break; // kept for consistency.
100  }
101 
102  /* check to see if the folder is the currently selected folder before polling */
103  if (!m_cur || mutt_buffer_is_empty(&m_cur->pathbuf) ||
104  (((m_check->type == MUTT_IMAP) || (m_check->type == MUTT_NNTP) ||
105  (m_check->type == MUTT_NOTMUCH) || (m_check->type == MUTT_POP)) ?
106  !mutt_str_equal(mailbox_path(m_check), mailbox_path(m_cur)) :
107  ((sb.st_dev != ctx_sb->st_dev) || (sb.st_ino != ctx_sb->st_ino))))
108  {
109  switch (m_check->type)
110  {
111  case MUTT_IMAP:
112  case MUTT_MBOX:
113  case MUTT_MMDF:
114  case MUTT_MAILDIR:
115  case MUTT_MH:
116  case MUTT_NOTMUCH:
117  if ((mx_mbox_check_stats(m_check, check_stats) > 0) && m_check->has_new)
118  MailboxCount++;
119  break;
120  default:; /* do nothing */
121  }
122  }
123  else if (C_CheckMboxSize && m_cur && mutt_buffer_is_empty(&m_cur->pathbuf))
124  m_check->size = (off_t) sb.st_size; /* update the size of current folder */
125 
126 #ifdef USE_SIDEBAR
127  if ((orig_new != m_check->has_new) || (orig_count != m_check->msg_count) ||
128  (orig_unread != m_check->msg_unread) || (orig_flagged != m_check->msg_flagged))
129  {
131  }
132 #endif
133 
134  if (!m_check->has_new)
135  m_check->notified = false;
136  else if (!m_check->notified)
137  MailboxNotify++;
138 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:194
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
int msg_count
Total number of messages.
Definition: mailbox.h:91
off_t size
Size of the Mailbox.
Definition: mailbox.h:87
WHERE bool C_MailCheckRecent
Config: Notify the user about new mail since the last time the mailbox was opened.
Definition: globals.h:231
if(!test_colorize_)
Definition: acutest.h:499
int msg_unread
Number of unread messages.
Definition: mailbox.h:92
&#39;NNTP&#39; (Usenet) Mailbox type
Definition: mailbox.h:52
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:93
Mailbox wasn&#39;t recognised.
Definition: mailbox.h:47
WHERE bool C_CheckMboxSize
Config: (mbox,mmdf) Use mailbox size as an indicator of new mail.
Definition: globals.h:203
#define REDRAW_SIDEBAR
Redraw the sidebar.
Definition: mutt_menu.h:49
bool has_new
Mailbox has new mail.
Definition: mailbox.h:88
static short MailboxCount
how many boxes with new mail
Definition: mutt_mailbox.c:46
&#39;Maildir&#39; Mailbox type
Definition: mailbox.h:51
static short MailboxNotify
of unnotified new boxes
Definition: mutt_mailbox.c:47
&#39;POP3&#39; Mailbox type
Definition: mailbox.h:55
&#39;mmdf&#39; Mailbox type
Definition: mailbox.h:49
&#39;MH&#39; Mailbox type
Definition: mailbox.h:50
bool newly_created
Mbox or mmdf just popped into existence.
Definition: mailbox.h:106
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
&#39;mbox&#39; Mailbox type
Definition: mailbox.h:48
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition: mx.c:1328
MailboxType
Supported mailbox formats.
Definition: mailbox.h:43
int mx_mbox_check_stats(struct Mailbox *m, int flags)
Check the statistics for a mailbox - Wrapper for MxOps::mbox_check_stats()
Definition: mx.c:1725
bool notified
User has been notified.
Definition: mailbox.h:104
struct Buffer pathbuf
Definition: mailbox.h:83
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_mailbox_check()

int mutt_mailbox_check ( struct Mailbox m_cur,
int  force 
)

Check all all Mailboxes for new mail.

Parameters
m_curCurrent Mailbox
forceForce flags, see below
Return values
numNumber of mailboxes with new mail

The force argument may be any combination of the following values:

  • MUTT_MAILBOX_CHECK_FORCE ignore MailboxTime and check for new mail
  • MUTT_MAILBOX_CHECK_FORCE_STATS ignore MailboxTime and calculate statistics

Check all all Mailboxes for new mail and total/new/flagged messages

Definition at line 152 of file mutt_mailbox.c.

153 {
154  struct stat contex_sb;
155  time_t t;
156  bool check_stats = false;
157  contex_sb.st_dev = 0;
158  contex_sb.st_ino = 0;
159 
160 #ifdef USE_IMAP
161  /* update postponed count as well, on force */
162  if (force & MUTT_MAILBOX_CHECK_FORCE)
164 #endif
165 
166  /* fastest return if there are no mailboxes */
168  return 0;
169 
170  t = mutt_date_epoch();
171  if (!force && (t - MailboxTime < C_MailCheck))
172  return MailboxCount;
173 
174  if ((force & MUTT_MAILBOX_CHECK_FORCE_STATS) ||
176  {
177  check_stats = true;
178  MailboxStatsTime = t;
179  }
180 
181  MailboxTime = t;
182  MailboxCount = 0;
183  MailboxNotify = 0;
184 
185  /* check device ID and serial number instead of comparing paths */
186  if (!m_cur || (m_cur->type == MUTT_IMAP) || (m_cur->type == MUTT_POP)
187 #ifdef USE_NNTP
188  || (m_cur->type == MUTT_NNTP)
189 #endif
190  || stat(mailbox_path(m_cur), &contex_sb) != 0)
191  {
192  contex_sb.st_dev = 0;
193  contex_sb.st_ino = 0;
194  }
195 
196  struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
198  struct MailboxNode *np = NULL;
199  STAILQ_FOREACH(np, &ml, entries)
200  {
201  if (np->mailbox->flags & MB_HIDDEN)
202  continue;
203 
204  mailbox_check(m_cur, np->mailbox, &contex_sb,
205  check_stats || (!np->mailbox->first_check_stats_done && C_MailCheckStats));
206  np->mailbox->first_check_stats_done = true;
207  }
209 
210  return MailboxCount;
211 }
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:414
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:194
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
&#39;NNTP&#39; (Usenet) Mailbox type
Definition: mailbox.h:52
struct AccountList accounts
List of all Accounts.
Definition: neomutt.h:40
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:135
Match any Mailbox type.
Definition: mailbox.h:45
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:158
bool first_check_stats_done
True when the check have been done at least on time.
Definition: mailbox.h:116
static time_t MailboxStatsTime
last time we check performed mail_check_stats
Definition: mutt_mailbox.c:45
static void mailbox_check(struct Mailbox *m_cur, struct Mailbox *m_check, struct stat *ctx_sb, bool check_stats)
Check a mailbox for new mail.
Definition: mutt_mailbox.c:61
Container for Accounts, Notifications.
Definition: neomutt.h:36
static short MailboxCount
how many boxes with new mail
Definition: mutt_mailbox.c:46
int flags
e.g. MB_NORMAL
Definition: mailbox.h:134
static short MailboxNotify
of unnotified new boxes
Definition: mutt_mailbox.c:47
short C_MailCheckStatsInterval
Config: How often to check for new mail.
Definition: mutt_mailbox.c:52
#define MB_HIDDEN
Definition: mailbox.h:38
&#39;POP3&#39; Mailbox type
Definition: mailbox.h:55
static time_t MailboxTime
last time we started checking for mail
Definition: mutt_mailbox.c:44
short C_MailCheck
Config: Number of seconds before NeoMutt checks for new mail.
Definition: mutt_mailbox.c:50
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
void mutt_update_num_postponed(void)
Force the update of the number of postponed messages.
Definition: postpone.c:199
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:16
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
List of Mailboxes.
Definition: mailbox.h:145
bool C_MailCheckStats
Config: Periodically check for new mail.
Definition: mutt_mailbox.c:51
#define TAILQ_EMPTY(head)
Definition: queue.h:714
&#39;IMAP&#39; Mailbox type
Definition: mailbox.h:53
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:147
#define MUTT_MAILBOX_CHECK_FORCE_STATS
Definition: mutt_mailbox.h:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_mailbox_notify()

bool mutt_mailbox_notify ( struct Mailbox m_cur)

Notify the user if there's new mail.

Parameters
m_curCurrent Mailbox
Return values
trueIf there is new mail

Definition at line 218 of file mutt_mailbox.c.

219 {
220  if ((mutt_mailbox_check(m_cur, 0) > 0) && MailboxNotify)
221  {
222  return mutt_mailbox_list();
223  }
224  return false;
225 }
bool mutt_mailbox_list(void)
List the mailboxes with new mail.
Definition: mutt_mailbox.c:231
static short MailboxNotify
of unnotified new boxes
Definition: mutt_mailbox.c:47
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:152
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_mailbox_list()

bool mutt_mailbox_list ( void  )

List the mailboxes with new mail.

Return values
trueIf there is new mail

Definition at line 231 of file mutt_mailbox.c.

232 {
233  char mailboxlist[512];
234  size_t pos = 0;
235  int first = 1;
236 
237  int have_unnotified = MailboxNotify;
238 
239  struct Buffer *path = mutt_buffer_pool_get();
240 
241  mailboxlist[0] = '\0';
242  pos += strlen(strncat(mailboxlist, _("New mail in "), sizeof(mailboxlist) - 1 - pos));
243  struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
245  struct MailboxNode *np = NULL;
246  STAILQ_FOREACH(np, &ml, entries)
247  {
248  /* Is there new mail in this mailbox? */
249  if (!np->mailbox->has_new || (have_unnotified && np->mailbox->notified))
250  continue;
251 
254 
255  if (!first && (MuttMessageWindow->state.cols >= 7) &&
256  ((pos + mutt_buffer_len(path)) >= ((size_t) MuttMessageWindow->state.cols - 7)))
257  {
258  break;
259  }
260 
261  if (!first)
262  pos += strlen(strncat(mailboxlist + pos, ", ", sizeof(mailboxlist) - 1 - pos));
263 
264  /* Prepend an asterisk to mailboxes not already notified */
265  if (!np->mailbox->notified)
266  {
267  /* pos += strlen (strncat(mailboxlist + pos, "*", sizeof(mailboxlist)-1-pos)); */
268  np->mailbox->notified = true;
269  MailboxNotify--;
270  }
271  pos += strlen(strncat(mailboxlist + pos, mutt_b2s(path), sizeof(mailboxlist) - 1 - pos));
272  first = 0;
273  }
275 
276  if (!first && np)
277  {
278  strncat(mailboxlist + pos, ", ...", sizeof(mailboxlist) - 1 - pos);
279  }
280 
282 
283  if (!first)
284  {
285  mutt_message("%s", mailboxlist);
286  return true;
287  }
288 
289  /* there were no mailboxes needing to be notified, so clean up since
290  * MailboxNotify has somehow gotten out of sync */
291  MailboxNotify = 0;
292  return false;
293 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:194
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define mutt_message(...)
Definition: logging.h:83
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:135
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
Match any Mailbox type.
Definition: mailbox.h:45
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:158
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
Container for Accounts, Notifications.
Definition: neomutt.h:36
void mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:688
bool has_new
Mailbox has new mail.
Definition: mailbox.h:88
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
#define mutt_b2s(buf)
Definition: buffer.h:41
static short MailboxNotify
of unnotified new boxes
Definition: mutt_mailbox.c:47
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:113
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:356
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
bool notified
User has been notified.
Definition: mailbox.h:104
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
struct MuttWindow * MuttMessageWindow
Message Window.
Definition: mutt_window.c:46
List of Mailboxes.
Definition: mailbox.h:145
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:147
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_mailbox_set_notified()

void mutt_mailbox_set_notified ( struct Mailbox m)

Note when the user was last notified of new mail.

Parameters
mMailbox

Definition at line 299 of file mutt_mailbox.c.

300 {
301  if (!m)
302  return;
303 
304  m->notified = true;
305 #ifdef HAVE_CLOCK_GETTIME
306  clock_gettime(CLOCK_REALTIME, &m->last_visited);
307 #else
309  m->last_visited.tv_nsec = 0;
310 #endif
311 }
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:414
time_t tv_sec
Definition: file.h:48
struct timespec last_visited
Time of last exit from this mailbox.
Definition: mailbox.h:108
long tv_nsec
Definition: file.h:49
bool notified
User has been notified.
Definition: mailbox.h:104
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_mailbox_next()

struct Mailbox* mutt_mailbox_next ( struct Mailbox m_cur,
struct Buffer s 
)

incoming folders completion routine

Parameters
m_curCurrent Mailbox
sBuffer containing name of current mailbox
Return values
ptrMailbox

Given a folder name, find the next incoming folder with new mail. The Mailbox will be returned and a pretty version of the path put into s.

Definition at line 322 of file mutt_mailbox.c.

323 {
325 
326  if (mutt_mailbox_check(m_cur, 0) > 0)
327  {
328  bool found = false;
329  for (int pass = 0; pass < 2; pass++)
330  {
331  struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
333  struct MailboxNode *np = NULL;
334  STAILQ_FOREACH(np, &ml, entries)
335  {
336  if (np->mailbox->type == MUTT_NOTMUCH) /* only match real mailboxes */
337  continue;
339  if ((found || (pass > 0)) && np->mailbox->has_new)
340  {
343  struct Mailbox *m_result = np->mailbox;
345  return m_result;
346  }
348  found = true;
349  }
351  }
352 
353  mutt_mailbox_check(m_cur, MUTT_MAILBOX_CHECK_FORCE); /* mailbox was wrong - resync things */
354  }
355 
356  mutt_buffer_reset(s); // no folders with new mail
357  return NULL;
358 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:879
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:194
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:135
Match any Mailbox type.
Definition: mailbox.h:45
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:158
Container for Accounts, Notifications.
Definition: neomutt.h:36
void mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using &#39;~&#39; or &#39;=&#39;.
Definition: muttlib.c:688
bool has_new
Mailbox has new mail.
Definition: mailbox.h:88
#define mutt_b2s(buf)
Definition: buffer.h:41
A mailbox.
Definition: mailbox.h:81
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:152
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
#define MUTT_MAILBOX_CHECK_FORCE
Definition: mutt_mailbox.h:16
&#39;Notmuch&#39; (virtual) Mailbox type
Definition: mailbox.h:54
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:327
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
List of Mailboxes.
Definition: mailbox.h:145
struct Buffer pathbuf
Definition: mailbox.h:83
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:147
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_mailbox_cleanup()

void mutt_mailbox_cleanup ( const char *  path,
struct stat *  st 
)

Restore the timestamp of a mailbox.

Parameters
pathPath to the mailbox
stTimestamp info from stat()

Fix up the atime and mtime after mbox/mmdf mailbox was modified according to stat() info taken before a modification.

Definition at line 368 of file mutt_mailbox.c.

369 {
370 #ifdef HAVE_UTIMENSAT
371  struct timespec ts[2];
372 #else
373  struct utimbuf ut;
374 #endif
375 
376  if (C_CheckMboxSize)
377  {
378  struct Mailbox *m = mailbox_find(path);
379  if (m && !m->has_new)
380  mailbox_update(m);
381  }
382  else
383  {
384  /* fix up the times so mailbox won't get confused */
385  if (st->st_mtime > st->st_atime)
386  {
387 #ifdef HAVE_UTIMENSAT
388  ts[0].tv_sec = 0;
389  ts[0].tv_nsec = UTIME_OMIT;
390  ts[1].tv_sec = 0;
391  ts[1].tv_nsec = UTIME_NOW;
392  utimensat(0, buf, ts, 0);
393 #else
394  ut.actime = st->st_atime;
395  ut.modtime = mutt_date_epoch();
396  utime(path, &ut);
397 #endif
398  }
399  else
400  {
401 #ifdef HAVE_UTIMENSAT
402  ts[0].tv_sec = 0;
403  ts[0].tv_nsec = UTIME_NOW;
404  ts[1].tv_sec = 0;
405  ts[1].tv_nsec = UTIME_NOW;
406  utimensat(0, buf, ts, 0);
407 #else
408  utime(path, NULL);
409 #endif
410  }
411  }
412 }
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:414
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
Definition: mailbox.c:91
WHERE bool C_CheckMboxSize
Config: (mbox,mmdf) Use mailbox size as an indicator of new mail.
Definition: globals.h:203
bool has_new
Mailbox has new mail.
Definition: mailbox.h:88
A mailbox.
Definition: mailbox.h:81
void mailbox_update(struct Mailbox *m)
Get the mailbox&#39;s current size.
Definition: mailbox.c:156
Time value with nanosecond precision.
Definition: file.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MailboxTime

time_t MailboxTime = 0
static

last time we started checking for mail

Definition at line 44 of file mutt_mailbox.c.

◆ MailboxStatsTime

time_t MailboxStatsTime = 0
static

last time we check performed mail_check_stats

Definition at line 45 of file mutt_mailbox.c.

◆ MailboxCount

short MailboxCount = 0
static

how many boxes with new mail

Definition at line 46 of file mutt_mailbox.c.

◆ MailboxNotify

short MailboxNotify = 0
static

of unnotified new boxes

Definition at line 47 of file mutt_mailbox.c.

◆ C_MailCheck

short C_MailCheck

Config: Number of seconds before NeoMutt checks for new mail.

Definition at line 50 of file mutt_mailbox.c.

◆ C_MailCheckStats

bool C_MailCheckStats

Config: Periodically check for new mail.

Definition at line 51 of file mutt_mailbox.c.

◆ C_MailCheckStatsInterval

short C_MailCheckStatsInterval

Config: How often to check for new mail.

Definition at line 52 of file mutt_mailbox.c.