Changeset 5025:0cb476dc70a7

Show
Ignore:
Timestamp:
2007-03-30 00:21:02 (22 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
default
Message:

Consult header cache if available for last known new mail count.
This prevents mutt from announcing new mail in mailboxes that have
unseen, but not new, messages, if those mailboxes are in the header
cache.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • imap/command.c

    r4993 r5025  
    3131#include "mx.h" 
    3232#include "buffy.h" 
     33#if USE_HCACHE 
     34#include "hcache.h" 
     35#endif 
    3336 
    3437#include <ctype.h> 
     
    819822  IMAP_STATUS *status, sb; 
    820823  int olduv, oldun; 
     824#if USE_HCACHE 
     825  header_cache_t *hc = NULL; 
     826  unsigned int *uidvalidity = NULL; 
     827  unsigned int *uidnext = NULL; 
     828#endif 
    821829 
    822830  mailbox = imap_next_word (s); 
     
    862870      s = imap_next_word (s); 
    863871  } 
    864   dprint (2, (debugfile, "%s (UIDVALIDITY: %d, UIDNEXT: %d) %d messages, %d recent, %d unseen\n", 
     872  dprint (3, (debugfile, "%s (UIDVALIDITY: %d, UIDNEXT: %d) %d messages, %d recent, %d unseen\n", 
    865873              status->name, status->uidvalidity, status->uidnext, 
    866874              status->messages, status->recent, status->unseen)); 
     
    873881  } 
    874882 
    875   dprint (2, (debugfile, "Running default STATUS handler\n")); 
     883  dprint (3, (debugfile, "Running default STATUS handler\n")); 
    876884 
    877885  /* should perhaps move this code back to imap_buffy_check */ 
     
    901909      if (value && !imap_mxcmp (mailbox, value)) 
    902910      { 
    903         dprint (2, (debugfile, "Found %s in buffy list (OV: %d ON: %d U: %d)\n", 
     911        dprint (3, (debugfile, "Found %s in buffy list (OV: %d ON: %d U: %d)\n", 
    904912                    mailbox, olduv, oldun, status->unseen)); 
    905913         
     914#if USE_HCACHE 
     915        /* fetch seen info from hcache if we haven't seen it yet this session */ 
     916        if (!olduv && !oldun) 
     917        { 
     918          hc = mutt_hcache_open (HeaderCache, inc->path); 
     919          if (hc) 
     920          { 
     921            uidvalidity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen); 
     922            uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen); 
     923            olduv = uidvalidity ? *uidvalidity : 0; 
     924            oldun = uidnext ? *uidnext : 0; 
     925            FREE (&uidvalidity); 
     926            FREE (&uidnext); 
     927            mutt_hcache_close (hc); 
     928            dprint (3, (debugfile, "hcache olduv %d, oldun %d\n", olduv, oldun)); 
     929          } 
     930        } 
     931#endif 
    906932        if (olduv && olduv == status->uidvalidity) 
    907933        { 
     
    909935          { 
    910936            inc->new = status->unseen; 
     937            /* forced back to keep detecting new mail until the mailbox is opened */ 
     938            status->uidnext = oldun; 
    911939          } 
    912940        } 
     
    914942          inc->new = status->unseen; 
    915943 
    916         /* forced back to keep detecting new mail until the mailbox is opened */ 
    917         status->uidnext = oldun; 
    918  
    919944        FREE (&value); 
    920945        return;