+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.
+
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")))))
+
(luna-define-class elmo-pop3-session (elmo-network-session))
;; buffer-local
(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)
+(defun elmo-pop3-read-response (process &optional not-command keep-lock)
(with-current-buffer (process-buffer process)
(let ((case-fold-search nil)
(response-string nil)
(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 elmo-pop3-total-size
(message "Retrieving...(%d/%d bytes)."
(buffer-size) elmo-pop3-total-size))))
(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))
(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))