Merged the change of elmo-mark branch at 2003-08-30.
authorhmurata <hmurata>
Fri, 5 Sep 2003 14:38:28 +0000 (14:38 +0000)
committerhmurata <hmurata>
Fri, 5 Sep 2003 14:38:28 +0000 (14:38 +0000)
14 files changed:
elmo/ChangeLog
elmo/elmo-archive.el
elmo/elmo-cache.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-nmz.el
elmo/elmo-nntp.el
elmo/elmo-pop3.el
elmo/elmo-sendlog.el
elmo/elmo-shimbun.el

index de135c0..1c4441b 100644 (file)
@@ -2,6 +2,48 @@
 
        * elmo-version.el (elmo-version): Up to 2.11.10.
 
+2003-08-30  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * elmo-msgdb.el (elmo-msgdb-mark-to-flags): New function.
+       (elmo-msgdb-flags-to-mark): Ditto.
+       (elmo-msgdb-append-entity): Ditto.
+
+       * elmo-archive.el (elmo-archive-msgdb-create-as-numlist-subr1):
+       Use `elmo-msgdb-append-entity' instead of construct msgdb.
+       (elmo-archive-msgdb-create-as-numlist-subr2): Ditto.
+       (elmo-archive-parse-mmdf): Ditto.
+
+       * elmo-cache.el (elmo-folder-msgdb-create): Ditto.
+
+       * elmo-filter.el (elmo-folder-msgdb-create): Ditto.
+
+       * elmo-localdir.el (elmo-folder-msgdb-create): Ditto.
+
+       * elmo-maildir.el (elmo-folder-msgdb-create): Ditto.
+
+       * elmo-mark.el (elmo-mark-folder-msgdb-create): Ditto.
+
+       * elmo-nmz.el (elmo-folder-msgdb-create): Ditto.
+
+       * elmo-sendlog.el (elmo-folder-msgdb-create): Ditto.
+
+       * elmo-shimbun.el (elmo-folder-msgdb-create): Ditto.
+
+       * elmo-imap4.el (elmo-imap4-fetch-callback-1-subr): Ditto.
+       (elmo-folder-msgdb-create-plugged): Set elmo-imap4-current-msgdb
+       to empty msgdb.
+
+       * elmo-nntp.el (elmo-nntp-create-msgdb-from-overview-string): Use
+       `elmo-msgdb-make-message-entity' and `elmo-msgdb-append-entity'
+       instead of directly construction.
+       (elmo-nntp-msgdb-create-message): Use `elmo-msgdb-append-entity'
+       instead of construct msgdb.
+
+       * elmo-pop3.el (elmo-pop3-sort-msgdb-by-original-number): Use
+       `elmo-msgdb-set-overview' instead of reconstruct msgdb.
+       (elmo-pop3-msgdb-create-message): Use `elmo-msgdb-append-entity'
+       instead of construct msgdb.
+
 2003-08-28  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * elmo-msgdb.el (elmo-msgdb-message-entity-field): Decode value
index 2fb1c3c..1ee9f08 100644 (file)
@@ -930,8 +930,8 @@ TYPE specifies the archiver's symbol."
   (let* ((type (elmo-archive-folder-archive-type-internal folder))
         (file (elmo-archive-get-archive-name folder))
         (method (elmo-archive-get-method type 'cat))
-        overview number-alist mark-alist entity
-        i percent num message-id seen gmark)
+        (new-msgdb (elmo-make-msgdb))
+        entity i percent num message-id gmark)
     (with-temp-buffer
       (setq num (length numlist))
       (setq i 0)
@@ -943,27 +943,15 @@ TYPE specifies the archiver's symbol."
               method file (car numlist) type
               (elmo-archive-folder-archive-prefix-internal folder)))
        (when entity
-         (setq overview
-               (elmo-msgdb-append-element
-                overview entity))
-         (setq number-alist
-               (elmo-msgdb-number-add
-                number-alist
-                (elmo-msgdb-overview-entity-get-number entity)
-                (car entity)))
-         (setq message-id (car entity))
-         (if (setq gmark
-                   (or (elmo-msgdb-global-mark-get message-id)
-                       (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
-                    (elmo-msgdb-overview-entity-get-number entity)
-                    gmark))))
+         (setq message-id (elmo-msgdb-overview-entity-get-id entity))
+         (setq gmark
+               (or (elmo-msgdb-global-mark-get message-id)
+                   (elmo-msgdb-mark
+                    (elmo-flag-table-get flag-table message-id)
+                    (elmo-file-cache-status
+                     (elmo-file-cache-get message-id))
+                    'new)))
+         (elmo-msgdb-append-entity new-msgdb entity gmark))
        (when (> num elmo-display-progress-threshold)
          (setq i (1+ i))
          (setq percent (/ (* i 100) num))
@@ -972,7 +960,7 @@ TYPE specifies the archiver's symbol."
           percent))
        (setq numlist (cdr numlist)))
       (message "Creating msgdb...done")
-      (list overview number-alist mark-alist))))
+      new-msgdb)))
 
 ;;; info-zip agent
 (defun elmo-archive-msgdb-create-as-numlist-subr2 (folder
@@ -986,8 +974,8 @@ TYPE specifies the archiver's symbol."
         (prog (car method))
         (args (cdr method))
         (arc (elmo-archive-get-archive-name folder))
-        n i percent num result overview number-alist mark-alist
-        msgs case-fold-search)
+        (new-msgdb (elmo-make-msgdb))
+        n i percent num msgs case-fold-search)
     (with-temp-buffer
       (setq num (length numlist))
       (setq i 0)
@@ -1010,15 +998,13 @@ TYPE specifies the archiver's symbol."
        (goto-char (point-min))
        (cond
         ((looking-at delim1)   ;; MMDF
-         (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))))
-;;;    ((looking-at delim2)    ;; UNIX MAIL
-;;;    (setq result (elmo-archive-parse-unixmail msgs))
-;;;    (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))))
+         (elmo-msgdb-append
+          new-msgdb
+          (elmo-archive-parse-mmdf msgs flag-table)))
+;;;     ((looking-at delim2)   ;; UNIX MAIL
+;;;      (elmo-msgdb-append
+;;;       new-msgdb
+;;;       (elmo-archive-parse-unixmail msgs flag-table)))
         (t                     ;; unknown format
          (error "Unknown format!")))
        (when (> num elmo-display-progress-threshold)
@@ -1027,11 +1013,12 @@ TYPE specifies the archiver's symbol."
          (elmo-display-progress
           'elmo-archive-msgdb-create-as-numlist-subr2 "Creating msgdb..."
           percent))))
-    (list overview number-alist mark-alist)))
+    new-msgdb))
 
 (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
+       (new-msgdb (elmo-make-msgdb))
+       number sp ep rest entity
        message-id gmark)
     (goto-char (point-min))
     (setq rest msgs)
@@ -1046,33 +1033,19 @@ TYPE specifies the archiver's symbol."
        (save-excursion
          (narrow-to-region sp ep)
          (setq entity (elmo-archive-msgdb-create-entity-subr number))
-         (setq overview
-               (elmo-msgdb-append-element
-                overview entity))
-         (setq number-alist
-               (elmo-msgdb-number-add
-                number-alist
-                (elmo-msgdb-overview-entity-get-number entity)
-                (car entity)))
-         (setq message-id (car entity))
-         (if (setq gmark
-                   (or (elmo-msgdb-global-mark-get message-id)
-                       (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
-                    (elmo-msgdb-overview-entity-get-number entity)
-                    gmark)))
-         (setq ret-val (append ret-val (list overview number-alist
-                                             mark-alist)))
+         (setq message-id (elmo-msgdb-overview-entity-get-id entity))
+         (setq gmark
+               (or (elmo-msgdb-global-mark-get message-id)
+                   (elmo-msgdb-mark
+                    (elmo-flag-table-get flag-table message-id)
+                    (elmo-file-cache-status
+                     (elmo-file-cache-get message-id))
+                    'new)))
+         (elmo-msgdb-append-entity new-msgdb entity gmark)
          (widen)))
       (forward-line 1)
       (setq rest (cdr rest)))
-    ret-val))
+    new-msgdb))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
index 84bcf3a..efc7042 100644 (file)
                                              numbers flag-table)
   (let ((i 0)
        (len (length numbers))
-       overview number-alist mark-alist entity message-id
-       num mark)
+       (new-msgdb (elmo-make-msgdb))
+       entity message-id mark)
     (message "Creating msgdb...")
     (while numbers
       (setq entity
            (elmo-msgdb-create-overview-entity-from-file
             (car numbers) (elmo-message-file-name folder (car numbers))))
-      (if (null entity)
-         ()
-       (setq num (elmo-msgdb-overview-entity-get-number entity))
-       (setq overview
-             (elmo-msgdb-append-element
-              overview entity))
+      (when entity
        (setq message-id (elmo-msgdb-overview-entity-get-id entity))
-       (setq number-alist
-             (elmo-msgdb-number-add number-alist
-                                    num
-                                    message-id))
-       (if (setq mark (or (elmo-msgdb-global-mark-get message-id)
-                          (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 mark)))
-       (when (> len elmo-display-progress-threshold)
-         (setq i (1+ i))
-         (elmo-display-progress
-          'elmo-cache-folder-msgdb-create "Creating msgdb..."
-          (/ (* i 100) len))))
+       (setq mark (or (elmo-msgdb-global-mark-get message-id)
+                      (elmo-msgdb-mark
+                       (elmo-flag-table-get flag-table message-id)
+                       (elmo-file-cache-status
+                        (elmo-file-cache-get message-id))
+                       'new)))
+       (elmo-msgdb-append-entity new-msgdb entity mark))
+      (when (> len elmo-display-progress-threshold)
+       (setq i (1+ i))
+       (elmo-display-progress
+        'elmo-cache-folder-msgdb-create "Creating msgdb..."
+        (/ (* i 100) len)))
       (setq numbers (cdr numbers)))
     (message "Creating msgdb...done")
-    (list overview number-alist mark-alist)))
+    new-msgdb))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-cache-folder)
                                               &optional flag number)
index 2ce03c0..0136d88 100644 (file)
       (let* ((target-folder (elmo-filter-folder-target-internal folder))
             (len (length numlist))
             (msgdb (elmo-folder-msgdb target-folder))
-            overview number-alist mark-alist message-id entity mark)
+            (new-msgdb (elmo-make-msgdb))
+            message-id entity mark)
        (when (> len elmo-display-progress-threshold)
          (elmo-progress-set 'elmo-folder-msgdb-create
                             len "Creating msgdb..."))
            (dolist (number numlist)
              (setq entity (elmo-msgdb-overview-get-entity number msgdb))
              (when entity
-               (setq overview (elmo-msgdb-append-element overview entity)
-                     message-id (elmo-msgdb-overview-entity-get-id entity)
-                     number-alist (elmo-msgdb-number-add number-alist
-                                                         number
-                                                         message-id))
-               (when (setq mark (elmo-msgdb-get-mark msgdb number))
-                 (setq mark-alist (elmo-msgdb-mark-append
-                                   mark-alist
-                                   number
-                                   mark))))
+               (setq mark (elmo-msgdb-get-mark msgdb number))
+               (elmo-msgdb-append-entity new-msgdb entity mark))
              (elmo-progress-notify 'elmo-folder-msgdb-create))
          (elmo-progress-clear 'elmo-folder-msgdb-create))
-       (list overview number-alist mark-alist))
+       new-msgdb)
     ;; Does not require msgdb.
     (elmo-folder-msgdb-create
      (elmo-filter-folder-target-internal folder)
index 0a8c707..151c7a1 100644 (file)
@@ -809,16 +809,9 @@ If CHOP-LENGTH is not specified, message set is not chopped."
                               (if elmo-imap4-use-cache
                                   elmo-msgdb-read-uncached-mark))
                           elmo-msgdb-new-mark))))))
-    (setq elmo-imap4-current-msgdb
-         (elmo-msgdb-append
-          elmo-imap4-current-msgdb
-          (list (list entity)
-                (list (cons (elmo-msgdb-overview-entity-get-number entity)
-                            (car entity)))
-                (if mark
-                    (list
-                     (list (elmo-msgdb-overview-entity-get-number entity)
-                           mark))))))))
+    (elmo-msgdb-append-entity elmo-imap4-current-msgdb
+                             entity
+                             mark)))
 
 ;; Current buffer is process buffer.
 (defun elmo-imap4-fetch-callback-1 (element app-data)
@@ -2289,7 +2282,7 @@ If optional argument REMOVE is non-nil, remove FLAG."
                      elmo-imap4-overview-fetch-chop-length))
       ;; Setup callback.
       (with-current-buffer (elmo-network-session-buffer session)
-       (setq elmo-imap4-current-msgdb nil
+       (setq elmo-imap4-current-msgdb (elmo-make-msgdb)
              elmo-imap4-seen-messages nil
              elmo-imap4-fetch-callback 'elmo-imap4-fetch-callback-1
              elmo-imap4-fetch-callback-data (cons flag-table
index 7deaf26..7ebcf1c 100644 (file)
                                              flag-table)
   (when numbers
     (let ((dir (elmo-localdir-folder-directory-internal folder))
-         overview number-alist mark-alist entity message-id
-         num gmark
+         (new-msgdb (elmo-make-msgdb))
+         entity message-id gmark
          (i 0)
          (len (length numbers)))
       (message "Creating msgdb...")
        (setq entity
              (elmo-localdir-msgdb-create-entity
               dir (car numbers)))
-       (if (null entity)
-           ()
-         (setq num (elmo-msgdb-overview-entity-get-number entity))
-         (setq overview
-               (elmo-msgdb-append-element
-                overview entity))
+       (when entity
          (setq message-id (elmo-msgdb-overview-entity-get-id entity))
-         (setq number-alist
-               (elmo-msgdb-number-add number-alist
-                                      num
-                                      message-id))
-         (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
-                             (unless (eq 'read (elmo-flag-table-get 
-                                                flag-table message-id))
-                               (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))))
+         (setq gmark (or (elmo-msgdb-global-mark-get message-id)
+                         (unless (eq 'read (elmo-flag-table-get 
+                                            flag-table message-id))
+                           (elmo-msgdb-mark
+                            (elmo-flag-table-get flag-table message-id)
+                            (elmo-file-cache-status
+                             (elmo-file-cache-get message-id))
+                            'new))))
+         (elmo-msgdb-append-entity new-msgdb entity gmark))
        (when (> len elmo-display-progress-threshold)
          (setq i (1+ i))
          (elmo-display-progress
           (/ (* i 100) len)))
        (setq numbers (cdr numbers)))
       (message "Creating msgdb...done")
-      (list overview number-alist mark-alist))))
+      new-msgdb)))
 
 (luna-define-method elmo-folder-list-subfolders ((folder elmo-localdir-folder)
                                                 &optional one-level)
index 8f61227..057cdab 100644 (file)
@@ -151,8 +151,9 @@ LOCATION."
         (answered-list (elmo-maildir-folder-answered-locations-internal
                         folder))
         (len (length numbers))
+        (new-msgdb (elmo-make-msgdb))
         (i 0)
-        overview number-alist mark-alist entity message-id flag
+        entity message-id flag
         file location pair mark cache-status file-flag)
     (message "Creating msgdb...")
     (dolist (number numbers)
@@ -163,19 +164,13 @@ LOCATION."
             (setq file
                   (elmo-maildir-message-file-name folder location))))
       (when entity
-       (setq overview
-             (elmo-msgdb-append-element overview entity)
-             number-alist
-             (elmo-msgdb-number-add number-alist
-                                    (elmo-message-entity-number entity)
-                                    (setq message-id
-                                          (elmo-message-entity-field
-                                           entity 'message-id)))
+       (setq message-id (elmo-message-entity-field
+                         entity 'message-id)
              ;; Precede flag-table to file-info.
              flag (elmo-flag-table-get flag-table message-id)
              file-flag nil
-             mark nil)
-       (setq cache-status
+             mark nil
+             cache-status
              (elmo-file-cache-status (elmo-file-cache-get message-id)))
        
        ;; Already flagged on filename (precede it to flag-table).
@@ -239,21 +234,14 @@ LOCATION."
             (delete location
                     (elmo-maildir-folder-unread-locations-internal
                      folder))))))
-       (if mark
-           (setq mark-alist
-                 (elmo-msgdb-mark-append
-                  mark-alist
-                  (elmo-msgdb-overview-entity-get-number
-                   entity)
-                  mark)))
+       (elmo-msgdb-append-entity new-msgdb entity mark)
        (when (> len elmo-display-progress-threshold)
          (setq i (1+ i))
          (elmo-display-progress
           'elmo-maildir-msgdb-create "Creating msgdb..."
           (/ (* i 100) len)))))
     (message "Creating msgdb...done")
-    (elmo-msgdb-sort-by-date
-     (list overview number-alist mark-alist))))
+    (elmo-msgdb-sort-by-date new-msgdb)))
 
 (defun elmo-maildir-cleanup-temporal (dir)
   ;; Delete files in the tmp dir which are not accessed
index 8773739..4215f7a 100644 (file)
 (defun elmo-mark-folder-msgdb-create (folder numbers)
   (let ((i 0)
        (len (length numbers))
-       overview number-alist mark-alist entity message-id
-       num)
+       (new-msgdb (elmo-make-msgdb))
+       entity message-id)
     (message "Creating msgdb...")
     (while numbers
       (setq entity
            (elmo-msgdb-create-overview-entity-from-file
             (car numbers) (elmo-message-file-name folder (car numbers))))
-      (if (null entity)
-         ()
-       (setq num (elmo-msgdb-overview-entity-get-number entity))
-       (setq overview
-             (elmo-msgdb-append-element
-              overview entity))
-       (setq message-id (elmo-msgdb-overview-entity-get-id entity))
-       (setq number-alist
-             (elmo-msgdb-number-add number-alist
-                                    num
-                                    message-id))
-       (setq mark-alist
-             (elmo-msgdb-mark-append
-              mark-alist
-              num (elmo-mark-folder-mark-internal folder))))
+      (when entity
+       (elmo-msgdb-append-entity new-msgdb
+                                 entity
+                                 (elmo-mark-folder-mark-internal folder)))
       (when (> len elmo-display-progress-threshold)
        (setq i (1+ i))
        (elmo-display-progress
         (/ (* i 100) len)))
       (setq numbers (cdr numbers)))
     (message "Creating msgdb...done")
-    (list overview number-alist mark-alist)))
+    new-msgdb))
 
 (luna-define-method elmo-folder-append-buffer ((folder elmo-mark-folder)
                                               &optional flag number)
index 782215d..13b101d 100644 (file)
@@ -99,8 +99,7 @@
 ;; elmo-flag-table-get
 ;; elmo-flag-table-save
 
-;; elmo-msgdb-append-entity
-;; msgdb entity flag-table
+;; elmo-msgdb-append-entity MSGDB ENTITY MARK-OR-FLAGS
 
 ;; ENTITY elmo-msgdb-make-entity ARGS
 ;; VALUE elmo-msgdb-entity-field ENTITY
@@ -189,6 +188,37 @@ If argument is a string, use it as a path to load message entities."
              (elmo-msgdb-overview-load msgdb-or-path)
            (elmo-msgdb-get-overview msgdb-or-path))))
 
+(defsubst elmo-msgdb-mark-to-flags (mark)
+  (append
+   (and (string= mark elmo-msgdb-new-mark)
+       '(new))
+   (and (string= mark elmo-msgdb-important-mark)
+       '(important))
+   (and (member mark (elmo-msgdb-unread-marks))
+       '(unread))
+   (and (member mark (elmo-msgdb-answered-marks))
+       '(answered))
+   (and (not (member mark (elmo-msgdb-uncached-marks)))
+       '(cached))))
+
+(defsubst elmo-msgdb-flags-to-mark (flags cached use-cache)
+  (cond ((memq 'new flags)
+        elmo-msgdb-new-mark)
+       ((memq 'important flags)
+        elmo-msgdb-important-mark)
+       ((memq 'answered flags)
+        (if cached
+            elmo-msgdb-answered-cached-mark
+          elmo-msgdb-answered-uncached-mark))
+       ((memq 'unread flags)
+        (if cached
+            elmo-msgdb-unread-cached-mark
+          elmo-msgdb-unread-uncached-mark))
+       (t
+        (if (or cached (not use-cache))
+            nil
+          elmo-msgdb-read-uncached-mark))))
+
 (defsubst elmo-msgdb-get-mark (msgdb number)
   "Get mark string from MSGDB which corresponds to the message with NUMBER."
   (cadr (elmo-get-hash-val (format "#%d" number)
@@ -366,6 +396,28 @@ FLAG is a symbol which is one of the following:
                  elmo-msgdb-unread-uncached-mark
                  elmo-msgdb-read-uncached-mark))))
 
+(defun elmo-msgdb-append-entity (msgdb entity &optional mark)
+  (when entity
+    (let ((number (elmo-msgdb-overview-entity-get-number entity))
+         (message-id (elmo-msgdb-overview-entity-get-id entity)))
+      (elmo-msgdb-set-overview
+       msgdb
+       (nconc (elmo-msgdb-get-overview msgdb)
+             (list entity)))
+      (elmo-msgdb-set-number-alist
+       msgdb
+       (nconc (elmo-msgdb-get-number-alist msgdb)
+             (list (cons number message-id))))
+      (when mark
+       (elmo-msgdb-set-mark-alist
+        msgdb
+        (nconc (elmo-msgdb-get-mark-alist msgdb)
+               (list (list number mark)))))
+      (elmo-msgdb-make-index
+       msgdb
+       (list entity)
+       (list (cons number mark))))))
+
 (defsubst elmo-msgdb-get-number (msgdb message-id)
   "Get number of the message which corrensponds to MESSAGE-ID from MSGDB."
   (elmo-msgdb-overview-entity-get-number
index 4469b7f..be5b936 100644 (file)
@@ -118,8 +118,8 @@ If the value is a list, all elements are used as index paths for namazu."
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-nmz-folder)
                                              numlist flag-table)
-  (let* (overview number-alist mark-alist entity
-                 i percent num pair)
+  (let ((new-msgdb (elmo-make-msgdb))
+       entity mark i percent num)
     (setq num (length numlist))
     (setq i 0)
     (message "Creating msgdb...")
@@ -128,24 +128,11 @@ If the value is a list, all elements are used as index paths for namazu."
            (elmo-nmz-msgdb-create-entity
             folder (car numlist)))
       (when entity
-       (setq overview
-             (elmo-msgdb-append-element
-              overview entity))
-       (setq number-alist
-             (elmo-msgdb-number-add number-alist
-                                    (elmo-msgdb-overview-entity-get-number
-                                     entity)
-                                    (elmo-msgdb-overview-entity-get-id
-                                     entity)))
-       (setq mark-alist
-             (elmo-msgdb-mark-append
-              mark-alist
-              (elmo-msgdb-overview-entity-get-number
-               entity)
-              (or (elmo-msgdb-global-mark-get
-                   (elmo-msgdb-overview-entity-get-id
-                    entity))
-                  elmo-msgdb-new-mark))))
+       (setq mark (or (elmo-msgdb-global-mark-get
+                       (elmo-msgdb-overview-entity-get-id
+                        entity))
+                      elmo-msgdb-new-mark))
+       (elmo-msgdb-append-entity new-msgdb entity mark))
       (when (> num elmo-display-progress-threshold)
        (setq i (1+ i))
        (setq percent (/ (* i 100) num))
@@ -154,7 +141,7 @@ If the value is a list, all elements are used as index paths for namazu."
         percent))
       (setq numlist (cdr numlist)))
     (message "Creating msgdb...done")
-    (list overview number-alist mark-alist)))
+    new-msgdb))
 
 (luna-define-method elmo-folder-message-file-p ((folder elmo-nmz-folder))
   t)
index 810da85..4a3958a 100644 (file)
@@ -736,8 +736,9 @@ Don't cache if nil.")
 (defun elmo-nntp-create-msgdb-from-overview-string (str
                                                    flag-table
                                                    &optional numlist)
-  (let (ov-list gmark message-id seen
-       ov-entity overview number-alist mark-alist num
+  (let ((new-msgdb (elmo-make-msgdb))
+       ov-list gmark message-id entity
+       ov-entity num
        extras extra ext field field-index)
     (setq ov-list (elmo-nntp-parse-overview-string str))
     (while ov-list
@@ -762,44 +763,31 @@ Don't cache if nil.")
                (setq field (elmo-msgdb-remove-field-string field)))
               (setq extra (cons (cons ext field) extra))))
          (setq extras (cdr extras)))
-       (setq overview
-             (elmo-msgdb-append-element
-              overview
-              (cons (aref ov-entity 4)
-                    (vector num
-                            (elmo-msgdb-get-last-message-id
-                             (aref ov-entity 5))
-                            ;; from
-                            (elmo-mime-string (elmo-delete-char
-                                               ?\"
-                                               (or
-                                                (aref ov-entity 2)
-                                                elmo-no-from) 'uni))
-                            ;; subject
-                            (elmo-mime-string (or (aref ov-entity 1)
-                                                  elmo-no-subject))
-                            (aref ov-entity 3) ;date
-                            nil ; to
-                            nil ; cc
-                            (string-to-int
-                             (aref ov-entity 6)) ; size
-                            extra ; extra-field-list
-                            ))))
-       (setq number-alist
-             (elmo-msgdb-number-add number-alist num
-                                    (aref ov-entity 4)))
-       (setq message-id (aref ov-entity 4))
-       (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
-                           (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))))
+       (setq entity (elmo-msgdb-make-message-entity
+                     :message-id (aref ov-entity 4)
+                     :number     num
+                     :references (elmo-msgdb-get-last-message-id
+                                   (aref ov-entity 5))
+                     :from       (elmo-mime-string (elmo-delete-char
+                                                    ?\"
+                                                    (or
+                                                     (aref ov-entity 2)
+                                                     elmo-no-from) 'uni))
+                     :subject    (elmo-mime-string (or (aref ov-entity 1)
+                                                       elmo-no-subject))
+                     :date       (aref ov-entity 3)
+                     :size       (string-to-int (aref ov-entity 6))
+                     :extra      extra))
+       (setq message-id (elmo-message-entity-field entity 'message-id))
+       (setq gmark (or (elmo-msgdb-global-mark-get message-id)
+                       (elmo-msgdb-mark
+                        (elmo-flag-table-get flag-table message-id)
+                        (elmo-file-cache-status
+                         (elmo-file-cache-get message-id))
+                        'new)))
+       (elmo-msgdb-append-entity new-msgdb entity gmark))
       (setq ov-list (cdr ov-list)))
-    (list overview number-alist mark-alist)))
+    new-msgdb))
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-nntp-folder)
                                              numbers flag-table)
@@ -1406,8 +1394,9 @@ Returns a list of cons cells like (NUMBER . VALUE)"
 
 (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)
+    (let ((new-msgdb (elmo-make-msgdb))
+         beg overview number-alist mark-alist
+         entity i num gmark seen message-id)
       (elmo-set-buffer-multibyte nil)
       (goto-char (point-min))
       (setq i 0)
@@ -1427,27 +1416,16 @@ Returns a list of cons cells like (NUMBER . VALUE)"
              (setq entity
                    (elmo-msgdb-create-overview-from-buffer num))
              (when entity
-               (setq overview
-                     (elmo-msgdb-append-element
-                      overview entity))
-               (setq number-alist
-                     (elmo-msgdb-number-add
-                      number-alist
-                      (elmo-msgdb-overview-entity-get-number entity)
-                      (car entity)))
-               (setq message-id (car entity))
-               (if (setq gmark
-                         (or (elmo-msgdb-global-mark-get message-id)
-                             (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)))
-               ))))
+               (setq message-id
+                     (elmo-message-entity-field entity 'message-id)
+                     gmark
+                     (or (elmo-msgdb-global-mark-get message-id)
+                         (elmo-msgdb-mark
+                          (elmo-flag-table-get flag-table message-id)
+                          (elmo-file-cache-status
+                           (elmo-file-cache-get message-id))
+                          'new)))
+               (elmo-msgdb-append-entity new-msgdb entity gmark)))))
        (when (> len elmo-display-progress-threshold)
          (setq i (1+ i))
          (if (or (zerop (% i 20)) (= i len))
@@ -1457,7 +1435,7 @@ Returns a list of cons cells like (NUMBER . VALUE)"
       (when (> len elmo-display-progress-threshold)
        (elmo-display-progress
         'elmo-nntp-msgdb-create-message "Creating msgdb..." 100))
-      (list overview number-alist mark-alist))))
+      new-msgdb)))
 
 (luna-define-method elmo-message-use-cache-p ((folder elmo-nntp-folder) number)
   elmo-nntp-use-cache)
index 8345095..9523450 100644 (file)
@@ -717,11 +717,13 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
 (defun elmo-pop3-sort-msgdb-by-original-number (folder msgdb)
   (message "Sorting...")
   (let ((overview (elmo-msgdb-get-overview msgdb)))
-    (setq overview (elmo-pop3-sort-overview-by-original-number
-                   overview
-                   (elmo-pop3-folder-location-alist-internal folder)))
+    (elmo-msgdb-set-overview
+     msgdb
+     (elmo-pop3-sort-overview-by-original-number
+      overview
+      (elmo-pop3-folder-location-alist-internal folder)))
     (message "Sorting...done")
-    (list overview (nth 1 msgdb)(nth 2 msgdb)(nth 3 msgdb))))
+    msgdb))
 
 (defun elmo-pop3-uidl-to-number (uidl)
   (string-to-number (elmo-get-hash-val uidl
@@ -766,8 +768,8 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
                                       flag-table
                                       loc-alist)
   (save-excursion
-    (let (beg overview number-alist mark-alist
-             entity i number message-id gmark seen size)
+    (let ((new-msgdb (elmo-make-msgdb))
+         beg entity i number message-id gmark)
       (set-buffer buffer)
       (elmo-set-buffer-multibyte default-enable-multibyte-characters)
       (goto-char (point-min))
@@ -785,9 +787,6 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
                   (car numlist)))
            (setq numlist (cdr numlist))
            (when entity
-             (setq overview
-                   (elmo-msgdb-append-element
-                    overview entity))
              (with-current-buffer (process-buffer process)
                (elmo-msgdb-overview-entity-set-size
                 entity
@@ -801,30 +800,21 @@ If IF-EXISTS is `any-exists', get BIFF session or normal session if exists."
                             (elmo-msgdb-overview-entity-get-number entity))
                            loc-alist)))
                    (elmo-msgdb-overview-entity-set-number entity number)))
