* elmo.el (elmo-folder-append-buffer): Changed argument from unread
authorteranisi <teranisi>
Tue, 25 Mar 2003 02:58:31 +0000 (02:58 +0000)
committerteranisi <teranisi>
Tue, 25 Mar 2003 02:58:31 +0000 (02:58 +0000)
to flag. (All other related portions are changed.)
(elmo-folder-msgdb-create): Likewise.
(elmo-generic-folder-append-messages): Use flag-table instead of seen-list.
(elmo-folder-move-messages): Removed redundant process.
(elmo-folder-synchronize): Likewise.

* elmo-msgdb.el (elmo-flag-table-get): New function.
(elmo-flag-table-save): Fixed.
(elmo-msgdb-length): New inline function.
(elmo-msgdb-flag-table): New function.
(elmo-msgdb-mark): Add optional argument new.
(elmo-msgdb-add-msgs-to-seen-list): Abolish.
(elmo-msgdb-seen-list): Ditto.
(elmo-msgdb-add-msgs-to-seen-list): Ditto.

20 files changed:
elmo/ChangeLog
elmo/elmo-archive.el
elmo/elmo-cache.el
elmo/elmo-dop.el
elmo/elmo-filter.el
elmo/elmo-imap4.el
elmo/elmo-localdir.el
elmo/elmo-maildir.el
elmo/elmo-mark.el
elmo/elmo-msgdb.el
elmo/elmo-multi.el
elmo/elmo-net.el
elmo/elmo-nmz.el
elmo/elmo-nntp.el
elmo/elmo-pipe.el
elmo/elmo-pop3.el
elmo/elmo-sendlog.el
elmo/elmo-shimbun.el
elmo/elmo-split.el
elmo/elmo.el

index 457ee32..bc97007 100644 (file)
@@ -1,3 +1,23 @@
+2003-03-25  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * elmo.el (elmo-folder-append-buffer): Changed argument from unread 
+       to flag. (All other related portions are changed.)
+       (elmo-folder-msgdb-create): Likewise.
+       (elmo-generic-folder-append-messages): Use flag-table instead of
+       seen-list.
+       (elmo-folder-move-messages): Removed redundant process.
+       (elmo-folder-synchronize): Likewise.
+
+       * elmo-msgdb.el (elmo-flag-table-get): New function.
+       (elmo-flag-table-save): Fixed.
+       (elmo-msgdb-length): New inline function.
+       (elmo-msgdb-flag-table): New function.
+       (elmo-msgdb-mark): Add optional argument new.
+       (elmo-msgdb-add-msgs-to-seen-list): Abolish.
+       (elmo-msgdb-seen-list): Ditto.
+       (elmo-msgdb-add-msgs-to-seen-list): Ditto.
+
+
 2003-03-24  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * elmo.el (elmo-message-set-mark): Abolish.
index f0ec870..eb94d29 100644 (file)
@@ -570,11 +570,11 @@ TYPE specifies the archiver's symbol."
   (elmo-archive-message-fetch-internal folder number))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-archive-folder)
-                                              unread &optional number)
-  (elmo-archive-folder-append-buffer folder unread number))
+                                              &optional flag number)
+  (elmo-archive-folder-append-buffer folder flag number))
 
 ;; verrrrrry slow!!
-(defun elmo-archive-folder-append-buffer (folder unread number)
+(defun elmo-archive-folder-append-buffer (folder flag 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))
@@ -906,7 +906,7 @@ TYPE specifies the archiver's symbol."
       (elmo-archive-msgdb-create-entity-subr number))))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-archive-folder)
-                                             numbers seen-list)
+                                             numbers flag-table)
   (when numbers
     (save-excursion ;; 981005
       (if (and elmo-archive-use-izip-agent
@@ -914,11 +914,11 @@ TYPE specifies the archiver's symbol."
                (elmo-archive-folder-archive-type-internal folder)
                'cat-headers))
          (elmo-archive-msgdb-create-as-numlist-subr2
-          folder numbers seen-list)
+          folder numbers flag-table)
        (elmo-archive-msgdb-create-as-numlist-subr1
-        folder numbers seen-list)))))
+        folder numbers flag-table)))))
 
