(mime-entity-children): Moved from mime-def.el; use
authormorioka <morioka>
Thu, 25 Jun 1998 14:16:08 +0000 (14:16 +0000)
committermorioka <morioka>
Thu, 25 Jun 1998 14:16:08 +0000 (14:16 +0000)
`mime-entity-children-internal'.
(mime-entity-node-id): Moved from mime-def.el; use
`mime-entity-node-id-internal'.
(mime-entity-number): Moved from mime-def.el; use
`mime-entity-node-id-internal'.
(mime-entity-buffer): Moved from mime-def.el; use
`mime-entity-buffer-internal'.
(mime-entity-point-min): Moved from mime-def.el; use
`mime-entity-header-start-internal'.
(mime-entity-point-max): Moved from mime-def.el; use
`mime-entity-body-end-internal'.
(mime-entity-header-start): Moved from mime-def.el; use
`mime-entity-header-start-internal'.
(mime-entity-header-end): Moved from mime-def.el; use
`mime-entity-header-end-internal'.
(mime-entity-content-type): Moved from mime-def.el; use
`mime-entity-content-type-internal'.
(mime-entity-content-disposition): Moved from mime-def.el; use
`mime-entity-content-disposition-internal'.
(mime-entity-encoding): Moved from mime-def.el; use
`mime-entity-encoding-internal'.
(mime-fetch-field): Use `mime-entity-original-header-internal' and
`mime-entity-set-original-header-internal'.
(mime-read-field): Use `mime-entity-parsed-header-internal' and
`mime-entity-set-parsed-header-internal'.
(eword-visible-field-p): Moved from eword-decode.el.
(mime-insert-decoded-header): Moved from eword-decode.el.
(mime-entity-body-start): Moved from mime-def.el; use
`mime-entity-body-start-internal'.
(mime-entity-body-end): Moved from mime-def.el; use
`mime-entity-body-end-internal'.
(mime-entity-media-type): Moved from mime-def.el.
(mime-entity-media-subtype): Moved from mime-def.el.
(mime-entity-parameters): Moved from mime-def.el.
(mime-entity-type/subtype): Moved from mime-def.el.

mime.el

diff --git a/mime.el b/mime.el
index 8e3615b..576def6 100644 (file)
--- a/mime.el
+++ b/mime.el
@@ -63,6 +63,13 @@ current-buffer, and return it.")
 ;;; @ Entity as node of message
 ;;;
 
+(defalias 'mime-entity-children        'mime-entity-children-internal)
+
+(defalias 'mime-entity-node-id 'mime-entity-node-id-internal)
+
+(defsubst mime-entity-number (entity)
+  (reverse (mime-entity-node-id-internal entity)))
+
 (defun mime-find-entity-from-number (entity-number &optional message)
   "Return entity from ENTITY-NUMBER in MESSAGE.
 If MESSAGE is not specified, `mime-message-structure' is used."
@@ -98,15 +105,31 @@ ENTITY is used."
   (null (mime-entity-node-id entity)))
 
 
+;;; @ Entity Buffer
+;;;
+
+(defalias 'mime-entity-buffer    'mime-entity-buffer-internal)
+(defalias 'mime-entity-point-min 'mime-entity-header-start-internal)
+(defalias 'mime-entity-point-max 'mime-entity-body-end-internal)
+
+
 ;;; @ Entity Header
 ;;;
 
+(defalias 'mime-entity-header-start 'mime-entity-header-start-internal)
+(defalias 'mime-entity-header-end   'mime-entity-header-end-internal)
+
+(defalias 'mime-entity-content-type    'mime-entity-content-type-internal)
+(defalias 'mime-entity-content-disposition
+  'mime-entity-content-disposition-internal)
+(defalias 'mime-entity-encoding                'mime-entity-encoding-internal)
+
 (defun mime-fetch-field (field-name &optional entity)
   (or (symbolp field-name)
       (setq field-name (intern (capitalize (capitalize field-name)))))
   (or entity
       (setq entity mime-message-structure))
-  (let* ((header (mime-entity-original-header entity))
+  (let* ((header (mime-entity-original-header-internal entity))
         (field-body (cdr (assq field-name header))))
     (or field-body
        (progn
@@ -118,7 +141,7 @@ ENTITY is used."
                  (setq field-body
                        (std11-fetch-field (symbol-name field-name)))
                  ))
-             (mime-entity-set-original-header
+             (mime-entity-set-original-header-internal
               entity (put-alist field-name field-body header))
            )
          field-body))))
@@ -138,7 +161,7 @@ ENTITY is used."
         (mime-entity-encoding entity)
         )
        (t
-        (let* ((header (mime-entity-parsed-header entity))
+        (let* ((header (mime-entity-parsed-header-internal entity))
                (field (cdr (assq field-name header))))
           (or field
               (let ((field-body (mime-fetch-field field-name entity)))
@@ -164,14 +187,94 @@ ENTITY is used."
                          (setq field (eword-decode-unstructured-field-body
                                       field-body))
                          ))
-                  (mime-entity-set-parsed-header
+                  (mime-entity-set-parsed-header-internal
                    entity (put-alist field-name field header))
                   field)))))))
 
