:group 'elmo)
;;; MSGDB interface.
+;;
+;; MSGDB elmo-load-msgdb PATH
+;; MARK elmo-msgdb-get-mark MSGDB NUMBER
+
+;; CACHED elmo-msgdb-get-cached MSGDB NUMBER
+;; VOID elmo-msgdb-set-cached MSGDB NUMBER CACHED USE-CACHE
+;; VOID elmo-msgdb-set-flag MSGDB FOLDER NUMBER FLAG
+;; VOID elmo-msgdb-unset-flag MSGDB FOLDER NUMBER FLAG
+
+;; LIST-OF-NUMBERS elmo-msgdb-count-marks MSGDB
+;; NUMBER elmo-msgdb-get-number MSGDB MESSAGE-ID
+;; FIELD-VALUE elmo-msgdb-get-field MSGDB NUMBER FIELD
+;; MSGDB elmo-msgdb-append MSGDB MSGDB-APPEND
+;; MSGDB elmo-msgdb-clear MSGDB
+;; elmo-msgdb-delete-msgs MSGDB NUMBERS
+;; elmo-msgdb-sort-by-date MSGDB
+
+;; elmo-msgdb-id-mark-table-load
+;; elmo-msgdb-id-mark-table-save
+
+;; elmo-msgdb-append-entity-from-buffer
+;; msgdb number flag id-mark-table &optional buffer
+
+;; ENTITY elmo-msgdb-make-entity ARGS
+;; VALUE elmo-msgdb-entity-field ENTITY
+;;
+
+;; OVERVIEW elmo-msgdb-get-overview MSGDB
+;; NUMBER-ALIST elmo-msgdb-get-number-alist MSGDB
+;; MARK-ALIST elmo-msgdb-get-mark-alist MSGDB
+;; elmo-msgdb-change-mark MSGDB BEFORE AFTER
+
+;; (for internal use?)
+;; LIST-OF-MARKS elmo-msgdb-unread-marks
+;; LIST-OF-MARKS elmo-msgdb-answered-marks
+;; LIST-OF-MARKS elmo-msgdb-uncached-marks
+;; elmo-msgdb-seen-save DIR OBJ
+;; elmo-msgdb-overview-save DIR OBJ
+
+;; elmo-msgdb-overview-entity-get-references ENTITY
+;; elmo-msgdb-overview-entity-set-references ENTITY
+;; elmo-msgdb-get-parent-entity ENTITY MSGDB
+;; elmo-msgdb-overview-enitty-get-number ENTITY
+;; elmo-msgdb-overview-enitty-get-from-no-decode ENTITY
+;; elmo-msgdb-overview-enitty-get-from ENTITY
+;; elmo-msgdb-overview-enitty-get-subject-no-decode ENTITY
+;; elmo-msgdb-overview-enitty-get-subject ENTITY
+;; elmo-msgdb-overview-enitty-get-date ENTITY
+;; elmo-msgdb-overview-enitty-get-to ENTITY
+;; elmo-msgdb-overview-enitty-get-cc ENTITY
+;; elmo-msgdb-overview-enitty-get-size ENTITY
+;; elmo-msgdb-overview-enitty-get-id ENTITY
+;; elmo-msgdb-overview-enitty-get-extra-field ENTITY
+;; elmo-msgdb-overview-enitty-get-extra ENTITY
+;; elmo-msgdb-overview-get-entity ID MSGDB
+
+;; elmo-msgdb-killed-list-load DIR
+;; elmo-msgdb-killed-list-save DIR
+;; elmo-msgdb-append-to-killed-list FOLDER MSG
+;; elmo-msgdb-killed-list-length KILLED-LIST
+;; elmo-msgdb-max-of-killed KILLED-LIST
+;; elmo-msgdb-killed-message-p KILLED-LIST MSG
+;; elmo-living-messages MESSAGES KILLED-LIST
+;; elmo-msgdb-finfo-load
+;; elmo-msgdb-finfo-save
+;; elmo-msgdb-flist-load
+;; elmo-msgdb-flist-save
+
+;; elmo-crosspost-alist-load
+;; elmo-crosspost-alist-save
+
+;; elmo-msgdb-add-msgs-to-seen-list MSGS MSGDB SEEN-LIST
+
+;; elmo-msgdb-create-overview-from-buffer NUMBER SIZE TIME
+;; elmo-msgdb-copy-overview-entity ENTITY
+;; elmo-msgdb-create-overview-entity-from-file NUMBER FILE
+;; elmo-msgdb-overview-sort-by-date OVERVIEW
+;; elmo-msgdb-clear-index
+
+;; elmo-folder-get-info
+;; elmo-folder-get-info-max
+;; elmo-folder-get-info-length
+;; elmo-folder-get-info-unread
+
+;; elmo-msgdb-list-flagged MSGDB FLAG
+;; (MACRO) elmo-msgdb-do-each-entity
+
(defun elmo-load-msgdb (path)
"Load the MSGDB from PATH."
(let ((inhibit-quit t))
(elmo-make-msgdb (elmo-msgdb-overview-load path)
(elmo-msgdb-number-load path)
- (elmo-msgdb-mark-load path))))
+ (elmo-msgdb-mark-load path)
+ path)))
-(defun elmo-make-msgdb (&optional overview number-alist mark-alist)
+(defun elmo-make-msgdb (&optional overview number-alist mark-alist path)
"Make a MSGDB."
- (let ((msgdb (list overview number-alist mark-alist nil)))
+ (let ((msgdb (list overview number-alist mark-alist nil path)))
(elmo-msgdb-make-index msgdb)
msgdb))
(cadr (elmo-get-hash-val (format "#%d" number)
(elmo-msgdb-get-mark-hashtb msgdb))))
-(defsubst elmo-msgdb-set-mark (msgdb number mark)
- "Set MARK of the message with NUMBER in the MSGDB.
-if MARK is nil, mark is removed."
- (let ((elem (elmo-get-hash-val (format "#%d" number)
- (elmo-msgdb-get-mark-hashtb msgdb))))
- (if elem
- (if mark
- ;; Set mark of the elem
- (setcar (cdr elem) mark)
- ;; Delete elem from mark-alist
- (elmo-msgdb-set-mark-alist
- msgdb
- (delq elem (elmo-msgdb-get-mark-alist msgdb)))
- (elmo-clear-hash-val (format "#%d" number)
- (elmo-msgdb-get-mark-hashtb msgdb)))
- (when mark
- ;; Append new element.
- (elmo-msgdb-set-mark-alist
- msgdb
- (nconc
- (elmo-msgdb-get-mark-alist msgdb)
- (list (setq elem (list number mark)))))
- (elmo-set-hash-val (format "#%d" number) elem
- (elmo-msgdb-get-mark-hashtb msgdb))))
- ;; return value.
- t))
-
(defun elmo-msgdb-get-cached (msgdb number)
"Return non-nil if message is cached."
(not (member (elmo-msgdb-get-mark msgdb number)
(elmo-msgdb-make-index
msgdb
(elmo-msgdb-get-overview msgdb-append)
- (elmo-msgdb-get-mark-alist msgdb-append))))
+ (elmo-msgdb-get-mark-alist msgdb-append))
+ (nth 4 msgdb)))
(defsubst elmo-msgdb-clear (&optional msgdb)
(if msgdb
(setcar msgdb nil)
(setcar (cdr msgdb) nil)
(setcar (cddr msgdb) nil)
- (setcar (nthcdr 3 msgdb) nil))
- (list nil nil nil nil)))
+ (setcar (nthcdr 3 msgdb) nil)
+ (setcar (nthcdr 4 msgdb) nil))
+ (list nil nil nil nil nil)))
(defun elmo-msgdb-delete-msgs (msgdb msgs)
"Delete MSGS from MSGDB
(number-alist (cadr msgdb))
(mark-alist (caddr msgdb))
(index (elmo-msgdb-get-index msgdb))
- (newmsgdb (list overview number-alist mark-alist index))
+ (newmsgdb (list overview number-alist mark-alist index
+ (nth 4 msgdb)))
ov-entity)
;; remove from current database.
(while msgs
(defsubst elmo-msgdb-get-mark-hashtb (msgdb)
(cdr (nth 3 msgdb)))
+(defsubst elmo-msgdb-get-path (msgdb)
+ (nth 4 msgdb))
+
;;
;; number <-> Message-ID handling
;;
(elmo-msgdb-append-element ret-val (cons number id)))
ret-val))
+;;; flag table
+;;
+(defvar elmo-flag-table-filename "flag-table")
+(defun elmo-flag-table-load (dir)
+ "Load flag hashtable for MSGDB."
+ (let ((table (elmo-make-hash))
+ ;; For backward compatibility
+ (seen-file (expand-file-name elmo-msgdb-seen-filename dir))
+ seen-list)
+ (when (file-exists-p seen-file)
+ (setq seen-list (elmo-object-load seen-file))
+ (delete-file seen-file))
+ (dolist (msgid seen-list)
+ (elmo-set-hash-val msgid 'read table))
+ (dolist (pair (elmo-object-load
+ (expand-file-name elmo-flag-table-filename dir)))
+ (elmo-set-hash-val (car pair) (cdr pair) table))
+ table))
+
+(defun elmo-flag-table-set (flag-table msg-id flag)
+ (elmo-set-hash-val msg-id flag flag-table))
+
+(defun elmo-flag-table-save (dir flag-table)
+ (elmo-object-save
+ (expand-file-name (expand-file-name elmo-flag-table-filename dir)
+ (mapatoms (lambda (atom)
+ (cons (symbol-name atom) (symbol-value atom)))
+ flag-table))))
;;;
;; persistent mark handling
;; (for each folder)
;;
;; overview handling
;;
-
-(defsubst elmo-msgdb-get-field-value (field-name beg end buffer)
- (save-excursion
- (save-restriction
- (set-buffer buffer)
- (narrow-to-region beg end)
- (elmo-field-body field-name))))
-
(defun elmo-multiple-field-body (name &optional boundary)
(save-excursion
(save-restriction
(defsubst elmo-msgdb-set-index (msgdb index)
(setcar (cdddr msgdb) index))
+(defsubst elmo-msgdb-set-path (msgdb path)
+ (setcar (cddddr msgdb) index))
+
(defsubst elmo-msgdb-overview-entity-get-references (entity)
(and entity (aref (cdr entity) 1)))
(and entity (aset (cdr entity) 8 extra))
entity)
-(defun elmo-msgdb-overview-get-entity-by-number (database number)
- (when number
- (let ((db database)
- entity)
- (while db
- (if (eq (elmo-msgdb-overview-entity-get-number (car db)) number)
- (setq entity (car db)
- db nil) ; exit loop
- (setq db (cdr db))))
- entity)))
-
(defun elmo-msgdb-overview-get-entity (id msgdb)
(when id
(let ((ht (elmo-msgdb-get-entity-hashtb msgdb)))
(let ((number (or number (wl-summary-message-number)))
buffer-read-only cur-mark)
(setq cur-mark (elmo-message-mark wl-summary-buffer-elmo-folder number))
- ;; set mark on buffer
- (unless (string= (wl-summary-persistent-mark) cur-mark)
- (delete-backward-char 1)
- (insert (or cur-mark " ")))
- (when wl-summary-highlight
- (wl-highlight-summary-current-line nil nil t))
- (set-buffer-modified-p nil)))
+ (save-excursion
+ ;; set mark on buffer
+ (unless (string= (wl-summary-persistent-mark) cur-mark)
+ (delete-backward-char 1)
+ (insert (or cur-mark " ")))
+ (when wl-summary-highlight
+ (wl-highlight-summary-current-line nil nil t))
+ (set-buffer-modified-p nil))))
(defsubst wl-summary-mark-as-read-internal (inverse
number-or-numbers
(elmo-folder-mark-as-read folder number-list no-folder-mark))
(dolist (number number-list)
(setq visible (wl-summary-jump-to-msg number)
- mark (elmo-message-mark folder number))
- (setq new-mark (elmo-message-mark folder number))
+ new-mark (elmo-message-mark folder number))
;; set mark on buffer
(when visible
- (unless (string= (wl-summary-persistent-mark) new-mark)
+ (unless (string= (wl-summary-persistent-mark) (or new-mark " "))
(delete-backward-char 1)
(insert (or new-mark " ")))
(if (and visible wl-summary-highlight)
(wl-highlight-summary-current-line nil nil t))
(set-buffer-modified-p nil))
(unless inverse
- (if (member mark (elmo-msgdb-unread-marks))
+ (if (member (elmo-message-mark folder number)
+ (elmo-msgdb-unread-marks))
(run-hooks 'wl-summary-unread-message-hook))))
(unless no-modeline-update
;; Update unread numbers.
(progn
;; server side mark
(save-match-data
+ (elmo-folder-unmark-important folder (list number)
+ no-server-update)
(unless no-server-update
- (elmo-folder-unmark-important folder (list number))
(elmo-msgdb-global-mark-delete message-id))
;; Remove cache if local folder.
(if (and (elmo-folder-local-p folder)
(elmo-file-cache-get-path message-id))))
(when visible
(delete-backward-char 1)
- (insert " "))
- (elmo-msgdb-set-mark msgdb number nil))
+ (elmo-message-mark folder number)))
;; server side mark
- (save-match-data
- (unless no-server-update
- (elmo-folder-mark-as-important folder (list number))))
+ (elmo-folder-mark-as-important folder (list number)
+ no-server-update)
(when visible
(delete-backward-char 1)
(insert elmo-msgdb-important-mark))
- (elmo-msgdb-set-mark msgdb number
- elmo-msgdb-important-mark)
(if (eq (elmo-file-cache-exists-p message-id) 'entire)
(elmo-folder-mark-as-read folder (list number))
;; Force cache message.
(elmo-folder-plugged-p
wl-summary-buffer-elmo-folder))
'leave)))
- (if (elmo-message-use-cache-p folder num)
- (elmo-message-set-cached folder num t))
- (wl-summary-mark-as-read num no-folder-mark)
+ (when (elmo-message-use-cache-p folder num)
+ (elmo-message-set-cached folder num t))
+ (if (member (elmo-message-mark wl-summary-buffer-elmo-folder
+ num)
+ (elmo-msgdb-unread-marks))
+ (wl-summary-mark-as-read num no-folder-mark)
+ (wl-summary-update-mark))
(setq wl-summary-buffer-current-msg num)
(when wl-summary-recenter
(recenter (/ (- (window-height) 2) 2))