-(defun elmo-archive-msgdb-create-as-numlist-subr1 (folder numlist seen-list)
+(defun elmo-archive-msgdb-create-as-numlist-subr1 (folder numlist flag-table)
   (let* ((type (elmo-archive-folder-archive-type-internal folder))
         (file (elmo-archive-get-archive-name folder))
         (method (elmo-archive-get-method type 'cat))
@@ -944,17 +944,13 @@ TYPE specifies the archiver's symbol."
                 (elmo-msgdb-overview-entity-get-number entity)
                 (car entity)))
          (setq message-id (car entity))
-         (setq seen (member message-id seen-list))
          (if (setq gmark
                    (or (elmo-msgdb-global-mark-get message-id)
-                       (if (elmo-file-cache-status
-                            (elmo-file-cache-get message-id))
-                           (if seen
-                               nil
-                             elmo-msgdb-unread-cached-mark)
-                         (if seen
-                             elmo-msgdb-read-uncached-mark
-                           elmo-msgdb-new-mark))))
+                       (elmo-msgdb-mark
+                        (elmo-flag-table-get flag-table message-id)
+                        (elmo-file-cache-status
+                         (elmo-file-cache-get message-id))
+                        'new)))
              (setq mark-alist
                    (elmo-msgdb-mark-append
                     mark-alist
@@ -973,7 +969,7 @@ TYPE specifies the archiver's symbol."
 ;;; info-zip agent
 (defun elmo-archive-msgdb-create-as-numlist-subr2 (folder
                                                   numlist
-                                                  seen-list)
+                                                  flag-table)
   (let* ((delim1 elmo-mmdf-delimiter)          ;; MMDF
         (delim2 elmo-unixmail-delimiter)       ;; UNIX Mail
         (type (elmo-archive-folder-archive-type-internal folder))
@@ -1006,7 +1002,7 @@ TYPE specifies the archiver's symbol."
        (goto-char (point-min))
        (cond
         ((looking-at delim1)   ;; MMDF
-         (setq result (elmo-archive-parse-mmdf msgs seen-list))
+         (setq result (elmo-archive-parse-mmdf msgs flag-table))
          (setq overview (append overview (nth 0 result)))
          (setq number-alist (append number-alist (nth 1 result)))
          (setq mark-alist (append mark-alist (nth 2 result))))
@@ -1025,10 +1021,10 @@ TYPE specifies the archiver's symbol."
           percent))))
     (list overview number-alist mark-alist)))
 
-(defun elmo-archive-parse-mmdf (msgs seen-list)
+(defun elmo-archive-parse-mmdf (msgs flag-table)
   (let ((delim elmo-mmdf-delimiter)
        number sp ep rest entity overview number-alist mark-alist ret-val
-       message-id seen gmark)
+       message-id gmark)
     (goto-char (point-min))
     (setq rest msgs)
     (while (and rest (re-search-forward delim nil t)
@@ -1051,17 +1047,13 @@ TYPE specifies the archiver's symbol."
                 (elmo-msgdb-overview-entity-get-number entity)
                 (car entity)))
          (setq message-id (car entity))
-         (setq seen (member message-id seen-list))
          (if (setq gmark
                    (or (elmo-msgdb-global-mark-get message-id)
-                       (if (elmo-file-cache-status
-                            (elmo-file-cache-get message-id))
-                           (if seen
-                               nil
-                             elmo-msgdb-unread-cached-mark)
-                         (if seen
-                             elmo-msgdb-read-uncached-mark
-                           elmo-msgdb-new-mark))))
+                       (elmo-msgdb-mark
+                        (elmo-flag-table-get flag-table message-id)
+                        (elmo-file-cache-status
+                         (elmo-file-cache-get message-id))
+                        'new)))
              (setq mark-alist
                    (elmo-msgdb-mark-append
                     mark-alist
index 5efac75..84bcf3a 100644 (file)
@@ -87,7 +87,7 @@
    (elmo-cache-folder-directory-internal folder)))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-cache-folder)
-                                             numbers seen-list)
+                                             numbers flag-table)
   (let ((i 0)
        (len (length numbers))
        overview number-alist mark-alist entity message-id
                                     num
                                     message-id))
        (if (setq mark (or (elmo-msgdb-global-mark-get message-id)
-                          (if (member message-id seen-list) nil
-                            elmo-msgdb-new-mark)))
+                          (elmo-msgdb-mark
+                           (elmo-flag-table-get flag-table message-id)
+                           (elmo-file-cache-status
+                            (elmo-file-cache-get message-id))
+                           'new)))
            (setq mark-alist
                  (elmo-msgdb-mark-append
                   mark-alist
     (list overview number-alist mark-alist)))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-cache-folder)
-                                              unread
-                                              &optional number)
+                                              &optional flag number)
   ;; dir-name is changed according to msgid.
   (unless (elmo-cache-folder-dir-name-internal folder)
     (let* ((file (elmo-file-cache-get-path (std11-field-body "message-id")))
index 3726736..fda2f92 100644 (file)
@@ -234,10 +234,10 @@ FOLDER is the folder structure."
                                 (car (elmo-dop-queue-arguments queue)))))))))
 
 ;;; DOP operations.
-(defsubst elmo-folder-append-buffer-dop (folder unread &optional number)
+(defsubst elmo-folder-append-buffer-dop (folder &optional flag number)
   (elmo-dop-queue-append
    folder 'elmo-folder-append-buffer-dop-delayed
-   (list unread
+   (list flag
         (elmo-dop-spool-folder-append-buffer
          folder)
         number)))
@@ -301,7 +301,7 @@ FOLDER is the folder structure."
     (cons (+ max-num spool-length) (+ (length number-list) spool-length))))
 
 ;;; Delayed operation (executed at online status).
-(defun elmo-folder-append-buffer-dop-delayed (folder unread number set-number)
+(defun elmo-folder-append-buffer-dop-delayed (folder flag number set-number)
   (let ((spool-folder (elmo-dop-spool-folder folder))
        failure saved dequeued)
     (with-temp-buffer
@@ -311,14 +311,17 @@ FOLDER is the folder structure."
          (condition-case nil
              (setq failure (not
                             (elmo-folder-append-buffer
-                             folder unread set-number)))
+                             folder
+                             (if (eq flag t) nil flag) ; for compatibility
+                             set-number)))
            (error (setq failure t)))
        (setq dequeued t)) ; Already deletef from queue.
       (when failure
        ;; Append failed...
        (setq saved (elmo-folder-append-buffer
                     (elmo-make-folder elmo-lost+found-folder)
-                    unread set-number)))
+                    (if (eq flag t) nil flag) ; for compatibility
+                    set-number)))
       (if (and (not dequeued)    ; if dequeued, no need to delete.
               (or (not failure) ; succeed
                   saved))       ; in lost+found
index 1e4c7a1..296efb9 100644 (file)
    type))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-filter-folder)
