+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.
(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)
(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))))
(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
"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)))
(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)