* elmo-util.el (elmo-file-field-primitive-condition-match): Fixed
[elisp/wanderlust.git] / elmo / elmo-pop3.el
index 05033f2..29ad744 100644 (file)
@@ -70,15 +70,13 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
 (defvar elmo-pop3-size-hash nil) ; number -> size
 (defvar elmo-pop3-uidl-done nil)
 (defvar elmo-pop3-list-done nil)
-(defvar elmo-pop3-lock nil)
 
 (defvar elmo-pop3-local-variables '(elmo-pop3-read-point
                                    elmo-pop3-uidl-number-hash
                                    elmo-pop3-number-uidl-hash
                                    elmo-pop3-uidl-done
                                    elmo-pop3-size-hash
-                                   elmo-pop3-list-done
-                                   elmo-pop3-lock))
+                                   elmo-pop3-list-done))
 
 (luna-define-method elmo-network-close-session ((session elmo-pop3-session))
   (when (elmo-network-session-process-internal session)
@@ -111,12 +109,11 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
       (erase-buffer))
     (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 keep-lock)
+(defun elmo-pop3-read-response (process &optional not-command)
   (with-current-buffer (process-buffer process)
     (let ((case-fold-search nil)
          (response-string nil)
@@ -153,8 +150,6 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
                      (concat return-value "\n" response-string)
                    response-string)))
          (setq elmo-pop3-read-point match-end)))
-      (unless keep-lock
-       (elmo-pop3-unlock))
       return-value)))
 
 (defun elmo-pop3-process-filter (process output)
@@ -217,7 +212,6 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
   (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.
@@ -326,7 +320,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
       (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 nil 'keep-lock))
+      (if (null (elmo-pop3-read-response process))
          (error "POP LIST command failed"))
       (if (null (setq response
                      (elmo-pop3-read-contents
@@ -340,7 +334,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
        (setq elmo-pop3-number-uidl-hash (elmo-make-hash (* count 2)))
        ;; UIDL
        (elmo-pop3-send-command process "uidl")
-       (unless (elmo-pop3-read-response process nil 'keep-lock)
+       (unless (elmo-pop3-read-response process)
          (error "POP UIDL failed"))
        (unless (setq response (elmo-pop3-read-contents
                                (current-buffer) process))
@@ -356,7 +350,6 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
        (accept-process-output process)
        (goto-char elmo-pop3-read-point))
       (setq match-end (point))
-      (elmo-pop3-unlock)
       (elmo-delete-cr
        (buffer-substring elmo-pop3-read-point
                         (- match-end 3))))))
@@ -387,7 +380,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
       (let (number uid list)
        (insert string)
        (goto-char (point-min))
-       (while (re-search-forward "^\\([0-9]+\\)[\t ]\\([^ \n]+\\)$" nil t)
+       (while (re-search-forward "^\\([0-9]+\\)[\t ]+\\([^ \n]+\\)$" nil t)
          (setq number  (elmo-match-buffer 1))
          (setq uid (elmo-match-buffer 2))
          (with-current-buffer buffer
@@ -405,7 +398,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)
@@ -474,7 +467,9 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
 (defun elmo-pop3-max-of-folder (spec)
   (elmo-pop3-commit spec)
   (if elmo-pop3-use-uidl
-      (elmo-pop3-list-by-uidl-subr spec 'nonsort)
+      (prog1
+         (elmo-pop3-list-by-uidl-subr spec 'nonsort)
+       (elmo-pop3-commit spec))
     (let* ((process
            (elmo-network-session-process-internal
             (elmo-pop3-get-session spec)))
@@ -489,6 +484,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
          (setq total
                (string-to-int
                 (substring response (match-beginning 1)(match-end 1 ))))
+         (elmo-pop3-commit spec)
          (cons total total))))))
 
 (defvar elmo-pop3-header-fetch-chop-length 200)
@@ -506,23 +502,6 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
    (t
     nil)))
 
-(defun elmo-pop3-lock ()
-  "Lock pop3 process."
-  (setq elmo-pop3-lock t))
-
-(defun elmo-pop3-unlock ()
-  "Unlock pop3 process."
-  (setq elmo-pop3-lock nil))
-
-(defun elmo-pop3-locked-p (process)
-  "Return t if pop3 PROCESS is locked."
-  (with-current-buffer (process-buffer process)
-    (if elmo-pop3-lock
-       (progn
-         (elmo-pop3-debug "POP3 is LOCKED!")
-         t)
-      nil)))
-     
 (defun elmo-pop3-retrieve-headers (buffer tobuffer process articles)
   (save-excursion
     (set-buffer buffer)
@@ -731,7 +710,6 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
        (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))
@@ -765,7 +743,7 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
        (unwind-protect
            (progn
              (when (null (setq response (elmo-pop3-read-response
-                                         process t 'keep-lock)))
+                                         process t)))
                (error "Fetching message failed"))
              (setq response (elmo-pop3-read-body process outbuf)))
          (setq elmo-pop3-total-size nil))
@@ -848,11 +826,8 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
 (defun elmo-pop3-commit (spec)
   (if (elmo-pop3-plugged-p spec)
       (let ((session (elmo-pop3-get-session spec 'if-exists)))
-       (when (and session
-                  (not (elmo-pop3-locked-p
-                        (elmo-network-session-process-internal session))))
+       (when session
          (elmo-network-close-session session)))))
-       
 
 (require 'product)
 (product-provide (provide 'elmo-pop3) (require 'elmo-version))