* modb.el (elmo-msgdb-create-message-entity-from-file): Define.
authorteranisi <teranisi>
Mon, 22 Sep 2003 02:42:12 +0000 (02:42 +0000)
committerteranisi <teranisi>
Mon, 22 Sep 2003 02:42:12 +0000 (02:42 +0000)
* modb-standard.el (toplevel): Require mime.
(modb-standard-entity-id): Use elmo-msgdb-message-entity-field.
(modb-standard-load-entity): Use elmo-msgdb-message-entity-field and
elmo-msgdb-message-entity-number.
(elmo-msgdb-append-entity): Ditto.
(elmo-msgdb-create-message-entity-from-file): Remove.
(elmo-msgdb-create-message-entity-from-buffer): Use msgdb which
corresponds to the entity.
(elmo-msgdb-message-entity-number): Do nothing currently.
(elmo-msgdb-message-entity-field): Ditto.
(elmo-msgdb-message-entity-set-field): Ditto.
(elmo-msgdb-copy-message-entity): Ditto.
(elmo-msgdb-match-condition-internal): Ditto.

* modb-legacy.el (elmo-msgdb-insert-file-header): Moved to elmo-util.el.
(elmo-msgdb-create-message-entity-from-file): Remove.

* elmo-util.el (elmo-msgdb-insert-file-header): Moved from modb-legacy.el.
(elmo-multiple-field-body): Moved from elmo-util.el.

* elmo-msgdb.el (elmo-multiple-field-body): Moved to elmo-util.el.

elmo/ChangeLog
elmo/elmo-msgdb.el
elmo/elmo-util.el
elmo/modb-legacy.el
elmo/modb-standard.el
elmo/modb.el

index ae48038..f7cf733 100644 (file)
@@ -1,3 +1,31 @@
+2003-09-22  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * modb.el (elmo-msgdb-create-message-entity-from-file): Define.
+
+       * modb-standard.el (toplevel): Require mime.
+       (modb-standard-entity-id): Use elmo-msgdb-message-entity-field.
+       (modb-standard-load-entity): Use elmo-msgdb-message-entity-field and
+       elmo-msgdb-message-entity-number.
+       (elmo-msgdb-append-entity): Ditto.
+       (elmo-msgdb-create-message-entity-from-file): Remove.
+       (elmo-msgdb-create-message-entity-from-buffer): Use msgdb which 
+       corresponds to the entity.
+       (elmo-msgdb-message-entity-number): Do nothing currently.
+       (elmo-msgdb-message-entity-field): Ditto.
+       (elmo-msgdb-message-entity-set-field): Ditto.
+       (elmo-msgdb-copy-message-entity): Ditto.
+       (elmo-msgdb-match-condition-internal): Ditto.
+
+       * modb-legacy.el (elmo-msgdb-insert-file-header): Moved to
+       elmo-util.el.
+       (elmo-msgdb-create-message-entity-from-file): Remove.
+
+       * elmo-util.el (elmo-msgdb-insert-file-header): Moved from
+       modb-legacy.el.
+       (elmo-multiple-field-body): Moved from elmo-util.el.
+
+       * elmo-msgdb.el (elmo-multiple-field-body): Moved to elmo-util.el.
+
 2003-09-21  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * modb.el (elmo-msgdb-make-message-entity): Define simple one.
index b68414e..c0628ca 100644 (file)
        (elmo-msgdb-flags msgdb number)))
     flag-table))
 
