+2001-06-15 Yuuichi Teranishi <teranisi@gohome.org>
+
+ * elmo-pop3.el (elmo-pop3-debug): New variable.
+ (elmo-pop3-debug-inhibit-logging): Ditto.
+ (elmo-pop3-debug): New function.
+ (elmo-pop3-send-command): Call elmo-pop3-debug.
+ (elmo-pop3-read-response): Added keep-lock optional argument;
+ Don't unlock if keep-lock is non-nil.
+ (elmo-pop3-process-filter): Call elmo-pop3-debug.
+ (elmo-network-authenticate-session): Bind
+ elmo-pop3-debug-inhibit-logging as t.
+ (elmo-network-setup-session): Call elmo-pop3-read-response with
+ keep-lock argument.
+ (elmo-pop3-read-msg): Ditto.
+ (elmo-pop3-locked-p): Call elmo-pop3-debug.
+ (elmo-pop3-read-body): Call elmo-pop3-unlock.
+ (elmo-network-initialize-session): Call elmo-pop3-lock.
+ (elmo-folder-close-internal): Don't clear location-alist slot.
+ (elmo-folder-check): Clear location-alist slot.
+
2001-06-13 Yuuichi Teranishi <teranisi@gohome.org>
* elmo-pop3.el (elmo-pop3-lock): New buffer local variable.
(defvar elmo-pop3-total-size nil)
+;; For debugging.
+(defvar elmo-pop3-debug 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")
+ (insert (apply 'format message args) "\n")))))
+
;;; ELMO POP3 folder
(eval-and-compile
(luna-define-class elmo-pop3-folder (elmo-net-folder)
(goto-char (point-min))
(setq elmo-pop3-read-point (point))
(elmo-pop3-lock)
+ (elmo-pop3-debug "SEND: %s\n" command)
(process-send-string process command)
(process-send-string process "\r\n")))
-(defun elmo-pop3-read-response (process &optional not-command buffer)
+(defun elmo-pop3-read-response (process &optional not-command keep-lock)
;; buffer is in case for process is dead.
- (with-current-buffer (or buffer (process-buffer process))
+ (with-current-buffer (process-buffer process)
(let ((case-fold-search nil)
(response-string nil)
(response-continue t)
(concat return-value "\n" response-string)
response-string)))
(setq elmo-pop3-read-point match-end)))
- (elmo-pop3-unlock)
+ (unless keep-lock (elmo-pop3-unlock))
return-value)))
(defun elmo-pop3-process-filter (process output)
(set-buffer (process-buffer process))
(goto-char (point-max))
(insert output)
+ (elmo-pop3-debug "RECEIVED: %s\n" output)
(if (and elmo-pop3-total-size
(> elmo-pop3-total-size
(min elmo-display-retrieval-progress-threshold 100)))
(let ((process (elmo-network-session-process-internal session))
response mechanism)
(with-current-buffer (process-buffer process)
+ (elmo-pop3-lock)
(set-process-filter process 'elmo-pop3-process-filter)
(setq elmo-pop3-read-point (point-min))
;; Skip garbage output from process before greeting.
(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))))
(setq elmo-pop3-size-hash (elmo-make-hash 31))
;; To get obarray of uidl and size
(elmo-pop3-send-command process "list")
- (if (null (elmo-pop3-read-response process))
+ (if (null (elmo-pop3-read-response process nil 'keep-lock))
(error "POP LIST command failed"))
(if (null (setq response
(elmo-pop3-read-contents
(setq elmo-pop3-number-uidl-hash (elmo-make-hash (* count 2)))
;; UIDL
(elmo-pop3-send-command process "uidl")
- (unless (elmo-pop3-read-response process)
+ (unless (elmo-pop3-read-response process nil 'keep-lock)
(error "POP UIDL failed"))
(unless (setq response (elmo-pop3-read-contents
(current-buffer) process))
(defun elmo-pop3-locked-p (process)
"Return t if pop3 PROCESS is locked."
(with-current-buffer (process-buffer process)
- elmo-pop3-lock))
+ (if elmo-pop3-lock
+ (progn
+ (elmo-pop3-debug "POP3 is LOCKED!")
+ t)
+ nil)))
(defun elmo-pop3-retrieve-headers (buffer tobuffer process articles)
(save-excursion
(accept-process-output process)
(goto-char start))
(setq end (point))
+ (elmo-pop3-unlock)
(with-current-buffer outbuf
(erase-buffer)
(insert-buffer-substring (process-buffer process) start (- end 3))))))
folder))))
(luna-define-method elmo-folder-close-internal ((folder elmo-pop3-folder))
- (elmo-pop3-folder-set-location-alist-internal folder nil)
(elmo-folder-check folder))
(luna-define-method elmo-message-fetch-plugged ((folder elmo-pop3-folder)
(unwind-protect
(progn
(when (null (setq response (elmo-pop3-read-response
- process t)))
+ process t 'keep-lock)))
(error "Fetching message failed"))
(setq response (elmo-pop3-read-body process outbuf)))
(setq elmo-pop3-total-size nil))
(and (elmo-folder-persistent-internal folder)
(elmo-pop3-folder-use-uidl-internal folder)))
-
(luna-define-method elmo-folder-check ((folder elmo-pop3-folder))
(if (elmo-folder-plugged-p folder)
(let ((session (elmo-pop3-get-session folder 'if-exists)))
(when (and session
(not (elmo-pop3-locked-p
(elmo-network-session-process-internal session))))
+ (elmo-pop3-folder-set-location-alist-internal folder nil)
(elmo-network-close-session session)))))
(require 'product)