-                                             numlist seen-list)
+                                             numlist flag-table)
   (if (elmo-filter-folder-require-msgdb-internal folder)
       (let* ((target-folder (elmo-filter-folder-target-internal folder))
             (len (length numlist))
     ;; Does not require msgdb.
     (elmo-folder-msgdb-create
      (elmo-filter-folder-target-internal folder)
-     numlist seen-list)))
+     numlist flag-table)))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-filter-folder)
-                                              unread &optional number)
+                                              &optional flag number)
   (elmo-folder-append-buffer
    (elmo-filter-folder-target-internal folder)
-   unread number))
+   flag number))
 
 (luna-define-method elmo-message-fetch ((folder elmo-filter-folder)
                                        number strategy
index e2d3dec..e998989 100644 (file)
@@ -770,12 +770,11 @@ If CHOP-LENGTH is not specified, message set is not chopped."
 
 ;;
 ;; app-data:
-;; cons of seen-list and result of use-flag-p.
+;; cons of flag-table and result of use-flag-p.
 (defsubst elmo-imap4-fetch-callback-1-subr (entity flags app-data)
   "A msgdb entity callback function."
   (let* ((use-flag (cdr app-data))
         (app-data (car app-data))
-        (seen (member (car entity) app-data))
         mark)
     (if (member "\\Flagged" flags)
        (elmo-msgdb-global-mark-set (car entity)
@@ -791,16 +790,14 @@ If CHOP-LENGTH is not specified, message set is not chopped."
                         ;; cached.
                         (if (member "\\Answered" flags)
                             elmo-msgdb-answered-cached-mark
-                          (if (or seen
-                                  (and use-flag
-                                       (member "\\Seen" flags)))
+                          (if (and use-flag
+                                   (member "\\Seen" flags))
                               nil
                             elmo-msgdb-unread-cached-mark))
                       (if (member "\\Answered" flags)
                           elmo-msgdb-answered-uncached-mark
-                        (if (or seen
-                                (and use-flag
-                                     (member "\\Seen" flags)))
+                        (if (and use-flag
+                                 (member "\\Seen" flags))
                             (if elmo-imap4-use-cache
                                 elmo-msgdb-read-uncached-mark)
                           elmo-msgdb-new-mark))))))
@@ -2245,7 +2242,7 @@ If optional argument REMOVE is non-nil, remove FLAG."
     (luna-call-next-method)))
 
 (luna-define-method elmo-folder-msgdb-create-plugged
-  ((folder elmo-imap4-folder) numbers seen-list)
+  ((folder elmo-imap4-folder) numbers flag-table)
   (when numbers
     (let ((session (elmo-imap4-get-session folder))
          (headers
@@ -2271,7 +2268,7 @@ If optional argument REMOVE is non-nil, remove FLAG."
        (setq elmo-imap4-current-msgdb nil
              elmo-imap4-seen-messages nil
              elmo-imap4-fetch-callback 'elmo-imap4-fetch-callback-1
-             elmo-imap4-fetch-callback-data (cons seen-list
+             elmo-imap4-fetch-callback-data (cons flag-table
                                                   (elmo-folder-use-flag-p
                                                    folder)))
        (while set-list
@@ -2491,7 +2488,7 @@ If optional argument REMOVE is non-nil, remove FLAG."
          (elmo-imap4-folder-mailbox-internal folder)))))
 
 (luna-define-method elmo-folder-append-buffer
-  ((folder elmo-imap4-folder) unread &optional number)
+  ((folder elmo-imap4-folder) &optional flag number)
   (if (elmo-folder-plugged-p folder)
       (let ((session (elmo-imap4-get-session folder))
            send-buffer result)
@@ -2507,13 +2504,16 @@ If optional argument REMOVE is non-nil, remove FLAG."
                    "append "
                    (elmo-imap4-mailbox (elmo-imap4-folder-mailbox-internal
                                         folder))
-                   (if unread " () " " (\\Seen) ")
+                   (cond 
+                    ((eq flag 'read) " (\\Seen) ")
+                    ((eq flag 'answered) " (\\Answered)")
+                    (t " () "))
                    (elmo-imap4-buffer-literal send-buffer))))
          (kill-buffer send-buffer))
        result)
     ;; Unplugged
     (if elmo-enable-disconnected-operation
-       (elmo-folder-append-buffer-dop folder unread number)
+       (elmo-folder-append-buffer-dop folder flag number)
       (error "Unplugged"))))
 
 (eval-when-compile
index 7308144..9df24d0 100644 (file)
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-localdir-folder)
                                              numbers
-                                             seen-list)
+                                             flag-table)
   (when numbers
     (let ((dir (elmo-localdir-folder-directory-internal folder))
          overview number-alist mark-alist entity message-id
-         num seen gmark
+         num gmark
          (i 0)
          (len (length numbers)))
       (message "Creating msgdb...")
                (elmo-msgdb-number-add number-alist
                                       num
                                       message-id))
-         (setq seen (member message-id seen-list))
          (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
-                             (if (elmo-file-cache-exists-p message-id) ; XXX
-                                 (if seen
-                                     nil
-                                   elmo-msgdb-unread-cached-mark)
-                               (if seen
-                                   nil ;;seen-mark
-                                 elmo-msgdb-new-mark))))
+                             (elmo-msgdb-mark
+                              (elmo-flag-table-get flag-table message-id)
+                              (elmo-file-cache-status
+                               (elmo-file-cache-get message-id))
+                              'new)))
              (setq mark-alist
                    (elmo-msgdb-mark-append
                     mark-alist
index 1558a9a..7b58ec4 100644 (file)
@@ -132,7 +132,7 @@ LOCATION."
   (elmo-maildir-folder-flagged-locations-internal folder))
 
 (luna-define-method elmo-folder-msgdb-create 
-  ((folder elmo-maildir-folder) numbers seen-list)
+  ((folder elmo-maildir-folder) numbers flag-table)
   (let* ((unread-list (elmo-maildir-folder-unread-locations-internal folder))
         (flagged-list (elmo-maildir-folder-flagged-locations-internal folder))
         (len (length numbers))
@@ -354,7 +354,7 @@ file name for maildir directories."
     filename))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-maildir-folder)
-                                              unread &optional number)
+                                              &optional status number)
   (let ((basedir (elmo-maildir-folder-directory-internal folder))
        (src-buf (current-buffer))
        dst-buf filename)
index c3116df..8773739 100644 (file)
@@ -84,7 +84,7 @@
    (elmo-map-message-location folder number)))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-mark-folder)
-                                             numbers seen-list)
+                                             numbers flag-table)
   (elmo-mark-folder-msgdb-create folder numbers))
 
 (defun elmo-mark-folder-msgdb-create (folder numbers)
     (list overview number-alist mark-alist)))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-mark-folder)
