| | 254 | } |
| | 255 | |
| | 256 | int 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; |