diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-11-22 16:01:39 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-11-22 16:01:39 +0000 |
commit | 995c71b07578f1a32cdc550cf4b47d1931bd72d9 (patch) | |
tree | 6c5ff7a7049299b083b0544953c741d31d2e9472 /imap | |
parent | 8c16ab2b84b6624f524bd871e0562ade76fe05ea (diff) |
IMAP folder creation and deletion. From Brendan Cully.
Diffstat (limited to 'imap')
-rw-r--r-- | imap/BUGS | 13 | ||||
-rw-r--r-- | imap/README | 1 | ||||
-rw-r--r-- | imap/TODO | 14 | ||||
-rw-r--r-- | imap/imap.c | 48 | ||||
-rw-r--r-- | imap/imap.h | 3 | ||||
-rw-r--r-- | imap/imap_private.h | 1 | ||||
-rw-r--r-- | imap/message.c | 2 | ||||
-rw-r--r-- | imap/util.c | 27 |
8 files changed, 78 insertions, 31 deletions
@@ -1,5 +1,16 @@ In no particular order: +* Mutt doesn't detect when a mailbox has only been opened read-only + (because, say, another process has it open), so it lets you store + changes that it can't commit. + --> just pick up the [READ-ONLY] in the tagged response, set mutt's flag + +* ~h searches download the entire folder, setting everything to \Seen in + the process. + --> Use SEARCH? or at least try to use .PEEK when doing scans. I've been + thinking of going to always PEEK anyway, but then you'd have to store + updates for every message you touched. Maybe a config option? + * 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 @@ -40,4 +51,4 @@ In no particular order: * The mutt_pretty routines don't work well when the delimiter isn't '/'. Brendan Cully <brendan@kublai.com> -Updated 19991102 +Updated 19991110 diff --git a/imap/README b/imap/README index c91c9571..b45706ad 100644 --- a/imap/README +++ b/imap/README @@ -25,3 +25,4 @@ New features vs. the stable distribution: * Use an IMAP path as your Maildir (set folder='') * Preserve message keywords * Preserve deleted messages if you don't choose to expunge them +* Delete mailboxes (from the browser) @@ -27,6 +27,12 @@ IMAP enhancements, by priority: PRIORITY: [** ] +* See if we can't add more info to the IMAP browser than just name (without + incurring too much overhead). eg which folders contain new mail, size, + number of messages. + + PRIORITY: [** ] + [ -- speed -- ] * Persistent caching of data. I think the nicest way to do this is to store local copies like IMAP does, with an invisible control message at the top, @@ -44,6 +50,12 @@ IMAP enhancements, by priority: PRIORITY: [* ] +* Instead of testing for the existence of a mailbox for APPEND, just append + and create/retry on failure. This is only a small bandwidth savings, but + it should be easy. + + PRIORITY: [* ] + [ -- new features -- ] * Implement the received folder on IMAP, now that COPY is done @@ -60,4 +72,4 @@ IMAP enhancements, by priority: PRIORITY: [** ] Brendan Cully <brendan@kublai.com> -Updated: 19990911 +Updated: 19991119 diff --git a/imap/imap.c b/imap/imap.c index 03d1699f..959d32f0 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -42,6 +42,37 @@ static char* imap_get_flags (LIST** hflags, char* s); static int imap_check_acl (IMAP_DATA *idata); static int imap_check_capabilities (IMAP_DATA *idata); +int imap_create_mailbox (CONTEXT* ctx, char* mailbox) +{ + char buf[LONG_STRING], mbox[LONG_STRING]; + + imap_quote_string (mbox, sizeof (mbox), mailbox); + snprintf (buf, sizeof (buf), "CREATE %s", mbox); + + if (imap_exec (buf, sizeof (buf), CTX_DATA, buf, 0) != 0) + { + imap_error ("imap_create_mailbox()", buf); + return -1; + } + return 0; +} + +int imap_delete_mailbox (CONTEXT* ctx, char* mailbox) +{ + char buf[LONG_STRING], mbox[LONG_STRING]; + + imap_quote_string (mbox, sizeof (mbox), mailbox); + snprintf (buf, sizeof (buf), "DELETE %s", mbox); + + if (imap_exec (buf, sizeof (buf), CTX_DATA, buf, 0) != 0) + { + imap_error ("imap_delete_mailbox", buf); + return -1; + } + + return 0; +} + void imap_set_logout (CONTEXT *ctx) { if (CTX_DATA) @@ -712,21 +743,6 @@ int imap_select_mailbox (CONTEXT* ctx, const char* path) return imap_open_mailbox (ctx); } -int imap_create_mailbox (IMAP_DATA* idata, char* mailbox) -{ - char buf[LONG_STRING], mbox[LONG_STRING]; - - imap_quote_string (mbox, sizeof (mbox), mailbox); - snprintf (buf, sizeof (buf), "CREATE %s", mbox); - - if (imap_exec (buf, sizeof (buf), idata, buf, 0) != 0) - { - imap_error ("imap_create_mailbox()", buf); - return (-1); - } - return 0; -} - int imap_open_mailbox_append (CONTEXT *ctx) { CONNECTION *conn; @@ -798,7 +814,7 @@ int imap_open_mailbox_append (CONTEXT *ctx) { return (-1); } - if (imap_create_mailbox (idata, mailbox) < 0) + if (imap_create_mailbox (ctx, mailbox) < 0) { return (-1); } diff --git a/imap/imap.h b/imap/imap.h index 978fe4bd..fd41112d 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -22,8 +22,11 @@ #include "browser.h" #include "mailbox.h" +/* imap.c */ int imap_check_mailbox (CONTEXT *ctx, int *index_hint); +int imap_create_mailbox (CONTEXT* idata, char* mailbox); int imap_close_connection (CONTEXT *ctx); +int imap_delete_mailbox (CONTEXT* idata, char* mailbox); int imap_open_mailbox (CONTEXT *ctx); int imap_open_mailbox_append (CONTEXT *ctx); int imap_select_mailbox (CONTEXT *ctx, const char* path); diff --git a/imap/imap_private.h b/imap/imap_private.h index 62b7a58c..b61e9d08 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -149,7 +149,6 @@ typedef struct /* -- private IMAP functions -- */ /* imap.c */ -int imap_create_mailbox (IMAP_DATA* idata, char* mailbox); int imap_make_msg_set (char* buf, size_t buflen, CONTEXT* ctx, int flag, int changed); int imap_open_connection (IMAP_DATA* idata, CONNECTION* conn); diff --git a/imap/message.c b/imap/message.c index 1b7c16c1..408bbcf8 100644 --- a/imap/message.c +++ b/imap/message.c @@ -580,7 +580,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) mutt_clear_error (); return -1; } - if (imap_create_mailbox (CTX_DATA, mbox) < 0) + if (imap_create_mailbox (ctx, mbox) < 0) return -1; } /* try again */ diff --git a/imap/util.c b/imap/util.c index b02dde96..6bc5d423 100644 --- a/imap/util.c +++ b/imap/util.c @@ -128,19 +128,23 @@ int imap_parse_path (char* path, char* host, size_t hlen, int* port, char *pt; /* set default port */ - *port = 0; + if (port) + *port = 0; if (socktype) *socktype = M_NEW_SOCKET; pc = path; if (*pc != '{') return -1; pc++; - n = 0; - while (*pc && *pc != '}' && *pc != ':' && *pc != '/' && (n < hlen-1)) - host[n++] = *pc++; - host[n] = 0; - /* catch NULL hosts */ - if (!*host) + /* skip over the entire host, but copy in only what we have room for */ + for (n = 0; *pc && *pc != '}' && *pc != ':' && *pc != '/'; pc++) + if (n+1 < hlen) + host[n++] = *pc; + if (hlen) + host[n] = 0; + + /* catch NULL hosts, unless we're deliberately not parsing them */ + if (hlen && !*host) { dprint (1, (debugfile, "imap_parse_path: NULL host in %s\n", path)); return -1; @@ -157,8 +161,9 @@ int imap_parse_path (char* path, char* host, size_t hlen, int* port, return -1; c = *pc; *pc = '\0'; - *port = atoi (pt); - if (!port) + if (port) + *port = atoi (pt); + if (port && !*port) { dprint (1, (debugfile, "imap_parse_path: bad port in %s\n", path)); return -1; @@ -178,7 +183,7 @@ int imap_parse_path (char* path, char* host, size_t hlen, int* port, { if (socktype) *socktype = M_NEW_SSL_SOCKET; - if (!*port) + if (port && !*port) *port = IMAP_SSL_PORT; } else #endif @@ -187,7 +192,7 @@ int imap_parse_path (char* path, char* host, size_t hlen, int* port, } pc++; - if (!*port) + if (port && !*port) *port = IMAP_PORT; *mbox = pc; |