:group 'qmtp)
(autoload 'binary-open-network-stream "raw-io")
+;;;###autoload
(defvar qmtp-open-connection-function (function binary-open-network-stream))
(defvar qmtp-error-response-alist
(defvar sasl-mechanisms)
(autoload 'binary-open-network-stream "raw-io")
+;;;###autoload
(defvar smtp-open-connection-function #'binary-open-network-stream)
(defvar smtp-read-point nil)
;;; eword-decode.el --- RFC 2047 based encoded-word decoder for GNU Emacs
-;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
;; Author: ENAMI Tsugutomo <enami@sys.ptg.sony.co.jp>
-;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; TANAKA Akira <akr@jaist.ac.jp>
+;; MORIOKA Tomohiko <tomo@m17n.org>
+;; TANAKA Akira <akr@m17n.org>
;; Created: 1995/10/03
;; Original: 1992/07/20 ENAMI Tsugutomo's `mime.el'.
;; Renamed: 1993/06/03 to tiny-mime.el by MORIOKA Tomohiko
(eval-when-compile (require 'cl)) ; list*, pop
-(defgroup eword-decode nil
- "Encoded-word decoding"
- :group 'mime)
-(defcustom eword-max-size-to-decode 1000
- "*Max size to decode header field."
- :group 'eword-decode
- :type '(choice (integer :tag "Limit (bytes)")
- (const :tag "Don't limit" nil)))
+;;; @ Variables
+;;;
+
+;; User options are defined in mime-def.el.
;;; @ MIME encoded-word definition
start-column
&optional max-column
start)
- (if (and eword-max-size-to-decode
- (> (length string) eword-max-size-to-decode))
+ (if (and mime-field-decoding-max-size
+ (> (length string) mime-field-decoding-max-size))
string
(or max-column
(setq max-column fill-column))
;;;###autoload
(defun mime-set-field-decoder (field &rest specs)
- "Set decoder of FILED.
+ "Set decoder of FIELD.
SPECS must be like `MODE1 DECODER1 MODE2 DECODER2 ...'.
Each mode must be `nil', `plain', `wide', `summary' or `nov'.
If mode is `nil', corresponding decoder is set up for every modes."
"*Max position of eword-lexical-analyze-cache.
It is max size of eword-lexical-analyze-cache - 1.")
-(defcustom eword-lexical-analyzer
+(defvar mime-header-lexical-analyzer
'(eword-analyze-quoted-string
eword-analyze-domain-literal
eword-analyze-comment
Previous function is preferred to next function. If a function
returns nil, next function is used. Otherwise the return value will
-be the result."
- :group 'eword-decode
- :type '(repeat function))
+be the result.")
(defun eword-analyze-quoted-string (string start &optional must-unfold)
(let ((p (std11-check-enclosure string ?\" ?\" nil start)))
dest ret)
(while (< start len)
(setq ret
- (let ((rest eword-lexical-analyzer)
+ (let ((rest mime-header-lexical-analyzer)
func r)
(while (and (setq func (car rest))
(null
;;; eword-encode.el --- RFC 2047 based encoded-word encoder for GNU Emacs
-;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
;; Keywords: encoded-word, MIME, multilingual, header, mail, news
;; This file is part of FLIM (Faithful Library about Internet Message).
;;; @ variables
;;;
-(defgroup eword-encode nil
- "Encoded-word encoding"
- :group 'mime)
-
-(defcustom eword-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 'eword-encode
- :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)))))
-
-(defvar eword-charset-encoding-alist
+;; User options are defined in mime-def.el.
+
+(defvar mime-header-charset-encoding-alist
'((us-ascii . nil)
(iso-8859-1 . "Q")
(iso-8859-2 . "Q")
(utf-8 . "B")
))
+(defvar mime-header-default-charset-encoding "Q")
+
;;; @ encoded-text encoder
;;;
ENCODING allows \"B\" or \"Q\".
MODE is allows `text', `comment', `phrase' or nil. Default value is
`phrase'."
- (let ((text (encoded-text-encode-string string encoding)))
+ (let ((text (encoded-text-encode-string string encoding mode)))
(if text
(concat "=?" (upcase (symbol-name charset)) "?"
encoding "?" text "?=")
(defun ew-find-charset-rule (charsets)
(if charsets
(let* ((charset (find-mime-charset-by-charsets charsets))
- (encoding (cdr (or (assq charset eword-charset-encoding-alist)
- '(nil . "Q")))))
- (list charset encoding)
- )))
+ (encoding
+ (cdr (or (assq charset mime-header-charset-encoding-alist)
+ (cons charset mime-header-default-charset-encoding)))))
+ (list charset encoding))))
(defun tm-eword::words-to-ruled-words (wl &optional mode)
(mapcar (function
;;; @ application interfaces
;;;
-(defcustom eword-encode-default-start-column 10
- "Default start column if it is omitted."
- :group 'eword-encode
- :type 'integer)
+(defvar eword-encode-default-start-column 10
+ "Default start column if it is omitted.")
(defun eword-encode-string (string &optional column mode)
"Encode STRING as encoded-words, and return the result.
(or column eword-encode-default-start-column)
(eword-encode-split-string string 'text))))
-(defun eword-encode-field-body (field-body field-name)
+;;;###autoload
+(defun mime-encode-field-body (field-body field-name)
"Encode FIELD-BODY as FIELD-NAME, and return the result.
A lexical token includes non-ASCII character is encoded as MIME
encoded-word. ASCII token is not encoded."
Resent-Sender To Resent-To
Cc Resent-Cc Bcc Resent-Bcc
Dcc))
- (eword-encode-address-list field-body start)
- )
+ (eword-encode-address-list field-body start))
((eq field-name 'In-Reply-To)
- (eword-encode-in-reply-to field-body start)
- )
+ (eword-encode-in-reply-to field-body start))
((memq field-name '(Mime-Version User-Agent))
- (eword-encode-structured-field-body field-body start)
- )
+ (eword-encode-structured-field-body field-body start))
(t
- (eword-encode-unstructured-field-body field-body start)
- ))
- )))
+ (eword-encode-unstructured-field-body field-body start))))))
+(defalias 'eword-encode-field-body 'mime-encode-field-body)
+(make-obsolete 'eword-encode-field-body 'mime-encode-field-body)
(defun eword-in-subject-p ()
(let ((str (std11-field-body "Subject")))
(if (and str (string-match eword-encoded-word-regexp str))
str)))
+(make-obsolete 'eword-in-subject-p "Don't use it.")
(defsubst eword-find-field-encoding-method (field-name)
(setq field-name (downcase field-name))
- (let ((alist eword-field-encoding-method-alist))
+ (let ((alist mime-field-encoding-method-alist))
(catch 'found
(while alist
(let* ((pair (car alist))
(throw 'found (cdr pair))
))
(setq alist (cdr alist)))
- (cdr (assq t eword-field-encoding-method-alist))
+ (cdr (assq t mime-field-encoding-method-alist))
)))
-(defun eword-encode-header (&optional code-conversion)
+;;;###autoload
+(defun mime-encode-header-in-buffer (&optional code-conversion)
"Encode header fields to network representation, such as MIME encoded-word.
-It refer variable `eword-field-encoding-method-alist'."
+It refer variable `mime-field-encoding-method-alist'."
(interactive "*")
(save-excursion
(save-restriction
(buffer-substring-no-properties bbeg end)
))
(delete-region bbeg end)
- (insert (eword-encode-field-body field-body
- field-name))
- ))
+ (insert (mime-encode-field-body field-body
+ field-name))))
(code-conversion
(let ((cs
(or (mime-charset-to-coding-system
))
))
)))
+(defalias 'eword-encode-header 'mime-encode-header-in-buffer)
+(make-obsolete 'eword-encode-header 'mime-encode-header-in-buffer)
;;; @ end
(buffer-string))))
(or (bolp) (insert ?\n)))
- (mel-define-method-function (encoded-text-encode-string string (nil "B"))
- 'base64-encode-string)
+ ;; (mel-define-method-function (encoded-text-encode-string string (nil "B"))
+ ;; 'base64-encode-string)
(mel-define-method encoded-text-decode-string (string (nil "B"))
(if (string-match (eval-when-compile
(concat "\\`" B-encoded-text-regexp "\\'"))
string)))
-(mel-define-service encoded-text-encode-string (string encoding)
- "Encode STRING as encoded-text using ENCODING. ENCODING must be string.")
+(mel-define-service encoded-text-encode-string)
+(defun encoded-text-encode-string (string encoding &optional mode)
+ "Encode STRING as encoded-text using ENCODING.
+ENCODING must be string.
+Optional argument MODE allows `text', `comment', `phrase' or nil.
+Default value is `phrase'."
+ (if (string= encoding "B")
+ (base64-encode-string string 'no-line-break)
+ (let ((f (mel-find-function 'encoded-text-encode-string encoding)))
+ (if f
+ (funcall f string mode)
+ string))))
(mel-define-service encoded-text-decode-string (string encoding)
"Decode STRING as encoded-text using ENCODING. ENCODING must be string.")
: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
;;;
(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)
(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)
;; (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
(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))