X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fpop3.el;h=0c2f73cc783828a27d87e1872050cd5eb023b6bc;hb=ca101d0305c3ff2ecc44dade2025c974ffc7168a;hp=aa040d228f0d716f9b7dbab1aeeca1b72979692e;hpb=a707b63af25b91cb730c12e65156ca364bf49a44;p=elisp%2Fgnus.git- diff --git a/lisp/pop3.el b/lisp/pop3.el index aa040d2..0c2f73c 100644 --- a/lisp/pop3.el +++ b/lisp/pop3.el @@ -1,6 +1,6 @@ ;;; pop3.el --- Post Office Protocol (RFC 1460) interface -;; Copyright (C) 1996, 1997, 1998, 1999, 2000 +;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 ;; Free Software Foundation, Inc. ;; Author: Richard L. Pieri @@ -75,7 +75,7 @@ Used for APOP authentication.") ;; query for password (if (and pop3-password-required (not pop3-password)) (setq pop3-password - (pop3-read-passwd (format "Password for %s: " pop3-maildrop)))) + (read-passwd (format "Password for %s: " pop3-maildrop)))) (cond ((equal 'apop pop3-authentication-scheme) (pop3-apop process pop3-maildrop)) ((equal 'pass pop3-authentication-scheme) @@ -106,6 +106,28 @@ Used for APOP authentication.") ) t) +(defun pop3-get-message-count () + "Return the number of messages in the maildrop." + (let* ((process (pop3-open-server pop3-mailhost pop3-port)) + message-count + (pop3-password pop3-password) + ) + ;; for debugging only + (if pop3-debug (switch-to-buffer (process-buffer process))) + ;; query for password + (if (and pop3-password-required (not pop3-password)) + (setq pop3-password + (read-passwd (format "Password for %s: " pop3-maildrop)))) + (cond ((equal 'apop pop3-authentication-scheme) + (pop3-apop process pop3-maildrop)) + ((equal 'pass pop3-authentication-scheme) + (pop3-user process pop3-maildrop) + (pop3-pass process)) + (t (error "Invalid POP3 authentication scheme"))) + (setq message-count (car (pop3-stat process))) + (pop3-quit process) + message-count)) + (defun pop3-open-server (mailhost port) "Open TCP connection to MAILHOST on PORT. Returns the process associated with the connection." @@ -117,7 +139,7 @@ Returns the process associated with the connection." mailhost))) (erase-buffer) (setq pop3-read-point (point-min)) - (setq process (open-network-stream "POP"(current-buffer) mailhost port)) + (setq process (open-network-stream "POP" (current-buffer) mailhost port)) (let ((response (pop3-read-response process t))) (setq pop3-timestamp (substring response (or (string-match "<" response) 0) @@ -152,7 +174,7 @@ Return the response string if optional second argument is non-nil." (set-buffer (process-buffer process)) (goto-char pop3-read-point) (while (not (search-forward "\r\n" nil t)) - (accept-process-output process 3) + (accept-process-output process 0 500) (goto-char pop3-read-point)) (setq match-end (point)) (goto-char pop3-read-point) @@ -166,17 +188,6 @@ Return the response string if optional second argument is non-nil." t) ))))) -(defvar pop3-read-passwd nil) -(defun pop3-read-passwd (prompt) - (if (not pop3-read-passwd) - (if (fboundp 'read-passwd) - (setq pop3-read-passwd 'read-passwd) - (if (load "passwd" t) - (setq pop3-read-passwd 'read-passwd) - (autoload 'ange-ftp-read-passwd "ange-ftp") - (setq pop3-read-passwd 'ange-ftp-read-passwd)))) - (funcall pop3-read-passwd prompt)) - (defun pop3-clean-region (start end) (setq end (set-marker (make-marker) end)) (save-excursion @@ -222,18 +233,23 @@ If NOW, use that time instead." (looking-at "\001\001\001\001\n") ; MMDF (looking-at "BABYL OPTIONS:") ; Babyl )) - (let ((from (mail-strip-quoted-names (mail-fetch-field "From"))) - (date (split-string (or (mail-fetch-field "Date") - (pop3-make-date)) - " ")) - (From_)) + (let* ((from (mail-strip-quoted-names (mail-fetch-field "From"))) + (tdate (mail-fetch-field "Date")) + (date (split-string (or (and tdate + (not (string= "" tdate)) + tdate) + (pop3-make-date)) + " ")) + (From_)) ;; sample date formats I have seen ;; Date: Tue, 9 Jul 1996 09:04:21 -0400 (EDT) ;; Date: 08 Jul 1996 23:22:24 -0400 ;; should be ;; Tue Jul 9 09:04:21 1996 (setq date - (cond ((string-match "[A-Z]" (nth 0 date)) + (cond ((not date) + "Tue Jan 1 00:00:0 1900") + ((string-match "[A-Z]" (nth 0 date)) (format "%s %s %s %s %s" (nth 0 date) (nth 2 date) (nth 1 date) (nth 4 date) (nth 3 date))) @@ -271,7 +287,7 @@ If NOW, use that time instead." (pop3-send-command process (format "USER %s" user)) (let ((response (pop3-read-response process t))) (if (not (and response (string-match "+OK" response))) - (error (format "USER %s not valid." user))))) + (error (format "USER %s not valid" user))))) (defun pop3-pass (process) "Send authentication information to the server." @@ -285,7 +301,7 @@ If NOW, use that time instead." (let ((pass pop3-password)) (if (and pop3-password-required (not pass)) (setq pass - (pop3-read-passwd (format "Password for %s: " pop3-maildrop)))) + (read-passwd (format "Password for %s: " pop3-maildrop)))) (if pass (let ((hash (pop3-md5 (concat pop3-timestamp pass)))) (pop3-send-command process (format "APOP %s %s" user hash)) @@ -310,7 +326,7 @@ If NOW, use that time instead." t (current-buffer) nil) ;; The meaningful output is the first 32 characters. ;; Don't return the newline that follows them! - (buffer-substring 1 33))))) + (buffer-substring (point-min) (+ 32 (point-min))))))) (defun pop3-stat (process) "Return the number of messages in the maildrop and the maildrop's size." @@ -332,7 +348,7 @@ This function currently does nothing.") (save-excursion (set-buffer (process-buffer process)) (while (not (re-search-forward "^\\.\r\n" nil t)) - (accept-process-output process 3) + (accept-process-output process 0 500) ;; bill@att.com ... to save wear and tear on the heap ;; uncommented because the condensed version below is a problem for ;; some.