+(defun eword-visible-field-p (field-name visible-fields invisible-fields)
+  (or (catch 'found
+       (while visible-fields
+         (let ((regexp (car visible-fields)))
+           (if (string-match regexp field-name)
+               (throw 'found t)
+             ))
+         (setq visible-fields (cdr visible-fields))
+         ))
+      (catch 'found
+       (while invisible-fields
+         (let ((regexp (car invisible-fields)))
+           (if (string-match regexp field-name)
+               (throw 'found nil)
+             ))
+         (setq invisible-fields (cdr invisible-fields))
+         )
+       t)))
+               
+(defun mime-insert-decoded-header (entity
+                                  &optional invisible-fields visible-fields
+                                  code-conversion)
+  "Insert before point a decoded header of ENTITY."
+  (let ((default-charset
+         (if code-conversion
+             (if (mime-charset-to-coding-system code-conversion)
+                 code-conversion
+               default-mime-charset))))
+    (save-restriction
+      (narrow-to-region (point)(point))
+      (let ((the-buf (current-buffer))
+           (src-buf (mime-entity-buffer entity))
+           (h-end (mime-entity-header-end entity))
+           beg p end field-name len field)
+       (save-excursion
+         (set-buffer src-buf)
+         (goto-char (mime-entity-header-start entity))
+         (save-restriction
+           (narrow-to-region (point) h-end)
+           (while (re-search-forward std11-field-head-regexp nil t)
+             (setq beg (match-beginning 0)
+                   p (match-end 0)
+                   field-name (buffer-substring beg (1- p))
+                   len (string-width field-name)
+                   end (std11-field-end))
+             (when (eword-visible-field-p field-name
+                                          visible-fields invisible-fields)
+               (setq field (intern (capitalize field-name)))
+               (save-excursion
+                 (set-buffer the-buf)
+                 (insert field-name)
+                 (insert ":")
+                 (cond ((memq field eword-decode-ignored-field-list)
+                        ;; Don't decode
+                        (insert-buffer-substring src-buf p end)
+                        )
+                       ((memq field eword-decode-structured-field-list)
+                        ;; Decode as structured field
+                        (let ((body (save-excursion
+                                      (set-buffer src-buf)
+                                      (buffer-substring p end)))
+                              (default-mime-charset default-charset))
+                          (insert (eword-decode-and-fold-structured-field
+                                   body (1+ len)))
+                          ))
+                       (t
+                        ;; Decode as unstructured field
+                        (let ((body (save-excursion
+                                      (set-buffer src-buf)
+                                      (buffer-substring p end)))
+                              (default-mime-charset default-charset))
+                          (insert (eword-decode-unstructured-field-body
+                                   body (1+ len)))
+                          )))
+                 (insert "\n")
+                 )))))))))
+
 
 ;;; @ Entity Content
 ;;;
 
+(defalias 'mime-entity-body-start 'mime-entity-body-start-internal)
+(defalias 'mime-entity-body-end   'mime-entity-body-end-internal)
+
 (defun mime-entity-content (entity)
   (save-excursion
     (set-buffer (mime-entity-buffer entity))
@@ -206,6 +309,17 @@ ENTITY is used."
             ))))
 
 
+(defsubst mime-entity-media-type (entity)
+  (mime-content-type-primary-type (mime-entity-content-type entity)))
+(defsubst mime-entity-media-subtype (entity)
+  (mime-content-type-subtype (mime-entity-content-type entity)))
+(defsubst mime-entity-parameters (entity)
+  (mime-content-type-parameters (mime-entity-content-type entity)))
+(defsubst mime-entity-type/subtype (entity-info)
+  (mime-type/subtype-string (mime-entity-media-type entity-info)
+                           (mime-entity-media-subtype entity-info)))
+
+
 ;;; @ end
 ;;;