Line
Link Here
|
0 |
-- a/buffy.c |
0 |
++ b/buffy.c |
Lines 394-415
static int buffy_maildir_hasnew (BUFFY* mailbox)
Link Here
|
394 |
} |
394 |
} |
395 |
|
395 |
|
396 |
/* update message counts for the sidebar */ |
396 |
/* update message counts for the sidebar */ |
397 |
void buffy_maildir_update (BUFFY* mailbox) |
397 |
static void buffy_maildir_update_dir (BUFFY* mailbox, const char *dir) |
398 |
{ |
398 |
{ |
399 |
char path[_POSIX_PATH_MAX]; |
399 |
char path[_POSIX_PATH_MAX]; |
400 |
DIR *dirp; |
400 |
DIR *dirp; |
401 |
struct dirent *de; |
401 |
struct dirent *de; |
402 |
char *p; |
402 |
char *p; |
|
|
403 |
int read; |
403 |
|
404 |
|
404 |
if(!option(OPTSIDEBAR)) |
405 |
snprintf (path, sizeof (path), "%s/%s", mailbox->path, dir); |
405 |
return; |
|
|
406 |
|
407 |
mailbox->msgcount = 0; |
408 |
mailbox->msg_unread = 0; |
409 |
mailbox->msg_flagged = 0; |
410 |
|
411 |
snprintf (path, sizeof (path), "%s/new", mailbox->path); |
412 |
|
413 |
if ((dirp = opendir (path)) == NULL) |
406 |
if ((dirp = opendir (path)) == NULL) |
414 |
{ |
407 |
{ |
415 |
mailbox->magic = 0; |
408 |
mailbox->magic = 0; |
Lines 421-462
void buffy_maildir_update (BUFFY* mailbox)
Link Here
|
421 |
if (*de->d_name == '.') |
414 |
if (*de->d_name == '.') |
422 |
continue; |
415 |
continue; |
423 |
|
416 |
|
424 |
if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { |
417 |
/* Matches maildir_parse_flags logic */ |
425 |
mailbox->new = 1; |
418 |
read = 0; |
426 |
mailbox->msgcount++; |
419 |
mailbox->msgcount++; |
427 |
mailbox->msg_unread++; |
420 |
if ((p = strstr (de->d_name, ":2,"))) { |
|
|
421 |
p += 3; |
422 |
if (strchr (p, 'S')) |
423 |
read = 1; |
424 |
if (strchr (p, 'F')) |
425 |
mailbox->msg_flagged++; |
428 |
} |
426 |
} |
|
|
427 |
if (!read) |
428 |
mailbox->msg_unread++; |
429 |
} |
429 |
} |
430 |
|
430 |
|
431 |
closedir (dirp); |
431 |
closedir (dirp); |
432 |
snprintf (path, sizeof (path), "%s/cur", mailbox->path); |
432 |
} |
433 |
|
433 |
void buffy_maildir_update (BUFFY* mailbox) |
434 |
if ((dirp = opendir (path)) == NULL) |
434 |
{ |
435 |
{ |
435 |
if (!option(OPTSIDEBAR)) |
436 |
mailbox->magic = 0; |
436 |
return; |
437 |
return; |
|
|
438 |
} |
439 |
|
440 |
while ((de = readdir (dirp)) != NULL) |
441 |
{ |
442 |
if (*de->d_name == '.') |
443 |
continue; |
444 |
|
437 |
|
445 |
if (!(p = strstr (de->d_name, ":2,")) || !strchr (p + 3, 'T')) { |
438 |
mailbox->msgcount = 0; |
446 |
mailbox->msgcount++; |
439 |
mailbox->msg_unread = 0; |
447 |
if ((p = strstr (de->d_name, ":2,"))) { |
440 |
mailbox->msg_flagged = 0; |
448 |
if (!strchr (p + 3, 'T')) { |
441 |
|
449 |
if (!strchr (p + 3, 'S')) |
442 |
buffy_maildir_update_dir (mailbox, "new"); |
450 |
mailbox->msg_unread++; |
443 |
if (mailbox->msgcount) |
451 |
if (strchr(p + 3, 'F')) |
444 |
mailbox->new = 1; |
452 |
mailbox->msg_flagged++; |
445 |
buffy_maildir_update_dir (mailbox, "cur"); |
453 |
} |
|
|
454 |
} |
455 |
} |
456 |
} |
457 |
|
446 |
|
458 |
mailbox->sb_last_checked = time(NULL); |
447 |
mailbox->sb_last_checked = time(NULL); |
459 |
closedir (dirp); |
|
|
460 |
} |
448 |
} |
461 |
|
449 |
|
462 |
/* returns 1 if mailbox has new mail */ |
450 |
/* returns 1 if mailbox has new mail */ |