X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=elmo%2Felmo-pop3.el;h=730c1a37b34360459415d73494a38e08dfc47f97;hb=08fe50f15e7aed9643f87a7cbb552690c6908318;hp=259c311853d655b641d5e011cb783274912e55e4;hpb=9e39553b80115a949a7f04ddced4459a7797f8bd;p=elisp%2Fwanderlust.git diff --git a/elmo/elmo-pop3.el b/elmo/elmo-pop3.el index 259c311..730c1a3 100644 --- a/elmo/elmo-pop3.el +++ b/elmo/elmo-pop3.el @@ -66,15 +66,15 @@ set as non-nil.") "Non-nil forces POP3 folder as debug mode. Debug information is inserted in the buffer \"*POP3 DEBUG*\"") -(defvar elmo-pop3-debug-inhibit-logging nil) - ;;; Debug (defsubst elmo-pop3-debug (message &rest args) (if elmo-pop3-debug - (with-current-buffer (get-buffer-create "*POP3 DEBUG*") - (goto-char (point-max)) - (if elmo-pop3-debug-inhibit-logging - (insert "NO LOGGING\n") + (let ((biff (string-match "BIFF-" (buffer-name))) + pos) + (with-current-buffer (get-buffer-create (concat "*POP3 DEBUG*" + (if biff "BIFF"))) + (goto-char (point-max)) + (setq pos (point)) (insert (apply 'format message args) "\n"))))) ;;; ELMO POP3 folder @@ -149,15 +149,13 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (when (memq (process-status (elmo-network-session-process-internal session)) '(open run)) - (let ((buffer (process-buffer - (elmo-network-session-process-internal session)))) - (elmo-pop3-send-command (elmo-network-session-process-internal session) - "quit") - ;; process is dead. - (or (elmo-pop3-read-response - (elmo-network-session-process-internal session) - t) - (error "POP error: QUIT failed")))) + (elmo-pop3-send-command (elmo-network-session-process-internal session) + "quit") + ;; process is dead. + (or (elmo-pop3-read-response + (elmo-network-session-process-internal session) + t) + (error "POP error: QUIT failed"))) (kill-buffer (process-buffer (elmo-network-session-process-internal session))) (delete-process (elmo-network-session-process-internal session)))) @@ -167,15 +165,20 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") nil (elmo-pop3-folder-use-uidl-internal folder)))) - (elmo-network-get-session 'elmo-pop3-session "POP3" folder if-exists))) - -(defun elmo-pop3-send-command (process command &optional no-erase) + (elmo-network-get-session 'elmo-pop3-session + (concat + (if (elmo-folder-biff-internal folder) + "BIFF-") + "POP3") + folder if-exists))) + +(defun elmo-pop3-send-command (process command &optional no-erase no-log) (with-current-buffer (process-buffer process) (unless no-erase (erase-buffer)) (goto-char (point-min)) (setq elmo-pop3-read-point (point)) - (elmo-pop3-debug "SEND: %s\n" command) + (elmo-pop3-debug "SEND: %s\n" (if no-log "" command)) (process-send-string process command) (process-send-string process "\r\n"))) @@ -190,7 +193,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (while response-continue (goto-char elmo-pop3-read-point) (while (not (re-search-forward "\r?\n" nil t)) - (accept-process-output process) + (accept-process-output process 1) (goto-char elmo-pop3-read-point)) (setq match-end (point)) (setq response-string @@ -220,8 +223,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") return-value))) (defun elmo-pop3-process-filter (process output) - (save-excursion - (set-buffer (process-buffer process)) + (with-current-buffer (process-buffer process) (goto-char (point-max)) (insert output) (elmo-pop3-debug "RECEIVED: %s\n" output) @@ -240,18 +242,24 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") ;; try USER/PASS (elmo-pop3-send-command process - (format "user %s" (elmo-network-session-user-internal session))) + (format "user %s" (elmo-network-session-user-internal session)) + nil 'no-log) (or (elmo-pop3-read-response process t) - (signal 'elmo-authenticate-error - '(elmo-pop-auth-user))) + (progn + (delete-process process) + (signal 'elmo-authenticate-error + '(elmo-pop-auth-user)))) (elmo-pop3-send-command process (format "pass %s" (elmo-get-passwd - (elmo-network-session-password-key session)))) + (elmo-network-session-password-key session))) + nil 'no-log) (or (elmo-pop3-read-response process t) - (signal 'elmo-authenticate-error - '(elmo-pop-auth-user))))) + (progn + (delete-process process) + (signal 'elmo-authenticate-error + '(elmo-pop-auth-user)))))) (defun elmo-pop3-auth-apop (session) (if (string-match "^\+OK .*\\(<[^\>]+>\\)" @@ -267,12 +275,15 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") 1 (elmo-network-session-greeting-internal session)) (elmo-get-passwd - (elmo-network-session-password-key session)))))) + (elmo-network-session-password-key session))))) + nil 'no-log) (or (elmo-pop3-read-response (elmo-network-session-process-internal session) t) - (signal 'elmo-authenticate-error - '(elmo-pop3-auth-apop)))) + (progn + (delete-process (elmo-network-session-process-internal session)) + (signal 'elmo-authenticate-error + '(elmo-pop3-auth-apop))))) (signal 'elmo-open-error '(elmo-pop3-auth-apop)))) (luna-define-method elmo-network-initialize-session-buffer :after @@ -314,7 +325,6 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (with-current-buffer (process-buffer (elmo-network-session-process-internal session)) (let* ((process (elmo-network-session-process-internal session)) - (elmo-pop3-debug-inhibit-logging t) (auth (elmo-network-session-auth-internal session)) (auth (mapcar '(lambda (mechanism) (upcase (symbol-name mechanism))) (if (listp auth) auth (list auth)))) @@ -355,7 +365,8 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (concat " " (elmo-base64-encode-string - (sasl-step-data step) 'no-line-break))))) ;) + (sasl-step-data step) 'no-line-break)))) + nil 'no-log) (catch 'done (while t (unless (setq response (elmo-pop3-read-response process t)) @@ -383,7 +394,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (if (sasl-step-data step) (elmo-base64-encode-string (sasl-step-data step) 'no-line-break) - ""))))))))) + "") nil 'no-log)))))))) (luna-define-method elmo-network-setup-session ((session elmo-pop3-session)) @@ -420,7 +431,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") match-end) (goto-char elmo-pop3-read-point) (while (not (re-search-forward "^\\.\r\n" nil t)) - (accept-process-output process) + (accept-process-output process 1) (goto-char elmo-pop3-read-point)) (setq match-end (point)) (elmo-delete-cr @@ -447,7 +458,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (setq session (elmo-pop3-get-session folder)) (if session (elmo-network-close-session session))))) - t)) + (file-directory-p (elmo-folder-msgdb-path folder)))) (defun elmo-pop3-parse-uidl-response (string) (let ((buffer (current-buffer)) @@ -565,7 +576,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (elmo-pop3-list-by-uidl-subr folder) (elmo-pop3-list-by-list folder))) -(luna-define-method elmo-folder-list-messages-internal +(luna-define-method elmo-folder-list-messages-plugged ((folder elmo-pop3-folder) &optional nohide) (elmo-pop3-folder-list-messages folder)) @@ -809,12 +820,13 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") end) (goto-char start) (while (not (re-search-forward "^\\.\r?\n" nil t)) - (accept-process-output process) + (accept-process-output process 1) (goto-char start)) (setq end (point)) (with-current-buffer outbuf (erase-buffer) - (insert-buffer-substring (process-buffer process) start (- end 3)))))) + (insert-buffer-substring (process-buffer process) start (- end 3))) + t))) (luna-define-method elmo-folder-open-internal ((folder elmo-pop3-folder)) (if (and (not elmo-inhibit-number-mapping) @@ -861,11 +873,12 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (when (null (setq response (elmo-pop3-read-response process t))) (error "Fetching message failed")) - (setq response (elmo-pop3-read-body process outbuf))) + (setq response (elmo-pop3-read-body process outbuf))) (setq elmo-pop3-total-size nil)) (unless elmo-inhibit-display-retrieval-progress (elmo-display-progress - 'elmo-display-retrieval-progress "" 100) ; remove progress bar. + 'elmo-display-retrieval-progress + "Retrieving..." 100) ; remove progress bar. (message "Retrieving...done.")) (set-buffer outbuf) (goto-char (point-min))