-;;
-;; overview handling
-;;
-(defun elmo-multiple-field-body (name &optional boundary)
-  (save-excursion
-    (save-restriction
-      (std11-narrow-to-header boundary)
-      (goto-char (point-min))
-      (let ((case-fold-search t)
-           (field-body nil))
-       (while (re-search-forward (concat "^" name ":[ \t]*") nil t)
-         (setq field-body
-               (nconc field-body
-                      (list (buffer-substring-no-properties
-                             (match-end 0) (std11-field-end))))))
-       field-body))))
-
 (defun elmo-multiple-fields-body-list (field-names &optional boundary)
   "Return list of each field-bodies of FIELD-NAMES of the message header
 in current buffer. If BOUNDARY is not nil, it is used as message
index bee64ac..bb8c321 100644 (file)
@@ -1997,6 +1997,39 @@ If ALIST is nil, `elmo-obsolete-variable-alist' is used."
              (nth 1 (eword-extract-address-components
                      (or (elmo-field-body "from") "nobody"))) ">"))))
 
+(defsubst elmo-msgdb-insert-file-header (file)
+  "Insert the header of the article."
+  (let ((beg 0)
+       insert-file-contents-pre-hook   ; To avoid autoconv-xmas...
+       insert-file-contents-post-hook
+       format-alist)
+    (when (file-exists-p file)
+      ;; Read until header separator is found.
+      (while (and (eq elmo-msgdb-file-header-chop-length
+                     (nth 1
+                          (insert-file-contents-as-binary
+                           file nil beg
+                           (incf beg elmo-msgdb-file-header-chop-length))))
+                 (prog1 (not (search-forward "\n\n" nil t))
+                   (goto-char (point-max))))))))
+
+;;
+;; overview handling
+;;
+(defun elmo-multiple-field-body (name &optional boundary)
+  (save-excursion
+    (save-restriction
+      (std11-narrow-to-header boundary)
+      (goto-char (point-min))
+      (let ((case-fold-search t)
+           (field-body nil))
+       (while (re-search-forward (concat "^" name ":[ \t]*") nil t)
+         (setq field-body
+               (nconc field-body
+                      (list (buffer-substring-no-properties
+                             (match-end 0) (std11-field-end))))))
+       field-body))))
+
 ;;; Queue.
 (defvar elmo-dop-queue-filename "queue"
   "*Disconnected operation queue is saved in this file.")
index ee483b4..3104ccf 100644 (file)
@@ -627,48 +627,6 @@ Return a list of message numbers which have duplicated message-ids."
                                                    args)
   (modb-legacy-make-message-entity args))
 
-(defsubst elmo-msgdb-insert-file-header (file)
-  "Insert the header of the article."
-  (let ((beg 0)
-       insert-file-contents-pre-hook   ; To avoid autoconv-xmas...
-       insert-file-contents-post-hook
-       format-alist)
-    (when (file-exists-p file)
-      ;; Read until header separator is found.
-      (while (and (eq elmo-msgdb-file-header-chop-length
-                     (nth 1
-                          (insert-file-contents-as-binary
-                           file nil beg
-                           (incf beg elmo-msgdb-file-header-chop-length))))
-                 (prog1 (not (search-forward "\n\n" nil t))
-                   (goto-char (point-max))))))))
-
-(luna-define-method elmo-msgdb-create-message-entity-from-file
-  ((msgdb modb-legacy) number file)
-  (let (insert-file-contents-pre-hook   ; To avoid autoconv-xmas...
-       insert-file-contents-post-hook header-end
-       (attrib (file-attributes file))
-       ret-val size mtime)
-    (with-temp-buffer
-      (if (not (file-exists-p file))
-         ()
-       (setq size (nth 7 attrib))
-       (setq mtime (timezone-make-date-arpa-standard
-                    (current-time-string (nth 5 attrib)) (current-time-zone)))
-       ;; insert header from file.
-       (catch 'done
-         (condition-case nil
-             (elmo-msgdb-insert-file-header file)
-           (error (throw 'done nil)))
-         (goto-char (point-min))
-         (setq header-end
-               (if (re-search-forward "\\(^--.*$\\)\\|\\(\n\n\\)" nil t)
-                   (point)
-                 (point-max)))
-         (narrow-to-region (point-min) header-end)
-         (elmo-msgdb-create-message-entity-from-buffer
-          msgdb number :size size :date mtime))))))
-
 (luna-define-method elmo-msgdb-create-message-entity-from-buffer
   ((msgdb modb-legacy) number args)
   (let ((extras elmo-msgdb-extra-fields)
index 356bb34..984bf23 100644 (file)
 (eval-when-compile (require 'cl))
 
 (require 'elmo-util)
+(require 'mime)
 (require 'modb)
-;; Currently, entity structure is same as legacy.
-(require 'modb-legacy)
-
 
 (defcustom modb-standard-divide-number 500
   "*Standard modb divide entity number."
@@ -67,7 +65,9 @@
 (defsubst modb-standard-entity-id (entity)
   (if (eq 'autoload (car-safe entity))
       (cddr entity)
-    (elmo-msgdb-overview-entity-get-id entity)))
+    (elmo-msgdb-message-entity-field
+     (elmo-message-entity-db entity)
+     entity 'message-id)))
 
 (defsubst modb-standard-entity-map (modb)
   (or (modb-standard-entity-map-internal modb)
                      (modb-standard-entity-filename section)
                      path)))
       (elmo-set-hash-val (modb-standard-key
-                         (elmo-msgdb-overview-entity-get-number entity))
+                         (elmo-msgdb-message-entity-number
+                          (elmo-message-entity-db entity)
+                          entity))
                         entity
                         table)
-      (elmo-set-hash-val (elmo-msgdb-overview-entity-get-id entity)
+      (elmo-set-hash-val (elmo-msgdb-message-entity-field
+                         (elmo-message-entity-db entity)
+                         entity 'message-id)
                         entity
                         table))
     (modb-standard-set-entity-map-internal modb table)))
 
 (luna-define-method elmo-msgdb-append-entity ((msgdb modb-standard)
                                              entity &optional flags)
-  (let ((number (elmo-msgdb-overview-entity-get-number entity))
-       (msg-id (elmo-msgdb-overview-entity-get-id entity))
+  (let ((number (elmo-msgdb-message-entity-number
+                (elmo-message-entity-db entity) entity))
+       (msg-id (elmo-msgdb-message-entity-field
+                (elmo-message-entity-db entity) entity 'message-id))
        duplicate)
     ;; number-list
     (modb-standard-set-number-list-internal
                                                    args)
   (modb-standard-make-message-entity args))
 
-(luna-define-method elmo-msgdb-create-message-entity-from-file
-  ((msgdb modb-standard) number file)
-  (let (insert-file-contents-pre-hook   ; To avoid autoconv-xmas...
-       insert-file-contents-post-hook header-end
-       (attrib (file-attributes file))
-       ret-val size mtime)
-    (with-temp-buffer
-      (if (not (file-exists-p file))
-         ()
-       (setq size (nth 7 attrib))
-       (setq mtime (timezone-make-date-arpa-standard
-                    (current-time-string (nth 5 attrib)) (current-time-zone)))
-       ;; insert header from file.
-       (catch 'done
-         (condition-case nil
-             (elmo-msgdb-insert-file-header file)
-           (error (throw 'done nil)))
-         (goto-char (point-min))
-         (setq header-end
-               (if (re-search-forward "\\(^--.*$\\)\\|\\(\n\n\\)" nil t)
-                   (point)
-                 (point-max)))
-         (narrow-to-region (point-min) header-end)
-         (elmo-msgdb-create-message-entity-from-buffer
-          msgdb number :size size :date mtime))))))
-
 (luna-define-method elmo-msgdb-create-message-entity-from-buffer
   ((msgdb modb-standard) number args)
   (let ((extras elmo-msgdb-extra-fields)
        entity message-id references from subject to cc date
        extra field-body charset size)
     (save-excursion
-      (setq entity (modb-standard-make-message-entity args))
+      (setq entity (modb-standard-make-message-entity args)
+           ;; For compatibility.
+           msgdb (elmo-message-entity-db entity))
       (elmo-set-buffer-multibyte default-enable-multibyte-characters)
       (setq message-id (elmo-msgdb-get-message-id-from-buffer))
       (and (setq charset (cdr (assoc "charset" (mime-read-Content-Type))))
 
 ;;; Message entity interface
 ;;
+(luna-define-method elmo-msgdb-message-entity-number ((msgdb modb-standard)
+                                                     entity)
+  ;; To be implemented.
+  )
+
+(luna-define-method elmo-msgdb-message-entity-set-number ((msgdb modb-standard)
+                                                         entity
+                                                         number)
+  ;; To be implemented.
+  )
+
 (luna-define-method elmo-msgdb-message-entity-field ((msgdb modb-standard)
                                                     entity field
                                                     &optional decode)
-  (and entity
-       (let ((field-value
-             (case field
-               (to (aref (cdr entity) 5))
-               (cc (aref (cdr entity) 6))
-               (date (aref (cdr entity) 4))
-               (subject (aref (cdr entity) 3))
-               (from (aref (cdr entity) 2))
-               (message-id (car entity))
-               (references (aref (cdr entity) 1))
-               (size (aref (cdr entity) 7))
-               (t (cdr (assoc (symbol-name field) (aref (cdr entity) 8)))))))
-        (if (and decode (memq field '(from subject)))
-            (elmo-msgdb-get-decoded-cache field-value)
-          field-value))))
+  ;; To be implemented.
+  )
 
 (luna-define-method elmo-msgdb-message-entity-set-field ((msgdb modb-standard)
                                                         entity field value)
-  (and entity
-       (case field
-        (number (aset (cdr entity) 0 value))
-        (to (aset (cdr entity) 5 value))
-        (cc (aset (cdr entity) 6 value))
-        (date (aset (cdr entity) 4 value))
-        (subject (aset (cdr entity) 3 value))
-        (from (aset (cdr entity) 2 value))
-        (message-id (setcar entity value))
-        (references (aset (cdr entity) 1 value))
-        (size (aset (cdr entity) 7 value))
-        (t
-         (let ((extras (and entity (aref (cdr entity) 8)))
-               extra)
-           (if (setq extra (assoc (symbol-name field) extras))
-               (setcdr extra value)
-             (aset (cdr entity) 8 (cons (cons (symbol-name field)
-                                              value) extras))))))))
+  ;; To be implemented.
+  )
 
 (luna-define-method elmo-msgdb-copy-message-entity ((msgdb modb-standard)
                                                    entity)
-  (cons (car entity)
-       (copy-sequence (cdr entity))))
+  ;; To be implemented.
+  )
 
 (luna-define-method elmo-msgdb-match-condition-internal ((msgdb modb-standard)
                                                         condition
                                                         entity flags numbers)
-  (cond
-   ((vectorp condition)
-    (elmo-msgdb-match-condition-primitive condition entity flags numbers))
-   ((eq (car condition) 'and)
-    (let ((lhs (elmo-msgdb-match-condition-internal msgdb
-                                                   (nth 1 condition)
-                                                   entity flags numbers)))
-      (cond
-       ((elmo-filter-condition-p lhs)
-       (let ((rhs (elmo-msgdb-match-condition-internal
-                   msgdb (nth 2 condition) entity flags numbers)))
-         (cond ((elmo-filter-condition-p rhs)
-                (list 'and lhs rhs))
-               (rhs
-                lhs))))
-       (lhs
-       (elmo-msgdb-match-condition-internal msgdb (nth 2 condition)
-                                            entity flags numbers)))))
-   ((eq (car condition) 'or)
-    (let ((lhs (elmo-msgdb-match-condition-internal msgdb (nth 1 condition)
-                                                   entity flags numbers)))
-      (cond
-       ((elmo-filter-condition-p lhs)
-       (let ((rhs (elmo-msgdb-match-condition-internal msgdb
-                                                       (nth 2 condition)
-                                                       entity flags numbers)))
-         (cond ((elmo-filter-condition-p rhs)
-                (list 'or lhs rhs))
-               (rhs
-                t)
-               (t
-                lhs))))
-       (lhs
-       t)
-       (t
-       (elmo-msgdb-match-condition-internal msgdb
-                                            (nth 2 condition)
-                                            entity flags numbers)))))))
+  ;; To be implemented.
+  )
 
 (require 'product)
 (product-provide (provide 'modb-standard) (require 'elmo-version))
index d03216b..d8e564f 100644 (file)
@@ -223,6 +223,34 @@ Header region is supposed to be narrowed.")
 (luna-define-method elmo-msgdb-length ((msgdb modb-generic))
   0)
 
+;; Generic method.
+(luna-define-method elmo-msgdb-create-message-entity-from-file
+  ((msgdb modb-generic) number file)
+  (let (insert-file-contents-pre-hook   ; To avoid autoconv-xmas...
+       insert-file-contents-post-hook header-end
+       (attrib (file-attributes file))
+       ret-val size mtime)
+    (with-temp-buffer
+      (if (not (file-exists-p file))
+         ()
+       (setq size (nth 7 attrib))
+       (setq mtime (timezone-make-date-arpa-standard
+                    (current-time-string (nth 5 attrib)) (current-time-zone)))
+       ;; insert header from file.
+       (catch 'done
+         (condition-case nil
+             (elmo-msgdb-insert-file-header file)
+           (error (throw 'done nil)))
+         (goto-char (point-min))
+         (setq header-end
+               (if (re-search-forward "\\(^--.*$\\)\\|\\(\n\n\\)" nil t)
+                   (point)
+                 (point-max)))
+         (narrow-to-region (point-min) header-end)
+         (elmo-msgdb-create-message-entity-from-buffer
+          msgdb number :size size :date mtime))))))
+
+;; Dummy message-entity methods.
 (luna-define-method elmo-msgdb-make-message-entity ((msgdb modb-generic)
                                                    args)
   (cons msgdb args))