/* check_status: curs_main uses imap_check_mailbox to detect
* whether the index needs updating */
idata->check_status = IMAP_NEWMAIL_PENDING;
- idata->reopen &= ~IMAP_NEWMAIL_PENDING;
- count = imap_read_headers (idata, idata->ctx->msgcount, count-1)+1;
+ imap_read_headers (idata, idata->ctx->msgcount, count-1);
}
else if (idata->reopen & IMAP_EXPUNGE_PENDING)
{
if ((rc = imap_cmd_step (idata)) != IMAP_CMD_CONTINUE)
break;
- pc = idata->cmd.buf + 2;
- pc = imap_next_word (pc);
- if (!ascii_strncasecmp ("EXISTS", pc, 6))
- {
- /* imap_handle_untagged will have picked up the EXISTS message and
- * set the NEW_MAIL flag. We clear it here. */
- idata->reopen &= ~IMAP_NEWMAIL_PENDING;
- count = idata->newMailCount;
- idata->newMailCount = 0;
- }
-
pc = idata->cmd.buf + 2;
/* Obtain list of available flags here, may be overridden by a
if ((pc = imap_get_flags (&(idata->flags), pc)) == NULL)
goto fail;
}
+ else
+ {
+ pc = imap_next_word (pc);
+ if (!ascii_strncasecmp ("EXISTS", pc, 6))
+ {
+ count = idata->newMailCount;
+ idata->newMailCount = 0;
+ }
+ }
}
while (rc == IMAP_CMD_CONTINUE);
idata->reopen &= IMAP_REOPEN_ALLOW;
idata->state = IMAP_AUTHENTICATED;
FREE (&(idata->mailbox));
+ mutt_free_list (&idata->flags);
}
/* free IMAP part of headers */
while ((msgend) >= idata->ctx->hdrmax)
mx_alloc_memory (idata->ctx);
+ oldmsgcount = ctx->msgcount;
+ idata->reopen &= ~IMAP_NEWMAIL_PENDING;
+ idata->newMailCount = 0;
+
for (msgno = msgbegin; msgno <= msgend ; msgno++)
{
if (ReadInc && (!msgno || ((msgno+1) % ReadInc == 0)))
memset (&h, 0, sizeof (h));
h.data = safe_calloc (1, sizeof (IMAP_HEADER_DATA));
- oldmsgcount = ctx->msgcount;
-
/* this DO loop does two things:
* 1. handles untagged messages, so we can try again on the same msg
* 2. fetches the tagged response at the end of the last message.
while ((rc != IMAP_CMD_OK) && ((mfhrc == -1) ||
((msgno + 1) >= fetchlast)));
- if (ctx->msgcount > oldmsgcount)
- mx_update_context (ctx, ctx->msgcount - oldmsgcount);
-
if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
{
imap_free_header_data ((void**) &h.data);
return -1;
}
- /* h.data shouldn't be freed here, it is kept in ctx->headers */
-
/* in case we get new mail while fetching the headers */
if (idata->reopen & IMAP_NEWMAIL_PENDING)
{
msgend = idata->newMailCount - 1;
while ((msgend) >= ctx->hdrmax)
mx_alloc_memory (ctx);
- idata->status &= ~IMAP_NEWMAIL_PENDING;
+ idata->reopen &= ~IMAP_NEWMAIL_PENDING;
+ idata->newMailCount = 0;
}
}
fclose(fp);
+ if (ctx->msgcount > oldmsgcount)
+ mx_update_context (ctx, ctx->msgcount - oldmsgcount);
+
return msgend;
}