X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=elmo%2Felmo-pop3.el;h=ae25a19d0adaad5cfa36e7d4b4a62bd4b3e14fd6;hb=62b291686c91b9092efd865e60e7552e893acca4;hp=6dfb0d7524d3ef4f518c34176dff0c4f1109bcb3;hpb=51f9787799e1f8a5ad1f9cde0fd99489dae071c3;p=elisp%2Fwanderlust.git diff --git a/elmo/elmo-pop3.el b/elmo/elmo-pop3.el index 6dfb0d7..ae25a19 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,33 +149,46 @@ 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)))) (defun elmo-pop3-get-session (folder &optional if-exists) + "Get POP3 session for FOLDER. +If IF-EXISTS is non-nil, don't get new session. +If IF-EXISTS is `any-exists', get BIFF session or normal session if exists." (let ((elmo-pop3-use-uidl-internal (if elmo-inhibit-number-mapping 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) + (if (eq if-exists 'any-exists) + (or (elmo-network-get-session 'elmo-pop3-session + "POP3" + folder if-exists) + (elmo-network-get-session 'elmo-pop3-session + "BIFF-POP3" + folder if-exists)) + (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 +203,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 +233,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 +252,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 +285,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 +335,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 +375,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 +404,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 +441,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 @@ -434,7 +455,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (expand-file-name (elmo-net-folder-server-internal folder) (expand-file-name "pop" - elmo-msgdb-dir))))) + elmo-msgdb-directory))))) (luna-define-method elmo-folder-exists-p ((folder elmo-pop3-folder)) (if (and elmo-pop3-exists-exactly @@ -447,7 +468,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)) @@ -474,7 +495,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") (with-temp-buffer (insert string) (goto-char (point-min)) - (while (re-search-forward "^\\([0-9]+\\)[\t ]\\([0-9]+\\)$" nil t) + (while (re-search-forward "^\\([0-9]+\\)[\t ]+\\([0-9]+\\)$" nil t) (setq alist (cons (cons (elmo-match-buffer 1) @@ -565,7 +586,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 +830,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,12 +883,13 @@ 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. - (message "Retrieving...done.")) + 'elmo-display-retrieval-progress + "Retrieving..." 100) ; remove progress bar. + (message "Retrieving...done")) (set-buffer outbuf) (goto-char (point-min)) (while (re-search-forward "^\\." nil t)