Changeset 1111:53998cee3e2d for buffy.c

Show
Ignore:
Timestamp:
1999-07-20 01:05:32 (9 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Bugs fixed
* Mutt sometimes forgets that IMAP folders with new mail have new

mail.

* On some common IMAP servers, Mutt erroneously insists that the

current folder has new mail.

* Mutt constantly polls the server for new messages,

disregarding the imap_checkinterval option.

New features
* tab-completion of IMAP folders. Not yet namespace aware, though it

will work within an alternate namespace (eg won't complete #ft ->
#ftp, but will complete #ftp/pu -> #ftp/pub). Some tweaking of the
browser was necessary to get it to cooperate with completion.
Some remains to be done.

(From: From: Brendan Cully <brendan@…>)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • buffy.c

    r1099 r1111  
    229229  struct stat contex_sb; 
    230230  time_t t; 
     231#ifdef USE_IMAP 
     232  static time_t last_imap_check = 0; 
     233  int do_imap_check = 1; 
     234 
     235  if (ImapCheckTime) 
     236  { 
     237    time_t now = time (NULL); 
     238    if (!force && (now - last_imap_check < ImapCheckTime)) 
     239      do_imap_check = 0; 
     240    else 
     241      last_imap_check = now; 
     242  } 
     243#endif 
    231244 
    232245  /* fastest return if there are no mailboxes */ 
     
    234247    return 0; 
    235248  t = time (NULL); 
    236   if (!force && t - BuffyTime < BuffyTimeout) 
     249  if (!force && (t - BuffyTime < BuffyTimeout)) 
    237250    return BuffyCount; 
    238251  
     
    241254  BuffyNotify = 0; 
    242255 
     256#ifdef USE_IMAP 
     257  if (!Context || Context->magic != M_IMAP) 
     258#endif 
    243259  /* check device ID and serial number instead of comparing paths */ 
    244260  if (!Context || !Context->path || stat (Context->path, &contex_sb) != 0) 
     
    250266  for (tmp = Incoming; tmp; tmp = tmp->next) 
    251267  { 
    252     tmp->new = 0; 
    253  
    254268#ifdef USE_IMAP 
    255269    if ((tmp->magic == M_IMAP) || mx_is_imap (tmp->path)) 
    256     { 
    257270      tmp->magic = M_IMAP; 
    258     } 
    259271    else 
    260272#endif 
    261     if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 || 
    262         (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0)) 
    263     { 
    264       /* if the mailbox still doesn't exist, set the newly created flag to 
    265        * be ready for when it does. 
    266        */ 
    267       tmp->newly_created = 1; 
    268       tmp->magic = 0; 
    269 #ifdef BUFFY_SIZE 
    270       tmp->size = 0; 
    271 #endif 
    272       continue; 
    273     } 
    274  
     273    { 
     274      tmp->new = 0; 
     275       
     276      if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 || 
     277          (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0)) 
     278      { 
     279        /* if the mailbox still doesn't exist, set the newly created flag to 
     280         * be ready for when it does. 
     281         */ 
     282        tmp->newly_created = 1; 
     283        tmp->magic = 0; 
     284#ifdef BUFFY_SIZE 
     285        tmp->size = 0; 
     286#endif 
     287        continue; 
     288      } 
     289 
     290#ifdef USE_IMAP 
     291    } 
     292#endif 
     293 
     294    /* check to see if the folder is the currently selected folder 
     295     * before polling */ 
    275296    if (!Context || !Context->path ||  
     297#ifdef USE_IMAP 
     298        /* unless folder is an IMAP folder */ 
     299        tmp->magic == M_IMAP || 
     300#endif 
    276301        sb.st_dev != contex_sb.st_dev || sb.st_ino != contex_sb.st_ino) 
    277302    { 
     
    327352#ifdef USE_IMAP 
    328353      case M_IMAP: 
    329         if (imap_buffy_check (tmp->path) > 0) 
    330         { 
    331           BuffyCount++; 
    332           tmp->new = 1; 
    333         } 
     354        /* poll on do_imap_check, else return cached value */ 
     355        if (do_imap_check) 
     356        { 
     357          tmp->new = 0; 
     358          if (imap_buffy_check (tmp->path) > 0) 
     359          { 
     360            BuffyCount++; 
     361            tmp->new = 1; 
     362          } 
     363        } 
     364        else 
     365        { 
     366          if (tmp->new) 
     367            BuffyCount++; 
     368        } 
     369 
    334370        break; 
    335371#endif 
     
    346382      BuffyNotify++; 
    347383  } 
     384 
    348385  BuffyDoneTime = BuffyTime; 
    349386  return (BuffyCount);