-                                              unread &optional number)
+                                              &optional flag number)
   (let* ((msgid (elmo-field-body "message-id"))
         (path (elmo-file-cache-get-path msgid))
         dir)
index 7fb5013..40c45de 100644 (file)
 ;; 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-flag-table-load
+;; elmo-flag-table-set
+;; elmo-flag-table-get
+;; elmo-flag-table-save
 
 ;; elmo-msgdb-append-entity-from-buffer
-;; msgdb number flag id-mark-table &optional buffer
+;; msgdb number flag-table &optional buffer
+
+;; 
 
 ;; ENTITY elmo-msgdb-make-entity ARGS
 ;; VALUE elmo-msgdb-entity-field ENTITY
 ;; 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
@@ -523,16 +525,20 @@ content of MSGDB is changed."
 (defun elmo-flag-table-set (flag-table msg-id flag)
   (elmo-set-hash-val msg-id flag flag-table))
 
+(defun elmo-flag-table-get (flag-table msg-id)
+  (elmo-get-hash-val msg-id flag-table))
+
 (defun elmo-flag-table-save (dir flag-table)
   (elmo-object-save
    (expand-file-name elmo-flag-table-filename dir)
-   (let (list)
-     (mapatoms (lambda (atom)
-                (setq list (cons (cons (symbol-name atom)
-                                       (symbol-value atom))
-                                 list)))
-              flag-table)
-     list)))
+   (if flag-table
+       (let (list)
+        (mapatoms (lambda (atom)
+                    (setq list (cons (cons (symbol-name atom)
+                                           (symbol-value atom))
+                                     list)))
+                  flag-table)
+        list))))
 ;;;
 ;; persistent mark handling
 ;; (for each folder)
@@ -542,24 +548,35 @@ content of MSGDB is changed."
   (setq alist (elmo-msgdb-append-element alist
                                         (list id mark))))
 
-(defun elmo-msgdb-seen-list (msgdb)
-  "Get SEEN-MSGID-LIST from MSGDB."
-  (let ((ov (elmo-msgdb-get-overview msgdb))
-       mark seen-list)
-    (while ov
-      (if (setq mark (elmo-msgdb-get-mark
-                     msgdb
-                     (elmo-msgdb-overview-entity-get-number (car ov))))
-         (if (and mark (not (member mark
-                                    (elmo-msgdb-unread-marks))))
-             (setq seen-list (cons
-                              (elmo-msgdb-overview-entity-get-id (car ov))
-                              seen-list)))
-       (setq seen-list (cons
-                        (elmo-msgdb-overview-entity-get-id (car ov))
-                        seen-list)))
-      (setq ov (cdr ov)))
-    seen-list))
+(defsubst elmo-msgdb-length (msgdb)
+  (length (elmo-msgdb-get-overview msgdb)))
+
+(defun elmo-msgdb-flag-table (msgdb &optional flag-table)
+  ;; Make a table of msgid flag (read, answered)
+  (let ((flag-table (or flag-table (elmo-make-hash (elmo-msgdb-length msgdb))))
+       mark)
+    (dolist (ov (elmo-msgdb-get-overview msgdb))
+      (setq mark (elmo-msgdb-get-mark
+                 msgdb
+                 (elmo-msgdb-overview-entity-get-number ov)))
+      (cond 
+       ((null mark)
+       (elmo-set-hash-val
+        (elmo-msgdb-overview-entity-get-id ov)
+        'read
+        flag-table))
+       ((and mark (member mark (elmo-msgdb-answered-marks)))
+       (elmo-set-hash-val
+        (elmo-msgdb-overview-entity-get-id ov)
+        'answered
+        flag-table))
+       ((and mark (not (member mark
+                              (elmo-msgdb-unread-marks))))
+       (elmo-set-hash-val
+        (elmo-msgdb-overview-entity-get-id ov)
+        'read
+        flag-table))))
+    flag-table))
 
 ;;
 ;; mime decode cache
@@ -675,18 +692,34 @@ header separator."
        (setcar (cdr entity) after))
       (setq mark-alist (cdr mark-alist)))))
 
