Changeset 5052:b0014913dd74

Show
Ignore:
Timestamp:
2007-04-02 19:19:55 (22 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
HEAD
Message:

Add hook for proper IMAP unseen count in mailbox browser

Files:
4 modified

Legend:

Unmodified
Added
Removed
  • browser.c

    r5010 r5052  
    427427  char buffer[LONG_STRING]; 
    428428  BUFFY *tmp = Incoming; 
     429#ifdef USE_IMAP 
     430  struct mailbox_state mbox; 
     431#endif 
    429432 
    430433  if (!Incoming) 
     
    439442    if (mx_is_imap (tmp->path)) 
    440443    { 
    441       add_folder (menu, state, tmp->path, NULL, tmp->new); 
     444      imap_mailbox_state (tmp->path, &mbox); 
     445      add_folder (menu, state, tmp->path, NULL, mbox.new); 
    442446      continue; 
    443447    } 
  • browser.h

    r4343 r5052  
    5656}; 
    5757 
     58struct mailbox_state 
     59{ 
     60  unsigned int new; 
     61  unsigned int old; 
     62  unsigned int messages; 
     63}; 
    5864#endif /* _BROWSER_H */ 
  • imap/browse.c

    r5018 r5052  
    252252  FREE (&mx.mbox); 
    253253  return -1; 
     254} 
     255 
     256int imap_mailbox_state (const char* path, struct mailbox_state* state) 
     257{ 
     258  IMAP_DATA* idata; 
     259  IMAP_MBOX mx; 
     260  IMAP_STATUS* status; 
     261 
     262  memset (state, 0, sizeof (*state)); 
     263  if (imap_parse_path (path, &mx) < 0) 
     264  { 
     265    dprint (1, (debugfile, "imap_mailbox_state: bad path %s\n", path)); 
     266    return -1; 
     267  } 
     268  if (!(idata = imap_conn_find (&mx.account, M_IMAP_CONN_NONEW))) 
     269  { 
     270    dprint (2, (debugfile, "imap_mailbox_state: no open connection for %s\n", 
     271                path)); 
     272    FREE (&mx.mbox); 
     273    return -1; 
     274  } 
     275 
     276  if ((status = imap_mboxcache_get (idata, mx.mbox, 0))) 
     277  { 
     278    state->new = status->unseen; 
     279    state->messages = status->messages; 
     280  } 
     281 
     282  return 0; 
    254283} 
    255284 
  • imap/imap.h

    r5028 r5052  
    5151/* browse.c */ 
    5252int imap_browse (char* path, struct browser_state* state); 
     53int imap_mailbox_state (const char* path, struct mailbox_state* state); 
    5354int imap_mailbox_create (const char* folder); 
    5455int imap_mailbox_rename (const char* mailbox);