Change default value of wl-info-lang
[elisp/wanderlust.git] / elmo / elmo-imap4.el
index 0706591..624da68 100644 (file)
     elmo-imap4-status-callback-data
     elmo-imap4-current-msgdb))
 
+(defvar elmo-imap4-display-literal-progress nil)
 ;;;;
 
 (defconst elmo-imap4-quoted-specials-list '(?\\ ?\"))
@@ -530,7 +531,7 @@ BUFFER must be a single-byte buffer."
                     elmo-default-imap4-user)
       (setq append-serv (concat ":" (elmo-imap4-spec-username spec))))
     (unless (eq (elmo-imap4-spec-auth spec)
-               elmo-default-imap4-authenticate-type)
+               (or elmo-default-imap4-authenticate-type 'clear))
       (setq append-serv 
            (concat append-serv "/" (symbol-name (elmo-imap4-spec-auth spec)))))
     (unless (string= (elmo-imap4-spec-hostname spec)
@@ -568,7 +569,7 @@ BUFFER must be a single-byte buffer."
                              (mapcar '(lambda (fld)
                                         (unless
                                             (string-match
-                                             (concat "^" (regexp-quote folder))
+                                             (concat "^" (regexp-quote folder) delim)
                                              fld)
                                           fld))
                                      result))))
@@ -1279,31 +1280,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
@@ -1351,16 +1352,25 @@ If optional argument UNMARK is non-nil, unmark."
     (with-current-buffer (elmo-network-session-buffer session)
       (setq elmo-imap4-fetch-callback nil)
       (setq elmo-imap4-fetch-callback-data nil))
-    (elmo-delete-cr
-     (elmo-imap4-response-bodydetail-text
-      (elmo-imap4-response-value-all
-       (elmo-imap4-send-command-wait session
-                                    (format
-                                     (if elmo-imap4-use-uid
-                                         "uid fetch %s body.peek[%s]"
-                                       "fetch %s body.peek[%s]")
-                                     msg part))
-       'fetch)))))
+    (unless elmo-inhibit-display-retrieval-progress
+      (setq elmo-imap4-display-literal-progress t))
+    (prog1
+       (unwind-protect
+           (elmo-delete-cr
+            (elmo-imap4-response-bodydetail-text
+             (elmo-imap4-response-value-all
+              (elmo-imap4-send-command-wait session
+                                            (format
+                                             (if elmo-imap4-use-uid
+                                                 "uid fetch %s body.peek[%s]"
+                                               "fetch %s body.peek[%s]")
+                                             msg part))
+              'fetch)))
+         (setq elmo-imap4-display-literal-progress nil))
+      (unless elmo-inhibit-display-retrieval-progress
+       (elmo-display-progress 'elmo-imap4-display-literal-progress
+                              "" 100)  ; remove progress bar.
+       (message "Retrieving...done.")))))
 
 (defun elmo-imap4-prefetch-msg (spec msg outbuf)
   (elmo-imap4-read-msg spec msg outbuf nil 'unseen))
@@ -1374,15 +1384,23 @@ If optional argument UNMARK is non-nil, unmark."
     (with-current-buffer (elmo-network-session-buffer session)
       (setq elmo-imap4-fetch-callback nil)
       (setq elmo-imap4-fetch-callback-data nil))
-    (setq response
-         (elmo-imap4-send-command-wait session
-                                       (format
-                                        (if elmo-imap4-use-uid
-                                            "uid fetch %s body%s[]"
-                                          "fetch %s body%s[]")
-                                        msg
-                                        (if leave-seen-flag-untouched
-                                            ".peek" ""))))
+    (unless elmo-inhibit-display-retrieval-progress
+      (setq elmo-imap4-display-literal-progress t))
+    (unwind-protect
+       (setq response
+             (elmo-imap4-send-command-wait session
+                                           (format
+                                            (if elmo-imap4-use-uid
+                                                "uid fetch %s body%s[]"
+                                              "fetch %s body%s[]")
+                                            msg
+                                            (if leave-seen-flag-untouched
+                                                ".peek" ""))))
+      (setq elmo-imap4-display-literal-progress nil))
+    (unless elmo-inhibit-display-retrieval-progress
+      (elmo-display-progress 'elmo-imap4-display-literal-progress
+                            "" 100)  ; remove progress bar.
+      (message "Retrieving...done."))    
     (and (setq response (elmo-imap4-response-bodydetail-text
                         (elmo-imap4-response-value-all
                          response 'fetch )))
@@ -1456,20 +1474,20 @@ If optional argument UNMARK is non-nil, unmark."
 
 (defun elmo-imap4-append-msg (spec string &optional msg no-see)
   (let ((session (elmo-imap4-get-session spec))
-       send-buf)
+       send-buf result)
     (elmo-imap4-session-select-mailbox session
                                       (elmo-imap4-spec-mailbox spec))
     (setq send-buf (elmo-imap4-setup-send-buffer string))
     (unwind-protect
-       (elmo-imap4-send-command-wait
-        session
-        (list
-         "append "
-         (elmo-imap4-mailbox (elmo-imap4-spec-mailbox spec))
-         (if no-see " " " (\\Seen) ")
-         (elmo-imap4-buffer-literal send-buf)))
-      (kill-buffer send-buf)))
-  t)
+       (setq result (elmo-imap4-send-command-wait
+                     session
+                     (list
+                      "append "
+                      (elmo-imap4-mailbox (elmo-imap4-spec-mailbox spec))
+                      (if no-see " " " (\\Seen) ")
+                      (elmo-imap4-buffer-literal send-buf))))
+      (kill-buffer send-buf))
+    result))
 
 (defun elmo-imap4-copy-msgs (dst-spec
                             msgs src-spec &optional expunge-it same-number)
@@ -1579,7 +1597,18 @@ Return nil if no complete line has arrived."
                           nil t)
     (if (match-string 1)
        (if (< (point-max) (+ (point) (string-to-number (match-string 1))))
-           nil
+           (progn
+             (if (and elmo-imap4-display-literal-progress
+                      (> (string-to-number (match-string 1))
+                         (min elmo-display-retrieval-progress-threshold 100)))
+                 (elmo-display-progress
+                  'elmo-imap4-display-literal-progress
+                  (format "Retrieving (%d/%d bytes)..."
+                          (- (point-max) (point))
+                          (string-to-number (match-string 1)))
+                  (/ (- (point-max) (point))
+                     (/ (string-to-number (match-string 1)) 100))))
+             nil)
          (goto-char (+ (point) (string-to-number (match-string 1))))
          (elmo-imap4-find-next-line))
       (point))))