+2001-06-06 Yuuichi Teranishi <teranisi@gohome.org>
+
+ * elmo.el (elmo-folder-reserve-status-p): New method.
+
+ * elmo-shimbun.el (elmo-shimbun-headers-cache): Abolish.
+ (elmo-shimbun-use-entire-index): New user option.
+ (shimbun-elmo-mua): New class.
+ (shimbun-mua-search-id): Define.
+ (shimbun-mua-use-entire-index): Ditto.
+ (elmo-shimbun-folder:last-check): New slot.
+ (elmo-shimbun-headers-cache-header-list): Abolish.
+ (elmo-shimbun-headers-cache-set-header-list): Ditto.
+ (elmo-shimbun-headers-cache-header-hash): Ditto.
+ (elmo-shimbun-headers-cache-set-header-hash): Ditto.
+ (elmo-shimbun-headers-cache-last-check): Ditto.
+ (elmo-shimbun-headers-cache-set-last-check): Ditto.
+ (elmo-shimbun-headers-check-p): Rewrite.
+ (elmo-shimbun-msgdb-to-headers): New function.
+ (elmo-shimbun-get-headers): Rewrite.
+ (elmo-folder-initialize): Set 1st argument of `shimbun-open'.
+ (elmo-folder-open-internal): Get headers only if
+ `elmo-shimbun-headers-check-p' is non-nil.
+ (elmo-folder-check): Check only if `elmo-shimbun-headers-check-p'
+ is non-nil.
+ (elmo-shimbun-msgdb-create-entity): Re-use old msgdb entities.
+ (elmo-quit): Removed.
+
+ * elmo-msgdb.el (elmo-msgdb-overview-entity-get-extra): New inline
+ function.
+ (elmo-msgdb-overview-entity-set-extra): Ditto.
+ (elmo-msgdb-make-overview-hashtb): Make hash if overview is non-nil.
+
+ * elmo-map.el (elmo-folder-status): Don't call
+ elmo-folder-close-internal if `elmo-folder-reserve-status-p'
+ is non-nil.
+
2001-06-05 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
* elmo-msgdb.el (elmo-msgdb-search-internal): Call itself instead
:type 'integer
:group 'elmo)
-;; Internal variable.
-;; A list of elements like:
-;; ("server.group" . [header-list header-hash last-check]).
-(defvar elmo-shimbun-headers-cache nil)
-
-(eval-and-compile
- (luna-define-class elmo-shimbun-folder
- (elmo-map-folder) (shimbun headers header-hash group))
- (luna-define-internal-accessors 'elmo-shimbun-folder))
-
-(defsubst elmo-shimbun-headers-cache-header-list (entry)
- (aref entry 0))
-
-(defsubst elmo-shimbun-headers-cache-set-header-list (entry list)
- (aset entry 0 list))
+(defcustom elmo-shimbun-use-entire-index nil
+ "*Nil means that shimbun check only the last index of articles."
+ :type 'boolean
+ :group 'elmo)
-(defsubst elmo-shimbun-headers-cache-header-hash (entry)
- (aref entry 1))
+;; Shimbun mua.
+(eval-and-compile
+ (luna-define-class shimbun-elmo-mua (shimbun-mua) (folder))
+ (luna-define-internal-accessors 'shimbun-elmo-mua))
-(defsubst elmo-shimbun-headers-cache-set-header-hash (entry hash)
- (aset entry 1 hash))
+(luna-define-method shimbun-mua-search-id ((mua shimbun-elmo-mua) id)
+ (elmo-msgdb-overview-get-entity id
+ (elmo-folder-msgdb
+ (shimbun-elmo-mua-folder-internal mua))))
-(defsubst elmo-shimbun-headers-cache-last-check (entry)
- (aref entry 2))
+(luna-define-method shimbun-mua-use-entire-index ((mua shimbun-elmo-mua))
+ elmo-shimbun-use-entire-index)
-(defsubst elmo-shimbun-headers-cache-set-last-check (entry time)
- (aset entry 2 time))
+(eval-and-compile
+ (luna-define-class elmo-shimbun-folder
+ (elmo-map-folder) (shimbun headers header-hash
+ group last-check))
+ (luna-define-internal-accessors 'elmo-shimbun-folder))
(defsubst elmo-shimbun-lapse-seconds (time)
(let ((now (current-time)))
(+ (* (- (car now) (car time)) 65536)
(- (nth 1 now) (nth 1 time)))))
-(defsubst elmo-shimbun-headers-cache-check-p (cache)
- (or (null (elmo-shimbun-headers-cache-last-check cache))
- (and (elmo-shimbun-headers-cache-last-check cache)
+(defsubst elmo-shimbun-headers-check-p (folder)
+ (or (null (elmo-shimbun-folder-last-check-internal folder))
+ (and (elmo-shimbun-folder-last-check-internal folder)
(> (elmo-shimbun-lapse-seconds
- (elmo-shimbun-headers-cache-last-check cache))
+ (elmo-shimbun-folder-last-check-internal folder))
elmo-shimbun-check-interval))))
+(defun elmo-shimbun-msgdb-to-headers (folder)
+ (let (headers)
+ (dolist (ov (elmo-msgdb-get-overview (elmo-folder-msgdb folder)))
+ (when (elmo-msgdb-overview-entity-get-extra-field ov "xref")
+ (setq headers
+ (cons (shimbun-make-header
+ (elmo-msgdb-overview-entity-get-number ov)
+ (shimbun-mime-encode-string
+ (elmo-msgdb-overview-entity-get-subject ov))
+ (shimbun-mime-encode-string
+ (elmo-msgdb-overview-entity-get-from ov))
+ (elmo-msgdb-overview-entity-get-date ov)
+ (elmo-msgdb-overview-entity-get-id ov)
+ (elmo-msgdb-overview-entity-get-references ov)
+ 0
+ 0
+ (elmo-msgdb-overview-entity-get-extra-field ov "xref"))
+ headers))))
+ (nreverse headers)))
+
(defun elmo-shimbun-get-headers (folder)
(shimbun-open-group
(elmo-shimbun-folder-shimbun-internal folder)
(key (concat (shimbun-server-internal shimbun)
"." (shimbun-current-group-internal shimbun)))
(elmo-hash-minimum-size 0)
- entry headers hash done)
- (if (setq entry (cdr (assoc key elmo-shimbun-headers-cache)))
- (unless (elmo-shimbun-headers-cache-check-p entry)
- (elmo-shimbun-folder-set-headers-internal
- folder
- (elmo-shimbun-headers-cache-header-list entry))
+ entry headers hash)
+ ;; new headers.
+ (setq headers
+ (delq nil
+ (mapcar
+ (lambda (x)
+ (unless (elmo-msgdb-overview-get-entity
+ (shimbun-header-id x)
+ (elmo-folder-msgdb folder))
+ x))
+ (shimbun-headers
+ (elmo-shimbun-folder-shimbun-internal folder)))))
+ (elmo-shimbun-folder-set-headers-internal
+ folder
+ (nconc (elmo-shimbun-msgdb-to-headers folder)
+ headers))
+ (setq hash
(elmo-shimbun-folder-set-header-hash-internal
folder
- (elmo-shimbun-headers-cache-header-hash entry))
- (elmo-shimbun-headers-cache-header-list entry)
- (setq done t)))
- (unless done
- (setq headers
- (elmo-shimbun-folder-set-headers-internal
- folder (shimbun-headers
- (elmo-shimbun-folder-shimbun-internal folder))))
- (setq hash
- (elmo-shimbun-folder-set-header-hash-internal
- folder
- (elmo-make-hash
- (length (elmo-shimbun-folder-headers-internal folder)))))
- ;; Set up header hash.
- (dolist (header (elmo-shimbun-folder-headers-internal folder))
- (elmo-set-hash-val
- (shimbun-header-id header) header
- (elmo-shimbun-folder-header-hash-internal folder)))
- (if entry
- (progn
- (elmo-shimbun-headers-cache-set-header-list entry headers)
- (elmo-shimbun-headers-cache-set-header-hash entry hash)
- (elmo-shimbun-headers-cache-set-last-check entry (current-time)))
- (setq elmo-shimbun-headers-cache
- (cons (cons key (vector headers hash (current-time)))
- elmo-shimbun-headers-cache))))))
+ (elmo-make-hash
+ (length (elmo-shimbun-folder-headers-internal folder)))))
+ ;; Set up header hash.
+ (dolist (header (elmo-shimbun-folder-headers-internal folder))
+ (elmo-set-hash-val
+ (shimbun-header-id header) header
+ (elmo-shimbun-folder-header-hash-internal folder)))
+ (elmo-shimbun-folder-set-last-check-internal folder (current-time))))
(luna-define-method elmo-folder-initialize ((folder
elmo-shimbun-folder)
(if (nth 0 server-group) ; server
(elmo-shimbun-folder-set-shimbun-internal
folder
- (shimbun-open (nth 0 server-group))))
+ (shimbun-open (nth 0 server-group)
+ (luna-make-entity 'shimbun-elmo-mua :folder folder))))
(if (nth 1 server-group)
(elmo-shimbun-folder-set-group-internal
folder
(luna-define-method elmo-folder-open-internal :before ((folder
elmo-shimbun-folder))
(when (elmo-folder-plugged-p folder)
- (elmo-shimbun-get-headers folder)))
+ (if (elmo-shimbun-headers-check-p folder)
+ (elmo-shimbun-get-headers folder))))
+
+(luna-define-method elmo-folder-reserve-status-p ((folder elmo-shimbun-folder))
+ t)
(luna-define-method elmo-folder-close-internal :after ((folder
elmo-shimbun-folder))
(luna-define-method elmo-folder-check :after ((folder elmo-shimbun-folder))
(when (shimbun-current-group-internal
(elmo-shimbun-folder-shimbun-internal folder))
- ;; Discard current headers information.
- (elmo-folder-close-internal folder)
- (elmo-folder-open-internal folder)))
+ (when (elmo-shimbun-headers-check-p folder)
+ ;; Discard current headers information.
+ (elmo-folder-close-internal folder)
+ (elmo-folder-open-internal folder))))
(luna-define-method elmo-folder-expand-msgdb-path ((folder
elmo-shimbun-folder))
(defun elmo-shimbun-msgdb-create-entity (folder number)
(let ((header (elmo-get-hash-val
(elmo-map-message-location folder number)
- (elmo-shimbun-folder-header-hash-internal folder))))
+ (elmo-shimbun-folder-header-hash-internal folder)))
+ ov)
(when header
(with-temp-buffer
(shimbun-header-insert
(elmo-shimbun-folder-shimbun-internal folder)
header)
- (elmo-msgdb-create-overview-from-buffer number)))))
+ (setq ov (elmo-msgdb-create-overview-from-buffer number))
+ (elmo-msgdb-overview-entity-set-extra
+ ov
+ (nconc
+ (elmo-msgdb-overview-entity-get-extra ov)
+ (list (cons "xref" (shimbun-header-xref header)))))))))
(luna-define-method elmo-folder-msgdb-create ((folder elmo-shimbun-folder)
numlist new-mark
numbers)
t)
-(luna-define-method elmo-quit ((folder elmo-shimbun-folder))
- (setq elmo-shimbun-headers-cache nil))
-
(require 'product)
(product-provide (provide 'elmo-shimbun) (require 'elmo-version))