From 908975bcd7a10836f92b6334d5ed4dbf4817a0cf Mon Sep 17 00:00:00 2001 From: tomo Date: Wed, 20 Dec 2000 09:42:00 +0000 Subject: [PATCH] Sync with flim-1_14_0. --- mail/qmtp.el | 1 + mail/smtp.el | 1 + mime/eword-decode.el | 32 +++++++---------- mime/eword-encode.el | 93 +++++++++++++++++--------------------------------- mime/mel.el | 18 +++++++--- mime/mime-def.el | 52 ++++++++++++++++++++++++++-- mime/mime.el | 23 ++++++++++++- 7 files changed, 133 insertions(+), 87 deletions(-) diff --git a/mail/qmtp.el b/mail/qmtp.el index cf5c294..1010857 100644 --- a/mail/qmtp.el +++ b/mail/qmtp.el @@ -61,6 +61,7 @@ called from `qmtp-via-qmtp' with arguments SENDER and RECIPIENTS.") :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 diff --git a/mail/smtp.el b/mail/smtp.el index 25b5f72..1ccc0e3 100644 --- a/mail/smtp.el +++ b/mail/smtp.el @@ -113,6 +113,7 @@ don't define this value." (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) diff --git a/mime/eword-decode.el b/mime/eword-decode.el index 2378fb1..d14016c 100644 --- a/mime/eword-decode.el +++ b/mime/eword-decode.el @@ -1,10 +1,10 @@ ;;; 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 -;; MORIOKA Tomohiko -;; TANAKA Akira +;; MORIOKA Tomohiko +;; TANAKA Akira ;; Created: 1995/10/03 ;; Original: 1992/07/20 ENAMI Tsugutomo's `mime.el'. ;; Renamed: 1993/06/03 to tiny-mime.el by MORIOKA Tomohiko @@ -38,15 +38,11 @@ (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 @@ -152,8 +148,8 @@ decode the charset included in it, it is not decoded." 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)) @@ -270,7 +266,7 @@ such as a version of Net$cape)." ;;;###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." @@ -594,7 +590,7 @@ as a version of Net$cape)." "*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 @@ -614,9 +610,7 @@ format. 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))) @@ -747,7 +741,7 @@ be the result." 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 diff --git a/mime/eword-encode.el b/mime/eword-encode.el index 9142f2e..f075db3 100644 --- a/mime/eword-encode.el +++ b/mime/eword-encode.el @@ -1,8 +1,8 @@ ;;; 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 +;; Author: MORIOKA Tomohiko ;; Keywords: encoded-word, MIME, multilingual, header, mail, news ;; This file is part of FLIM (Faithful Library about Internet Message). @@ -33,39 +33,9 @@ ;;; @ 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") @@ -89,6 +59,8 @@ If method is nil, this field will not be encoded." (utf-8 . "B") )) +(defvar mime-header-default-charset-encoding "Q") + ;;; @ encoded-text encoder ;;; @@ -99,7 +71,7 @@ CHARSET is a symbol to indicate MIME charset of the encoded-word. 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 "?=") @@ -189,10 +161,10 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is (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 @@ -579,10 +551,8 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is ;;; @ 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. @@ -625,7 +595,8 @@ Optional argument COLUMN is start-position of the field." (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." @@ -644,27 +615,25 @@ 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)) @@ -674,13 +643,14 @@ encoded-word. ASCII token is not encoded." (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 @@ -700,9 +670,8 @@ It refer variable `eword-field-encoding-method-alist'." (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 @@ -713,6 +682,8 @@ It refer variable `eword-field-encoding-method-alist'." )) )) ))) +(defalias 'eword-encode-header 'mime-encode-header-in-buffer) +(make-obsolete 'eword-encode-header 'mime-encode-header-in-buffer) ;;; @ end diff --git a/mime/mel.el b/mime/mel.el index 6306d2f..8c84ac5 100644 --- a/mime/mel.el +++ b/mime/mel.el @@ -122,8 +122,8 @@ mmencode included in metamail or XEmacs package)." (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 "\\'")) @@ -202,8 +202,18 @@ the STRING by its value." 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.") diff --git a/mime/mime-def.el b/mime/mime-def.el index 74158ec..0f5579c 100644 --- a/mime/mime-def.el +++ b/mime/mime-def.el @@ -68,6 +68,54 @@ :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 ;;; @@ -166,11 +214,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) diff --git a/mime/mime.el b/mime/mime.el index 328d599..2160569 100644 --- a/mime/mime.el +++ b/mime/mime.el @@ -33,7 +33,7 @@ (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" @@ -65,6 +65,10 @@ current-buffer, and return it.") ) +(autoload 'mime-encode-field-body "eword-encode" + "Encode FIELD-BODY as FIELD-NAME, and return the result.") + + ;;; @ Entity Representation and Implementation ;;; @@ -87,10 +91,12 @@ representation-type." ;;; (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) @@ -263,6 +269,7 @@ If MESSAGE is specified, it is regarded as root 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 @@ -271,6 +278,7 @@ If MESSAGE is specified, it is regarded as root entity." )))) (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 @@ -279,6 +287,10 @@ If MESSAGE is specified, it is regarded as root entity." )))) (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 @@ -390,19 +402,28 @@ If MESSAGE is specified, it is regarded as root entity." (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)) -- 1.7.10.4