-(defsubst elmo-msgdb-mark (flag cached)
-  (case flag
-    (unread
-     (if cached
-        elmo-msgdb-unread-cached-mark
-       elmo-msgdb-unread-uncached-mark))
-    (important
-     elmo-msgdb-important-mark)
-    (answered
-     (if cached
-        elmo-msgdb-answered-cached-mark
-       elmo-msgdb-answered-uncached-mark))))
+(defsubst elmo-msgdb-mark (flag cached &optional new)
+  (if new
+      (case flag
+       (read
+        (if cached
+            nil
+          elmo-msgdb-read-uncached-mark))
+       (important
+        elmo-msgdb-important-mark)
+       (answered
+        (if cached
+            elmo-msgdb-answered-cached-mark
+          elmo-msgdb-answered-uncached-mark))
+       (t
+        (if cached
+            elmo-msgdb-unread-cached-mark
+          elmo-msgdb-new-mark)))
+    (case flag
+      (unread
+       (if cached
+          elmo-msgdb-unread-cached-mark
+        elmo-msgdb-unread-uncached-mark))
+      (important
+       elmo-msgdb-important-mark)
+      (answered
+       (if cached
+          elmo-msgdb-answered-cached-mark
+        elmo-msgdb-answered-uncached-mark)))))
 
 (defsubst elmo-msgdb-seen-save (dir obj)
   (elmo-object-save
@@ -1047,24 +1080,6 @@ Return CONDITION itself if no entity exists in msgdb."
                     elmo-msgdb-directory)
                    alist))
 
-(defun elmo-msgdb-add-msgs-to-seen-list (msgs msgdb seen-list)
-  ;; Add to seen list.
-  (let (mark)
-    (while msgs
-      (if (setq mark (elmo-msgdb-get-mark msgdb (car msgs)))
-         (unless (member mark (elmo-msgdb-unread-marks)) ;; not unread mark
-           (setq seen-list
-                 (cons
-                  (elmo-msgdb-get-field msgdb (car msgs) 'message-id)
-                  seen-list)))
-       ;; no mark ... seen...
-       (setq seen-list
-             (cons 
-              (elmo-msgdb-get-field msgdb (car msgs) 'message-id)
-              seen-list)))
-      (setq msgs (cdr msgs)))
-    seen-list))
-
 (defun elmo-msgdb-get-message-id-from-buffer ()
   (let ((msgid (elmo-field-body "message-id")))
     (if msgid
index 31f7573..3c49cca 100644 (file)
     numbers-list))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-multi-folder)
-                                             numbers seen-list)
+                                             numbers flag-table)
   (let* ((folders (elmo-multi-folder-children-internal folder))
         overview number-alist mark-alist entity
         numbers-list
                 (elmo-multi-msgdb
                  (elmo-folder-msgdb-create (nth cur-number folders)
                                            (nth cur-number numbers-list)
-                                           seen-list)
+                                           flag-table)
                  (* (elmo-multi-folder-divide-number-internal folder)
                     (1+ cur-number))))))
       (setq cur-number (1+ cur-number)))
