Change default value of wl-info-lang
[elisp/wanderlust.git] / elmo / elmo-imap4.el
index aa0c58a..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))))
@@ -749,12 +750,17 @@ Returns response value if selecting folder succeed. "
                "search %s") flag))
      'search)))
 
-(defun elmo-imap4-list-folder (spec)
-  (let ((killed (and elmo-use-killed-list
-                    (elmo-msgdb-killed-list-load
-                     (elmo-msgdb-expand-path spec))))
-       numbers)
-    (setq numbers (elmo-imap4-list spec "all"))
+(defun elmo-imap4-list-folder (spec &optional nohide)
+  (let* ((killed (and elmo-use-killed-list
+                     (elmo-msgdb-killed-list-load
+                      (elmo-msgdb-expand-path spec))))
+        (max (elmo-msgdb-max-of-killed killed))
+        numbers)
+    (setq numbers (elmo-imap4-list spec
+                                  (if (or nohide
+                                          (null (eq max 0)))
+                                      (format "uid %d:*" (1+ max))
+                                    "all")))
     (elmo-living-messages numbers killed)))
 
 (defun elmo-imap4-list-folder-unread (spec number-alist mark-alist
@@ -1274,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
@@ -1346,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))
@@ -1369,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 )))
@@ -1451,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)
@@ -1574,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))))