summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-09-23 21:03:00 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-09-23 21:03:00 +0000
commit6be24609f8fb6097a328364718d6bc9ab86070e4 (patch)
tree0b83666f17cc98deeb41d079ca93473f4fd0863d /imap
parent77a33a93661c724890491e42b2f0c1f7c277d875 (diff)
Brendan Cully's latest changes:
* includes all of my last patch, since it hasn't been committed yet. * catches a couple segfault problems if Context is NULL. * works harder to avoid sending null STORE FLAGS commands. May not be perfect yet, but also has extra debugging code. * has the beginnings of a more interactive IMAP error handler. Doesn't do anything yet, I'm just including it because I want to get the rest of the patch out.
Diffstat (limited to 'imap')
-rw-r--r--imap/BUGS7
-rw-r--r--imap/imap.c32
-rw-r--r--imap/imap_private.h2
-rw-r--r--imap/socket.c4
-rw-r--r--imap/util.c6
5 files changed, 30 insertions, 21 deletions
diff --git a/imap/BUGS b/imap/BUGS
index bdf54fe9..357de91b 100644
--- a/imap/BUGS
+++ b/imap/BUGS
@@ -1,13 +1,10 @@
In no particular order:
+* Mutt is uninterruptible during socket calls. We should handle SIGINT.
+
* Not really an IMAP bug, but postponed-message checking is done too often,
incurring needless network overhead.
-* Server copy won't be able to implement decode/decrypt options to
- message saving. If people want this we'll have to add a new variable
- which, when set, causes mutt to fetch, transform and append instead of
- using server copy.
-
* Server copy currently doesn't take into account uncommitted changes in
messages about to be copied. Sync first.
diff --git a/imap/imap.c b/imap/imap.c
index b696c9dc..ddbfb7b8 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -728,7 +728,8 @@ static char* imap_get_flags (LIST** hflags, char* s)
s++;
ctmp = *s;
*s = '\0';
- mutt_add_list (flags, flag_word);
+ if (*flag_word)
+ mutt_add_list (flags, flag_word);
*s = ctmp;
}
@@ -737,6 +738,8 @@ static char* imap_get_flags (LIST** hflags, char* s)
{
dprint (1, (debugfile,
"imap_get_flags: Unterminated FLAGS response: %s\n", s));
+ mutt_free_list (hflags);
+
return NULL;
}
@@ -881,16 +884,15 @@ int imap_open_mailbox (CONTEXT *ctx)
mutt_error (s);
idata->state = IMAP_AUTHENTICATED;
sleep (1);
- return (-1);
+ return -1;
}
if (mutt_bit_isset (idata->capabilities, ACL))
{
if (imap_check_acl (idata))
- {
- return (-1);
- }
+ return -1;
}
+ /* assume we have all rights if ACL is unavailable */
else
{
mutt_bit_set (idata->rights, IMAP_ACL_LOOKUP);
@@ -1232,7 +1234,8 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge)
flags);
/* now make sure we don't lose custom tags */
- imap_add_keywords (flags, ctx->hdrs[n], CTX_DATA->flags);
+ if (mutt_bit_isset (CTX_DATA->rights, IMAP_ACL_WRITE))
+ imap_add_keywords (flags, ctx->hdrs[n], CTX_DATA->flags);
mutt_remove_trailing_ws (flags);
@@ -1253,10 +1256,17 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge)
else
snprintf (buf, sizeof (buf), "STORE %d FLAGS.SILENT (%s)",
ctx->hdrs[n]->index + 1, flags);
- if (imap_exec (buf, sizeof (buf), CTX_DATA, buf, 0) != 0)
+
+ /* after all this it's still possible to have no flags, if you
+ * have no ACL rights */
+ if (*flags && imap_exec (buf, sizeof (buf), CTX_DATA, buf, 0) != 0)
{
- imap_error ("imap_sync_mailbox()", buf);
- /* Give up on this message if we pass here again */
+ /* Rex Walters indicates that sometimes an empty flag set
+ * is still executed. How? */
+ dprint(2, (debugfile, "imap_sync_mailbox: flags[0]: [%c] flags: %s",
+ flags[0], flags));
+ imap_error ("imap_sync_mailbox: STORE failed", buf);
+ /* give up on this message if we pass here again */
ctx->hdrs[n]->changed = 0;
return -1;
}
@@ -1274,7 +1284,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge)
mutt_message _("Closing mailbox...");
if (imap_exec (buf, sizeof (buf), CTX_DATA, "CLOSE", 0) != 0)
{
- imap_error ("imap_sync_mailbox()", buf);
+ imap_error ("imap_sync_mailbox: CLOSE failed", buf);
return -1;
}
CTX_DATA->state = IMAP_AUTHENTICATED;
@@ -1285,7 +1295,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge)
CTX_DATA->status = IMAP_EXPUNGE;
if (imap_exec (buf, sizeof (buf), CTX_DATA, "EXPUNGE", 0) != 0)
{
- imap_error ("imap_sync_mailbox()", buf);
+ imap_error ("imap_sync_mailbox: EXPUNGE failed", buf);
return -1;
}
CTX_DATA->status = 0;
diff --git a/imap/imap_private.h b/imap/imap_private.h
index 31a29af9..0b67c606 100644
--- a/imap/imap_private.h
+++ b/imap/imap_private.h
@@ -168,7 +168,7 @@ void imap_free_header_data (void** data);
int imap_read_headers (CONTEXT* ctx, int msgbegin, int msgend);
/* util.c */
-void imap_error (const char* where, const char* msg);
+int 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);
diff --git a/imap/socket.c b/imap/socket.c
index 75f7c7d4..a31f7fdf 100644
--- a/imap/socket.c
+++ b/imap/socket.c
@@ -70,13 +70,13 @@ int mutt_socket_read_line (char *buf, size_t buflen, CONNECTION *conn)
int mutt_socket_read_line_d (char *buf, size_t buflen, CONNECTION *conn)
{
int r = mutt_socket_read_line (buf, buflen, conn);
- dprint (1,(debugfile,"mutt_socket_read_line_d():%s\n", buf));
+ dprint (1,(debugfile,"< %s\n", buf));
return r;
}
int mutt_socket_write (CONNECTION *conn, const char *buf)
{
- dprint (1,(debugfile,"mutt_socket_write():%s", buf));
+ dprint (1,(debugfile,"> %s", buf));
return (write (conn->fd, buf, mutt_strlen (buf)));
}
diff --git a/imap/util.c b/imap/util.c
index b8a94c83..594d7554 100644
--- a/imap/util.c
+++ b/imap/util.c
@@ -29,9 +29,11 @@
/* 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 */
-void imap_error (const char *where, const char *msg)
+int imap_error (const char *where, const char *msg)
{
- mutt_error (_("imap_error(): unexpected response in %s: %s\n"), where, msg);
+ mutt_error (_("%s [%s]\n"), where, msg);
+ sleep (2);
+ return mutt_yesorno (_("Continue?"), 0);
}
/*