diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-11-02 15:49:52 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-11-02 15:49:52 +0000 |
commit | 723cfce3208aa0ac111f6ccd3165612b17c17ae6 (patch) | |
tree | a7549bf5b76de2d53a9de4a1e88145ac8e7306ce /imap | |
parent | 0cc41dfffdfd1b74cc2004aec6bf11c4573203f7 (diff) |
Various IMAP-related fixes from Brendan Cully.
Diffstat (limited to 'imap')
-rw-r--r-- | imap/BUGS | 17 | ||||
-rw-r--r-- | imap/command.c | 11 | ||||
-rw-r--r-- | imap/imap.c | 5 | ||||
-rw-r--r-- | imap/imap_private.h | 6 | ||||
-rw-r--r-- | imap/message.c | 15 | ||||
-rw-r--r-- | imap/util.c | 31 |
6 files changed, 56 insertions, 29 deletions
@@ -1,5 +1,11 @@ In no particular order: +* No checks are performed on long commands to make sure that they are + still correct after they've been made to fit in their buffers. + Tagged message sets can exceed the fixed space we've allocated for + them in large mailboxes. Time to move to dynamic string allocation, + at least for these commands. + * Mutt doesn't handle timeouts or dropped connections gracefully. You may see occasional segfaults. Solving this cleanly requires some major architectural updates. Until that happens, I recommend you keep @@ -9,15 +15,6 @@ In no particular order: files. I haven't been able to reproduce this, and am not sure how to track it down. But it's very naughty indeed. -* Mutt sometimes doesn't notice new mail has arrived until you've opened - another folder, leading to the wrong number of messages being downloaded. - To make matters worse, imap_read_headers doesn't detect the * BAD response. - --> note: although the command structure may change, currently this can - be handled by adding imap_cmd_finish after any command which may - operate in the SELECTED state. - Also any code that does SELECT (eg imap_open_mailbox) should be - taking care to reset IMAP_DATA state on success. Apparently it's not. - * Mutt marks your connection for logout as soon as you say quit, even if you bail out with ^G later. --> This should be fixed by not using imap_set_logout. Instead there @@ -43,4 +40,4 @@ In no particular order: * The mutt_pretty routines don't work well when the delimiter isn't '/'. Brendan Cully <brendan@kublai.com> -Updated 19991030 +Updated 19991102 diff --git a/imap/command.c b/imap/command.c index 4755e013..12ecf492 100644 --- a/imap/command.c +++ b/imap/command.c @@ -244,6 +244,17 @@ int imap_handle_untagged (IMAP_DATA *idata, char *s) return 0; } +/* imap_make_sequence: make a tag suitable for starting an IMAP command */ +void imap_make_sequence (char *buf, size_t buflen) +{ + static int sequence = 0; + + snprintf (buf, buflen, "a%04d", sequence++); + + if (sequence > 9999) + sequence = 0; +} + /* cmd_parse_capabilities: set capability bits according to CAPABILITY * response */ static void cmd_parse_capabilities (IMAP_DATA *idata, char *s) diff --git a/imap/imap.c b/imap/imap.c index 9b081d32..a9998629 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -551,7 +551,8 @@ int imap_open_mailbox (CONTEXT *ctx) idata->selected_ctx = ctx; - /* clear ACL */ + /* clear status, ACL */ + idata->status = 0; memset (idata->rights, 0, (RIGHTSMAX+7)/8); mutt_message (_("Selecting %s..."), idata->selected_mailbox); @@ -1026,7 +1027,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge) if (*flags && (imap_exec (buf, sizeof (buf), CTX_DATA, buf, 0) != 0) && (err_continue != M_YES)) { - err_continue = imap_error ("imap_sync_mailbox: STORE failed", buf); + err_continue = imap_continue ("imap_sync_mailbox: STORE failed", buf); if (err_continue != M_YES) return -1; } diff --git a/imap/imap_private.h b/imap/imap_private.h index 70cc3d22..6a5c3fe7 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -167,6 +167,7 @@ int imap_code (const char* s); int imap_exec (char* buf, size_t buflen, IMAP_DATA* idata, const char* cmd, int flags); int imap_handle_untagged (IMAP_DATA* idata, char* s); +void imap_make_sequence (char *buf, size_t buflen); /* message.c */ void imap_add_keywords (char* s, HEADER* keywords, LIST* mailbox_flags); @@ -174,11 +175,12 @@ void imap_free_header_data (void** data); int imap_read_headers (CONTEXT* ctx, int msgbegin, int msgend); /* util.c */ -int imap_error (const char* where, const char* msg); +int imap_continue (const char* msg, const char* resp); +void imap_error (const char* where, const char* msg); char* imap_fix_path (IMAP_DATA* idata, char* mailbox, char* path, size_t plen); int imap_get_literal_count (const char* buf, long* bytes); -void imap_make_sequence (char *buf, size_t buflen); +char* imap_get_qualifier (char* buf); char* imap_next_word (char* s); void imap_quote_string (char* dest, size_t slen, const char* src); void imap_unquote_string (char* s); diff --git a/imap/message.c b/imap/message.c index e37bfb4a..9b143259 100644 --- a/imap/message.c +++ b/imap/message.c @@ -517,7 +517,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg) * 1: non-fatal error - try fetch/append */ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) { - char buf[LONG_STRING]; + char buf[HUGE_STRING]; char cmd[LONG_STRING]; char mbox[LONG_STRING]; char host[SHORT_STRING]; @@ -565,12 +565,21 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) rc = imap_exec (buf, sizeof (buf), CTX_DATA, cmd, IMAP_OK_FAIL); if (rc == -2) { - /* command failed because folder doesn't exist */ + /* bail out if command failed for reasons other than nonexistent target */ + if (strncmp (imap_get_qualifier (buf), "[TRYCREATE]", 11)) + { + imap_error ("imap_copy_messages", buf); + return -1; + } + dprint (2, (debugfile, "imap_copy_messages: server suggests TRYCREATE\n")); if (option (OPTCONFIRMCREATE)) { snprintf (buf, sizeof (buf), _("Create %s?"), mbox); if (mutt_yesorno (buf, 1) < 1) + { + mutt_clear_error (); return -1; + } if (imap_create_mailbox (CTX_DATA, mbox) < 0) return -1; } @@ -587,7 +596,6 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) if (delete) { if (!h) - { for (n = 0; n < ctx->msgcount; n++) { if (ctx->hdrs[n]->tagged) @@ -597,7 +605,6 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0); } } - } else { mutt_set_flag (ctx, h, M_DELETE, 1); diff --git a/imap/util.c b/imap/util.c index 02a94ba1..5e6d7f71 100644 --- a/imap/util.c +++ b/imap/util.c @@ -26,13 +26,19 @@ #include <stdlib.h> #include <ctype.h> -/* imap_error: handle IMAP errors. Should be expanded to display the error - * to the user and ask whether to continue, return result code to caller */ -int imap_error (const char *where, const char *msg) +/* imap_continue: display a message and ask the user if she wants to + * go on. */ +int imap_continue (const char* msg, const char* resp) +{ + imap_error (msg, resp); + return mutt_yesorno (_("Continue?"), 0); +} + +/* imap_error: show an error and abort */ +void imap_error (const char *where, const char *msg) { mutt_error (_("%s [%s]\n"), where, msg); sleep (2); - return mutt_yesorno (_("Continue?"), 0); } /* @@ -89,15 +95,18 @@ int imap_get_literal_count(const char *buf, long *bytes) return (0); } -/* imap_make_sequence: make a tag suitable for starting an IMAP command */ -void imap_make_sequence (char *buf, size_t buflen) +/* imap_get_qualifier: in a tagged response, skip tag and status for + * the qualifier message. Used by imap_copy_message for TRYCREATE */ +char* imap_get_qualifier (char* buf) { - static int sequence = 0; - - snprintf (buf, buflen, "a%04d", sequence++); + char *s = buf; - if (sequence > 9999) - sequence = 0; + /* skip tag */ + s = imap_next_word (s); + /* skip OK/NO/BAD response */ + s = imap_next_word (s); + + return s; } /* imap_next_word: return index into string where next IMAP word begins */ |