(elmo-folder-flag-table): New API.
(elmo-folder-close-flag-table): Ditto.
(elmo-folder-preserve-falgs): New function.
(elmo-generic-folder-append-messages): Use
`elmo-folder-flag-table' and `elmo-folder-close-flag-table'.
Flag of a non-registered message, it sets to nil.
Does not set flag to flag-table.
* elmo-maildir.el (elmo-folder-append-buffer): Use
`elmo-folder-preserve-falgs'.
(elmo-folder-append-messages): Use `elmo-folder-flag-table' and
`elmo-folder-close-flag-table'.
* elmo-archive.el (elmo-folder-append-buffer): Fix interface.
(elmo-archive-folder-append-buffer): Use
`elmo-folder-preserve-falgs'.
* elmo-cache.el (elmo-folder-append-buffer): Ditto.
* elmo-imap4.el (elmo-folder-append-buffer): Ditto.
* elmo-localdir.el (elmo-folder-append-buffer): Ditto.
(elmo-folder-append-messages): Use `elmo-folder-flag-table' and
`elmo-folder-close-flag-table'.
2004-04-18 Hiroya Murata <lapis-lazuli@pop06.odn.ne.jp>
+ * elmo.el (elmo-folder): Add new slot `flag-table'.
+ (elmo-folder-flag-table): New API.
+ (elmo-folder-close-flag-table): Ditto.
+ (elmo-folder-preserve-falgs): New function.
+ (elmo-generic-folder-append-messages): Use
+ `elmo-folder-flag-table' and `elmo-folder-close-flag-table'.
+ Flag of a non-registered message, it sets to nil.
+ Does not set flag to flag-table.
+
+ * elmo-maildir.el (elmo-folder-append-buffer): Use
+ `elmo-folder-preserve-falgs'.
+ (elmo-folder-append-messages): Use `elmo-folder-flag-table' and
+ `elmo-folder-close-flag-table'.
+
+ * elmo-archive.el (elmo-folder-append-buffer): Fix interface.
+ (elmo-archive-folder-append-buffer): Use
+ `elmo-folder-preserve-falgs'.
+
+ * elmo-cache.el (elmo-folder-append-buffer): Ditto.
+
+ * elmo-imap4.el (elmo-folder-append-buffer): Ditto.
+
+ * elmo-localdir.el (elmo-folder-append-buffer): Ditto.
+ (elmo-folder-append-messages): Use `elmo-folder-flag-table' and
+ `elmo-folder-close-flag-table'.
+
* elmo-version.el (elmo-version): Up to 2.11.26.
2004-04-18 Yoichi NAKAYAMA <yoichi@geiin.org>
(elmo-archive-message-fetch-internal folder number))
(luna-define-method elmo-folder-append-buffer ((folder elmo-archive-folder)
- &optional flag number)
- (elmo-archive-folder-append-buffer folder flag number))
+ &optional flags number)
+ (elmo-archive-folder-append-buffer folder flags number))
;; verrrrrry slow!!
-(defun elmo-archive-folder-append-buffer (folder flag number)
+(defun elmo-archive-folder-append-buffer (folder flags number)
(let* ((type (elmo-archive-folder-archive-type-internal folder))
(prefix (elmo-archive-folder-archive-prefix-internal folder))
(arc (elmo-archive-get-archive-name folder))
(as-binary-output-file
(write-region (point-min) (point-max) newfile nil 'no-msg))
(elmo-archive-call-method method (list arc newfile))
+ (elmo-folder-preserve-falgs
+ folder
+ (with-current-buffer src-buffer
+ (elmo-msgdb-get-message-id-from-buffer))
+ flags)
t)
nil))))))
(not (file-exists-p file)))
(write-region-as-binary
(point-min) (point-max) file nil 'no-msg)
+ (elmo-folder-preserve-falgs folder msgid flags)
t)))))
(luna-define-method elmo-map-folder-delete-messages ((folder elmo-cache-folder)
" () ")
(elmo-imap4-buffer-literal send-buffer))))
(kill-buffer send-buffer))
+ (when result
+ (elmo-folder-preserve-falgs
+ folder (elmo-msgdb-get-message-id-from-buffer) flags))
result)
;; Unplugged
(if elmo-enable-disconnected-operation
(not (file-exists-p filename)))
(write-region-as-binary
(point-min) (point-max) filename nil 'no-msg)
- (let* ((path (elmo-folder-msgdb-path folder))
- (table (elmo-flag-table-load path))
- (msgid (std11-field-body "message-id")))
- (when msgid
- (elmo-flag-table-set table msgid flags)
- (elmo-flag-table-save path table)))
+ (elmo-folder-preserve-falgs
+ folder (elmo-msgdb-get-message-id-from-buffer) flags)
t)))
(luna-define-method elmo-folder-append-messages :around
(if (elmo-folder-message-file-p src-folder)
(let ((src-msgdb-exists (not (zerop (elmo-folder-length src-folder))))
(dir (elmo-localdir-folder-directory-internal folder))
- (table (elmo-flag-table-load (elmo-folder-msgdb-path folder)))
+ (table (elmo-folder-flag-table folder))
(succeeds numbers)
(next-num (1+ (car (elmo-folder-status folder))))
flags id)
(1+ (car (elmo-folder-status folder)))
(1+ next-num)))))
(when (elmo-folder-persistent-p folder)
- (elmo-flag-table-save (elmo-folder-msgdb-path folder) table))
+ (elmo-folder-close-flag-table folder))
succeeds)
(luna-call-next-method)))
(expand-file-name
(concat "new/" (file-name-nondirectory filename))
basedir))
- (let* ((path (elmo-folder-msgdb-path folder))
- (table (elmo-flag-table-load path))
- (msgid (std11-field-body "message-id")))
- (when msgid
- (elmo-flag-table-set table msgid flags)
- (elmo-flag-table-save path table)))
+ (elmo-folder-preserve-falgs
+ folder (elmo-msgdb-get-message-id-from-buffer) flags)
t)
;; If an error occured, return nil.
(error))))
(if (elmo-folder-message-file-p src-folder)
(let ((src-msgdb-exists (not (zerop (elmo-folder-length src-folder))))
(dir (elmo-maildir-folder-directory-internal folder))
- (table (elmo-flag-table-load (elmo-folder-msgdb-path folder)))
+ (table (elmo-folder-flag-table folder))
(succeeds numbers)
filename flags id)
(dolist (number numbers)
(elmo-flag-table-set table id flags))
(elmo-progress-notify 'elmo-folder-move-messages))
(when (elmo-folder-persistent-p folder)
- (elmo-flag-table-save (elmo-folder-msgdb-path folder) table))
+ (elmo-folder-close-flag-table folder))
succeeds)
(luna-call-next-method)))
path ; directory path for msgdb.
msgdb ; msgdb (may be nil).
killed-list ; killed list.
+ flag-table ; flag table.
persistent ; non-nil if persistent.
process-duplicates ; read or hide
biff ; folder for biff
(luna-define-generic elmo-folder-append-buffer (folder &optional flags
number)
"Append current buffer as a new message.
-FOLDER is the destination folder(ELMO folder structure).
+FOLDER is the destination folder (ELMO folder structure).
FLAGS is the status of appended message (list of symbols).
+If it is nil, it is not that there is no flag and what is not defined is meant.
If optional argument NUMBER is specified, the new message number is set
\(if possible\).
Return nil on failure.")
(luna-define-method elmo-folder-have-subfolder-p ((folder elmo-folder))
t)
+;; Flag table
+(luna-define-generic elmo-folder-flag-table (folder &optional if-exists)
+ "Return the flag-table of FOLDER.
+If optional argument IF-EXISTS is nil, load on demand.
+\(For internal use only.\)")
+
+(luna-define-generic elmo-folder-close-flag-table (folder)
+ "Close flag-table of FOLDER.")
+
+(luna-define-method elmo-folder-flag-table ((folder elmo-folder)
+ &optional if-exists)
+ (or (elmo-folder-flag-table-internal folder)
+ (unless if-exists
+ (elmo-folder-set-flag-table-internal
+ folder
+ (elmo-flag-table-load (elmo-folder-msgdb-path folder))))))
+
+(luna-define-method elmo-folder-close-flag-table ((folder elmo-folder))
+ (elmo-flag-table-save (elmo-folder-msgdb-path folder)
+ (elmo-folder-flag-table folder))
+ (elmo-folder-set-flag-table-internal folder nil))
+
+(defun elmo-folder-preserve-falgs (folder msgid flags)
+ "Preserve FLAGS into FOLDER for a message that has MSGID."
+ (when (and msgid flags)
+ (let ((flag-table (elmo-folder-flag-table folder 'if-exists))
+ load-now)
+ (when (setq load-now (null flag-table))
+ (setq flag-table (elmo-folder-flag-table folder)))
+ (elmo-flag-table-set flag-table msgid flags)
+ (when load-now
+ (elmo-folder-close-flag-table folder)))))
+
;;; Folder info
;; Folder info is a message number information cache (hashtable)
(defsubst elmo-folder-get-info (folder &optional hashtb)
(let ((src-msgdb-exists (not (zerop (elmo-folder-length src-folder))))
unseen table flags
succeed-numbers failure cache id)
- (setq table (elmo-flag-table-load (elmo-folder-msgdb-path folder)))
+ (setq table (elmo-folder-flag-table folder))
(with-temp-buffer
(set-buffer-multibyte nil)
(while numbers
id (and src-msgdb-exists
(elmo-message-field src-folder (car numbers)
'message-id))
- flags (elmo-message-flags src-folder (car numbers)))
+ flags (or (elmo-message-flags src-folder (car numbers))
+ (and id '(read))))
(condition-case nil
(setq cache (elmo-file-cache-get id)
failure
(> (buffer-size) 0)
(elmo-folder-append-buffer
folder
- (or flags '(read))
+ flags
(if same-number (car numbers))))))
(error (setq failure t)))
;; FETCH & APPEND finished
(unless failure
- (when id
- (elmo-flag-table-set table id flags))
(setq succeed-numbers (cons (car numbers) succeed-numbers)))
(elmo-progress-notify 'elmo-folder-move-messages)
(setq numbers (cdr numbers)))
(when (elmo-folder-persistent-p folder)
- (elmo-flag-table-save (elmo-folder-msgdb-path folder) table))
+ (elmo-folder-close-flag-table folder))
succeed-numbers)))
;; Arguments should be reduced.