* elmo-pop3.el (elmo-pop3-lock): New buffer local variable.
authorteranisi <teranisi>
Wed, 13 Jun 2001 10:08:52 +0000 (10:08 +0000)
committerteranisi <teranisi>
Wed, 13 Jun 2001 10:08:52 +0000 (10:08 +0000)
(elmo-pop3-send-command): Call elmo-pop3-lock.
(elmo-pop3-read-response): Call elmo-pop3-unlock.
(elmo-pop3-read-contents): Ditto.
(elmo-pop3-lock): New function.
(elmo-pop3-unlock): Ditto.
(elmo-pop3-locked-p): Ditto.
(elmo-pop3-commit): Don't delete process if elmo-pop3-locked-p
returns t.

elmo/ChangeLog
elmo/elmo-pop3.el

index 7e45117..73becaf 100644 (file)
@@ -1,3 +1,15 @@
+2001-06-13  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * elmo-pop3.el (elmo-pop3-lock): New buffer local variable.
+       (elmo-pop3-send-command): Call elmo-pop3-lock.
+       (elmo-pop3-read-response): Call elmo-pop3-unlock.
+       (elmo-pop3-read-contents): Ditto.
+       (elmo-pop3-lock): New function.
+       (elmo-pop3-unlock): Ditto.
+       (elmo-pop3-locked-p): Ditto.
+       (elmo-pop3-commit): Don't delete process if elmo-pop3-locked-p
+       returns t.
+
 2001-06-11  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * elmo-util.el (elmo-file-field-primitive-condition-match):
index e36af94..acf13cc 100644 (file)
 (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-list-done
+                                   elmo-pop3-lock))
 
 (luna-define-method elmo-network-close-session ((session elmo-pop3-session))
   (when (elmo-network-session-process-internal session)
@@ -93,6 +95,7 @@
       (erase-buffer))
     (goto-char (point-min))
     (setq elmo-pop3-read-point (point))
+    (elmo-pop3-lock)
     (process-send-string process command)
     (process-send-string process "\r\n")))
 
                      (concat return-value "\n" response-string)
                    response-string)))
          (setq elmo-pop3-read-point match-end)))
+      (elmo-pop3-unlock)
       return-value)))
 
 (defun elmo-pop3-process-filter (process output)
        (elmo-pop3-parse-uidl-response response)))))
 
 (defun elmo-pop3-read-contents (buffer process)
-  (save-excursion
-    (set-buffer buffer)
+  (with-current-buffer buffer
     (let ((case-fold-search nil)
          match-end)
       (goto-char elmo-pop3-read-point)
        (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))))))
       nil))
    (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)
+    elmo-pop3-lock))
      
 (defun elmo-pop3-retrieve-headers (buffer tobuffer process articles)
   (save-excursion
 (defun elmo-pop3-commit (spec)
   (if (elmo-pop3-plugged-p spec)
       (let ((session (elmo-pop3-get-session spec 'if-exists)))
-       (and session
-            (elmo-network-close-session session)))))
+       (when (and session
+                  (not (elmo-pop3-locked-p
+                        (elmo-network-session-process-internal session))))
+         (elmo-network-close-session session)))))
        
 
 (require 'product)