]> granicus.if.org Git - mutt/commitdiff
Extend IMAP host completion to complete over open connections. Next up:
authorBrendan Cully <brendan@kublai.com>
Sun, 7 Aug 2005 21:56:25 +0000 (21:56 +0000)
committerBrendan Cully <brendan@kublai.com>
Sun, 7 Aug 2005 21:56:25 +0000 (21:56 +0000)
account and folder hooks.

imap/imap.c

index 30ba8b68be53c831a30b5d0f6e596691e65ad7df..731258c86865d862f6c8694ae4104e38e14da6f7 100644 (file)
@@ -1426,6 +1426,7 @@ static int
 imap_complete_hosts (char *dest, size_t len)
 {
   BUFFY* mailbox;
+  CONNECTION* conn;
   int rc = -1;
   int matchlen;
   
@@ -1444,6 +1445,31 @@ imap_complete_hosts (char *dest, size_t len)
     }
   }
   
+  for (conn = mutt_socket_head (); conn->next; conn = conn->next)
+  {
+    ciss_url_t url;
+    char urlstr[LONG_STRING];
+
+    if (conn->account.type != M_ACCT_TYPE_IMAP)
+      continue;
+
+    mutt_account_tourl (&conn->account, &url);
+    /* FIXME: how to handle multiple users on the same host? */
+    url.user = NULL;
+    url.path = NULL;
+    url_ciss_tostring (&url, urlstr, sizeof (urlstr), 0);
+    if (!mutt_strncmp (dest, urlstr, matchlen))
+    {
+      if (rc)
+      {
+        strfcpy (dest, urlstr, len);
+        rc = 0;
+      }
+      else
+        longest_common_prefix (dest, urlstr, matchlen, len);
+    }
+  }
+
   return rc;
 }