<<< Date Index >>>     <<< Thread Index >>>

[PATCH] Fix CAPABILITY handling for IMAP



Hi,

for some time now I wanted to play with IDLE. Though advertised in the CAPABILITY response, mutt wouldn't want to use it even with $imap_idle set.

Now I had time to track it down: the server sends different responses: only IMAP4rev1 and AUTH=... before authentication but much more items after authentication.

I don't know the IMAP code too well so I think it sends the first CAPABILITY line regardless. The first attached patch makes mutt send it again after authentication for new connections to re-adjust capabilities.

Here mutt then detects the IDLE capability and uses it.

The second patch adds more verbose debugging to the socket layer: print which connection gets what file descriptor and use that when logging socket traffic to distinct between different hosts with identical protocols (it's really hard to debug otherwise).

  bye, Rocco
--
:wq!
diff --git a/imap/imap.c b/imap/imap.c
index 17b445f..2a3eacc 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -378,6 +378,7 @@ IMAP_DATA* imap_conn_find (const ACCOUNT
   {
     /* get root delimiter, '/' as default */
     idata->delim = '/';
+    imap_cmd_queue (idata, "CAPABILITY");
     imap_cmd_queue (idata, "LIST \"\" \"\"");
     if (option (OPTIMAPCHECKSUBSCRIBED))
       imap_cmd_queue (idata, "LSUB \"\" \"*\"");
diff --git a/mutt_socket.c b/mutt_socket.c
index baca445..0ce2a31 100644
--- a/mutt_socket.c
+++ b/mutt_socket.c
@@ -56,10 +56,18 @@ static CONNECTION* socket_new_conn (void
 /* Wrappers */
 int mutt_socket_open (CONNECTION* conn) 
 {
+  int rc;
+
   if (socket_preconnect ())
     return -1;
 
-  return conn->conn_open (conn);
+  rc = conn->conn_open (conn);
+
+  dprint (1, (debugfile, "talking to %s:%d for user=%s/login=%s on fd=%d\n",
+             NONULL (conn->account.host), conn->account.port,
+             NONULL (conn->account.user), NONULL (conn->account.login), 
conn->fd));
+
+  return rc;
 }
 
 int mutt_socket_close (CONNECTION* conn)
@@ -104,7 +112,7 @@ int mutt_socket_write_d (CONNECTION *con
 {
   int rc;
 
-  dprint (dbg, (debugfile,"> %s", buf));
+  dprint (dbg, (debugfile,"%d > %s", conn->fd, buf));
 
   if (conn->fd < 0)
   {
@@ -200,7 +208,7 @@ int mutt_socket_readln_d (char* buf, siz
   else
     buf[i] = '\0';
 
-  dprint (dbg, (debugfile, "< %s\n", buf));
+  dprint (dbg, (debugfile, "%d < %s\n", conn->fd, buf));
   
   /* number of bytes read, not strlen */
   return i + 1;