* elmo2.el (elmo-folder-diff-async-callback): New variable.
authorteranisi <teranisi>
Mon, 25 Sep 2000 03:45:00 +0000 (03:45 +0000)
committerteranisi <teranisi>
Mon, 25 Sep 2000 03:45:00 +0000 (03:45 +0000)
(elmo-folder-diff-async-callback-data): Ditto.
(elmo-folder-diff-async): New function.

* elmo-net.el (elmo-network-session-name-prefix): New variable.
(elmo-network-session-cache-key): Use it as a prefix of the session
name.
(elmo-network-open-session): Ditto.

* elmo-imap4.el (elmo-imap4-status-callback): New local variable.
(elmo-imap4-status-callback-data): Ditto.
(elmo-imap4-server-diff-async-callback): New variable.
(elmo-imap4-server-diff-async-callback-data): Ditto.
(elmo-imap4-local-variables): Added `elmo-imap4-status-callback' and
`elmo-imap4-status-callback-data'.
(elmo-imap4-max-of-folder): Set `elmo-imap4-status-callback' and
`elmo-imap4-status-callback-data' as nil.
(elmo-imap4-server-diff): Ditto.
(elmo-imap4-server-diff-async-callback-1): New function.
(elmo-imap4-server-diff-async): Ditto.
(elmo-imap4-parse-status): Call `elmo-imap4-status-callback'.

elmo/ChangeLog
elmo/elmo-imap4.el
elmo/elmo-net.el
elmo/elmo2.el

index 4488c3b..2295d80 100644 (file)
@@ -1,3 +1,27 @@
+2000-09-25  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * elmo2.el (elmo-folder-diff-async-callback): New variable.
+       (elmo-folder-diff-async-callback-data): Ditto.
+       (elmo-folder-diff-async): New function.
+
+       * elmo-net.el (elmo-network-session-name-prefix): New variable.
+       (elmo-network-session-cache-key): Use it as a prefix of the session
+       name.
+       (elmo-network-open-session): Ditto.
+
+       * elmo-imap4.el (elmo-imap4-status-callback): New local variable.
+       (elmo-imap4-status-callback-data): Ditto.
+       (elmo-imap4-server-diff-async-callback): New variable.
+       (elmo-imap4-server-diff-async-callback-data): Ditto.
+       (elmo-imap4-local-variables): Added `elmo-imap4-status-callback' and
+       `elmo-imap4-status-callback-data'.
+       (elmo-imap4-max-of-folder): Set `elmo-imap4-status-callback' and
+       `elmo-imap4-status-callback-data' as nil.
+       (elmo-imap4-server-diff): Ditto.
+       (elmo-imap4-server-diff-async-callback-1): New function.
+       (elmo-imap4-server-diff-async): Ditto.
+       (elmo-imap4-parse-status): Call `elmo-imap4-status-callback'.
+
 2000-09-24  OKAZAKI Tetsurou  <okazaki@be.to>
 
        * elmo-util.el (elmo-list-delete): Doc fix.
index fe96f92..4f9e9b8 100644 (file)
 
 (defvar elmo-imap4-fetch-callback nil)
 (defvar elmo-imap4-fetch-callback-data nil)
+(defvar elmo-imap4-status-callback nil)
+(defvar elmo-imap4-status-callback-data nil)
+
+(defvar elmo-imap4-server-diff-async-callback nil)
+(defvar elmo-imap4-server-diff-async-callback-data nil)
 
 ;;; progress...(no use?)
 (defvar elmo-imap4-count-progress nil)
 ;;; XXX Temporal implementation
 (defvar elmo-imap4-current-msgdb nil)
 
