3 # User Brendan Cully <brendan@kublai.com>
5 # Node ID 0bb4645e994b24bb8b3e5c450a5b040028b4354d
6 # Parent eda7244885d12b4f22fa3b38369c997560cc4a69
7 Add imap_close_connection to fully reset IMAP state. (closes: #2717)
8 Thanks to Sergey Svishchev for the original patch.
10 --- a/imap/command.c Wed Feb 28 16:27:47 2007 +0000
11 +++ b/imap/command.c Wed Feb 28 17:47:13 2007 +0000
12 @@ -375,11 +375,7 @@ static void cmd_handle_fatal (IMAP_DATA*
15 if (idata->state < IMAP_SELECTED)
17 - idata->state = IMAP_DISCONNECTED;
18 - mutt_socket_close (idata->conn);
21 + imap_close_connection (idata);
24 /* cmd_handle_untagged: fallback parser for otherwise unhandled messages. */
25 --- a/imap/imap.c Wed Feb 28 16:27:47 2007 +0000
26 +++ b/imap/imap.c Wed Feb 28 17:47:13 2007 +0000
27 @@ -399,8 +399,7 @@ int imap_open_connection (IMAP_DATA* ida
29 if (imap_cmd_step (idata) != IMAP_CMD_CONTINUE)
31 - mutt_socket_close (idata->conn);
32 - idata->state = IMAP_DISCONNECTED;
33 + imap_close_connection (idata);
37 @@ -467,12 +466,19 @@ int imap_open_connection (IMAP_DATA* ida
41 - mutt_socket_close (idata->conn);
42 - idata->state = IMAP_DISCONNECTED;
43 + imap_close_connection (idata);
46 FREE (&idata->capstr);
50 +void imap_close_connection(IMAP_DATA* idata)
52 + mutt_socket_close (idata->conn);
53 + idata->state = IMAP_DISCONNECTED;
54 + idata->seqno = idata->nextcmd = idata->lastcmd = idata->status = 0;
55 + memset (idata->cmds, 0, sizeof (IMAP_COMMAND) * IMAP_PIPELINE_DEPTH);
58 /* imap_get_flags: Make a simple list out of a FLAGS response.
59 --- a/imap/imap_private.h Wed Feb 28 16:27:47 2007 +0000
60 +++ b/imap/imap_private.h Wed Feb 28 17:47:13 2007 +0000
61 @@ -235,6 +235,7 @@ int imap_make_msg_set (IMAP_DATA* idata,
62 int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed,
64 int imap_open_connection (IMAP_DATA* idata);
65 +void imap_close_connection (IMAP_DATA* idata);
66 IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags);
67 int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes, progress_t*);
68 void imap_expunge_mailbox (IMAP_DATA* idata);