index 22d40f6..06c661e 100644 (file)
@@ -438,22 +438,22 @@ Returned value is searched from `elmo-network-stream-type-alist'."
   (elmo-folder-delete-messages-dop folder numbers))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-net-folder)
-                                             numbers seen-list)
+                                             numbers flag-table)
   (if (elmo-folder-plugged-p folder)
       (elmo-folder-send folder 'elmo-folder-msgdb-create-plugged
-                       numbers seen-list)
+                       numbers flag-table)
     (elmo-folder-send folder 'elmo-folder-msgdb-create-unplugged
-                     numbers seen-list)))
+                     numbers flag-table)))
 
 (luna-define-method elmo-folder-msgdb-create-unplugged ((folder
                                                         elmo-net-folder)
                                                        numbers
-                                                       seen-list)
+                                                       flag-table)
   ;; XXXX should be appended to already existing msgdb.
   (elmo-dop-msgdb
    (elmo-folder-msgdb-create (elmo-dop-spool-folder folder)
                             (mapcar 'abs numbers)
-                            seen-list)))
+                            flag-table)))
 
 (luna-define-method elmo-folder-unmark-important :before ((folder
                                                           elmo-net-folder)
index 4459d24..59fe128 100644 (file)
@@ -117,7 +117,7 @@ If the value is a list, all elements are used as index paths for namazu."
     entity))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-nmz-folder)
-                                             numlist seen-list)
+                                             numlist flag-table)
   (let* (overview number-alist mark-alist entity
                  i percent num pair)
     (setq num (length numlist))
index f34d0ea..97a2f6d 100644 (file)
@@ -703,7 +703,7 @@ Don't cache if nil.")
     ("xref" . 8)))
 
 (defun elmo-nntp-create-msgdb-from-overview-string (str
-                                                   seen-list
+                                                   flag-table
                                                    &optional numlist)
   (let (ov-list gmark message-id seen
        ov-entity overview number-alist mark-alist num
@@ -758,17 +758,12 @@ Don't cache if nil.")
              (elmo-msgdb-number-add number-alist num
                                     (aref ov-entity 4)))
        (setq message-id (aref ov-entity 4))
-       (setq seen (member message-id seen-list))
        (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
-                           (if (elmo-file-cache-status
-                                (elmo-file-cache-get message-id))
-                               (if seen
-                                   nil
-                                 elmo-msgdb-unread-cached-mark)
-                             (if seen
-                                 (if elmo-nntp-use-cache
-                                     elmo-msgdb-read-uncached-mark)
-                               elmo-msgdb-new-mark))))
+                           (elmo-msgdb-mark
+                            (elmo-flag-table-get flag-table message-id)
+                            (elmo-file-cache-status
+                             (elmo-file-cache-get message-id))
+                            'new)))
            (setq mark-alist
                  (elmo-msgdb-mark-append mark-alist
                                          num gmark))))
@@ -776,10 +771,10 @@ Don't cache if nil.")
     (list overview number-alist mark-alist)))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-nntp-folder)
-                                             numbers seen-list)
-  (elmo-nntp-folder-msgdb-create folder numbers seen-list))
+                                             numbers flag-table)
+  (elmo-nntp-folder-msgdb-create folder numbers flag-table))
 
-(defun elmo-nntp-folder-msgdb-create (folder numbers seen-list)
+(defun elmo-nntp-folder-msgdb-create (folder numbers flag-table)
   (let ((filter numbers)
        (session (elmo-nntp-get-session folder))
        beg-num end-num cur length
@@ -808,7 +803,7 @@ Don't cache if nil.")
                     ret-val
                     (elmo-nntp-create-msgdb-from-overview-string
                      ov-str
-                     seen-list
+                     flag-table
                      filter
                      )))))
        (if (null (elmo-nntp-read-response session t))
@@ -829,7 +824,7 @@ Don't cache if nil.")
         'elmo-nntp-msgdb-create "Getting overview..." 100)))
     (if (not use-xover)
        (setq ret-val (elmo-nntp-msgdb-create-by-header
-                      session numbers seen-list))
+                      session numbers flag-table))
       (with-current-buffer (elmo-network-session-buffer session)
        (if ov-str
            (setq ret-val
@@ -837,7 +832,7 @@ Don't cache if nil.")
                   ret-val
                   (elmo-nntp-create-msgdb-from-overview-string
                    ov-str
-                   seen-list
+                   flag-table
                    filter))))))
     (elmo-folder-set-killed-list-internal
      folder
@@ -897,11 +892,11 @@ Don't cache if nil.")
                   (nconc number-alist
                          (list (cons max-number nil))))))))))
 
-(defun elmo-nntp-msgdb-create-by-header (session numbers seen-list)
+(defun elmo-nntp-msgdb-create-by-header (session numbers flag-table)
   (with-temp-buffer
     (elmo-nntp-retrieve-headers session (current-buffer) numbers)
     (elmo-nntp-msgdb-create-message
-     (length numbers) seen-list)))
+     (length numbers) flag-table)))
 
 (defun elmo-nntp-parse-xhdr-response (string)
   (let (response)
@@ -1380,7 +1375,7 @@ Returns a list of cons cells like (NUMBER . VALUE)"
 
 ;; end of from Gnus
 
-(defun elmo-nntp-msgdb-create-message (len seen-list)
+(defun elmo-nntp-msgdb-create-message (len flag-table)
   (save-excursion
     (let (beg overview number-alist mark-alist
              entity i num gmark seen message-id)
@@ -1412,18 +1407,13 @@ Returns a list of cons cells like (NUMBER . VALUE)"
                       (elmo-msgdb-overview-entity-get-number entity)
                       (car entity)))
                (setq message-id (car entity))
-               (setq seen (member message-id seen-list))
                (if (setq gmark
                          (or (elmo-msgdb-global-mark-get message-id)
-                             (if (elmo-file-cache-status
-                                  (elmo-file-cache-get message-id))
-                                 (if seen
-                                     nil
-                                   elmo-msgdb-unread-cached-mark)
-                               (if seen
-                                   (if elmo-nntp-use-cache
-                                       elmo-msgdb-read-uncached-mark)
-                                 elmo-msgdb-new-mark))))
+                             (elmo-msgdb-mark
+                              (elmo-flag-table-get flag-table message-id)
+                              (elmo-file-cache-status
+                               (elmo-file-cache-get message-id))
+                              'new)))
                    (setq mark-alist
                          (elmo-msgdb-mark-append
                           mark-alist
index eb48a3e..87c477a 100644 (file)
@@ -67,9 +67,9 @@
       (elmo-folder-contains-type (elmo-pipe-folder-dst-internal folder) type)))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-pipe-folder)
-                                             numlist seen-list)
+                                             numlist flag-table)
   (elmo-folder-msgdb-create (elmo-pipe-folder-dst-internal folder)
-                           numlist seen-list))
+                           numlist flag-table))
 
 (luna-define-method elmo-folder-append-messages ((folder elmo-pipe-folder)
                                                 src-folder numbers
@@ -79,9 +79,9 @@
                               same-number))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-pipe-folder)
-                                              unread &optional number)
+                                              &optional flag number)
   (elmo-folder-append-buffer (elmo-pipe-folder-dst-internal folder)
-                            unread number))
+                            flag number))
 
 (luna-define-method elmo-message-fetch ((folder elmo-pipe-folder)
                                        number strategy
index 0192041..0d9c9d7 100644 (file)
@@ -677,7 +677,7 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
       (copy-to-buffer tobuffer (point-min) (point-max)))))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-pop3-folder)
-                                             numlist seen-list)
+                                             numlist flag-table)
   (let ((process (elmo-network-session-process-internal
                  (elmo-pop3-get-session folder))))
     (with-current-buffer (process-buffer process)
@@ -686,7 +686,7 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
        (elmo-pop3-msgdb-create-by-header
        process
        numlist
-       seen-list
+       flag-table
        (if (elmo-pop3-folder-use-uidl-internal folder)
            (elmo-pop3-folder-location-alist-internal folder)))))))
 
@@ -724,7 +724,7 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
                     elmo-pop3-size-hash))
 
 (defun elmo-pop3-msgdb-create-by-header (process numlist
-                                                seen-list
+                                                flag-table
                                                 loc-alist)
   (let ((tmp-buffer (get-buffer-create " *ELMO Overview TMP*")))
     (with-current-buffer (process-buffer process)
@@ -744,14 +744,14 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
           process
           (length numlist)
           numlist
-          seen-list loc-alist)
+          flag-table loc-alist)
        (kill-buffer tmp-buffer)))))
 
 (defun elmo-pop3-msgdb-create-message (buffer
                                       process
                                       num
                                       numlist
-                                      seen-list
+                                      flag-table
                                       loc-alist)
   (save-excursion
     (let (beg overview number-alist mark-alist
@@ -795,17 +795,12 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
                     (elmo-msgdb-overview-entity-get-number entity)
                     (car entity)))
              (setq message-id (car entity))
-             (setq seen (member message-id seen-list))
              (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
-                                 (if (elmo-file-cache-status
-                                      (elmo-file-cache-get message-id))
-                                     (if seen
-                                         nil
-                                       elmo-msgdb-unread-cached-mark)
-                                   (if seen
-                                       (if elmo-pop3-use-cache
-                                           elmo-msgdb-read-uncached-mark)
-                                     elmo-msgdb-new-mark))))
+                                 (elmo-msgdb-mark
+                                  (elmo-flag-table-get flag-table message-id)
+                                  (elmo-file-cache-status
+                                   (elmo-file-cache-get message-id))
+                                  'new)))
                  (setq mark-alist
                        (elmo-msgdb-mark-append
                         mark-alist
index de753f8..c8cbbc4 100644 (file)
@@ -81,7 +81,7 @@
    (elmo-map-message-location folder number)))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-sendlog-folder)
-                                             numbers seen-list)
+                                             numbers flag-table)
   (let ((i 0)
        (len (length numbers))
        overview number-alist mark-alist entity message-id
                                     num
                                     message-id))
        (if (setq mark (or (elmo-msgdb-global-mark-get message-id)
-                          (if (member message-id seen-list) nil
-                            elmo-msgdb-new-mark)))
+                          (elmo-msgdb-mark
+                           (elmo-flag-table-get flag-table message-id)
+                           (elmo-file-cache-status
+                            (elmo-file-cache-get message-id))
+                           'new)))
            (setq mark-alist
                  (elmo-msgdb-mark-append
                   mark-alist
index 924e535..b606f15 100644 (file)
@@ -349,7 +349,7 @@ update overview when message is fetched."
          (list (cons "xref" (shimbun-header-xref header)))))))))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-shimbun-folder)
-                                             numlist seen-list)
+                                             numlist flag-table)
   (let* (overview number-alist mark-alist entity
                  i percent number length pair msgid gmark seen)
     (setq length (length numlist))
@@ -368,15 +368,12 @@ update overview when message is fetched."
        (setq number-alist
              (elmo-msgdb-number-add number-alist
                                     number msgid))
-       (setq seen (member msgid seen-list))
        (if (setq gmark (or (elmo-msgdb-global-mark-get msgid)
-                           (if (elmo-file-cache-status
-                                (elmo-file-cache-get msgid))
-                               (if seen nil elmo-msgdb-unread-cached-mark)
-                             (if seen
-                                 (if elmo-shimbun-use-cache
-                                     elmo-msgdb-read-uncached-mark)
-                               elmo-msgdb-new-mark))))
+                           (elmo-msgdb-mark
+                            (elmo-flag-table-get flag-table msgid)
+                            (elmo-file-cache-status
+                             (elmo-file-cache-get msgid))
+                            'new)))
            (setq mark-alist
                  (elmo-msgdb-mark-append mark-alist
                                          number gmark))))
index 03a975e..79090cb 100644 (file)
@@ -326,7 +326,7 @@ If prefix argument ARG is specified, do a reharsal (no harm)."
                                         action)))
                                    (elmo-folder-create target-folder)))
                                (elmo-folder-open-internal target-folder)
-                               (elmo-folder-append-buffer target-folder 'unread)
+                               (elmo-folder-append-buffer target-folder)
                                (elmo-folder-close-internal target-folder))
                            (error (setq failure t)
                                   (incf fcount)))
index 3a99fb0..22c1ad5 100644 (file)
@@ -333,11 +333,11 @@ CONDITION is a condition structure for testing.
 NUMBERS is a list of message numbers,
 use to be test for \"last\" and \"first\" predicates.")
 
-(luna-define-generic elmo-folder-msgdb-create (folder numbers id-mark-table)
+(luna-define-generic elmo-folder-msgdb-create (folder numbers flag-table)
   "Create a message database (implemented in each backends).
 FOLDER is the ELMO folder structure.
 NUMBERS is a list of message numbers to create msgdb.
-ID-MARK-TABLE is a hashtable of message-id and its status mark.")
+FLAG-TABLE is a hashtable of message-id and flag.")
 
 (luna-define-generic elmo-folder-unmark-important (folder
                                                   numbers
@@ -379,10 +379,11 @@ NUMBERS is a list of message numbers to be processed.")
 FOLDER is the ELMO folder structure.
 NUMBERS is a list of message numbers to be processed.")
 
-(luna-define-generic elmo-folder-append-buffer (folder unread &optional number)
+(luna-define-generic elmo-folder-append-buffer (folder &optional flag
+                                                      number)
   "Append current buffer as a new message.
 FOLDER is the destination folder(ELMO folder structure).
-If UNREAD is non-nil, message is appended as unread.
+FLAG is the status of appended message.
 If optional argument NUMBER is specified, the new message number is set
 \(if possible\).")
 
@@ -1006,11 +1007,20 @@ Return a cons cell of (NUMBER-CROSSPOSTS . NEW-MARK-ALIST).")
 
 (defun elmo-generic-folder-append-messages (folder src-folder numbers
                                                   same-number)
-  (let (unseen seen-list succeed-numbers failure cache)
+  (let (unseen table flag mark
+              succeed-numbers failure cache)
+    (setq table (elmo-flag-table-load (elmo-folder-msgdb-path folder)))
     (with-temp-buffer
       (set-buffer-multibyte nil)
       (while numbers
-       (setq failure nil)
+       (setq failure nil
+             mark (elmo-message-mark src-folder (car numbers))
+             flag (cond
+                   ((member mark (elmo-msgdb-answered-marks))
+                    'answered)
+                   ;;
+                   ((not (member mark (elmo-msgdb-unread-marks)))
+                    'read)))
        (condition-case nil
            (setq cache (elmo-file-cache-get
                         (elmo-message-field src-folder
@@ -1037,26 +1047,22 @@ Return a cons cell of (NUMBER-CROSSPOSTS . NEW-MARK-ALIST).")
                    (> (buffer-size) 0)
                    (elmo-folder-append-buffer
                     folder
-                    (setq unseen (member (elmo-message-mark
-                                          src-folder (car numbers))
-                                         (elmo-msgdb-unread-marks)))
+                    flag
                     (if same-number (car numbers))))))
          (error (setq failure t)))
        ;; FETCH & APPEND finished
        (unless failure
-         (unless unseen
-           (setq seen-list (cons (elmo-message-field
-                                  src-folder (car numbers)
-                                  'message-id)
-                                 seen-list)))
+         (when flag
+           (elmo-flag-table-set table
+                                (elmo-message-field
+                                 src-folder (car numbers)
+                                 'message-id)
+                                flag))
          (setq succeed-numbers (cons (car numbers) succeed-numbers)))
        (elmo-progress-notify 'elmo-folder-move-messages)
        (setq numbers (cdr numbers)))
-      (if (and seen-list (elmo-folder-persistent-p folder))
-         (elmo-msgdb-seen-save (elmo-folder-msgdb-path folder)
-                               (nconc (elmo-msgdb-seen-load
-                                       (elmo-folder-msgdb-path folder))
-                                      seen-list)))
+      (when (elmo-folder-persistent-p folder)
+       (elmo-flag-table-save (elmo-folder-msgdb-path folder) table))
       succeed-numbers)))
 
 ;; Arguments should be reduced.
@@ -1085,17 +1091,7 @@ Return a cons cell of (NUMBER-CROSSPOSTS . NEW-MARK-ALIST).")
                                                              same-number))
            (error "move: append message to %s failed"
                   (elmo-folder-name-internal dst-folder)))
-         (elmo-folder-close dst-folder))
-       (when (and (elmo-folder-persistent-p dst-folder)
-                  save-unread)
-         ;; Save to seen list.
-         (let* ((dir (elmo-folder-msgdb-path dst-folder))
-                (seen-list (elmo-msgdb-seen-load dir)))
-           (setq seen-list
-                 (elmo-msgdb-add-msgs-to-seen-list
-                  msgs (elmo-folder-msgdb src-folder)
-                  seen-list))
-           (elmo-msgdb-seen-save dir seen-list))))
+         (elmo-folder-close dst-folder)))
       (if (and (not no-delete) succeeds)
          (progn
            (if (not no-delete-info)
@@ -1399,20 +1395,16 @@ If update process is interrupted, return nil."
        (before-append t)
        number-alist mark-alist
        old-msgdb diff diff-2 delete-list new-list new-msgdb mark
-       seen-list crossed after-append)
+       flag-table crossed after-append)
     (setq old-msgdb (elmo-folder-msgdb folder))
-    ;; Load seen-list.
-    (setq seen-list (elmo-msgdb-seen-load (elmo-folder-msgdb-path folder)))
+    (setq flag-table (elmo-flag-table-load (elmo-folder-msgdb-path folder)))
     (setq number-alist (elmo-msgdb-get-number-alist
                        (elmo-folder-msgdb folder)))
     (setq mark-alist (elmo-msgdb-get-mark-alist
                      (elmo-folder-msgdb folder)))
-    (if ignore-msgdb
-       (progn
-         (setq seen-list (nconc (elmo-msgdb-seen-list
-                                 (elmo-folder-msgdb folder))
-                                seen-list))
-         (elmo-folder-clear folder (eq ignore-msgdb 'visible-only))))
+    (when ignore-msgdb
+      (elmo-msgdb-flag-table (elmo-folder-msgdb folder) flag-table)
+      (elmo-folder-clear folder (eq ignore-msgdb 'visible-only)))
     (unless no-check (elmo-folder-check folder))
     (condition-case nil
        (progn
@@ -1448,14 +1440,14 @@ If update process is interrupted, return nil."
                             (elmo-folder-msgdb folder) delete-list))
            (when new-list
              (setq new-msgdb (elmo-folder-msgdb-create
-                              folder new-list seen-list))
+                              folder new-list flag-table))
              (elmo-msgdb-change-mark (elmo-folder-msgdb folder)
                                      elmo-msgdb-new-mark
                                      elmo-msgdb-unread-uncached-mark)
-             ;; Clear seen-list.
+             ;; Clear flag-table
              (if (elmo-folder-persistent-p folder)
-                 (setq seen-list (elmo-msgdb-seen-save
-                                  (elmo-folder-msgdb-path folder) nil)))
+                 (elmo-flag-table-save (elmo-folder-msgdb-path folder)
+                                       nil))
              (setq before-append nil)
              (setq crossed (elmo-folder-append-msgdb folder new-msgdb))
              ;; process crosspost.
@@ -1467,8 +1459,7 @@ If update process is interrupted, return nil."
            (or crossed 0)))
       (quit
        ;; Resume to the original status.
-       (if before-append
-          (elmo-folder-set-msgdb-internal folder old-msgdb))
+       (if before-append (elmo-folder-set-msgdb-internal folder old-msgdb))
        (elmo-folder-set-killed-list-internal folder killed-list)
        nil))))