-(defvar elmo-imap4-local-variables '(elmo-imap4-status
-                                    elmo-imap4-current-response
-                                    elmo-imap4-seqno
-                                    elmo-imap4-parsing
-                                    elmo-imap4-reached-tag
-                                    elmo-imap4-count-progress
-                                    elmo-imap4-count-progress-message
-                                    elmo-imap4-progress-count
-                                    elmo-imap4-fetch-callback
-                                    elmo-imap4-fetch-callback-data
-                                    elmo-imap4-current-msgdb))
+(defvar elmo-imap4-local-variables
+  '(elmo-imap4-status
+    elmo-imap4-current-response
+    elmo-imap4-seqno
+    elmo-imap4-parsing
+    elmo-imap4-reached-tag
+    elmo-imap4-count-progress
+    elmo-imap4-count-progress-message
+    elmo-imap4-progress-count
+    elmo-imap4-fetch-callback
+    elmo-imap4-fetch-callback-data
+    elmo-imap4-status-callback
+    elmo-imap4-status-callback-data
+    elmo-imap4-current-msgdb))
 
 (defvar elmo-imap4-authenticator-alist
   '((login     elmo-imap4-auth-login)
@@ -610,14 +618,19 @@ BUFFER must be a single-byte buffer."
          (elmo-imap4-spec-mailbox new-spec)))))
 
 (defun elmo-imap4-max-of-folder (spec)
-  (let ((status (elmo-imap4-response-value
-                (elmo-imap4-send-command-wait
-                 (elmo-imap4-get-session spec)
-                 (list "status "
-                       (elmo-imap4-mailbox
-                        (elmo-imap4-spec-mailbox spec))
-                       " (uidnext messages)"))
-                'status)))
+  (let ((session (elmo-imap4-get-session spec))
+       status)
+    (with-current-buffer (elmo-network-session-buffer session)
+      (setq elmo-imap4-status-callback nil)
+      (setq elmo-imap4-status-callback-data nil))
+    (setq status (elmo-imap4-response-value
+                 (elmo-imap4-send-command-wait
+                  session
+                  (list "status "
+                        (elmo-imap4-mailbox
+                         (elmo-imap4-spec-mailbox spec))
+                        " (uidnext messages)"))
+                 'status))
     (cons
      (- (elmo-imap4-response-value status 'uidnext) 1)
      (elmo-imap4-response-value status 'messages))))
@@ -1376,13 +1389,39 @@ If optional argument UNMARK is non-nil, unmark."
       (elmo-imap4-send-command-wait session "expunge"))
     t))
 
+(defun elmo-imap4-server-diff-async-callback-1 (status data)
+  (funcall elmo-imap4-server-diff-async-callback
+          (cons (elmo-imap4-response-value status 'unseen)
+                (elmo-imap4-response-value status 'messages))
+          data))
+
+(defun elmo-imap4-server-diff-async (spec)
+  (let ((session (elmo-imap4-get-session spec)))
+    ;; commit.
+    ;; (elmo-imap4-commit spec)
+    (with-current-buffer (elmo-network-session-buffer session)
+      (setq elmo-imap4-status-callback
+           'elmo-imap4-server-diff-async-callback-1)
+      (setq elmo-imap4-status-callback-data
+           elmo-imap4-server-diff-async-callback-data))
+    (elmo-imap4-send-command session
+                            (list
+                             "status "
+                             (elmo-imap4-mailbox
+                              (elmo-imap4-spec-mailbox spec))
+                             " (unseen messages)"))))
+
 (defun elmo-imap4-server-diff (spec)
   "Get server status"
-  (let (response)
+  (let ((session (elmo-imap4-get-session spec))
+       response)
     ;; commit.
 ;    (elmo-imap4-commit spec)
+    (with-current-buffer (elmo-network-session-buffer session)
+      (setq elmo-imap4-status-callback nil)
+      (setq elmo-imap4-status-callback-data nil))
     (setq response
-         (elmo-imap4-send-command-wait (elmo-imap4-get-session spec)
+         (elmo-imap4-send-command-wait session
                                        (list
                                         "status "
                                         (elmo-imap4-mailbox
@@ -1805,6 +1844,10 @@ Return nil if no complete line has arrived."
                         "Unknown status data %s in mailbox %s ignored"
                         token mailbox))))
               status))))
+    (and elmo-imap4-status-callback
+        (funcall elmo-imap4-status-callback
+                 status
+                 elmo-imap4-status-callback-data))
     (list 'status status)))
 
 
index 631786e..653d707 100644 (file)
          (elmo-network-session-port-internal session)))
 
 (defvar elmo-network-session-cache nil)
+(defvar elmo-network-session-name-prefix nil)
 
 (defsubst elmo-network-session-cache-key (name host port user auth stream-type)
   "Returns session cache key."
   (format "%s:%s/%s@%s:%d%s"
-         name user auth host port (or stream-type "")))
+         (concat elmo-network-session-name-prefix name)
+         user auth host port (or stream-type "")))
 
 (defun elmo-network-clear-session-cache ()
   "Clear session cache."
@@ -174,7 +176,7 @@ Returns a process object. if making session failed, returns nil."
                           :process nil
                           :greeting nil))
        (buffer (format " *%s session for %s@%s:%d%s"
-                       name
+                       (concat elmo-network-session-name-prefix name)
                        user
                        host
                        port
index 2905b77..17abb1e 100644 (file)
@@ -666,6 +666,27 @@ without cacheing."
 (defun elmo-clear-killed (folder)
   (elmo-msgdb-killed-list-save (elmo-msgdb-expand-path folder) nil))
 
+(defvar elmo-folder-diff-async-callback nil)
+(defvar elmo-folder-diff-async-callback-data nil)
+
+(defun elmo-folder-diff-async (folder)
+  "Get diff of FOLDER asynchronously.
+`elmo-folder-diff-async-callback' is called with arguments of
+FOLDER and DIFF (cons cell of UNSEEN and MESSAGES).
+Currently works on IMAP4 folder only."
+  (if (eq (elmo-folder-get-type folder) 'imap4)
+      ;; Only works on imap4 with server diff.
+      (progn
+       (setq elmo-imap4-server-diff-async-callback
+             elmo-folder-diff-async-callback)
+       (setq elmo-imap4-server-diff-async-callback-data
+             elmo-folder-diff-async-callback-data)
+       (elmo-imap4-server-diff-async (elmo-folder-get-spec folder)))
+    (and elmo-folder-diff-async-callback
+        (funcall elmo-folder-diff-async-callback
+                 folder
+                 (elmo-folder-diff folder)))))
+
 ;; returns cons cell of (unsync . number-of-messages-in-folder)
 (defun elmo-folder-diff (fld &optional number-alist)
   (interactive)