-             (setq number-alist
-                   (elmo-msgdb-number-add
-                    number-alist
-                    (elmo-msgdb-overview-entity-get-number entity)
-                    (car entity)))
-             (setq message-id (car entity))
-             (if (setq gmark (or (elmo-msgdb-global-mark-get message-id)
-                                 (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
-                        (elmo-msgdb-overview-entity-get-number entity)
-                        gmark))))))
+             (setq message-id (elmo-message-entity-field entity 'message-id))
+             (setq gmark (or (elmo-msgdb-global-mark-get message-id)
+                             (elmo-msgdb-mark
+                              (elmo-flag-table-get flag-table message-id)
+                              (elmo-file-cache-status
+                               (elmo-file-cache-get message-id))
+                              'new)))
+             (elmo-msgdb-append-entity new-msgdb entity gmark))))
        (when (> num elmo-display-progress-threshold)
          (setq i (1+ i))
          (if (or (zerop (% i 5)) (= i num))
              (elmo-display-progress
               'elmo-pop3-msgdb-create-message "Creating msgdb..."
               (/ (* i 100) num)))))
-      (list overview number-alist mark-alist))))
+      new-msgdb)))
 
 (defun elmo-pop3-read-body (process outbuf)
   (with-current-buffer (process-buffer process)
index c8cbbc4..dbbf1b1 100644 (file)
@@ -84,8 +84,8 @@
                                              numbers flag-table)
   (let ((i 0)
        (len (length numbers))
-       overview number-alist mark-alist entity message-id
-       num mark)
+       (new-msgdb (elmo-make-msgdb))
+       entity message-id mark)
     (message "Creating msgdb...")
     (while numbers
       (setq entity
           (nconc
            (elmo-folder-killed-list-internal folder)
            (list (car numbers))))
-       (setq num (elmo-msgdb-overview-entity-get-number entity))
-       (setq overview
-             (elmo-msgdb-append-element
-              overview entity))
        (setq message-id (elmo-msgdb-overview-entity-get-id entity))
-       (setq number-alist
-             (elmo-msgdb-number-add number-alist
-                                    num
-                                    message-id))
-       (if (setq mark (or (elmo-msgdb-global-mark-get message-id)
-                          (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 mark)))
-       (when (> len elmo-display-progress-threshold)
-         (setq i (1+ i))
-         (elmo-display-progress
-          'elmo-sendlog-folder-msgdb-create "Creating msgdb..."
-          (/ (* i 100) len))))
+       (setq mark (or (elmo-msgdb-global-mark-get message-id)
+                      (elmo-msgdb-mark
+                       (elmo-flag-table-get flag-table message-id)
+                       (elmo-file-cache-status
+                        (elmo-file-cache-get message-id))
+                       'new)))
+       (elmo-msgdb-append-entity new-msgdb entity mark))
+      (when (> len elmo-display-progress-threshold)
+       (setq i (1+ i))
+       (elmo-display-progress
+        'elmo-sendlog-folder-msgdb-create "Creating msgdb..."
+        (/ (* i 100) len)))
       (setq numbers (cdr numbers)))
     (message "Creating msgdb...done")
-    (list overview number-alist mark-alist)))
+    new-msgdb))
 
 (luna-define-method elmo-message-fetch-with-cache-process
   ((folder elmo-sendlog-folder) number strategy &optional section unseen)
index 3f3b792..cecef52 100644 (file)
@@ -350,8 +350,8 @@ update overview when message is fetched."
 
 (luna-define-method elmo-folder-msgdb-create ((folder elmo-shimbun-folder)
                                              numlist flag-table)
-  (let* (overview number-alist mark-alist entity
-                 i percent number length pair msgid gmark seen)
+  (let ((new-msgdb (elmo-make-msgdb))
+       entity i percent length msgid gmark)
     (setq length (length numlist))
     (setq i 0)
     (message "Creating msgdb...")
@@ -360,23 +360,14 @@ update overview when message is fetched."
            (elmo-shimbun-msgdb-create-entity
             folder (car numlist)))
       (when entity
-       (setq overview
-             (elmo-msgdb-append-element
-              overview entity))
-       (setq number (elmo-msgdb-overview-entity-get-number entity))
        (setq msgid (elmo-msgdb-overview-entity-get-id entity))
-       (setq number-alist
-             (elmo-msgdb-number-add number-alist
-                                    number msgid))
-       (if (setq gmark (or (elmo-msgdb-global-mark-get msgid)
-                           (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))))
+       (setq gmark (or (elmo-msgdb-global-mark-get msgid)
+                       (elmo-msgdb-mark
+                        (elmo-flag-table-get flag-table msgid)
+                        (elmo-file-cache-status
+                         (elmo-file-cache-get msgid))
+                        'new)))
+       (elmo-msgdb-append-entity new-msgdb entity gmark))
       (when (> length elmo-display-progress-threshold)
        (setq i (1+ i))
        (setq percent (/ (* i 100) length))
@@ -385,8 +376,7 @@ update overview when message is fetched."
         percent))
       (setq numlist (cdr numlist)))
     (message "Creating msgdb...done")
-    (elmo-msgdb-sort-by-date
-     (list overview number-alist mark-alist))))
+    (elmo-msgdb-sort-by-date new-msgdb)))
 
 (luna-define-method elmo-folder-message-file-p ((folder elmo-shimbun-folder))
   nil)