Import No Gnus v0.4.
[elisp/gnus.git-] / lisp / imap.el
index 238e0b9..6d489b6 100644 (file)
@@ -1,6 +1,7 @@
 ;;; imap.el --- imap library
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-;;        Free Software Foundation, Inc.
+
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <jas@pdc.kth.se>
 ;; Keywords: mail
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -171,8 +172,7 @@ the list is tried until a successful connection is made."
   :type '(repeat string))
 
 (defcustom imap-gssapi-program (list
-                               (concat "gsasl --client --connect %s:%p "
-                                       "--imap --application-data "
+                               (concat "gsasl %s %p "
                                        "--mechanism GSSAPI "
                                        "--authentication-id %l")
                                "imtest -m gssapi -u %l -p %p %s")
@@ -588,6 +588,13 @@ sure of changing the value of `foo'."
            (while (and (memq (process-status process) '(open run))
                        (set-buffer buffer) ;; XXX "blue moon" nntp.el bug
                        (goto-char (point-min))
+                       ;; Athena IMTEST can output SSL verify errors
+                       (or (while (looking-at "^verify error:num=")
+                             (forward-line))
+                           t)
+                       (or (while (looking-at "^TLS connection established")
+                             (forward-line))
+                           t)
                        ;; cyrus 1.6.x (13? < x <= 22) queries capabilities
                        (or (while (looking-at "^C:")
                              (forward-line))
@@ -596,6 +603,10 @@ sure of changing the value of `foo'."
                        (or (not (looking-at "S: "))
                            (forward-char 3)
                            t)
+                       ;; GNU SASL may print 'Trying ...' first.
+                       (or (not (looking-at "Trying "))
+                           (forward-line)
+                           t)
                        (not (and (imap-parse-greeting)
                                  ;; success in imtest 1.6:
                                  (re-search-forward
@@ -638,6 +649,10 @@ sure of changing the value of `foo'."
             (coding-system-for-read imap-coding-system-for-read)
             (coding-system-for-write imap-coding-system-for-write)
             (process-connection-type imap-process-connection-type)
+            (set-process-query-on-exit-flag
+             (if (fboundp 'set-process-query-on-exit-flag)
+                 'set-process-query-on-exit-flag
+               'process-kill-without-query))
             process)
        (when (progn
                (setq process (start-process
@@ -647,7 +662,7 @@ sure of changing the value of `foo'."
                                            (format-spec-make
                                             ?s server
                                             ?p (number-to-string port)))))
-               (process-kill-without-query process)
+               (funcall set-process-query-on-exit-flag process nil)
                process)
          (with-current-buffer buffer
            (goto-char (point-min))
@@ -1087,8 +1102,11 @@ necessary.  If nil, the buffer name is generated."
                           stream))
                      ;; We're done, kill the first connection
                      (imap-close buffer)
-                     (kill-buffer buffer)
-                     (rename-buffer buffer)
+                     (let ((name (if (stringp buffer)
+                                     buffer
+                                   (buffer-name buffer))))
+                       (kill-buffer buffer)
+                       (rename-buffer name))
                      (message "imap: Reconnecting with stream `%s'...done"
                               stream)
                      (setq imap-stream stream)