;;; mime.el --- MIME library module
-;; Copyright (C) 1998,1999,2000 Free Software Foundation, Inc.
+;; Copyright (C) 1998,1999,2000,2001,2003 Free Software Foundation, Inc.
;; Author: MORIOKA Tomohiko <tomo@m17n.org>
;; Keywords: MIME, multimedia, mail, news
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Code:
(eval-and-compile
-(autoload 'eword-encode-header "eword-encode"
+(autoload 'mime-encode-header-in-buffer "eword-encode"
"Encode header fields to network representation, such as MIME encoded-word.")
(autoload 'mime-parse-Content-Type "mime-parse"
)
+(autoload 'mime-encode-field-body "eword-encode"
+ "Encode FIELD-BODY as FIELD-NAME, and return the result.")
+
+
;;; @ Entity Representation and Implementation
;;;
;;;
(defun mime-entity-children (entity)
+ "Return list of entities included in the ENTITY."
(or (mime-entity-children-internal entity)
(luna-send entity 'mime-entity-children entity)))
(defun mime-entity-node-id (entity)
+ "Return node-id of ENTITY."
(mime-entity-node-id-internal entity))
(defun mime-entity-number (entity)
(defun mime-find-root-entity (entity)
"Return root entity of ENTITY."
- (let ((p (mime-entity-parent entity)))
- (if (null p)
- entity
- (mime-entity-parent p))))
+ (while (not (mime-root-entity-p entity))
+ (setq entity (mime-entity-parent entity)))
+ entity)
;;; @ Header buffer (obsolete)
;; (make-obsolete 'mime-fetch-field 'mime-entity-fetch-field)
(defun mime-entity-content-type (entity)
+ "Return content-type of ENTITY."
(or (mime-entity-content-type-internal entity)
(let ((ret (mime-entity-fetch-field entity "Content-Type")))
(if ret
))))
(defun mime-entity-content-disposition (entity)
+ "Return content-disposition of ENTITY."
(or (mime-entity-content-disposition-internal entity)
(let ((ret (mime-entity-fetch-field entity "Content-Disposition")))
(if ret
))))
(defun mime-entity-encoding (entity &optional default-encoding)
+ "Return content-transfer-encoding of ENTITY.
+If the ENTITY does not have Content-Transfer-Encoding field, this
+function returns DEFAULT-ENCODING. If it is nil, \"7bit\" is used as
+default value."
(or (mime-entity-encoding-internal entity)
(let ((ret (mime-entity-fetch-field entity "Content-Transfer-Encoding")))
(mime-entity-set-encoding-internal
(prog1
field-name
(setq field-name (symbol-name field-name)))
- (intern (capitalize (capitalize field-name))))))
+ (intern (capitalize field-name)))))
(cond ((eq sym 'Content-Type)
(mime-entity-content-type entity)
)
(defun mime-entity-filename (entity)
"Return filename of ENTITY."
(or (mime-entity-uu-filename entity)
- (mime-content-disposition-filename
- (mime-entity-content-disposition entity))
+ (let ((ret (mime-content-disposition-filename
+ (mime-entity-content-disposition entity))))
+ (if (and mime-header-accept-quoted-encoded-words
+ ret)
+ (eword-decode-string ret)
+ ret))
(cdr (let ((param (mime-content-type-parameters
(mime-entity-content-type entity))))
(or (assoc "name" param)
- (assoc "x-name" param))
- ))))
+ (assoc "x-name" param))))))
(defsubst mime-entity-media-type (entity)
+ "Return primary media-type of ENTITY."
(mime-content-type-primary-type (mime-entity-content-type entity)))
+
(defsubst mime-entity-media-subtype (entity)
+ "Return media-subtype of ENTITY."
(mime-content-type-subtype (mime-entity-content-type entity)))
+
(defsubst mime-entity-parameters (entity)
+ "Return parameters of Content-Type of ENTITY."
(mime-content-type-parameters (mime-entity-content-type entity)))
+
(defsubst mime-entity-type/subtype (entity-info)
+ "Return type/subtype of Content-Type of ENTITY."
(mime-type/subtype-string (mime-entity-media-type entity-info)
(mime-entity-media-subtype entity-info)))
(defun mime-entity-set-content-type (entity content-type)
+ "Set ENTITY's content-type to CONTENT-TYPE."
(mime-entity-set-content-type-internal entity content-type))
(defun mime-entity-set-encoding (entity encoding)
+ "Set ENTITY's content-transfer-encoding to ENCODING."
(mime-entity-set-encoding-internal entity encoding))