* tests/test-sasl.el(test-sasl-ntlm-imap): Fix
[elisp/flim.git] / mime-def.el
index 88e788e..24dca95 100644 (file)
@@ -1,8 +1,6 @@
-;;; mime-def.el --- definition module about MIME
+;;; mime-def.el --- definition module about MIME -*- coding: iso-2022-jp; -*-
 
-;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
-;; Copyright (C) 1999 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
+;; Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
 ;; Keywords: definition, MIME, multimedia, mail, news
 
 ;;; Code:
 
-(require 'poe)
-(require 'poem)
-(require 'pcustom)
+(require 'custom)
 (require 'mcharset)
 (require 'alist)
 
-(eval-when-compile (require 'cl))      ; list*
+(eval-when-compile
+  (require 'cl)   ; list*
+  (require 'luna) ; luna-arglist-to-arguments
+  )
 
 (eval-and-compile
-  (defconst mime-library-product ["Chao" (1 13 0) "JR Fujinomori"]
-    "Product name, version number and code name of MIME-library package.")
-  )
+  (defconst mime-library-product ["SLIM" (1 14 6) "\e$BGO^<1QN$2?\e(B"]
+    "Product name, version number and code name of MIME-library package."))
 
 (defmacro mime-product-name (product)
   `(aref ,product 0))
@@ -59,8 +57,6 @@
 ;;; @ variables
 ;;;
 
-(require 'custom)
-
 (defgroup mime '((default-mime-charset custom-variable))
   "Emacs MIME Interfaces"
   :group 'news
   :type '(repeat string))
 
 
+;;; @@ for encoded-word
+;;;
+
+(defgroup mime-header nil
+  "Header representation, specially encoded-word"
+  :group 'mime)
+
+;;; @@@ decoding
+;;;
+
+(defcustom mime-field-decoding-max-size 1000
+  "*Max size to decode header field."
+  :group 'mime-header
+  :type '(choice (integer :tag "Limit (bytes)")
+                (const :tag "Don't limit" nil)))
+
+;;; @@@ encoding
+;;;
+
+(defcustom mime-field-encoding-method-alist
+  '(("X-Nsubject" . iso-2022-jp-2)
+    ("Newsgroups" . nil)
+    ("Message-ID" . nil)
+    (t            . mime)
+    )
+  "*Alist to specify field encoding method.
+Its key is field-name, value is encoding method.
+
+If method is `mime', this field will be encoded into MIME format.
+
+If method is a MIME-charset, this field will be encoded as the charset
+when it must be convert into network-code.
+
+If method is `default-mime-charset', this field will be encoded as
+variable `default-mime-charset' when it must be convert into
+network-code.
+
+If method is nil, this field will not be encoded."
+  :group 'mime-header
+  :type '(repeat (cons (choice :tag "Field"
+                              (string :tag "Name")
+                              (const :tag "Default" t))
+                      (choice :tag "Method"
+                              (const :tag "MIME conversion" mime)
+                              (symbol :tag "non-MIME conversion")
+                              (const :tag "no-conversion" nil)))))
+
+
 ;;; @ required functions
 ;;;
 
 (defsubst regexp-or (&rest args)
   (concat "\\(" (mapconcat (function identity) args "\\|") "\\)"))
 
+(or (fboundp 'char-int)
+    (defalias 'char-int 'identity))
+
 
 ;;; @ about STD 11
 ;;;
   (cdr (car content-type)))
 
 (defsubst mime-content-type-subtype (content-type)
-  "Return primary-type of CONTENT-TYPE."
+  "Return subtype of CONTENT-TYPE."
   (cdr (cadr content-type)))
 
 (defsubst mime-content-type-parameters (content-type)
-  "Return primary-type of CONTENT-TYPE."
+  "Return parameters of CONTENT-TYPE."
   (cddr content-type))
 
 (defsubst mime-content-type-parameter (content-type parameter)
   (mime-content-disposition-parameter content-disposition "filename"))
 
 
-;;; @ MIME entity
-;;;
-
-(require 'luna)
-
-(luna-define-class mime-entity ()
-                  (location
-                   content-type children parent
-                   node-id
-                   content-disposition encoding
-                   ;; for other fields
-                   original-header parsed-header))
-
-(defalias 'mime-entity-representation-type-internal 'luna-class-name)
-(defalias 'mime-entity-set-representation-type-internal 'luna-set-class-name)
-
-(luna-define-internal-accessors 'mime-entity)
-
-(luna-define-method mime-entity-fetch-field ((entity mime-entity)
-                                            field-name)
-  (or (symbolp field-name)
-      (setq field-name (intern (capitalize (capitalize field-name)))))
-  (cdr (assq field-name
-            (mime-entity-original-header-internal entity))))
-
-
-;;; @ for mm-backend
-;;;
-
-(defmacro mm-expand-class-name (type)
-  `(intern (format "mime-%s-entity" ,type)))
-
-(defmacro mm-define-backend (type &optional parents)
-  `(luna-define-class ,(mm-expand-class-name type)
-                     ,(nconc (mapcar (lambda (parent)
-                                       (mm-expand-class-name parent)
-                                       )
-                                     parents)
-                             '(mime-entity))))
-
-(defmacro mm-define-method (name args &rest body)
-  (or (eq name 'initialize-instance)
-      (setq name (intern (format "mime-%s" name))))
-  (let ((spec (car args)))
-    (setq args
-         (cons (list (car spec)
-                     (mm-expand-class-name (nth 1 spec)))
-               (cdr args)))
-    `(luna-define-method ,name ,args ,@body)
-    ))
-
-(put 'mm-define-method 'lisp-indent-function 'defun)
-
-(def-edebug-spec mm-define-method
-  (&define name ((arg symbolp)
-                [&rest arg]
-                [&optional ["&optional" arg &rest arg]]
-                &optional ["&rest" arg]
-                )
-          def-body))
-
-
 ;;; @ message structure
 ;;;