X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=imap%2Fcommand.c;h=141af125b43a43470c5237487b99b5abbae869eb;hb=b1dfcb5c755ef8c2be60369432bc91e434b72a1f;hp=47cd3edfe53345a4b2c639d0b645e628b4c6c9dd;hpb=6833ce8bdca2d64e14485118f2a4417b7e1cb1b1;p=apps%2Fmadmutt.git diff --git a/imap/command.c b/imap/command.c index 47cd3ed..141af12 100644 --- a/imap/command.c +++ b/imap/command.c @@ -21,6 +21,10 @@ /* command.c: routines for sending commands to an IMAP server and parsing * responses */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "imap_private.h" #include "message.h" @@ -115,7 +119,7 @@ int imap_cmd_step (IMAP_DATA* idata) if (c <= 0) { dprint (1, (debugfile, "imap_cmd_step: Error reading server response.\n")); - cmd_handle_fatal (idata); + /* cmd_handle_fatal (idata); */ return IMAP_CMD_BAD; } @@ -206,6 +210,13 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags) rc = imap_cmd_step (idata); while (rc == IMAP_CMD_CONTINUE); + if (rc == IMAP_CMD_BAD) { + if (imap_reconnect(idata->ctx)!=0) { + return -1; + } + return 0; + } + if (rc == IMAP_CMD_NO && (flags & IMAP_CMD_FAIL_OK)) return -2; @@ -286,10 +297,12 @@ static void cmd_handle_fatal (IMAP_DATA* idata) (idata->reopen & IMAP_REOPEN_ALLOW) && !idata->ctx->closing) { - mx_fastclose_mailbox (idata->ctx); + /*mx_fastclose_mailbox (idata->ctx);*/ mutt_error (_("Mailbox closed")); mutt_sleep (1); idata->state = IMAP_DISCONNECTED; + if (imap_reconnect(idata->ctx)!=0) + mx_fastclose_mailbox(idata->ctx); } if (idata->state != IMAP_SELECTED) @@ -373,12 +386,16 @@ static int cmd_handle_untagged (IMAP_DATA* idata) SKIPWS (s); mutt_error ("%s", s); idata->status = IMAP_BYE; - if (idata->state == IMAP_SELECTED) - mx_fastclose_mailbox (idata->ctx); - mutt_socket_close (idata->conn); - idata->state = IMAP_DISCONNECTED; - return -1; + /*if (imap_reconnect(idata->ctx)!=0) { + if (idata->state == IMAP_SELECTED) + mx_fastclose_mailbox (idata->ctx); */ /* XXX memleak? */ + mutt_socket_close (idata->conn); + idata->state = IMAP_DISCONNECTED; + return -1; + /*} else { + return 0; + } */ } else if (option (OPTIMAPSERVERNOISE) && (ascii_strncasecmp ("NO", s, 2) == 0)) { @@ -395,7 +412,7 @@ static int cmd_handle_untagged (IMAP_DATA* idata) /* cmd_make_sequence: make a tag suitable for starting an IMAP command */ static void cmd_make_sequence (IMAP_DATA* idata) { - snprintf (idata->cmd.seq, sizeof (idata->cmd.seq), "a%04d", idata->seqno++); + snprintf (idata->cmd.seq, sizeof (idata->cmd.seq), "a%04u", idata->seqno++); if (idata->seqno > 9999) idata->seqno = 0; @@ -468,19 +485,20 @@ static void cmd_parse_fetch (IMAP_DATA* idata, char* s) msgno = atoi (s); + if (msgno <= idata->ctx->msgcount) /* see cmd_parse_expunge */ - for (cur = 0; cur < idata->ctx->msgcount; cur++) - { - h = idata->ctx->hdrs[cur]; - - if (h->active && h->index+1 == msgno) + for (cur = 0; cur < idata->ctx->msgcount; cur++) { - dprint (2, (debugfile, "Message UID %d updated\n", HEADER_DATA(h)->uid)); - break; + h = idata->ctx->hdrs[cur]; + + if (h->active && h->index+1 == msgno) + { + dprint (2, (debugfile, "Message UID %d updated\n", HEADER_DATA(h)->uid)); + break; + } + + h = NULL; } - - h = NULL; - } if (!h) {