X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fpop3.el;h=ee4345c2f4fee1f7e268a196779790bb2283ed89;hb=5beb390633ce1e32cdf319c6ba19926244bbfdf2;hp=90e11b3ca8f0f8f35cc24aef2493fe04319d6f1d;hpb=4c893e4b485044c1ac40d3dc65cc98161cacc11e;p=gnus diff --git a/lisp/pop3.el b/lisp/pop3.el index 90e11b3ca..ee4345c2f 100644 --- a/lisp/pop3.el +++ b/lisp/pop3.el @@ -1,6 +1,6 @@ ;;; pop3.el --- Post Office Protocol (RFC 1460) interface -;; Copyright (C) 1996-2011 Free Software Foundation, Inc. +;; Copyright (C) 1996-2012 Free Software Foundation, Inc. ;; Author: Richard L. Pieri ;; Maintainer: FSF @@ -167,23 +167,39 @@ Use streaming commands." (defun pop3-send-streaming-command (process command count total-size) (erase-buffer) - (let ((i 1)) + (let ((i 1) + (start-point (point-min)) + (waited-for 0)) (while (>= count i) (process-send-string process (format "%s %d\r\n" command i)) ;; Only do 100 messages at a time to avoid pipe stalls. (when (zerop (% i pop3-stream-length)) - (pop3-wait-for-messages process i total-size)) - (incf i))) - (pop3-wait-for-messages process count total-size)) - -(defun pop3-wait-for-messages (process count total-size) - (while (< (pop3-number-of-responses total-size) count) + (setq start-point + (pop3-wait-for-messages process pop3-stream-length + total-size start-point)) + (incf waited-for pop3-stream-length)) + (incf i)) + (pop3-wait-for-messages process (- count waited-for) + total-size start-point))) + +(defun pop3-wait-for-messages (process count total-size start-point) + (while (> count 0) + (goto-char start-point) + (while (or (and (re-search-forward "^\\+OK" nil t) + (or (not total-size) + (re-search-forward "^\\.\r?\n" nil t))) + (re-search-forward "^-ERR " nil t)) + (decf count) + (setq start-point (point))) + (unless (memq (process-status process) '(open run)) + (error "pop3 process died")) (when total-size (message "pop3 retrieved %dKB (%d%%)" (truncate (/ (buffer-size) 1000)) (truncate (* (/ (* (buffer-size) 1.0) total-size) 100)))) - (pop3-accept-process-output process))) + (pop3-accept-process-output process)) + start-point) (defun pop3-write-to-file (file) (let ((pop-buffer (current-buffer)) @@ -217,17 +233,6 @@ Use streaming commands." (delete-char 1)) (write-region (point-min) (point-max) file nil 'nomesg))))) -(defun pop3-number-of-responses (endp) - (let ((responses 0)) - (save-excursion - (goto-char (point-min)) - (while (or (and (re-search-forward "^\\+OK" nil t) - (or (not endp) - (re-search-forward "^\\.\r?\n" nil t))) - (re-search-forward "^-ERR " nil t)) - (incf responses))) - responses)) - (defun pop3-logon (process) (let ((pop3-password pop3-password)) ;; for debugging only @@ -265,11 +270,11 @@ Use streaming commands." message-count)) (defcustom pop3-stream-type nil - "*Transport security type for POP3 connexions. -This may be either nil (plain connexion), `ssl' (use an + "*Transport security type for POP3 connections. +This may be either nil (plain connection), `ssl' (use an SSL/TSL-secured stream) or `starttls' (use the starttls mechanism to turn on TLS security after opening the stream). However, if -this is nil, `ssl' is assumed for connexions to port +this is nil, `ssl' is assumed for connections to port 995 (pop3s)." :version "23.1" ;; No Gnus :group 'pop3 @@ -306,7 +311,8 @@ Returns the process associated with the connection." (t (or pop3-stream-type 'network))) :capability-command "CAPA\r\n" - :end-of-command "^\\.\r?\n\\|^\\(-ERR\\|+OK \\).*\n" + :end-of-command "^\\(-ERR\\|+OK\\).*\n" + :end-of-capability "^\\.\r?\n\\|^-ERR" :success "^\\+OK.*\n" :return-list t :starttls-function