* WL-ELS (SASL-MODULES): Remove sasl-scram, md4, ntlm,
[elisp/wanderlust.git] / elmo / elmo-imap4.el
index ba3c1af..e3296bd 100644 (file)
@@ -661,7 +661,7 @@ BUFFER must be a single-byte buffer."
   (if elmo-use-server-diff
       (elmo-imap4-server-diff spec)
     (elmo-generic-folder-diff spec folder number-list)))
-    
+
 (defun elmo-imap4-get-session (spec &optional if-exists)
   (elmo-network-get-session
    'elmo-imap4-session
@@ -1272,31 +1272,31 @@ If optional argument UNMARK is non-nil, unmark."
                   session
                   (concat "AUTHENTICATE " name
                           (and (sasl-step-data step)
-                               (concat 
+                               (concat
                                 " "
                                 (elmo-base64-encode-string
                                  (sasl-step-data step)
-                                 'no-lin-break)))))) ;)
+                                 'no-lin-break))))))
            (catch 'done
              (while t
                (setq response
                      (elmo-imap4-read-untagged
                       (elmo-network-session-process-internal session)))
-               (if (elmo-imap4-response-continue-req-p response)
-                   (unless (sasl-next-step client step)
-                     ;; response is '+' but there's no next step.
-                     (signal 'elmo-authenticate-error
-                             (list (intern
-                                    (concat "elmo-imap4-auth-"
-                                            (downcase name))))))
-                 ;; response is OK.
-                 (if (elmo-imap4-response-ok-p response)
-                     (throw 'done nil) ; finished.
-                   ;; response is NO or BAD.
-                   (signal 'elmo-authenticate-error
-                           (list (intern
-                                  (concat "elmo-imap4-auth-"
-                                          (downcase name)))))))
+               (if (elmo-imap4-response-ok-p response)
+                   (if (sasl-next-step client step)
+                       ;; Bogus server?
+                       (signal 'elmo-authenticate-error
+                               (list (intern
+                                      (concat "elmo-imap4-auth-"
+                                              (downcase name)))))
+                     ;; The authentication process is finished.
+                     (throw 'done nil)))
+               (unless (elmo-imap4-response-continue-req-p response)
+                 ;; response is NO or BAD.
+                 (signal 'elmo-authenticate-error
+                         (list (intern
+                                (concat "elmo-imap4-auth-"
+                                        (downcase name))))))
                (sasl-step-set-data
                 step
                 (elmo-base64-decode-string
@@ -1356,10 +1356,10 @@ If optional argument UNMARK is non-nil, unmark."
        'fetch)))))
 
 (defun elmo-imap4-prefetch-msg (spec msg outbuf)
-  (elmo-imap4-read-msg spec msg outbuf 'unseen))
+  (elmo-imap4-read-msg spec msg outbuf nil 'unseen))
 
 (defun elmo-imap4-read-msg (spec msg outbuf
-                                &optional leave-seen-flag-untouched)
+                                &optional msgdb leave-seen-flag-untouched)
   (let ((session (elmo-imap4-get-session spec))
        response)
     (elmo-imap4-session-select-mailbox session
@@ -1371,15 +1371,14 @@ If optional argument UNMARK is non-nil, unmark."
          (elmo-imap4-send-command-wait session
                                        (format
                                         (if elmo-imap4-use-uid
-                                            "uid fetch %s rfc822%s"
-                                          "fetch %s rfc822%s")
+                                            "uid fetch %s body%s[]"
+                                          "fetch %s body%s[]")
                                         msg
                                         (if leave-seen-flag-untouched
                                             ".peek" ""))))
-    (and (setq response (elmo-imap4-response-value
+    (and (setq response (elmo-imap4-response-bodydetail-text
                         (elmo-imap4-response-value-all
-                         response 'fetch )
-                        'rfc822))
+                         response 'fetch )))
         (with-current-buffer outbuf
           (erase-buffer)
           (insert response)
@@ -1583,6 +1582,7 @@ Return nil if no complete line has arrived."
 
 (defun elmo-imap4-arrival-filter (proc string)
   "IMAP process filter."
+  (when (buffer-live-p (process-buffer proc))
   (with-current-buffer (process-buffer proc)
     (elmo-imap4-debug "-> %s" string)
     (goto-char (point-max))
@@ -1610,7 +1610,7 @@ Return nil if no complete line has arrived."
                    (t
                     (message "Unknown state %s in arrival filter"
                              elmo-imap4-status))))
-         (delete-region (point-min) (point-max)))))))
+         (delete-region (point-min) (point-max))))))))
 
 ;; IMAP parser.