annotate lisp/vm/vm-mime.el @ 194:2947057885e5

Added tag r20-3b23 for changeset f53b5ca2e663
author cvs
date Mon, 13 Aug 2007 09:58:32 +0200
parents 2d532a89d707
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1 ;;; MIME support functions
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1997 Kyle E. Jones
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3 ;;;
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
7 ;;; any later version.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
8 ;;;
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
13 ;;;
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
14 ;;; You should have received a copy of the GNU General Public License
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
15 ;;; along with this program; if not, write to the Free Software
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
17
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
18 (provide 'vm-mime)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
19
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
20 (defun vm-mime-error (&rest args)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
21 (signal 'vm-mime-error (list (apply 'format args)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
22 (error "can't return from vm-mime-error"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
23
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
24 (if (fboundp 'define-error)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
25 (define-error 'vm-mime-error "MIME error")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
26 (put 'vm-mime-error 'error-conditions '(vm-mime-error error))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
27 (put 'vm-mime-error 'error-message "MIME error"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
28
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
29 (defun vm-mm-layout-type (e) (aref e 0))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
30 (defun vm-mm-layout-qtype (e) (aref e 1))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
31 (defun vm-mm-layout-encoding (e) (aref e 2))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
32 (defun vm-mm-layout-id (e) (aref e 3))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
33 (defun vm-mm-layout-description (e) (aref e 4))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
34 (defun vm-mm-layout-disposition (e) (aref e 5))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
35 (defun vm-mm-layout-qdisposition (e) (aref e 6))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
36 (defun vm-mm-layout-header-start (e) (aref e 7))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
37 (defun vm-mm-layout-body-start (e) (aref e 8))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
38 (defun vm-mm-layout-body-end (e) (aref e 9))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
39 (defun vm-mm-layout-parts (e) (aref e 10))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
40 (defun vm-mm-layout-cache (e) (aref e 11))
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
41 ;; if display of MIME part fails, error string will be here.
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
42 (defun vm-mm-layout-display-error (e) (aref e 12))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
43
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
44 (defun vm-set-mm-layout-type (e type) (aset e 0 type))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
45 (defun vm-set-mm-layout-cache (e c) (aset e 11 c))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
46 (defun vm-set-mm-layout-display-error (e c) (aset e 12 c))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
47
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
48 (defun vm-mm-layout (m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
49 (or (vm-mime-layout-of m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
50 (progn (vm-set-mime-layout-of
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
51 m
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
52 (condition-case data
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
53 (vm-mime-parse-entity m)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
54 (vm-mime-error (message "%s" (car (cdr data))))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
55 (vm-mime-layout-of m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
56
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
57 (defun vm-mm-encoded-header (m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
58 (or (vm-mime-encoded-header-flag-of m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
59 (progn (setq m (vm-real-message-of m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
60 (vm-set-mime-encoded-header-flag-of
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
61 m
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
62 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
63 (set-buffer (vm-buffer-of m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
64 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
65 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
66 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
67 (goto-char (vm-headers-of m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
68 (or (re-search-forward vm-mime-encoded-word-regexp
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
69 (vm-text-of m) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
70 'none)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
71 (vm-mime-encoded-header-flag-of m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
72
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
73 (defun vm-mime-Q-decode-region (start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
74 (let ((buffer-read-only nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
75 (subst-char-in-region start end ?_ (string-to-char " ") t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
76 (vm-mime-qp-decode-region start end)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
77
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
78 (fset 'vm-mime-B-decode-region 'vm-mime-base64-decode-region)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
79
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
80 (defun vm-mime-Q-encode-region (start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
81 (let ((buffer-read-only nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
82 (subst-char-in-region start end (string-to-char " ") ?_ t)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
83 (vm-mime-qp-encode-region start end t)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
84
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
85 (defun vm-mime-B-encode-region (start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
86 (vm-mime-base64-encode-region start end nil t))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
87
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
88 (defun vm-mime-crlf-to-lf-region (start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
89 (let ((buffer-read-only nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
90 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
91 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
92 (narrow-to-region start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
93 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
94 (while (search-forward "\r\n" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
95 (delete-char -2)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
96 (insert "\n"))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
97
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
98 (defun vm-mime-lf-to-crlf-region (start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
99 (let ((buffer-read-only nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
100 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
101 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
102 (narrow-to-region start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
103 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
104 (while (search-forward "\n" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
105 (delete-char -1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
106 (insert "\r\n"))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
107
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
108 (defun vm-mime-charset-decode-region (charset start end)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
109 (or (markerp end) (setq end (vm-marker end)))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
110 (cond (vm-xemacs-mule-p
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
111 (if (eq (device-type) 'x)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
112 (let ((buffer-read-only nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
113 (cell (cdr (vm-string-assoc
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
114 charset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
115 vm-mime-mule-charset-to-coding-alist)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
116 (oend (marker-position end))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
117 (opoint (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
118 (if cell
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
119 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
120 (set-marker end (+ start
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
121 (or (decode-coding-region
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
122 start end (car cell))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
123 (- oend start))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
124 (put-text-property start end 'vm-string t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
125 (put-text-property start end 'vm-charset charset)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
126 (put-text-property start end 'vm-coding (car cell))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
127 ;; In XEmacs 20.0 beta93 decode-coding-region moves point.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
128 (goto-char opoint))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
129 ((not (vm-multiple-fonts-possible-p)) nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
130 ((vm-string-member charset vm-mime-default-face-charsets) nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
131 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
132 (let ((font (cdr (vm-string-assoc
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
133 charset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
134 vm-mime-charset-font-alist)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
135 (face (make-face (make-symbol "temp-face")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
136 (e (vm-make-extent start end)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
137 (put-text-property start end 'vm-string t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
138 (put-text-property start end 'vm-charset charset)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
139 (if font
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
140 (condition-case data
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
141 (progn (set-face-font face font)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
142 (vm-set-extent-property e 'face face))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
143 (error nil)))))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
144
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
145 (defun vm-mime-transfer-decode-region (layout start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
146 (let ((case-fold-search t) (crlf nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
147 (cond ((string-match "^base64$" (vm-mm-layout-encoding layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
148 (cond ((vm-mime-types-match "text"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
149 (car (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
150 (setq crlf t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
151 ((vm-mime-types-match "message"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
152 (car (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
153 (setq crlf t)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
154 (vm-mime-base64-decode-region start end crlf))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
155 ((string-match "^quoted-printable$"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
156 (vm-mm-layout-encoding layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
157 (vm-mime-qp-decode-region start end)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
158
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
159 (defun vm-mime-base64-decode-region (start end &optional crlf)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
160 (message "Decoding base64...")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
161 (let ((work-buffer nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
162 (done nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
163 (counter 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
164 (bits 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
165 (lim 0) inputpos
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
166 (non-data-chars (concat "^=" vm-mime-base64-alphabet)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
167 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
168 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
169 (setq work-buffer (generate-new-buffer " *vm-work*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
170 (buffer-disable-undo work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
171 (if vm-mime-base64-decoder-program
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
172 (let* ((binary-process-output t) ; any text already has CRLFs
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
173 (status (apply 'vm-run-command-on-region
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
174 start end work-buffer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
175 vm-mime-base64-decoder-program
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
176 vm-mime-base64-decoder-switches)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
177 (if (not (eq status t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
178 (vm-mime-error "%s" (cdr status))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
179 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
180 (skip-chars-forward non-data-chars end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
181 (while (not done)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
182 (setq inputpos (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
183 (cond
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
184 ((> (skip-chars-forward vm-mime-base64-alphabet end) 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
185 (setq lim (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
186 (while (< inputpos lim)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
187 (setq bits (+ bits
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
188 (aref vm-mime-base64-alphabet-decoding-vector
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
189 (char-after inputpos))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
190 (vm-increment counter)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
191 (vm-increment inputpos)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
192 (cond ((= counter 4)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
193 (vm-insert-char (lsh bits -16) 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
194 (vm-insert-char (logand (lsh bits -8) 255) 1 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
195 work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
196 (vm-insert-char (logand bits 255) 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
197 (setq bits 0 counter 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
198 (t (setq bits (lsh bits 6)))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
199 (cond
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
200 ((= (point) end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
201 (if (not (zerop counter))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
202 (vm-mime-error "at least %d bits missing at end of base64 encoding"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
203 (* (- 4 counter) 6)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
204 (setq done t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
205 ((= (char-after (point)) 61) ; 61 is ASCII equals
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
206 (setq done t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
207 (cond ((= counter 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
208 (vm-mime-error "at least 2 bits missing at end of base64 encoding"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
209 ((= counter 2)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
210 (vm-insert-char (lsh bits -10) 1 nil work-buffer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
211 ((= counter 3)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
212 (vm-insert-char (lsh bits -16) 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
213 (vm-insert-char (logand (lsh bits -8) 255)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
214 1 nil work-buffer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
215 ((= counter 0) t)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
216 (t (skip-chars-forward non-data-chars end)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
217 (and crlf
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
218 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
219 (set-buffer work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
220 (vm-mime-crlf-to-lf-region (point-min) (point-max))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
221 (or (markerp end) (setq end (vm-marker end)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
222 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
223 (insert-buffer-substring work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
224 (delete-region (point) end))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
225 (and work-buffer (kill-buffer work-buffer))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
226 (message "Decoding base64... done"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
227
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
228 (defun vm-mime-base64-encode-region (start end &optional crlf B-encoding)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
229 (and (> (- end start) 200)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
230 (message "Encoding base64..."))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
231 (let ((work-buffer nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
232 (counter 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
233 (cols 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
234 (bits 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
235 (alphabet vm-mime-base64-alphabet)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
236 inputpos)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
237 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
238 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
239 (setq work-buffer (generate-new-buffer " *vm-work*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
240 (buffer-disable-undo work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
241 (if crlf
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
242 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
243 (or (markerp end) (setq end (vm-marker end)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
244 (vm-mime-lf-to-crlf-region start end)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
245 (if vm-mime-base64-encoder-program
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
246 (let ((status (apply 'vm-run-command-on-region
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
247 start end work-buffer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
248 vm-mime-base64-encoder-program
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
249 vm-mime-base64-encoder-switches)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
250 (if (not (eq status t))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
251 (vm-mime-error "%s" (cdr status)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
252 (if B-encoding
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
253 (progn
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
254 ;; if we're B encoding, strip out the line breaks
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
255 (goto-char (point-min))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
256 (while (search-forward "\n" nil t)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
257 (delete-char -1)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
258 (setq inputpos start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
259 (while (< inputpos end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
260 (setq bits (+ bits (char-after inputpos)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
261 (vm-increment counter)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
262 (cond ((= counter 3)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
263 (vm-insert-char (aref alphabet (lsh bits -18)) 1 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
264 work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
265 (vm-insert-char (aref alphabet (logand (lsh bits -12) 63))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
266 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
267 (vm-insert-char (aref alphabet (logand (lsh bits -6) 63))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
268 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
269 (vm-insert-char (aref alphabet (logand bits 63)) 1 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
270 work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
271 (setq cols (+ cols 4))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
272 (cond ((= cols 72)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
273 (setq cols 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
274 (if (not B-encoding)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
275 (vm-insert-char ?\n 1 nil work-buffer))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
276 (setq bits 0 counter 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
277 (t (setq bits (lsh bits 8))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
278 (vm-increment inputpos))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
279 ;; write out any remaining bits with appropriate padding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
280 (if (= counter 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
281 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
282 (setq bits (lsh bits (- 16 (* 8 counter))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
283 (vm-insert-char (aref alphabet (lsh bits -18)) 1 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
284 work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
285 (vm-insert-char (aref alphabet (logand (lsh bits -12) 63))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
286 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
287 (if (= counter 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
288 (vm-insert-char ?= 2 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
289 (vm-insert-char (aref alphabet (logand (lsh bits -6) 63))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
290 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
291 (vm-insert-char ?= 1 nil work-buffer)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
292 (if (> cols 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
293 (vm-insert-char ?\n 1 nil work-buffer)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
294 (or (markerp end) (setq end (vm-marker end)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
295 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
296 (insert-buffer-substring work-buffer)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
297 (delete-region (point) end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
298 (and (> (- end start) 200)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
299 (message "Encoding base64... done"))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
300 (- end start))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
301 (and work-buffer (kill-buffer work-buffer)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
302
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
303 (defun vm-mime-qp-decode-region (start end)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
304 (and (> (- end start) 200)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
305 (message "Decoding quoted-printable..."))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
306 (let ((work-buffer nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
307 (buf (current-buffer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
308 (case-fold-search nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
309 (hex-digit-alist '((?0 . 0) (?1 . 1) (?2 . 2) (?3 . 3)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
310 (?4 . 4) (?5 . 5) (?6 . 6) (?7 . 7)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
311 (?8 . 8) (?9 . 9) (?A . 10) (?B . 11)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
312 (?C . 12) (?D . 13) (?E . 14) (?F . 15)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
313 inputpos stop-point copy-point)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
314 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
315 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
316 (setq work-buffer (generate-new-buffer " *vm-work*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
317 (buffer-disable-undo work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
318 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
319 (setq inputpos start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
320 (while (< inputpos end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
321 (skip-chars-forward "^=\n" end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
322 (setq stop-point (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
323 (cond ((looking-at "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
324 ;; spaces or tabs before a hard line break must be ignored
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
325 (skip-chars-backward " \t")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
326 (setq copy-point (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
327 (goto-char stop-point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
328 (t (setq copy-point stop-point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
329 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
330 (set-buffer work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
331 (insert-buffer-substring buf inputpos copy-point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
332 (cond ((= (point) end) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
333 ((looking-at "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
334 (vm-insert-char ?\n 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
335 (forward-char))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
336 (t ;; looking at =
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
337 (forward-char)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
338 (cond ((looking-at "[0-9A-F][0-9A-F]")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
339 (vm-insert-char (+ (* (cdr (assq (char-after (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
340 hex-digit-alist))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
341 16)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
342 (cdr (assq (char-after
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
343 (1+ (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
344 hex-digit-alist)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
345 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
346 (forward-char 2))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
347 ((looking-at "\n") ; soft line break
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
348 (forward-char))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
349 ((looking-at "\r")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
350 ;; assume the user's goatloving
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
351 ;; delivery software didn't convert
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
352 ;; from Internet's CRLF newline
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
353 ;; convention to the local LF
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
354 ;; convention.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
355 (forward-char))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
356 ((looking-at "[ \t]")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
357 ;; garbage added in transit
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
358 (skip-chars-forward " \t" end))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
359 (t (vm-mime-error "something other than line break or hex digits after = in quoted-printable encoding")))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
360 (setq inputpos (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
361 (or (markerp end) (setq end (vm-marker end)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
362 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
363 (insert-buffer-substring work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
364 (delete-region (point) end))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
365 (and work-buffer (kill-buffer work-buffer))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
366 (and (> (- end start) 200)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
367 (message "Decoding quoted-printable... done")))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
368
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
369 (defun vm-mime-qp-encode-region (start end &optional Q-encoding quote-from)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
370 (and (> (- end start) 200)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
371 (message "Encoding quoted-printable..."))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
372 (let ((work-buffer nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
373 (buf (current-buffer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
374 (cols 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
375 (hex-digit-alist '((?0 . 0) (?1 . 1) (?2 . 2) (?3 . 3)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
376 (?4 . 4) (?5 . 5) (?6 . 6) (?7 . 7)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
377 (?8 . 8) (?9 . 9) (?A . 10) (?B . 11)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
378 (?C . 12) (?D . 13) (?E . 14) (?F . 15)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
379 char inputpos)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
380 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
381 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
382 (setq work-buffer (generate-new-buffer " *vm-work*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
383 (buffer-disable-undo work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
384 (setq inputpos start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
385 (while (< inputpos end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
386 (setq char (char-after inputpos))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
387 (cond ((= char ?\n)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
388 (vm-insert-char char 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
389 (setq cols 0))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
390 ((and (= char 32)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
391 (not (= (1+ inputpos) end))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
392 (not (= ?\n (char-after (1+ inputpos)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
393 (vm-insert-char char 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
394 (vm-increment cols))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
395 ((or (< char 33) (> char 126) (= char 61)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
396 (and quote-from (= cols 0) (let ((case-fold-search nil))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
397 (looking-at "From ")))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
398 (and (= cols 0) (= char ?.)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
399 (looking-at "\\.\\(\n\\|\\'\\)")))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
400 (vm-insert-char ?= 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
401 (vm-insert-char (car (rassq (lsh char -4) hex-digit-alist))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
402 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
403 (vm-insert-char (car (rassq (logand char 15)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
404 hex-digit-alist))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
405 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
406 (setq cols (+ cols 3)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
407 (t (vm-insert-char char 1 nil work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
408 (vm-increment cols)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
409 (cond ((> cols 70)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
410 (setq cols 0)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
411 (if Q-encoding
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
412 nil
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
413 (vm-insert-char ?= 1 nil work-buffer)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
414 (vm-insert-char ?\n 1 nil work-buffer))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
415 (vm-increment inputpos))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
416 (or (markerp end) (setq end (vm-marker end)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
417 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
418 (insert-buffer-substring work-buffer)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
419 (delete-region (point) end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
420 (and (> (- end start) 200)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
421 (message "Encoding quoted-printable... done"))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
422 (- end start))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
423 (and work-buffer (kill-buffer work-buffer)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
424
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
425 (defun vm-decode-mime-message-headers (m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
426 (let ((case-fold-search t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
427 (buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
428 charset encoding match-start match-end start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
429 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
430 (goto-char (vm-headers-of m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
431 (while (re-search-forward vm-mime-encoded-word-regexp (vm-text-of m) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
432 (setq match-start (match-beginning 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
433 match-end (match-end 0)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
434 charset (buffer-substring (match-beginning 1) (match-end 1))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
435 encoding (buffer-substring (match-beginning 2) (match-end 2))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
436 start (match-beginning 3)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
437 end (vm-marker (match-end 3)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
438 ;; don't change anything if we can't display the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
439 ;; character set properly.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
440 (if (not (vm-mime-charset-internally-displayable-p charset))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
441 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
442 (delete-region end match-end)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
443 (condition-case data
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
444 (cond ((string-match "B" encoding)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
445 (vm-mime-B-decode-region start end))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
446 ((string-match "Q" encoding)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
447 (vm-mime-Q-decode-region start end))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
448 (t (vm-mime-error "unknown encoded word encoding, %s"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
449 encoding)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
450 (vm-mime-error (apply 'message (cdr data))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
451 (goto-char start)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
452 (insert "**invalid encoded word**")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
453 (delete-region (point) end)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
454 (vm-mime-charset-decode-region charset start end)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
455 (delete-region match-start start))))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
456
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
457 (defun vm-decode-mime-encoded-words ()
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
458 (let ((case-fold-search t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
459 (buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
460 charset encoding match-start match-end start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
461 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
462 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
463 (while (re-search-forward vm-mime-encoded-word-regexp nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
464 (setq match-start (match-beginning 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
465 match-end (match-end 0)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
466 charset (buffer-substring (match-beginning 1) (match-end 1))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
467 encoding (buffer-substring (match-beginning 2) (match-end 2))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
468 start (match-beginning 3)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
469 end (vm-marker (match-end 3)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
470 ;; don't change anything if we can't display the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
471 ;; character set properly.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
472 (if (not (vm-mime-charset-internally-displayable-p charset))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
473 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
474 (delete-region end match-end)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
475 (condition-case data
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
476 (cond ((string-match "B" encoding)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
477 (vm-mime-B-decode-region start end))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
478 ((string-match "Q" encoding)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
479 (vm-mime-Q-decode-region start end))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
480 (t (vm-mime-error "unknown encoded word encoding, %s"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
481 encoding)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
482 (vm-mime-error (apply 'message (cdr data))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
483 (goto-char start)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
484 (insert "**invalid encoded word**")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
485 (delete-region (point) end)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
486 (vm-mime-charset-decode-region charset start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
487 (delete-region match-start start))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
488
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
489 (defun vm-decode-mime-encoded-words-in-string (string)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
490 (if (and vm-display-using-mime
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
491 (string-match vm-mime-encoded-word-regexp string))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
492 (vm-with-string-as-temp-buffer string 'vm-decode-mime-encoded-words)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
493 string ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
494
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
495 (defun vm-reencode-mime-encoded-words ()
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
496 (let ((charset nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
497 start coding pos q-encoding
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
498 old-size
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
499 (case-fold-search t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
500 (done nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
501 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
502 (setq start (point-min))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
503 (while (not done)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
504 (setq charset (get-text-property start 'vm-charset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
505 (setq pos (next-single-property-change start 'vm-charset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
506 (or pos (setq pos (point-max) done t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
507 (if charset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
508 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
509 (if (setq coding (get-text-property start 'vm-coding))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
510 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
511 (setq old-size (buffer-size))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
512 (encode-coding-region start pos coding)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
513 (setq pos (+ pos (- (buffer-size) old-size)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
514 (setq pos
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
515 (+ start
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
516 (if (setq q-encoding
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
517 (string-match "^iso-8859-\\|^us-ascii"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
518 charset))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
519 (vm-mime-Q-encode-region start pos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
520 (vm-mime-B-encode-region start pos))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
521 (goto-char pos)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
522 (insert "?=")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
523 (setq pos (point))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
524 (goto-char start)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
525 (insert "=?" charset "?" (if q-encoding "Q" "B") "?")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
526 (setq start pos)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
527
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
528 (defun vm-reencode-mime-encoded-words-in-string (string)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
529 (if (and vm-display-using-mime
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
530 (text-property-any 0 (length string) 'vm-string t string))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
531 (vm-with-string-as-temp-buffer string 'vm-reencode-mime-encoded-words)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
532 string ))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
533
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
534 (fset 'vm-mime-parse-content-header 'vm-parse-structured-header)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
535
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
536 (defun vm-mime-get-header-contents (header-name-regexp)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
537 (let ((contents nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
538 regexp)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
539 (setq regexp (concat "^\\(" header-name-regexp "\\)\\|\\(^$\\)"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
540 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
541 (let ((case-fold-search t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
542 (if (and (re-search-forward regexp nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
543 (match-beginning 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
544 (progn (goto-char (match-beginning 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
545 (vm-match-header)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
546 (vm-matched-header-contents)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
547 nil )))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
548
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
549 (defun vm-mime-parse-entity (&optional m default-type default-encoding)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
550 (let ((case-fold-search t) version type qtype encoding id description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
551 disposition qdisposition boundary boundary-regexp start
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
552 multipart-list c-t c-t-e done p returnval)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
553 (catch 'return-value
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
554 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
555 (if m
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
556 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
557 (setq m (vm-real-message-of m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
558 (set-buffer (vm-buffer-of m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
559 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
560 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
561 (if m
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
562 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
563 (setq version (vm-get-header-contents m "MIME-Version:")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
564 version (car (vm-mime-parse-content-header version))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
565 type (vm-get-header-contents m "Content-Type:")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
566 qtype (vm-mime-parse-content-header type ?\; t)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
567 type (vm-mime-parse-content-header type ?\;)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
568 encoding (or (vm-get-header-contents
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
569 m "Content-Transfer-Encoding:")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
570 "7bit")
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
571 encoding (or (car
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
572 (vm-mime-parse-content-header encoding))
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
573 "7bit")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
574 id (vm-get-header-contents m "Content-ID:")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
575 id (car (vm-mime-parse-content-header id))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
576 description (vm-get-header-contents
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
577 m "Content-Description:")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
578 description (and description
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
579 (if (string-match "^[ \t\n]$"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
580 description)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
581 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
582 description))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
583 disposition (vm-get-header-contents
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
584 m "Content-Disposition:")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
585 qdisposition (and disposition
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
586 (vm-mime-parse-content-header
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
587 disposition ?\; t))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
588 disposition (and disposition
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
589 (vm-mime-parse-content-header
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
590 disposition ?\;)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
591 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
592 (narrow-to-region (vm-headers-of m) (vm-text-end-of m)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
593 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
594 (setq type (vm-mime-get-header-contents "Content-Type:")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
595 qtype (or (vm-mime-parse-content-header type ?\; t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
596 default-type)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
597 type (or (vm-mime-parse-content-header type ?\;)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
598 default-type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
599 encoding (or (vm-mime-get-header-contents
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
600 "Content-Transfer-Encoding:")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
601 default-encoding)
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
602 encoding (or (car (vm-mime-parse-content-header encoding))
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
603 default-encoding)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
604 id (vm-mime-get-header-contents "Content-ID:")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
605 id (car (vm-mime-parse-content-header id))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
606 description (vm-mime-get-header-contents
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
607 "Content-Description:")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
608 description (and description (if (string-match "^[ \t\n]+$"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
609 description)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
610 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
611 description))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
612 disposition (vm-mime-get-header-contents
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
613 "Content-Disposition:")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
614 qdisposition (and disposition
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
615 (vm-mime-parse-content-header
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
616 disposition ?\; t))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
617 disposition (and disposition
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
618 (vm-mime-parse-content-header
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
619 disposition ?\;))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
620 (cond ((null m) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
621 ((null version)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
622 (throw 'return-value 'none))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
623 ((or vm-mime-ignore-mime-version (string= version "1.0")) t)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
624 (t (vm-mime-error "Unsupported MIME version: %s" version)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
625 (cond ((and m (null type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
626 (throw 'return-value
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
627 (vector '("text/plain" "charset=us-ascii")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
628 '("text/plain" "charset=us-ascii")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
629 encoding id description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
630 disposition qdisposition
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
631 (vm-headers-of m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
632 (vm-text-of m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
633 (vm-text-end-of m)
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
634 nil nil nil )))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
635 ((null type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
636 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
637 (or (re-search-forward "^\n\\|\n\\'" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
638 (vm-mime-error "MIME part missing header/body separator line"))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
639 (vector default-type default-type
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
640 encoding id description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
641 disposition qdisposition
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
642 (vm-marker (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
643 (vm-marker (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
644 (vm-marker (point-max))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
645 nil nil nil ))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
646 ((null (string-match "[^/ ]+/[^/ ]+" (car type)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
647 (vm-mime-error "Malformed MIME content type: %s" (car type)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
648 ((and (string-match "^multipart/\\|^message/" (car type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
649 (null (string-match "^\\(7bit\\|8bit\\|binary\\)$"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
650 encoding)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
651 (vm-mime-error "Opaque transfer encoding used with multipart or message type: %s, %s" (car type) encoding))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
652 ((and (string-match "^message/partial$" (car type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
653 (null (string-match "^7bit$" encoding)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
654 (vm-mime-error "Non-7BIT transfer encoding used with message/partial message: %s" encoding))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
655 ((string-match "^multipart/digest" (car type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
656 (setq c-t '("message/rfc822")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
657 c-t-e "7bit"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
658 ((string-match "^multipart/" (car type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
659 (setq c-t '("text/plain" "charset=us-ascii")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
660 c-t-e "7bit")) ; below
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
661 ((string-match "^message/\\(rfc822\\|news\\)" (car type))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
662 (setq c-t '("text/plain" "charset=us-ascii")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
663 c-t-e "7bit")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
664 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
665 (or (re-search-forward "^\n\\|\n\\'" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
666 (vm-mime-error "MIME part missing header/body separator line"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
667 (throw 'return-value
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
668 (vector type qtype encoding id description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
669 disposition qdisposition
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
670 (vm-marker (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
671 (vm-marker (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
672 (vm-marker (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
673 (list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
674 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
675 (narrow-to-region (point) (point-max))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
676 (vm-mime-parse-entity-safe nil c-t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
677 c-t-e)))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
678 nil nil )))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
679 (t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
680 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
681 (or (re-search-forward "^\n\\|\n\\'" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
682 (vm-mime-error "MIME part missing header/body separator line"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
683 (throw 'return-value
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
684 (vector type qtype encoding id description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
685 disposition qdisposition
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
686 (vm-marker (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
687 (vm-marker (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
688 (vm-marker (point-max))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
689 nil nil nil ))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
690 (setq p (cdr type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
691 boundary nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
692 (while p
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
693 (if (string-match "^boundary=" (car p))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
694 (setq boundary (car (vm-parse (car p) "=\\(.+\\)"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
695 p nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
696 (setq p (cdr p))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
697 (or boundary
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
698 (vm-mime-error
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
699 "Boundary parameter missing in %s type specification"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
700 (car type)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
701 ;; the \' in the regexp is to "be liberal" in the
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
702 ;; face of broken software that does not add a line
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
703 ;; break after the final boundary of a nested
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
704 ;; multipart entity.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
705 (setq boundary-regexp
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
706 (concat "^--" (regexp-quote boundary)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
707 "\\(--\\)?[ \t]*\\(\n\\|\\'\\)"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
708 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
709 (setq start nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
710 multipart-list nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
711 done nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
712 (while (and (not done) (re-search-forward boundary-regexp nil t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
713 (cond ((null start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
714 (setq start (match-end 0)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
715 (t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
716 (and (match-beginning 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
717 (setq done t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
718 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
719 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
720 (narrow-to-region start (1- (match-beginning 0)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
721 (setq start (match-end 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
722 (setq multipart-list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
723 (cons (vm-mime-parse-entity-safe nil c-t c-t-e)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
724 multipart-list)))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
725 (if (not done)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
726 (vm-mime-error "final %s boundary missing" boundary))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
727 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
728 (or (re-search-forward "^\n\\|\n\\'" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
729 (vm-mime-error "MIME part missing header/body separator line"))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
730 (vector type qtype encoding id description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
731 disposition qdisposition
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
732 (vm-marker (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
733 (vm-marker (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
734 (vm-marker (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
735 (nreverse multipart-list)
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
736 nil nil )))))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
737
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
738 (defun vm-mime-parse-entity-safe (&optional m c-t c-t-e)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
739 (or c-t (setq c-t '("text/plain" "charset=us-ascii")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
740 ;; don't let subpart parse errors make the whole parse fail. use default
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
741 ;; type if the parse fails.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
742 (condition-case error-data
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
743 (vm-mime-parse-entity nil c-t c-t-e)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
744 (vm-mime-error
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
745 (let ((header (if m
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
746 (vm-headers-of m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
747 (vm-marker (point-min))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
748 (text (if m
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
749 (vm-text-of m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
750 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
751 (re-search-forward "^\n\\|\n\\'"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
752 nil 0)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
753 (vm-marker (point)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
754 (text-end (if m
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
755 (vm-text-end-of m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
756 (vm-marker (point-max)))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
757 (vector c-t c-t
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
758 (vm-determine-proper-content-transfer-encoding text text-end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
759 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
760 ;; cram the error message into the description slot
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
761 (car (cdr error-data))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
762 ;; mark as an attachment to improve the chance that the user
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
763 ;; will see the description.
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
764 '("attachment") '("attachment")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
765 header
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
766 text
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
767 text-end
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
768 nil nil nil)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
769
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
770 (defun vm-mime-get-xxx-parameter (layout name param-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
771 (let ((match-end (1+ (length name)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
772 (name-regexp (concat (regexp-quote name) "="))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
773 (case-fold-search t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
774 (done nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
775 (while (and param-list (not done))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
776 (if (and (string-match name-regexp (car param-list))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
777 (= (match-end 0) match-end))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
778 (setq done t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
779 (setq param-list (cdr param-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
780 (and (car param-list) (car (vm-parse (car param-list) "=\\(.*\\)")))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
781
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
782 (defun vm-mime-get-parameter (layout name)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
783 (vm-mime-get-xxx-parameter layout name (cdr (vm-mm-layout-type layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
784
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
785 (defun vm-mime-get-disposition-parameter (layout name)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
786 (vm-mime-get-xxx-parameter layout name
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
787 (cdr (vm-mm-layout-disposition layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
788
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
789 (defun vm-mime-insert-mime-body (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
790 (vm-insert-region-from-buffer (marker-buffer (vm-mm-layout-body-start layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
791 (vm-mm-layout-body-start layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
792 (vm-mm-layout-body-end layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
793
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
794 (defun vm-mime-insert-mime-headers (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
795 (vm-insert-region-from-buffer (marker-buffer (vm-mm-layout-body-start layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
796 (vm-mm-layout-header-start layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
797 (vm-mm-layout-body-start layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
798 (if (and (not (bobp)) (char-equal (char-after (1- (point))) ?\n))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
799 (delete-char -1)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
800
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
801 (defun vm-make-presentation-copy (m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
802 (let ((mail-buffer (current-buffer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
803 b mm
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
804 (real-m (vm-real-message-of m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
805 (modified (buffer-modified-p)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
806 (cond ((or (null vm-presentation-buffer-handle)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
807 (null (buffer-name vm-presentation-buffer-handle)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
808 (setq b (generate-new-buffer (concat (buffer-name)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
809 " Presentation")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
810 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
811 (set-buffer b)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
812 (if (fboundp 'buffer-disable-undo)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
813 (buffer-disable-undo (current-buffer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
814 ;; obfuscation to make the v19 compiler not whine
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
815 ;; about obsolete functions.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
816 (let ((x 'buffer-flush-undo))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
817 (funcall x (current-buffer))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
818 (setq mode-name "VM Presentation"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
819 major-mode 'vm-presentation-mode
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
820 vm-message-pointer (list nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
821 vm-mail-buffer mail-buffer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
822 mode-popup-menu (and vm-use-menus vm-popup-menu-on-mouse-3
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
823 (vm-menu-support-possible-p)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
824 (vm-menu-mode-menu))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
825 ;; Default to binary file type for DOS/NT.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
826 buffer-file-type t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
827 ;; Tell XEmacs/MULE not to mess with the text on writes.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
828 buffer-read-only t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
829 mode-line-format vm-mode-line-format)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
830 ;; scroll in place messes with scroll-up and this loses
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
831 (defvar scroll-in-place)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
832 (make-local-variable 'scroll-in-place)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
833 (setq scroll-in-place nil)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
834 (and vm-xemacs-mule-p
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
835 (set-buffer-file-coding-system 'binary t))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
836 (cond (vm-fsfemacs-19-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
837 ;; need to do this outside the let because
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
838 ;; loading disp-table initializes
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
839 ;; standard-display-table.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
840 (require 'disp-table)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
841 (let* ((standard-display-table
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
842 (copy-sequence standard-display-table)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
843 (standard-display-european t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
844 (setq buffer-display-table standard-display-table))))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
845 (if (and vm-mutable-frames vm-frame-per-folder
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
846 (vm-multiple-frames-possible-p))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
847 (vm-set-hooks-for-frame-deletion))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
848 (use-local-map vm-mode-map)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
849 (and (vm-toolbar-support-possible-p) vm-use-toolbar
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
850 (vm-toolbar-install-toolbar))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
851 (and (vm-menu-support-possible-p)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
852 (vm-menu-install-menus))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
853 (run-hooks 'vm-presentation-mode-hook))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
854 (setq vm-presentation-buffer-handle b)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
855 (setq b vm-presentation-buffer-handle
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
856 vm-presentation-buffer vm-presentation-buffer-handle
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
857 vm-mime-decoded nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
858 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
859 (set-buffer (vm-buffer-of real-m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
860 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
861 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
862 ;; must reference this now so that headers will be in
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
863 ;; their final position before the message is copied.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
864 ;; otherwise the vheader offset computed below will be
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
865 ;; wrong.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
866 (vm-vheaders-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
867 (set-buffer b)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
868 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
869 (let ((buffer-read-only nil)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
870 ;; disable read-only text properties
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
871 (inhibit-read-only t)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
872 (modified (buffer-modified-p)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
873 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
874 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
875 (erase-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
876 (insert-buffer-substring (vm-buffer-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
877 (vm-start-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
878 (vm-end-of real-m)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
879 (set-buffer-modified-p modified)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
880 (setq mm (copy-sequence m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
881 (vm-set-location-data-of mm (vm-copy (vm-location-data-of m)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
882 (set-marker (vm-start-of mm) (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
883 (set-marker (vm-headers-of mm) (+ (vm-start-of mm)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
884 (- (vm-headers-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
885 (vm-start-of real-m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
886 (set-marker (vm-vheaders-of mm) (+ (vm-start-of mm)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
887 (- (vm-vheaders-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
888 (vm-start-of real-m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
889 (set-marker (vm-text-of mm) (+ (vm-start-of mm)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
890 (- (vm-text-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
891 (vm-start-of real-m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
892 (set-marker (vm-text-end-of mm) (+ (vm-start-of mm)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
893 (- (vm-text-end-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
894 (vm-start-of real-m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
895 (set-marker (vm-end-of mm) (+ (vm-start-of mm)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
896 (- (vm-end-of real-m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
897 (vm-start-of real-m))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
898 (setcar vm-message-pointer mm)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
899
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
900 (fset 'vm-presentation-mode 'vm-mode)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
901 (put 'vm-presentation-mode 'mode-class 'special)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
902
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
903 (defvar buffer-file-coding-system)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
904
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
905 (defun vm-determine-proper-charset (beg end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
906 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
907 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
908 (narrow-to-region beg end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
909 (catch 'done
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
910 (goto-char (point-min))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
911 (if vm-xemacs-mule-p
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
912 (let ((charsets (delq 'ascii (charsets-in-region beg end))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
913 (cond ((null charsets)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
914 "us-ascii")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
915 ((cdr charsets)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
916 (or (car (cdr
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
917 (assq (coding-system-name
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
918 buffer-file-coding-system)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
919 vm-mime-mule-coding-to-charset-alist)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
920 "iso-2022-jp"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
921 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
922 (or (car (cdr
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
923 (assoc
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
924 (car charsets)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
925 vm-mime-mule-charset-to-charset-alist)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
926 "unknown"))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
927 (and (re-search-forward "[^\000-\177]" nil t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
928 (throw 'done (or vm-mime-8bit-composition-charset
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
929 "iso-8859-1")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
930 (throw 'done "us-ascii"))))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
931
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
932 (defun vm-determine-proper-content-transfer-encoding (beg end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
933 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
934 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
935 (narrow-to-region beg end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
936 (catch 'done
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
937 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
938 (and (re-search-forward "[\000\015]" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
939 (throw 'done "binary"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
940
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
941 (let ((toolong nil) bol)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
942 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
943 (setq bol (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
944 (while (and (not (eobp)) (not toolong))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
945 (forward-line)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
946 (setq toolong (> (- (point) bol) 998)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
947 bol (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
948 (and toolong (throw 'done "binary")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
949
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
950 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
951 (and (re-search-forward "[\200-\377]" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
952 (throw 'done "8bit"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
953
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
954 "7bit"))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
955
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
956 (defun vm-mime-types-match (type type/subtype)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
957 (let ((case-fold-search t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
958 (cond ((string-match "/" type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
959 (if (and (string-match (regexp-quote type) type/subtype)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
960 (equal 0 (match-beginning 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
961 (equal (length type/subtype) (match-end 0)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
962 t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
963 nil ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
964 ((and (string-match (regexp-quote type) type/subtype)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
965 (equal 0 (match-beginning 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
966 (equal (save-match-data
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
967 (string-match "/" type/subtype (match-end 0)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
968 (match-end 0)))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
969
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
970 (defvar native-sound-only-on-console)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
971
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
972 (defun vm-mime-can-display-internal (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
973 (let ((type (car (vm-mm-layout-type layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
974 (cond ((vm-mime-types-match "image/jpeg" type)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
975 (and vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
976 (featurep 'jpeg)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
977 (eq (device-type) 'x)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
978 ((vm-mime-types-match "image/gif" type)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
979 (and vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
980 (featurep 'gif)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
981 (eq (device-type) 'x)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
982 ((vm-mime-types-match "image/png" type)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
983 (and vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
984 (featurep 'png)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
985 (eq (device-type) 'x)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
986 ((vm-mime-types-match "image/tiff" type)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
987 (and vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
988 (featurep 'tiff)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
989 (eq (device-type) 'x)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
990 ((vm-mime-types-match "audio/basic" type)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
991 (and vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
992 (or (featurep 'native-sound)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
993 (featurep 'nas-sound))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
994 (or (device-sound-enabled-p)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
995 (and (featurep 'native-sound)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
996 (not native-sound-only-on-console)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
997 (eq (device-type) 'x)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
998 ((vm-mime-types-match "multipart" type) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
999 ((vm-mime-types-match "message/external-body" type) nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1000 ((vm-mime-types-match "message" type) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1001 ((or (vm-mime-types-match "text/plain" type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1002 (vm-mime-types-match "text/enriched" type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1003 (let ((charset (or (vm-mime-get-parameter layout "charset")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1004 "us-ascii")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1005 (vm-mime-charset-internally-displayable-p charset)))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1006 ((vm-mime-types-match "text/html" type)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1007 (condition-case ()
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1008 (progn (require 'w3)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1009 (fboundp 'w3-region))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1010 (error nil)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1011 (t nil))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1012
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1013 (defun vm-mime-can-convert (type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1014 (let ((alist vm-mime-type-converter-alist)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1015 ;; fake layout. make it the wrong length so an error will
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1016 ;; be signaled if vm-mime-can-display-internal ever asks
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1017 ;; for one of the other fields
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1018 (fake-layout (make-vector 1 (list nil)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1019 (done nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1020 (while (and alist (not done))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1021 (cond ((and (vm-mime-types-match (car (car alist)) type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1022 (or (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1023 (setcar (aref fake-layout 0) (nth 1 (car alist)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1024 (vm-mime-can-display-internal fake-layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1025 (vm-mime-find-external-viewer (nth 1 (car alist)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1026 (setq done t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1027 (t (setq alist (cdr alist)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1028 (and alist (car alist))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1029
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1030 (defun vm-mime-convert-undisplayable-layout (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1031 (let ((ooo (vm-mime-can-convert (car (vm-mm-layout-type layout)))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1032 (message "Converting %s to %s..."
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1033 (car (vm-mm-layout-type layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1034 (nth 1 ooo))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1035 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1036 (set-buffer (generate-new-buffer " *mime object*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1037 (setq vm-message-garbage-alist
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1038 (cons (cons (current-buffer) 'kill-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1039 vm-message-garbage-alist))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1040 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1041 (vm-mime-transfer-decode-region layout (point-min) (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1042 (call-process-region (point-min) (point-max) shell-file-name
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1043 t t nil shell-command-switch (nth 2 ooo))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1044 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1045 (insert "Content-Type: " (nth 1 ooo) "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1046 (insert "Content-Transfer-Encoding: binary\n\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1047 (set-buffer-modified-p nil)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1048 (message "Converting %s to %s... done"
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1049 (car (vm-mm-layout-type layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1050 (nth 1 ooo))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1051 (vector (list (nth 1 ooo))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1052 (list (nth 1 ooo))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1053 "binary"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1054 (vm-mm-layout-id layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1055 (vm-mm-layout-description layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1056 (vm-mm-layout-disposition layout)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1057 (vm-mm-layout-qdisposition layout)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1058 (vm-marker (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1059 (vm-marker (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1060 (vm-marker (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1061 nil
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1062 nil
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1063 nil))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1064
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1065 (defun vm-mime-should-display-button (layout dont-honor-content-disposition)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1066 (if (and vm-honor-mime-content-disposition
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1067 (not dont-honor-content-disposition)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1068 (vm-mm-layout-disposition layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1069 (let ((case-fold-search t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1070 (string-match "^attachment$" (car (vm-mm-layout-disposition layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1071 (let ((i-list vm-auto-displayed-mime-content-types)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1072 (type (car (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1073 (matched nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1074 (if (eq i-list t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1075 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1076 (while (and i-list (not matched))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1077 (if (vm-mime-types-match (car i-list) type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1078 (setq matched t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1079 (setq i-list (cdr i-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1080 (not matched) ))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1081
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1082 (defun vm-mime-should-display-internal (layout dont-honor-content-disposition)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1083 (if (and vm-honor-mime-content-disposition
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1084 (not dont-honor-content-disposition)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1085 (vm-mm-layout-disposition layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1086 (let ((case-fold-search t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1087 (string-match "^inline$" (car (vm-mm-layout-disposition layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1088 (let ((i-list vm-mime-internal-content-types)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1089 (type (car (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1090 (matched nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1091 (if (eq i-list t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1092 t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1093 (while (and i-list (not matched))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1094 (if (vm-mime-types-match (car i-list) type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1095 (setq matched t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1096 (setq i-list (cdr i-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1097 matched ))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1098
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1099 (defun vm-mime-find-external-viewer (type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1100 (let ((e-alist vm-mime-external-content-types-alist)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1101 (matched nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1102 (while (and e-alist (not matched))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1103 (if (and (vm-mime-types-match (car (car e-alist)) type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1104 (cdr (car e-alist)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1105 (setq matched (cdr (car e-alist)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1106 (setq e-alist (cdr e-alist))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1107 matched ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1108 (fset 'vm-mime-should-display-external 'vm-mime-find-external-viewer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1109
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1110 (defun vm-mime-delete-button-maybe (extent)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1111 (let ((buffer-read-only))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1112 ;; if displayed MIME object should replace the button
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1113 ;; remove the button now.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1114 (cond ((vm-extent-property extent 'vm-mime-disposable)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1115 (delete-region (vm-extent-start-position extent)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1116 (vm-extent-end-position extent))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1117 (vm-detach-extent extent)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1118
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1119 (defun vm-decode-mime-message ()
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1120 "Decode the MIME objects in the current message.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1121
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1122 The first time this command is run on a message, decoding is done.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1123 The second time, buttons for all the objects are displayed instead.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1124 The third time, the raw, undecoded data is displayed.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1125
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1126 If decoding, the decoded objects might be displayed immediately, or
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1127 buttons might be displayed that you need to activate to view the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1128 object. See the documentation for the variables
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1129
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1130 vm-auto-displayed-mime-content-types
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1131 vm-mime-internal-content-types
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1132 vm-mime-external-content-types-alist
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1133
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1134 to see how to control whether you see buttons or objects.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1135
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1136 If the variable vm-mime-display-function is set, then its value
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1137 is called as a function with no arguments, and none of the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1138 actions mentioned in the preceding paragraphs are done. At the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1139 time of the call, the current buffer will be the presentation
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1140 buffer for the folder and a copy of the current message will be
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1141 in the buffer. The function is expected to make the message
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1142 `MIME presentable' to the user in whatever manner it sees fit."
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1143 (interactive)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1144 (vm-follow-summary-cursor)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1145 (vm-select-folder-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1146 (vm-check-for-killed-summary)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1147 (vm-check-for-killed-presentation)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1148 (vm-error-if-folder-empty)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1149 (if (and (not vm-display-using-mime)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1150 (null vm-mime-display-function))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1151 (error "MIME display disabled, set vm-display-using-mime non-nil to enable."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1152 (if vm-mime-display-function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1153 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1154 (vm-make-presentation-copy (car vm-message-pointer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1155 (set-buffer vm-presentation-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1156 (funcall vm-mime-display-function))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1157 (if vm-mime-decoded
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1158 (if (eq vm-mime-decoded 'decoded)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1159 (let ((vm-preview-read-messages nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1160 (vm-auto-decode-mime-messages t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1161 (vm-honor-mime-content-disposition nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1162 (vm-auto-displayed-mime-content-types '("multipart")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1163 (setq vm-mime-decoded nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1164 (intern (buffer-name) vm-buffers-needing-display-update)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1165 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1166 (vm-preview-current-message))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1167 (setq vm-mime-decoded 'buttons))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1168 (let ((vm-preview-read-messages nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1169 (vm-auto-decode-mime-messages nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1170 (intern (buffer-name) vm-buffers-needing-display-update)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1171 (vm-preview-current-message)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1172 (let ((layout (vm-mm-layout (car vm-message-pointer)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1173 (m (car vm-message-pointer)))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1174 (message "Decoding MIME message...")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1175 (cond ((stringp layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1176 (error "Invalid MIME message: %s" layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1177 (if (vm-mime-plain-message-p m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1178 (error "Message needs no decoding."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1179 (or vm-presentation-buffer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1180 ;; maybe user killed it
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1181 (error "No presentation buffer."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1182 (set-buffer vm-presentation-buffer)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1183 (if (and (interactive-p) (eq vm-system-state 'previewing))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1184 (let ((vm-display-using-mime nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1185 (vm-show-current-message)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1186 (setq m (car vm-message-pointer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1187 (vm-save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1188 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1189 (goto-char (vm-text-of m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1190 (let ((buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1191 (modified (buffer-modified-p)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1192 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1193 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1194 (and (not (eq (vm-mm-encoded-header m) 'none))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1195 (vm-decode-mime-message-headers m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1196 (if (vectorp layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1197 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1198 (vm-decode-mime-layout layout)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1199 (delete-region (point) (point-max))))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1200 (vm-energize-urls)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1201 (vm-highlight-headers-maybe)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1202 (vm-energize-headers-and-xfaces))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1203 (set-buffer-modified-p modified))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1204 (save-excursion (set-buffer vm-mail-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1205 (setq vm-mime-decoded 'decoded))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1206 (intern (buffer-name vm-mail-buffer) vm-buffers-needing-display-update)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1207 (vm-update-summary-and-mode-line)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1208 (message "Decoding MIME message... done"))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1209 (vm-display nil nil '(vm-decode-mime-message)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1210 '(vm-decode-mime-message reading-message)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1211
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1212 (defun vm-decode-mime-layout (layout &optional dont-honor-c-d)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1213 (let ((modified (buffer-modified-p)) type type-no-subtype (extent nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1214 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1215 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1216 (if (not (vectorp layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1217 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1218 (setq extent layout
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1219 layout (vm-extent-property extent 'vm-mime-layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1220 (goto-char (vm-extent-start-position extent))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1221 (setq type (downcase (car (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1222 type-no-subtype (car (vm-parse type "\\([^/]+\\)")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1223 (cond ((and (vm-mime-should-display-button layout dont-honor-c-d)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1224 (or (condition-case nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1225 (funcall (intern
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1226 (concat "vm-mime-display-button-"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1227 type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1228 layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1229 (void-function nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1230 (condition-case nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1231 (funcall (intern
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1232 (concat "vm-mime-display-button-"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1233 type-no-subtype))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1234 layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1235 (void-function nil)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1236 ((and (vm-mime-should-display-internal layout dont-honor-c-d)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1237 (condition-case nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1238 (funcall (intern
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1239 (concat "vm-mime-display-internal-"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1240 type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1241 layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1242 (void-function nil))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1243 ((vm-mime-types-match "multipart" type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1244 (or (condition-case nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1245 (funcall (intern
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1246 (concat "vm-mime-display-internal-"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1247 type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1248 layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1249 (void-function nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1250 (vm-mime-display-internal-multipart/mixed layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1251 ((and (vm-mime-should-display-external type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1252 (vm-mime-display-external-generic layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1253 (and extent (vm-set-extent-property
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1254 extent 'vm-mime-disposable nil)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1255 ((vm-mime-can-convert type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1256 (vm-decode-mime-layout
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1257 (vm-mime-convert-undisplayable-layout layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1258 ((and (or (vm-mime-types-match "message" type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1259 (vm-mime-types-match "text" type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1260 ;; display unmatched message and text types as
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1261 ;; text/plain.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1262 (vm-mime-display-internal-text/plain layout)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1263 (t (and extent (vm-mime-rewrite-failed-button
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1264 extent
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1265 (or (vm-mm-layout-display-error layout)
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1266 "no external viewer defined for type")))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1267 (vm-mime-display-internal-application/octet-stream
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1268 (or extent layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1269 (and extent (vm-mime-delete-button-maybe extent)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1270 (set-buffer-modified-p modified)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1271 t )
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1272
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1273 (defun vm-mime-display-button-text (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1274 (vm-mime-display-button-xxxx layout t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1275
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1276 (defun vm-mime-display-internal-text/html (layout)
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1277 (if (fboundp 'w3-region)
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1278 (let ((buffer-read-only nil)
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1279 (work-buffer nil))
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1280 (message "Inlining text/html, be patient...")
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1281 ;; w3-region is not as tame as we would like.
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1282 ;; make sure the yoke is firmly attached.
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1283 (unwind-protect
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1284 (progn
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1285 (save-excursion
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1286 (set-buffer (setq work-buffer
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1287 (generate-new-buffer " *workbuf*")))
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1288 (vm-mime-insert-mime-body layout)
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1289 (vm-mime-transfer-decode-region layout (point-min) (point-max))
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1290 (save-excursion
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1291 (save-window-excursion
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1292 (w3-region (point-min) (point-max)))))
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1293 (insert-buffer-substring work-buffer))
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1294 (and work-buffer (kill-buffer work-buffer)))
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1295 (message "Inlining text/html... done")
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1296 t )
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1297 (vm-set-mm-layout-display-error layout "Need W3 to inline HTML")
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1298 nil ))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1299
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1300 (defun vm-mime-display-internal-text/plain (layout &optional no-highlighting)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1301 (let ((start (point)) end old-size
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1302 (buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1303 (charset (or (vm-mime-get-parameter layout "charset") "us-ascii")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1304 (if (not (vm-mime-charset-internally-displayable-p charset))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1305 (progn
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1306 (vm-set-mm-layout-display-error
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1307 layout (concat "Undisplayable charset: " charset))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1308 nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1309 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1310 (setq end (point-marker))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1311 (vm-mime-transfer-decode-region layout start end)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1312 (setq old-size (buffer-size))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1313 (vm-mime-charset-decode-region charset start end)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1314 (set-marker end (+ end (- (buffer-size) old-size)))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1315 (or no-highlighting (vm-energize-urls-in-message-region start end))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1316 (goto-char end)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1317 t )))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1318
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1319 (defun vm-mime-display-internal-text/enriched (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1320 (require 'enriched)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1321 (let ((start (point)) end
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1322 (buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1323 (enriched-verbose t))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1324 (message "Decoding text/enriched, be patient...")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1325 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1326 (setq end (point-marker))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1327 (vm-mime-transfer-decode-region layout start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1328 ;; enriched-decode expects a couple of headers at the top of
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1329 ;; the region and will remove anything that looks like a
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1330 ;; header. Put a header section here for it to eat so it
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1331 ;; won't eat message text instead.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1332 (goto-char start)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1333 (insert "Comment: You should not see this header\n\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1334 (enriched-decode start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1335 (vm-energize-urls-in-message-region start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1336 (goto-char end)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1337 (message "Decoding text/enriched... done")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1338 t ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1339
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1340 (defun vm-mime-display-external-generic (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1341 (let ((program-list (vm-mime-find-external-viewer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1342 (car (vm-mm-layout-type layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1343 (buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1344 (start (point))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1345 process tempfile cache end)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1346 (setq cache (cdr (assq 'vm-mime-display-external-generic
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1347 (vm-mm-layout-cache layout)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1348 process (nth 0 cache)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1349 tempfile (nth 1 cache))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1350 (if (and (processp process) (eq (process-status process) 'run))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1351 t
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1352 (cond ((or (null tempfile) (null (file-exists-p tempfile)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1353 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1354 (setq end (point-marker))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1355 (vm-mime-transfer-decode-region layout start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1356 (setq tempfile (vm-make-tempfile-name))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1357 (let ((buffer-file-type buffer-file-type)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1358 buffer-file-coding-system)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1359 ;; Tell DOS/Windows NT whether the file is binary
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1360 (setq buffer-file-type (not (vm-mime-text-type-p layout)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1361 ;; Tell XEmacs/MULE not to mess with the bits unless
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1362 ;; this is a text type.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1363 (if vm-xemacs-mule-p
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1364 (if (vm-mime-text-type-p layout)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1365 (set-buffer-file-coding-system 'no-conversion nil)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1366 (set-buffer-file-coding-system 'binary t)))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1367 ;; Write an empty tempfile out to disk and set its
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1368 ;; permissions to 0600, then write the actual buffer
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1369 ;; contents to tempfile.
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1370 (write-region start start tempfile nil 0)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1371 (set-file-modes tempfile 384)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1372 (write-region start end tempfile nil 0))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1373 (delete-region start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1374 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1375 (vm-select-folder-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1376 (setq vm-folder-garbage-alist
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1377 (cons (cons tempfile 'delete-file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1378 vm-folder-garbage-alist)))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1379 (message "Launching %s..." (mapconcat 'identity program-list " "))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1380 (setq process
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1381 (apply 'start-process
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1382 (format "view %25s" (vm-mime-layout-description layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1383 nil (append program-list (list tempfile))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1384 (process-kill-without-query process t)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1385 (message "Launching %s... done" (mapconcat 'identity
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1386 program-list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1387 " "))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1388 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1389 (vm-select-folder-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1390 (setq vm-message-garbage-alist
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1391 (cons (cons process 'delete-process)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1392 vm-message-garbage-alist)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1393 (vm-set-mm-layout-cache
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1394 layout
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1395 (nconc (vm-mm-layout-cache layout)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1396 (list (cons 'vm-mime-display-external-generic
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1397 (list process tempfile)))))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1398 t )
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1399
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1400 (defun vm-mime-display-internal-application/octet-stream (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1401 (if (vectorp layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1402 (let ((buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1403 (description (vm-mm-layout-description layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1404 (vm-mime-insert-button
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1405 (format "%-35.35s [%s to save to a file]"
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1406 (vm-mime-layout-description layout)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1407 (if (vm-mouse-support-possible-here-p)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1408 "Click mouse-2"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1409 "Press RETURN"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1410 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1411 (lambda (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1412 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1413 (vm-mime-display-internal-application/octet-stream layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1414 layout nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1415 (goto-char (vm-extent-start-position layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1416 (setq layout (vm-extent-property layout 'vm-mime-layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1417 ;; support old "name" paramater for application/octet-stream
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1418 ;; but don't override the "filename" parameter extracted from
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1419 ;; Content-Disposition, if any.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1420 (let ((default-filename
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1421 (if (vm-mime-get-disposition-parameter layout "filename")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1422 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1423 (vm-mime-get-parameter layout "name"))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1424 (vm-mime-send-body-to-file layout default-filename)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1425 t )
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1426 (fset 'vm-mime-display-button-application/octet-stream
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1427 'vm-mime-display-internal-application/octet-stream)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1428
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1429 (defun vm-mime-display-button-application (layout)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1430 (vm-mime-display-button-xxxx layout nil))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1431
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1432 (defun vm-mime-display-button-image (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1433 (vm-mime-display-button-xxxx layout t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1434
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1435 (defun vm-mime-display-button-audio (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1436 (vm-mime-display-button-xxxx layout nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1437
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1438 (defun vm-mime-display-button-video (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1439 (vm-mime-display-button-xxxx layout t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1440
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1441 (defun vm-mime-display-button-message (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1442 (vm-mime-display-button-xxxx layout t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1443
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1444 (defun vm-mime-display-button-multipart (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1445 (vm-mime-display-button-xxxx layout t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1446
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1447 (defun vm-mime-display-internal-multipart/mixed (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1448 (let ((part-list (vm-mm-layout-parts layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1449 (while part-list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1450 (vm-decode-mime-layout (car part-list))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1451 (setq part-list (cdr part-list)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1452 t ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1453
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1454 (defun vm-mime-display-internal-multipart/alternative (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1455 (let (best-layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1456 (cond ((eq vm-mime-alternative-select-method 'best)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1457 (let ((done nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1458 (best nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1459 part-list type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1460 (setq part-list (vm-mm-layout-parts layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1461 part-list (nreverse (copy-sequence part-list)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1462 (while (and part-list (not done))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1463 (setq type (car (vm-mm-layout-type (car part-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1464 (if (or (vm-mime-can-display-internal (car part-list))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1465 (vm-mime-find-external-viewer type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1466 (setq best (car part-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1467 done t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1468 (setq part-list (cdr part-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1469 (setq best-layout (or best (car (vm-mm-layout-parts layout))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1470 ((eq vm-mime-alternative-select-method 'best-internal)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1471 (let ((done nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1472 (best nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1473 (second-best nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1474 part-list type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1475 (setq part-list (vm-mm-layout-parts layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1476 part-list (nreverse (copy-sequence part-list)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1477 (while (and part-list (not done))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1478 (setq type (car (vm-mm-layout-type (car part-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1479 (cond ((vm-mime-can-display-internal (car part-list))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1480 (setq best (car part-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1481 done t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1482 ((and (null second-best)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1483 (vm-mime-find-external-viewer type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1484 (setq second-best (car part-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1485 (setq part-list (cdr part-list)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1486 (setq best-layout (or best second-best
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1487 (car (vm-mm-layout-parts layout)))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1488 (vm-decode-mime-layout best-layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1489
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1490 (defun vm-mime-display-button-multipart/parallel (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1491 (vm-mime-insert-button
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1492 (format "%-35.35s [%s to display in parallel]"
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1493 (vm-mime-layout-description layout)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1494 (if (vm-mouse-support-possible-here-p)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1495 "Click mouse-2"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1496 "Press RETURN"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1497 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1498 (lambda (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1499 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1500 (let ((vm-auto-displayed-mime-content-types t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1501 (vm-decode-mime-layout layout t)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1502 layout t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1503
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1504 (fset 'vm-mime-display-internal-multipart/parallel
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1505 'vm-mime-display-internal-multipart/mixed)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1506
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1507 (defun vm-mime-display-internal-multipart/digest (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1508 (if (vectorp layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1509 (let ((buffer-read-only nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1510 (vm-mime-insert-button
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1511 (format "%-35.35s [%s to display]"
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1512 (vm-mime-layout-description layout)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1513 (if (vm-mouse-support-possible-here-p)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1514 "Click mouse-2"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1515 "Press RETURN"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1516 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1517 (lambda (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1518 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1519 (vm-mime-display-internal-multipart/digest layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1520 layout nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1521 (goto-char (vm-extent-start-position layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1522 (setq layout (vm-extent-property layout 'vm-mime-layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1523 (set-buffer (generate-new-buffer (format "digest from %s/%s"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1524 (buffer-name vm-mail-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1525 (vm-number-of
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1526 (car vm-message-pointer)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1527 (setq vm-folder-type vm-default-folder-type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1528 (vm-mime-burst-layout layout nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1529 (vm-save-buffer-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1530 (vm-goto-new-folder-frame-maybe 'folder)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1531 (vm-mode))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1532 ;; temp buffer, don't offer to save it.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1533 (setq buffer-offer-save nil)
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1534 (vm-display (or vm-presentation-buffer (current-buffer)) t
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
1535 (list this-command) '(vm-mode startup)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1536 t )
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1537 (fset 'vm-mime-display-button-multipart/digest
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1538 'vm-mime-display-internal-multipart/digest)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1539
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1540 (defun vm-mime-display-button-message/rfc822 (layout)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1541 (let ((buffer-read-only nil))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1542 (vm-mime-insert-button
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1543 (format "%-35.35s [%s to display]"
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1544 (vm-mime-layout-description layout)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1545 (if (vm-mouse-support-possible-here-p)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1546 "Click mouse-2"
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1547 "Press RETURN"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1548 (function
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1549 (lambda (layout)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1550 (save-excursion
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1551 (vm-mime-display-internal-message/rfc822 layout))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1552 layout nil)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1553 (fset 'vm-mime-display-button-message/news
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1554 'vm-mime-display-button-message/rfc822)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1555
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1556 (defun vm-mime-display-internal-message/rfc822 (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1557 (if (vectorp layout)
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1558 (let ((start (point))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1559 (buffer-read-only nil))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1560 (vm-mime-insert-mime-headers (car (vm-mm-layout-parts layout)))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1561 (insert ?\n)
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1562 (save-excursion
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1563 (goto-char start)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1564 (vm-reorder-message-headers nil vm-visible-headers
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1565 vm-invisible-header-regexp))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1566 (save-restriction
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1567 (narrow-to-region start (point))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1568 (vm-decode-mime-encoded-words))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
1569 (vm-mime-display-internal-multipart/mixed layout))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1570 (goto-char (vm-extent-start-position layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1571 (setq layout (vm-extent-property layout 'vm-mime-layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1572 (set-buffer (generate-new-buffer
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1573 (format "message from %s/%s"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1574 (buffer-name vm-mail-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1575 (vm-number-of
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1576 (car vm-message-pointer)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1577 (setq vm-folder-type vm-default-folder-type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1578 (vm-mime-burst-layout layout nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1579 (set-buffer-modified-p nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1580 (vm-save-buffer-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1581 (vm-goto-new-folder-frame-maybe 'folder)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1582 (vm-mode))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1583 ;; temp buffer, don't offer to save it.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1584 (setq buffer-offer-save nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1585 (vm-display (or vm-presentation-buffer (current-buffer)) t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1586 (list this-command) '(vm-mode startup)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1587 t )
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1588 (fset 'vm-mime-display-internal-message/news
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1589 'vm-mime-display-internal-message/rfc822)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1590
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1591 (defun vm-mime-display-internal-message/partial (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1592 (if (vectorp layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1593 (let ((buffer-read-only nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1594 (number (vm-mime-get-parameter layout "number"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1595 (total (vm-mime-get-parameter layout "total")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1596 (vm-mime-insert-button
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1597 (format "%-35.35s [%s to attempt assembly]"
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1598 (concat (vm-mime-layout-description layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1599 (and number (concat ", part " number))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1600 (and number total (concat " of " total)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1601 (if (vm-mouse-support-possible-here-p)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1602 "Click mouse-2"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1603 "Press RETURN"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1604 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1605 (lambda (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1606 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1607 (vm-mime-display-internal-message/partial layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1608 layout nil))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1609 (message "Assembling message...")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1610 (let ((parts nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1611 (missing nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1612 (work-buffer nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1613 extent id o number total m i prev part-header-pos
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1614 p-id p-number p-total p-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1615 (setq extent layout
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1616 layout (vm-extent-property extent 'vm-mime-layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1617 id (vm-mime-get-parameter layout "id"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1618 (if (null id)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1619 (vm-mime-error
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1620 "message/partial message missing id parameter"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1621 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1622 (set-buffer (marker-buffer (vm-mm-layout-body-start layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1623 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1624 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1625 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1626 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1627 (while (and (search-forward id nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1628 (setq m (vm-message-at-point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1629 (setq o (vm-mm-layout m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1630 (if (not (vectorp o))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1631 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1632 (setq p-list (vm-mime-find-message/partials o id))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1633 (while p-list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1634 (setq p-id (vm-mime-get-parameter (car p-list) "id"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1635 (setq p-total (vm-mime-get-parameter (car p-list) "total"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1636 (if (null p-total)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1637 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1638 (setq p-total (string-to-int p-total))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1639 (if (< p-total 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1640 (vm-mime-error "message/partial specified part total < 0, %d" p-total))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1641 (if total
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1642 (if (not (= total p-total))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1643 (vm-mime-error "message/partial speificed total differs between parts, (%d != %d)" p-total total))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1644 (setq total p-total)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1645 (setq p-number (vm-mime-get-parameter (car p-list) "number"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1646 (if (null p-number)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1647 (vm-mime-error
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1648 "message/partial message missing number parameter"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1649 (setq p-number (string-to-int p-number))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1650 (if (< p-number 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1651 (vm-mime-error "message/partial part number < 0, %d"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1652 p-number))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1653 (if (and total (> p-number total))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1654 (vm-mime-error "message/partial part number greater than expected number of parts, (%d > %d)" p-number total))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1655 (setq parts (cons (list p-number (car p-list)) parts)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1656 p-list (cdr p-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1657 (goto-char (vm-mm-layout-body-end o))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1658 (if (null total)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1659 (vm-mime-error "total number of parts not specified in any message/partial part"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1660 (setq parts (sort parts
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1661 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1662 (lambda (p q)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1663 (< (car p)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1664 (car q))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1665 (setq i 0
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1666 p-list parts)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1667 (while p-list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1668 (cond ((< i (car (car p-list)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1669 (vm-increment i)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1670 (cond ((not (= i (car (car p-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1671 (setq missing (cons i missing)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1672 (t (setq prev p-list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1673 p-list (cdr p-list)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1674 (t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1675 ;; remove duplicate part
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1676 (setcdr prev (cdr p-list))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1677 (setq p-list (cdr p-list)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1678 (while (< i total)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1679 (vm-increment i)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1680 (setq missing (cons i missing)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1681 (if missing
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1682 (vm-mime-error "part%s %s%s missing"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1683 (if (cdr missing) "s" "")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1684 (mapconcat
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1685 (function identity)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1686 (nreverse (mapcar 'int-to-string
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1687 (or (cdr missing) missing)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1688 ", ")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1689 (if (cdr missing)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1690 (concat " and " (car missing))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1691 "")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1692 (set-buffer (generate-new-buffer "assembled message"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1693 (setq vm-folder-type vm-default-folder-type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1694 (vm-mime-insert-mime-headers (car (cdr (car parts))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1695 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1696 (vm-reorder-message-headers
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1697 nil nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1698 "\\(Encrypted\\|Content-\\|MIME-Version\\|Message-ID\\|Subject\\|X-VM-\\|Status\\)")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1699 (goto-char (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1700 (setq part-header-pos (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1701 (while parts
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1702 (vm-mime-insert-mime-body (car (cdr (car parts))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1703 (setq parts (cdr parts)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1704 (goto-char part-header-pos)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1705 (vm-reorder-message-headers
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1706 nil '("Subject" "MIME-Version" "Content-" "Message-ID" "Encrypted") nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1707 (vm-munge-message-separators vm-folder-type (point-min) (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1708 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1709 (insert (vm-leading-message-separator))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1710 (goto-char (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1711 (insert (vm-trailing-message-separator))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1712 (set-buffer-modified-p nil)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1713 (message "Assembling message... done")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1714 (vm-save-buffer-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1715 (vm-goto-new-folder-frame-maybe 'folder)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1716 (vm-mode))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1717 ;; temp buffer, don't offer to save it.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1718 (setq buffer-offer-save nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1719 (vm-display (or vm-presentation-buffer (current-buffer)) t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1720 (list this-command) '(vm-mode startup)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1721 t ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1722 (fset 'vm-mime-display-button-message/partial
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1723 'vm-mime-display-internal-message/partial)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1724
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1725 (defun vm-mime-display-internal-image-xxxx (layout feature name)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1726 (if (and vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1727 (featurep feature)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1728 (eq (device-type) 'x))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1729 (let ((start (point)) end tempfile g e
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1730 (buffer-read-only nil))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1731 (if (setq g (cdr (assq 'vm-mime-display-internal-image-xxxx
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1732 (vm-mm-layout-cache layout))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1733 nil
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1734 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1735 (setq end (point-marker))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1736 (vm-mime-transfer-decode-region layout start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1737 (setq tempfile (vm-make-tempfile-name))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1738 ;; Write an empty tempfile out to disk and set its
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1739 ;; permissions to 0600, then write the actual buffer
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1740 ;; contents to tempfile.
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1741 (write-region start start tempfile nil 0)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1742 (set-file-modes tempfile 384)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1743 ;; coding system for presentation buffer is binary so
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1744 ;; we don't need to set it here.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1745 (write-region start end tempfile nil 0)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1746 (message "Creating %s glyph..." name)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1747 (setq g (make-glyph
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1748 (list
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1749 (cons (list 'win)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1750 (vector feature ':file tempfile))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1751 (cons (list 'win)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1752 (vector 'string
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1753 ':data
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
1754 (format "[Unknown/Bad %s image encoding]\n"
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1755 name)))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1756 (cons nil
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1757 (vector 'string
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1758 ':data
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1759 (format "[%s image]\n" name))))))
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
1760 (message "")
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1761 (vm-set-mm-layout-cache
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1762 layout
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1763 (nconc (vm-mm-layout-cache layout)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1764 (list (cons 'vm-mime-display-internal-image-xxxx g))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1765 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1766 (vm-select-folder-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1767 (setq vm-folder-garbage-alist
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1768 (cons (cons tempfile 'delete-file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1769 vm-folder-garbage-alist)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1770 (delete-region start end))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1771 (if (not (bolp))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1772 (insert-char ?\n 2)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1773 (insert-char ?\n 1))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1774 (setq e (vm-make-extent (1- (point)) (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1775 (vm-set-extent-property e 'begin-glyph g)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1776 t )))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1777
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1778 (defun vm-mime-display-internal-image/gif (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1779 (vm-mime-display-internal-image-xxxx layout 'gif "GIF"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1780
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1781 (defun vm-mime-display-internal-image/jpeg (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1782 (vm-mime-display-internal-image-xxxx layout 'jpeg "JPEG"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1783
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1784 (defun vm-mime-display-internal-image/png (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1785 (vm-mime-display-internal-image-xxxx layout 'png "PNG"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1786
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1787 (defun vm-mime-display-internal-image/tiff (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1788 (vm-mime-display-internal-image-xxxx layout 'tiff "TIFF"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1789
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1790 (defun vm-mime-display-internal-audio/basic (layout)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1791 (if (and vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1792 (or (featurep 'native-sound)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1793 (featurep 'nas-sound))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1794 (or (device-sound-enabled-p)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1795 (and (featurep 'native-sound)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1796 (not native-sound-only-on-console)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1797 (eq (device-type) 'x))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1798 (let ((start (point)) end tempfile
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1799 (buffer-read-only nil))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1800 (if (setq tempfile (cdr (assq 'vm-mime-display-internal-audio/basic
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1801 (vm-mm-layout-cache layout))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1802 nil
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1803 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1804 (setq end (point-marker))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1805 (vm-mime-transfer-decode-region layout start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1806 (setq tempfile (vm-make-tempfile-name))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1807 ;; Write an empty tempfile out to disk and set its
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1808 ;; permissions to 0600, then write the actual buffer
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1809 ;; contents to tempfile.
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1810 (write-region start start tempfile nil 0)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1811 (set-file-modes tempfile 384)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1812 ;; coding system for presentation buffer is binary, so
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
1813 ;; we don't need to set it here.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1814 (write-region start end tempfile nil 0)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1815 (vm-set-mm-layout-cache
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1816 layout
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1817 (nconc (vm-mm-layout-cache layout)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1818 (list (cons 'vm-mime-display-internal-audio/basic
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1819 tempfile))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1820 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1821 (vm-select-folder-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1822 (setq vm-folder-garbage-alist
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1823 (cons (cons tempfile 'delete-file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1824 vm-folder-garbage-alist)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1825 (delete-region start end))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1826 (start-itimer "audioplayer"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1827 (list 'lambda nil (list 'play-sound-file tempfile))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1828 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1829 t )
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1830 nil ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1831
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1832 (defun vm-mime-display-button-xxxx (layout disposable)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1833 (let ((description (vm-mime-layout-description layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1834 (vm-mime-insert-button
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1835 (format "%-35.35s [%s to attempt display]"
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1836 description
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1837 (if (vm-mouse-support-possible-here-p)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1838 "Click mouse-2"
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
1839 "Press RETURN"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1840 (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1841 (lambda (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1842 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1843 (let ((vm-auto-displayed-mime-content-types t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1844 (vm-decode-mime-layout layout t)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1845 layout disposable)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1846 t ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1847
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1848 (defun vm-mime-run-display-function-at-point (&optional function dispose)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1849 (interactive)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1850 ;; save excursion to keep point from moving. its motion would
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1851 ;; drag window point along, to a place arbitrarily far from
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1852 ;; where it was when the user triggered the button.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1853 (save-excursion
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1854 (cond (vm-fsfemacs-19-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1855 (let (o-list o (found nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1856 (setq o-list (overlays-at (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1857 (while (and o-list (not found))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1858 (cond ((overlay-get (car o-list) 'vm-mime-layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1859 (setq found t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1860 (funcall (or function (overlay-get (car o-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1861 'vm-mime-function))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1862 (car o-list))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1863 (setq o-list (cdr o-list)))))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1864 (vm-xemacs-p
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1865 (let ((e (extent-at (point) nil 'vm-mime-layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1866 (funcall (or function (extent-property e 'vm-mime-function))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1867 e))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1868
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1869 ;; for the karking compiler
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1870 (defvar vm-menu-mime-dispose-menu)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1871
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1872 (defun vm-mime-set-extent-glyph-for-type (e type)
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1873 (if (and vm-xemacs-p
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1874 (featurep 'xpm)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1875 (eq (device-type) 'x)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1876 (> (device-bitplanes) 7))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1877 (let ((dir vm-image-directory)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1878 (colorful (> (device-bitplanes) 15))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1879 (tuples
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1880 '(("text" "document-simple.xpm" "document-colorful.xpm")
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
1881 ("image" "mona_stamp-simple.xpm" "mona_stamp-colorful.xpm")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1882 ("audio" "audio_stamp-simple.xpm" "audio_stamp-colorful.xpm")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1883 ("video" "film-simple.xpm" "film-colorful.xpm")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1884 ("message" "message-simple.xpm" "message-colorful.xpm")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1885 ("application" "gear-simple.xpm" "gear-colorful.xpm")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1886 ("multipart" "stuffed_box-simple.xpm"
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1887 "stuffed_box-colorful.xpm")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1888 glyph file sym p)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1889 (setq file (catch 'done
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1890 (while tuples
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1891 (if (vm-mime-types-match (car (car tuples)) type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1892 (throw 'done (car tuples))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1893 (setq tuples (cdr tuples))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1894 nil)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1895 file (and file (if colorful (nth 2 file) (nth 1 file)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1896 sym (and file (intern file vm-image-obarray))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1897 glyph (and sym (boundp sym) (symbol-value sym))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
1898 glyph (or glyph
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
1899 (and file
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
1900 (make-glyph
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
1901 (list
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
1902 (vector 'xpm ':file
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
1903 (expand-file-name file dir))
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 155
diff changeset
1904 [nothing])))))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
1905 (and sym (not (boundp sym)) (set sym glyph))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1906 (and glyph (set-extent-begin-glyph e glyph)))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1907
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1908 (defun vm-mime-insert-button (caption action layout disposable)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1909 (let ((start (point)) e
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1910 (keymap (make-sparse-keymap))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1911 (buffer-read-only nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1912 (if (fboundp 'set-keymap-parents)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1913 (if (current-local-map)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1914 (set-keymap-parents keymap (list (current-local-map))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1915 (setq keymap (nconc keymap (current-local-map))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1916 (define-key keymap "\r" 'vm-mime-run-display-function-at-point)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1917 (if (and (vm-mouse-xemacs-mouse-p) vm-popup-menu-on-mouse-3)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1918 (define-key keymap 'button3 'vm-menu-popup-mime-dispose-menu))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1919 (if (not (bolp))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1920 (insert "\n"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1921 (insert caption "\n")
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1922 ;; we must use the same interface that the vm-extent functions
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1923 ;; use. if they use overlays, then we call make-overlay.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1924 (if (eq (symbol-function 'vm-make-extent) 'make-overlay)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1925 ;; we MUST have the five arg make-overlay. overlays must
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1926 ;; advance when text is inserted at their start position or
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1927 ;; inline text and graphics will seep into the button
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1928 ;; overlay and then be removed when the button is removed.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1929 (setq e (make-overlay start (point) nil t nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1930 (setq e (make-extent start (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1931 (set-extent-property e 'start-open t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1932 (set-extent-property e 'end-open t))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1933 (vm-mime-set-extent-glyph-for-type e (car (vm-mm-layout-type layout)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1934 ;; for emacs
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1935 (vm-set-extent-property e 'mouse-face 'highlight)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1936 (vm-set-extent-property e 'local-map keymap)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1937 ;; for xemacs
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1938 (vm-set-extent-property e 'highlight t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1939 (vm-set-extent-property e 'keymap keymap)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1940 (vm-set-extent-property e 'balloon-help 'vm-mouse-3-help)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1941 ;; for all
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1942 (vm-set-extent-property e 'vm-mime-disposable disposable)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1943 (vm-set-extent-property e 'face vm-mime-button-face)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1944 (vm-set-extent-property e 'vm-mime-layout layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1945 (vm-set-extent-property e 'vm-mime-function action)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1946
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1947 (defun vm-mime-rewrite-failed-button (button error-string)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1948 (let* ((buffer-read-only nil)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1949 (start (point)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1950 (goto-char (vm-extent-start-position button))
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
1951 (insert (format "DISPLAY FAILED -- %s\n" error-string))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1952 (vm-set-extent-endpoints button start (vm-extent-end-position button))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1953 (delete-region (point) (vm-extent-end-position button))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
1954
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1955 (defun vm-mime-send-body-to-file (layout &optional default-filename)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1956 (if (not (vectorp layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1957 (setq layout (vm-extent-property layout 'vm-mime-layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1958 (or default-filename
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1959 (setq default-filename
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1960 (vm-mime-get-disposition-parameter layout "filename")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1961 (and default-filename
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1962 (setq default-filename (file-name-nondirectory default-filename)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1963 (let ((work-buffer nil)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1964 ;; evade the XEmacs dialog box, yeccch.
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1965 (use-dialog-box nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1966 (dir vm-mime-attachment-save-directory)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1967 (done nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1968 file)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1969 (while (not done)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1970 (setq file
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1971 (read-file-name
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1972 (if default-filename
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1973 (format "Write MIME body to file (default %s): "
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1974 default-filename)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1975 "Write MIME body to file: ")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1976 dir default-filename)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1977 file (expand-file-name file dir))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1978 (if (not (file-directory-p file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1979 (setq done t)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1980 (if default-filename
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1981 (message "%s is a directory" file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1982 (error "%s is a directory" file))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1983 (sit-for 2)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1984 (setq dir file
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1985 default-filename (if (string-match "/$" file)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1986 (concat file default-filename)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1987 (concat file "/" default-filename)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1988 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1989 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1990 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1991 (setq work-buffer (generate-new-buffer " *vm-work*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1992 (buffer-disable-undo work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1993 (set-buffer work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1994 ;; Tell DOS/Windows NT whether the file is binary
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
1995 (setq buffer-file-type (not (vm-mime-text-type-p layout)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1996 ;; Tell XEmacs/MULE not to mess with the bits unless
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1997 ;; this is a text type.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
1998 (if vm-xemacs-mule-p
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
1999 (if (vm-mime-text-type-p layout)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2000 (set-buffer-file-coding-system 'no-conversion nil)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2001 (set-buffer-file-coding-system 'binary t)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2002 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2003 (vm-mime-transfer-decode-region layout (point-min) (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2004 (or (not (file-exists-p file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2005 (y-or-n-p "File exists, overwrite? ")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2006 (error "Aborted"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2007 (write-region (point-min) (point-max) file nil nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2008 (and work-buffer (kill-buffer work-buffer))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2009
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2010 (defun vm-mime-pipe-body-to-command (command layout &optional discard-output)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2011 (if (not (vectorp layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2012 (setq layout (vm-extent-property layout 'vm-mime-layout)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2013 (let ((output-buffer (if discard-output
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2014 0
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2015 (get-buffer-create "*Shell Command Output*")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2016 (work-buffer nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2017 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2018 (if (bufferp output-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2019 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2020 (set-buffer output-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2021 (erase-buffer)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2022 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2023 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2024 (setq work-buffer (generate-new-buffer " *vm-work*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2025 (buffer-disable-undo work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2026 (set-buffer work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2027 (vm-mime-insert-mime-body layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2028 (vm-mime-transfer-decode-region layout (point-min) (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2029 (let ((pop-up-windows (and pop-up-windows
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2030 (eq vm-mutable-windows t)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2031 ;; Tell DOS/Windows NT whether the input is binary
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2032 (binary-process-input (not (vm-mime-text-type-p layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2033 (call-process-region (point-min) (point-max)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2034 (or shell-file-name "sh")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2035 nil output-buffer nil
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2036 shell-command-switch command)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2037 (and work-buffer (kill-buffer work-buffer)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2038 (if (bufferp output-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2039 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2040 (set-buffer output-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2041 (if (not (zerop (buffer-size)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2042 (vm-display output-buffer t (list this-command)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2043 '(vm-pipe-message-to-command))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2044 (vm-display nil nil (list this-command)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2045 '(vm-pipe-message-to-command)))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2046 t )
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2047
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2048 (defun vm-mime-pipe-body-to-queried-command (layout &optional discard-output)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2049 (let ((command (read-string "Pipe to command: ")))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2050 (vm-mime-pipe-body-to-command command layout discard-output)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2051
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2052 (defun vm-mime-pipe-body-to-queried-command-discard-output (layout)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2053 (vm-mime-pipe-body-to-queried-command layout t))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2054
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2055 (defun vm-mime-send-body-to-printer (layout)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2056 (vm-mime-pipe-body-to-command (mapconcat (function identity)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2057 (nconc (list vm-print-command)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2058 vm-print-command-switches)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2059 " ")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2060 layout))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2061
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2062 (defun vm-mime-display-body-as-text (button)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2063 (let ((vm-auto-displayed-mime-content-types '("text/plain"))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2064 (layout (copy-sequence (vm-extent-property button 'vm-mime-layout))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2065 (vm-set-extent-property button 'vm-mime-disposable t)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2066 (vm-set-extent-property button 'vm-mime-layout layout)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2067 ;; not universally correct, but close enough.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2068 (vm-set-mm-layout-type layout '("text/plain" "charset=us-ascii"))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2069 (goto-char (vm-extent-start-position button))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2070 (vm-decode-mime-layout button t)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2071
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2072 (defun vm-mime-display-body-using-external-viewer (button)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2073 (let ((layout (vm-extent-property button 'vm-mime-layout)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2074 (goto-char (vm-extent-start-position button))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2075 (if (not (vm-mime-find-external-viewer (car (vm-mm-layout-type layout))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2076 (error "No viewer defined for type %s"
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2077 (car (vm-mm-layout-type layout)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2078 (vm-mime-display-external-generic layout))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2079
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2080 (defun vm-mime-scrub-description (string)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2081 (let ((work-buffer nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2082 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2083 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2084 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2085 (setq work-buffer (generate-new-buffer " *vm-work*"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2086 (buffer-disable-undo work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2087 (set-buffer work-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2088 (insert string)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2089 (while (re-search-forward "[ \t\n]+" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2090 (replace-match " "))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2091 (buffer-string))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2092 (and work-buffer (kill-buffer work-buffer))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2093
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2094 (defun vm-mime-layout-description (layout)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2095 (let ((type (car (vm-mm-layout-type layout)))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2096 description name)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2097 (setq description
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2098 (if (vm-mm-layout-description layout)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2099 (vm-mime-scrub-description (vm-mm-layout-description layout))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2100 (concat
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2101 (if description description "")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2102 (if description ", " "")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2103 (cond ((vm-mime-types-match "multipart/digest" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2104 (let ((n (length (vm-mm-layout-parts layout))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2105 (format "digest (%d message%s)" n (if (= n 1) "" "s"))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2106 ((vm-mime-types-match "multipart/alternative" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2107 "multipart alternative")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2108 ((vm-mime-types-match "multipart" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2109 (let ((n (length (vm-mm-layout-parts layout))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2110 (format "multipart message (%d part%s)" n (if (= n 1) "" "s"))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2111 ((vm-mime-types-match "text/plain" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2112 (format "plain text%s"
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2113 (let ((charset (vm-mime-get-parameter layout "charset")))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2114 (if charset
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2115 (concat ", " charset)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2116 ""))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2117 ((vm-mime-types-match "text/enriched" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2118 "enriched text")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2119 ((vm-mime-types-match "text/html" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2120 "HTML")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2121 ((vm-mime-types-match "image/gif" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2122 "GIF image")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2123 ((vm-mime-types-match "image/jpeg" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2124 "JPEG image")
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2125 ((and (vm-mime-types-match "application/octet-stream" type)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2126 (setq name (vm-mime-get-parameter layout "name"))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2127 (save-match-data (not (string-match "^[ \t]*$" name))))
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2128 name)
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2129 (t type)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2130
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2131 (defun vm-mime-layout-contains-type (layout type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2132 (if (vm-mime-types-match type (car (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2133 layout
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2134 (let ((p (vm-mm-layout-parts layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2135 (result nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2136 (done nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2137 (while (and p (not done))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2138 (if (setq result (vm-mime-layout-contains-type (car p) type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2139 (setq done t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2140 (setq p (cdr p))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2141 result )))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2142
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2143 ;; breadth first traversal
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2144 (defun vm-mime-find-digests-in-layout (layout)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2145 (let ((layout-list (list layout))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2146 layout-type
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2147 (result nil))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2148 (while layout-list
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2149 (setq layout-type (car (vm-mm-layout-type (car layout-list))))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2150 (cond ((string-match "^multipart/digest\\|message/\\(rfc822\\|news\\)"
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2151 layout-type)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2152 (setq result (nconc result (list (car layout-list)))))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2153 ((vm-mime-composite-type-p layout-type)
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2154 (setq layout-list (nconc layout-list
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2155 (copy-sequence
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2156 (vm-mm-layout-parts
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2157 (car layout-list)))))))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2158 (setq layout-list (cdr layout-list)))
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2159 result ))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2160
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2161 (defun vm-mime-plain-message-p (m)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2162 (save-match-data
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2163 (let ((o (vm-mm-layout m))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2164 (case-fold-search t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2165 (and (eq (vm-mm-encoded-header m) 'none)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2166 (or (not (vectorp o))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2167 (and (vm-mime-types-match "text/plain"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2168 (car (vm-mm-layout-type o)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2169 (let* ((charset (or (vm-mime-get-parameter o "charset")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2170 "us-ascii")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2171 (vm-string-member charset vm-mime-default-face-charsets))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2172 (string-match "^\\(7bit\\|8bit\\|binary\\)$"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2173 (vm-mm-layout-encoding o))))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2174
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2175 (defun vm-mime-text-type-p (layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2176 (or (vm-mime-types-match "text" (car (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2177 (vm-mime-types-match "message" (car (vm-mm-layout-type layout)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2178
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2179 (defun vm-mime-charset-internally-displayable-p (name)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2180 (cond ((and vm-xemacs-mule-p (eq (device-type) 'x))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2181 (vm-string-assoc name vm-mime-mule-charset-to-coding-alist))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2182 ((vm-multiple-fonts-possible-p)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2183 (or (vm-string-member name vm-mime-default-face-charsets)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2184 (vm-string-assoc name vm-mime-charset-font-alist)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2185 (t
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2186 (vm-string-member name vm-mime-default-face-charsets))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2187
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2188 (defun vm-mime-find-message/partials (layout id)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2189 (let ((list nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2190 (type (vm-mm-layout-type layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2191 (cond ((vm-mime-types-match "multipart" (car type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2192 (let ((parts (vm-mm-layout-parts layout)) o)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2193 (while parts
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2194 (setq o (vm-mime-find-message/partials (car parts) id))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2195 (if o
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2196 (setq list (nconc o list)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2197 (setq parts (cdr parts)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2198 ((vm-mime-types-match "message/partial" (car type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2199 (if (equal (vm-mime-get-parameter layout "id") id)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2200 (setq list (cons layout list)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2201 list ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2202
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2203 (defun vm-message-at-point ()
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2204 (let ((mp vm-message-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2205 (point (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2206 (done nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2207 (while (and mp (not done))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2208 (if (and (>= point (vm-start-of (car mp)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2209 (<= point (vm-end-of (car mp))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2210 (setq done t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2211 (setq mp (cdr mp))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2212 (car mp)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2213
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2214 (defun vm-mime-make-multipart-boundary ()
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2215 (let ((boundary (make-string 10 ?a))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2216 (i 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2217 (random t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2218 (while (< i (length boundary))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2219 (aset boundary i (aref vm-mime-base64-alphabet
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2220 (% (vm-abs (lsh (random) -8))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2221 (length vm-mime-base64-alphabet))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2222 (vm-increment i))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2223 boundary ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2224
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2225 (defun vm-mime-attach-file (file type &optional charset description)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2226 "Attach a file to a VM composition buffer to be sent along with the message.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2227 The file is not inserted into the buffer and MIME encoded until
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2228 you execute vm-mail-send or vm-mail-send-and-exit. A visible tag
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2229 indicating the existence of the attachment is placed in the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2230 composition buffer. You can move the attachment around or remove
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2231 it entirely with normal text editing commands. If you remove the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2232 attachment tag, the attachment will not be sent.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2233
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2234 First argument, FILE, is the name of the file to attach. Second
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2235 argument, TYPE, is the MIME Content-Type of the file. Optional
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2236 third argument CHARSET is the character set of the attached
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2237 document. This argument is only used for text types, and it is
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2238 ignored for other types. Optional fourth argument DESCRIPTION
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2239 should be a one line description of the file.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2240
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2241 When called interactively all arguments are read from the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2242 minibuffer.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2243
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2244 This command is for attaching files that do not have a MIME
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2245 header section at the top. For files with MIME headers, you
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2246 should use vm-mime-attach-mime-file to attach such a file. VM
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2247 will extract the content type information from the headers in
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2248 this case and not prompt you for it in the minibuffer."
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2249 (interactive
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2250 ;; protect value of last-command and this-command
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2251 (let ((last-command last-command)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2252 (this-command this-command)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2253 (charset nil)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2254 description file default-type type)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2255 (if (null vm-send-using-mime)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2256 (error "MIME attachments disabled, set vm-send-using-mime non-nil to enable."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2257 (setq file (vm-read-file-name "Attach file: " nil nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2258 default-type (or (vm-mime-default-type-from-filename file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2259 "application/octet-stream")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2260 type (completing-read
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2261 (format "Content type (default %s): "
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2262 default-type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2263 vm-mime-type-completion-alist)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2264 type (if (> (length type) 0) type default-type))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2265 (if (vm-mime-types-match "text" type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2266 (setq charset (completing-read "Character set (default US-ASCII): "
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2267 vm-mime-charset-completion-alist)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2268 charset (if (> (length charset) 0) charset)))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2269 (setq description (read-string "One line description: "))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2270 (if (string-match "^[ \t]*$" description)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2271 (setq description nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2272 (list file type charset description)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2273 (if (null vm-send-using-mime)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2274 (error "MIME attachments disabled, set vm-send-using-mime non-nil to enable."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2275 (if (file-directory-p file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2276 (error "%s is a directory, cannot attach" file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2277 (if (not (file-exists-p file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2278 (error "No such file: %s" file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2279 (if (not (file-readable-p file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2280 (error "You don't have permission to read %s" file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2281 (and charset (setq charset (list (concat "charset=" charset))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2282 (and description (setq description (vm-mime-scrub-description description)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2283 (vm-mime-attach-object file type charset description nil))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2284
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2285 (defun vm-mime-attach-mime-file (file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2286 "Attach a MIME encoded file to a VM composition buffer to be sent
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2287 along with the message.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2288
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2289 The file is not inserted into the buffer until you execute
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2290 vm-mail-send or vm-mail-send-and-exit. A visible tag indicating
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2291 the existence of the attachment is placed in the composition
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2292 buffer. You can move the attachment around or remove it entirely
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2293 with normal text editing commands. If you remove the attachment
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2294 tag, the attachment will not be sent.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2295
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2296 The sole argument, FILE, is the name of the file to attach.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2297 When called interactively the FILE argument is read from the
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2298 minibuffer.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2299
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2300 This command is for attaching files that have a MIME
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2301 header section at the top. For files without MIME headers, you
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2302 should use vm-mime-attach-file to attach such a file. VM
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2303 will interactively query you for the file type information."
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2304 (interactive
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2305 ;; protect value of last-command and this-command
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2306 (let ((last-command last-command)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2307 (this-command this-command)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2308 file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2309 (if (null vm-send-using-mime)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2310 (error "MIME attachments disabled, set vm-send-using-mime non-nil to enable."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2311 (setq file (vm-read-file-name "Attach file: " nil nil t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2312 (list file)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2313 (if (null vm-send-using-mime)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2314 (error "MIME attachments disabled, set vm-send-using-mime non-nil to enable."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2315 (if (file-directory-p file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2316 (error "%s is a directory, cannot attach" file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2317 (if (not (file-exists-p file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2318 (error "No such file: %s" file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2319 (if (not (file-readable-p file))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2320 (error "You don't have permission to read %s" file))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2321 (vm-mime-attach-object file nil nil nil t))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2322
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2323 (defun vm-mime-attach-object (object type params description mimed)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2324 (if (not (eq major-mode 'mail-mode))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2325 (error "Command must be used in a VM Mail mode buffer."))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2326 (let (start end e tag-string disposition)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2327 (if (< (point) (save-excursion (mail-text) (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2328 (mail-text))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2329 (setq start (point)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2330 tag-string (format "[ATTACHMENT %s, %s]" object
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2331 (or type "MIME file")))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2332 (insert tag-string "\n")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2333 (setq end (1- (point)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2334 (if (and (stringp object) (not mimed))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2335 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2336 (if (or (vm-mime-types-match "application" type)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2337 (vm-mime-types-match "model" type))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2338 (setq disposition (list "attachment"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2339 (setq disposition (list "inline")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2340 (setq disposition (nconc disposition
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2341 (list
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2342 (concat "filename=\""
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2343 (file-name-nondirectory object)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2344 "\"")))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2345 (setq disposition (list "unspecified")))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2346 (cond (vm-fsfemacs-19-p
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2347 (put-text-property start end 'front-sticky nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2348 (put-text-property start end 'rear-nonsticky t)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2349 ;; can't be intangible because menu clicking at a position needs
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2350 ;; to set point inside the tag so that a command can access the
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2351 ;; text properties there.
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2352 ;; (put-text-property start end 'intangible object)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2353 (put-text-property start end 'face vm-mime-button-face)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2354 (put-text-property start end 'vm-mime-type type)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2355 (put-text-property start end 'vm-mime-object object)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2356 (put-text-property start end 'vm-mime-parameters params)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2357 (put-text-property start end 'vm-mime-description description)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2358 (put-text-property start end 'vm-mime-disposition disposition)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2359 (put-text-property start end 'vm-mime-encoded mimed)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2360 (put-text-property start end 'vm-mime-object object))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2361 (vm-xemacs-p
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2362 (setq e (make-extent start end))
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2363 (vm-mime-set-extent-glyph-for-type e (or type "text/plain"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2364 (set-extent-property e 'start-open t)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2365 (set-extent-property e 'face vm-mime-button-face)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2366 (set-extent-property e 'duplicable t)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2367 (let ((keymap (make-sparse-keymap)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2368 (if vm-popup-menu-on-mouse-3
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2369 (define-key keymap 'button3
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2370 'vm-menu-popup-content-disposition-menu))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2371 (set-extent-property e 'keymap keymap)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2372 (set-extent-property e 'balloon-help 'vm-mouse-3-help))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2373 (set-extent-property e 'vm-mime-type type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2374 (set-extent-property e 'vm-mime-object object)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2375 (set-extent-property e 'vm-mime-parameters params)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2376 (set-extent-property e 'vm-mime-description description)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2377 (set-extent-property e 'vm-mime-disposition disposition)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2378 (set-extent-property e 'vm-mime-encoded mimed)))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2379
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2380 (defun vm-mime-attachment-disposition-at-point ()
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2381 (cond (vm-fsfemacs-19-p
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2382 (let ((disp (get-text-property (point) 'vm-mime-disposition)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2383 (intern (car disp))))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2384 (vm-xemacs-p
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2385 (let* ((e (extent-at (point) nil 'vm-mime-disposition))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2386 (disp (extent-property e 'vm-mime-disposition)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2387 (intern (car disp))))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2388
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2389 (defun vm-mime-set-attachment-disposition-at-point (sym)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2390 (cond (vm-fsfemacs-19-p
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2391 (let ((disp (get-text-property (point) 'vm-mime-disposition)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2392 (setcar disp (symbol-name sym))))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2393 (vm-xemacs-p
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2394 (let* ((e (extent-at (point) nil 'vm-mime-disposition))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2395 (disp (extent-property e 'vm-mime-disposition)))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2396 (setcar disp (symbol-name sym))))))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2397
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2398 (defun vm-disallow-overlay-endpoint-insertion (overlay after start end
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2399 &optional old-size)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2400 (cond ((null after) nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2401 ((= start (overlay-start overlay))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2402 (move-overlay overlay end (overlay-end overlay)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2403 ((= start (overlay-end overlay))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2404 (move-overlay overlay (overlay-start overlay) start))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2405
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2406 (defun vm-mime-fake-attachment-overlays (start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2407 (let ((o-list nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2408 (done nil)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2409 (pos start)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
2410 object props o)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2411 (save-excursion
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2412 (save-restriction
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2413 (narrow-to-region start end)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2414 (while (not done)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2415 (setq object (get-text-property pos 'vm-mime-object))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2416 (setq pos (next-single-property-change pos 'vm-mime-object))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2417 (or pos (setq pos (point-max) done t))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2418 (if object
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2419 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2420 (setq o (make-overlay start pos))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2421 (overlay-put o 'insert-in-front-hooks
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2422 '(vm-disallow-overlay-endpoint-insertion))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2423 (overlay-put o 'insert-behind-hooks
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2424 '(vm-disallow-overlay-endpoint-insertion))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2425 (setq props (text-properties-at start))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2426 (while props
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2427 (overlay-put o (car props) (car (cdr props)))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2428 (setq props (cdr (cdr props))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2429 (setq o-list (cons o o-list))))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2430 (setq start pos))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2431 o-list ))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2432
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2433 (defun vm-mime-default-type-from-filename (file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2434 (let ((alist vm-mime-attachment-auto-type-alist)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2435 (case-fold-search t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2436 (done nil))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2437 (while (and alist (not done))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2438 (if (string-match (car (car alist)) file)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2439 (setq done t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2440 (setq alist (cdr alist))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2441 (and alist (cdr (car alist)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2442
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2443 (defun vm-remove-mail-mode-header-separator ()
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2444 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2445 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2446 (if (re-search-forward (concat "^" mail-header-separator "$") nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2447 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2448 (delete-region (match-beginning 0) (match-end 0))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2449 t )
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2450 nil )))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2451
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2452 (defun vm-add-mail-mode-header-separator ()
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2453 (save-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2454 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2455 (if (re-search-forward "^$" nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2456 (replace-match mail-header-separator t t))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2457
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2458 (defun vm-mime-transfer-encode-region (encoding beg end crlf)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2459 (let ((case-fold-search t)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2460 (armor-from (and vm-mime-composition-armor-from-lines
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2461 (let ((case-fold-search nil))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2462 (save-excursion
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2463 (goto-char beg)
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
2464 (re-search-forward "^From " nil t)))))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
2465 (armor-dot (let ((case-fold-search nil))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
2466 (save-excursion
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
2467 (goto-char beg)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
2468 (re-search-forward "^\\.\\n" nil t)))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2469 (cond ((string-match "^binary$" encoding)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2470 (vm-mime-base64-encode-region beg end crlf)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2471 (setq encoding "base64"))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
2472 ((and (not armor-from) (not armor-dot)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 146
diff changeset
2473 (string-match "^7bit$" encoding)) t)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2474 ((string-match "^base64$" encoding) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2475 ((string-match "^quoted-printable$" encoding) t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2476 ((eq vm-mime-8bit-text-transfer-encoding 'quoted-printable)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2477 (vm-mime-qp-encode-region beg end nil armor-from)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2478 (setq encoding "quoted-printable"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2479 ((eq vm-mime-8bit-text-transfer-encoding 'base64)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2480 (vm-mime-base64-encode-region beg end crlf)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2481 (setq encoding "base64"))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2482 (armor-from (vm-mime-qp-encode-region beg end nil armor-from))
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2483 ((eq vm-mime-8bit-text-transfer-encoding '8bit) t))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2484 encoding ))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2485
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2486 (defun vm-mime-transfer-encode-layout (layout)
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2487 (let ((list (vm-mm-layout-parts layout))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2488 (type (car (vm-mm-layout-type layout)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2489 (encoding "7bit")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2490 (vm-mime-8bit-text-transfer-encoding
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2491 vm-mime-8bit-text-transfer-encoding))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2492 (cond ((vm-mime-composite-type-p type)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2493 ;; MIME messages of type "message" and
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2494 ;; "multipart" are required to have a non-opaque
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2495 ;; content transfer encoding. This means that
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2496 ;; if the user only wants to send out 7bit data,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2497 ;; then any subpart that contains 8bit data must
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2498 ;; have an opaque (qp or base64) 8->7bit
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2499 ;; conversion performed on it so that the
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2500 ;; enclosing entity can use a non-opaque
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2501 ;; encoding.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2502 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2503 ;; message/partial requires a "7bit" encoding so
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2504 ;; force 8->7 conversion in that case.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2505 (cond ((memq vm-mime-8bit-text-transfer-encoding
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2506 '(quoted-printable base64))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2507 t)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2508 ((vm-mime-types-match "message/partial" type)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2509 (setq vm-mime-8bit-text-transfer-encoding
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2510 'quoted-printable)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2511 (while list
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2512 (if (equal (vm-mime-transfer-encode-layout (car list)) "8bit")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2513 (setq encoding "8bit"))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2514 (setq list (cdr list))))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2515 (t
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2516 (if (and (vm-mime-types-match "message/partial" type)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2517 (not (memq vm-mime-8bit-text-transfer-encoding
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2518 '(quoted-printable base64))))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2519 (setq vm-mime-8bit-text-transfer-encoding
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2520 'quoted-printable))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2521 (setq encoding
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2522 (vm-mime-transfer-encode-region (vm-mm-layout-encoding layout)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2523 (vm-mm-layout-body-start layout)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2524 (vm-mm-layout-body-end layout)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2525 (vm-mime-text-type-p layout)))))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2526 (save-excursion
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2527 (save-restriction
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2528 (goto-char (vm-mm-layout-header-start layout))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2529 (narrow-to-region (point) (vm-mm-layout-body-start layout))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2530 (vm-reorder-message-headers nil nil "Content-Transfer-Encoding:")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2531 (if (not (equal encoding "7bit"))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2532 (insert "CONTENT-TRANSFER-ENCODING: " encoding "\n"))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2533 encoding ))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2534
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2535 (defun vm-mime-encode-composition ()
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2536 "MIME encode the current mail composition buffer.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2537 Attachment tags added to the buffer with vm-mime-attach-file are expanded
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2538 and the approriate content-type and boundary markup information is added."
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2539 (interactive)
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2540 (cond (vm-xemacs-mule-p
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2541 (vm-mime-xemacs-encode-composition))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2542 (vm-xemacs-p
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2543 (vm-mime-xemacs-encode-composition))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
2544 (vm-fsfemacs-19-p
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2545 (vm-mime-fsfemacs-encode-composition))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2546 (t
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2547 (error "don't know how to MIME encode composition for %s"
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2548 (emacs-version)))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2549
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2550 (defvar enriched-mode)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2551
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2552 (defun vm-mime-xemacs-encode-composition ()
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2553 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2554 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2555 (if (not (eq major-mode 'mail-mode))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2556 (error "Command must be used in a VM Mail mode buffer."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2557 (or (null (vm-mail-mode-get-header-contents "MIME-Version:"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2558 (error "Message is already MIME encoded."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2559 (let ((8bit nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2560 (just-one nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2561 (boundary-positions nil)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2562 (enriched (and (boundp 'enriched-mode) enriched-mode))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2563 already-mimed layout e e-list boundary
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2564 type encoding charset params description disposition object
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2565 opoint-min)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2566 (mail-text)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2567 (setq e-list (extent-list nil (point) (point-max))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2568 e-list (vm-delete (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2569 (lambda (e)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2570 (extent-property e 'vm-mime-object)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2571 e-list t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2572 e-list (sort e-list (function
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2573 (lambda (e1 e2)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2574 (< (extent-end-position e1)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2575 (extent-end-position e2))))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2576 ;; If there's just one attachment and no other readable
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2577 ;; text in the buffer then make the message type just be
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2578 ;; the attachment type rather than sending a multipart
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2579 ;; message with one attachment
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2580 (setq just-one (and (= (length e-list) 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2581 (looking-at "[ \t\n]*")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2582 (= (match-end 0)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2583 (extent-start-position (car e-list)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2584 (save-excursion
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2585 (goto-char (extent-end-position (car e-list)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2586 (looking-at "[ \t\n]*\\'"))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2587 (if (null e-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2588 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2589 (narrow-to-region (point) (point-max))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2590 ;; support enriched-mode for text/enriched composition
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2591 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2592 (let ((enriched-initial-annotation ""))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2593 (enriched-encode (point-min) (point-max))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2594 (setq charset (vm-determine-proper-charset (point-min)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2595 (point-max)))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2596 (if vm-xemacs-mule-p
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2597 (encode-coding-region (point-min) (point-max)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2598 buffer-file-coding-system))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2599 (setq encoding (vm-determine-proper-content-transfer-encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2600 (point-min)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2601 (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2602 encoding (vm-mime-transfer-encode-region encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2603 (point-min)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2604 (point-max)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2605 t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2606 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2607 (vm-remove-mail-mode-header-separator)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2608 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2609 (vm-reorder-message-headers
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2610 nil nil "\\(Content-Type:\\|Content-Transfer-Encoding\\|MIME-Version:\\)")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2611 (insert "MIME-Version: 1.0\n")
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2612 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2613 (insert "Content-Type: text/enriched; charset=" charset "\n")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2614 (insert "Content-Type: text/plain; charset=" charset "\n"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2615 (insert "Content-Transfer-Encoding: " encoding "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2616 (vm-add-mail-mode-header-separator))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2617 (while e-list
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2618 (setq e (car e-list))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2619 (if (or just-one (= (point) (extent-start-position e)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2620 nil
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2621 (narrow-to-region (point) (extent-start-position e))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2622 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2623 (let ((enriched-initial-annotation ""))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2624 (enriched-encode (point-min) (point-max))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2625 (setq charset (vm-determine-proper-charset (point-min)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2626 (point-max)))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2627 (if vm-xemacs-mule-p
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2628 (encode-coding-region (point-min) (point-max)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2629 buffer-file-coding-system))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2630 (setq encoding (vm-determine-proper-content-transfer-encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2631 (point-min)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2632 (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2633 encoding (vm-mime-transfer-encode-region encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2634 (point-min)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2635 (point-max)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2636 t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2637 (setq boundary-positions (cons (point-marker) boundary-positions))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2638 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2639 (insert "Content-Type: text/enriched; charset=" charset "\n")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2640 (insert "Content-Type: text/plain; charset=" charset "\n"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2641 (insert "Content-Transfer-Encoding: " encoding "\n\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2642 (widen))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2643 (goto-char (extent-start-position e))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2644 (narrow-to-region (point) (point))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2645 (setq object (extent-property e 'vm-mime-object))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2646 ;; insert the object
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2647 (cond ((bufferp object)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2648 (insert-buffer-substring object))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2649 ((stringp object)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2650 (let ((coding-system-for-read 'no-conversion)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2651 ;; don't let buffer-file-coding-system be changed
131
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
2652 ;; by insert-file-contents-literally. The
869e1851236b Import from CVS: tag xemacs-20-1p4
cvs
parents: 126
diff changeset
2653 ;; value we bind to it to here isn't important.
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2654 (buffer-file-coding-system 'no-conversion))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2655 (insert-file-contents-literally object))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2656 ;; gather information about the object from the extent.
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2657 (if (setq already-mimed (extent-property e 'vm-mime-encoded))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2658 (setq layout (vm-mime-parse-entity
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2659 nil (list "text/plain" "charset=us-ascii")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2660 "7bit")
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2661 type (or (extent-property e 'vm-mime-type)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2662 (car (vm-mm-layout-type layout)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2663 params (or (extent-property e 'vm-mime-parameters)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2664 (cdr (vm-mm-layout-qtype layout)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2665 description (extent-property e 'vm-mime-description)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2666 disposition
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2667 (if (not
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2668 (equal
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2669 (car (extent-property e 'vm-mime-disposition))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2670 "unspecified"))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2671 (extent-property e 'vm-mime-disposition)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2672 (vm-mm-layout-qdisposition layout)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2673 (setq type (extent-property e 'vm-mime-type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2674 params (extent-property e 'vm-mime-parameters)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2675 description (extent-property e 'vm-mime-description)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2676 disposition
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2677 (if (not (equal
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2678 (car (extent-property e 'vm-mime-disposition))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2679 "unspecified"))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2680 (extent-property e 'vm-mime-disposition)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2681 nil)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2682 (cond ((vm-mime-types-match "text" type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2683 (setq encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2684 (vm-determine-proper-content-transfer-encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2685 (if already-mimed
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2686 (vm-mm-layout-body-start layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2687 (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2688 (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2689 encoding (vm-mime-transfer-encode-region
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2690 encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2691 (if already-mimed
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2692 (vm-mm-layout-body-start layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2693 (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2694 (point-max)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2695 t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2696 (setq 8bit (or 8bit (equal encoding "8bit"))))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2697 ((vm-mime-composite-type-p type)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2698 (setq opoint-min (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2699 (if (not already-mimed)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2700 (setq layout (vm-mime-parse-entity
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2701 nil (list "text/plain" "charset=us-ascii")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2702 "7bit")))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
2703 (setq encoding (vm-mime-transfer-encode-layout layout))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2704 (setq 8bit (or 8bit (equal encoding "8bit")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2705 (goto-char (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2706 (widen)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2707 (narrow-to-region opoint-min (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2708 (t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2709 (vm-mime-base64-encode-region
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2710 (if already-mimed
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2711 (vm-mm-layout-body-start layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2712 (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2713 (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2714 (setq encoding "base64")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2715 (if just-one
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2716 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2717 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2718 (setq boundary-positions (cons (point-marker) boundary-positions))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2719 (if (not already-mimed)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2720 nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2721 ;; trim headers
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2722 (vm-reorder-message-headers
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2723 nil (nconc (list "Content-Disposition:" "Content-ID:")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2724 (if description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2725 (list "Content-Description:")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2726 nil))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2727 nil)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2728 ;; remove header/text separator
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2729 (goto-char (1- (vm-mm-layout-body-start layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2730 (if (looking-at "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2731 (delete-char 1)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2732 (insert "Content-Type: " type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2733 (if params
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2734 (if vm-mime-avoid-folding-content-type
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2735 (insert "; " (mapconcat 'identity params "; ") "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2736 (insert ";\n\t" (mapconcat 'identity params ";\n\t") "\n"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2737 (insert "\n"))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2738 (and description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2739 (insert "Content-Description: " description "\n"))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2740 (if disposition
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2741 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2742 (insert "Content-Disposition: " (car disposition))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2743 (if (cdr disposition)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2744 (insert ";\n\t" (mapconcat 'identity
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2745 (cdr disposition)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2746 ";\n\t")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2747 (insert "\n")))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2748 (insert "Content-Transfer-Encoding: " encoding "\n\n"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2749 (goto-char (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2750 (widen)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2751 (save-excursion
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2752 (goto-char (extent-start-position e))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 26
diff changeset
2753 (vm-assert (looking-at "\\[ATTACHMENT")))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2754 (delete-region (extent-start-position e)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2755 (extent-end-position e))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2756 (detach-extent e)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2757 (if (looking-at "\n")
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2758 (delete-char 1))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2759 (setq e-list (cdr e-list)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2760 ;; handle the remaining chunk of text after the last
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2761 ;; extent, if any.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2762 (if (or just-one (= (point) (point-max)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2763 nil
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2764 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2765 (let ((enriched-initial-annotation ""))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2766 (enriched-encode (point) (point-max))))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2767 (setq charset (vm-determine-proper-charset (point)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2768 (point-max)))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2769 (if vm-xemacs-mule-p
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2770 (encode-coding-region (point) (point-max)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2771 buffer-file-coding-system))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2772 (setq encoding (vm-determine-proper-content-transfer-encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2773 (point)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2774 (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2775 encoding (vm-mime-transfer-encode-region encoding
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2776 (point)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2777 (point-max)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2778 t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2779 (setq 8bit (or 8bit (equal encoding "8bit")))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2780 (setq boundary-positions (cons (point-marker) boundary-positions))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2781 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2782 (insert "Content-Type: text/enriched; charset=" charset "\n")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2783 (insert "Content-Type: text/plain; charset=" charset "\n"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2784 (insert "Content-Transfer-Encoding: " encoding "\n\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2785 (goto-char (point-max)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2786 (setq boundary (vm-mime-make-multipart-boundary))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2787 (mail-text)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2788 (while (re-search-forward (concat "^--"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2789 (regexp-quote boundary)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2790 "\\(--\\)?$")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2791 nil t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2792 (setq boundary (vm-mime-make-multipart-boundary))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2793 (mail-text))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2794 (goto-char (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2795 (or just-one (insert "\n--" boundary "--\n"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2796 (while boundary-positions
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2797 (goto-char (car boundary-positions))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2798 (insert "\n--" boundary "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2799 (setq boundary-positions (cdr boundary-positions)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2800 (if (and just-one already-mimed)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2801 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2802 (goto-char (vm-mm-layout-header-start layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2803 ;; trim headers
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2804 (vm-reorder-message-headers
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2805 nil '("Content-Description:" "Content-ID:") nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2806 ;; remove header/text separator
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2807 (goto-char (1- (vm-mm-layout-body-start layout)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2808 (if (looking-at "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2809 (delete-char 1))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2810 ;; copy remainder to enclosing entity's header section
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2811 (insert-buffer-substring (current-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2812 (vm-mm-layout-header-start layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2813 (vm-mm-layout-body-start layout))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2814 (delete-region (vm-mm-layout-header-start layout)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2815 (vm-mm-layout-body-start layout))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2816 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2817 (vm-remove-mail-mode-header-separator)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2818 (vm-reorder-message-headers
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2819 nil nil "\\(Content-Type:\\|MIME-Version:\\|Content-Transfer-Encoding\\)")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2820 (vm-add-mail-mode-header-separator)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2821 (insert "MIME-Version: 1.0\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2822 (if (not just-one)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2823 (insert (if vm-mime-avoid-folding-content-type
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2824 "Content-Type: multipart/mixed; boundary=\""
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2825 "Content-Type: multipart/mixed;\n\tboundary=\"")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2826 boundary "\"\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2827 (insert "Content-Type: " type)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2828 (if params
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2829 (if vm-mime-avoid-folding-content-type
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2830 (insert "; " (mapconcat 'identity params "; ") "\n")
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2831 (insert ";\n\t" (mapconcat 'identity params ";\n\t") "\n"))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2832 (insert "\n")))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2833 (if just-one
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2834 (and description
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2835 (insert "Content-Description: " description "\n")))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2836 (if (and just-one disposition)
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2837 (progn
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2838 (insert "Content-Disposition: " (car disposition))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2839 (if (cdr disposition)
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2840 (if vm-mime-avoid-folding-content-type
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2841 (insert "; " (mapconcat 'identity (cdr disposition) "; ")
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2842 "\n")
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2843 (insert ";\n\t" (mapconcat 'identity (cdr disposition)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2844 ";\n\t")))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
2845 (insert "\n"))))
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
2846 (if just-one
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2847 (insert "Content-Transfer-Encoding: " encoding "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2848 (if 8bit
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2849 (insert "Content-Transfer-Encoding: 8bit\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2850 (insert "Content-Transfer-Encoding: 7bit\n")))))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
2851
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2852 (defun vm-mime-fsfemacs-encode-composition ()
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2853 (save-restriction
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2854 (widen)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2855 (if (not (eq major-mode 'mail-mode))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2856 (error "Command must be used in a VM Mail mode buffer."))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2857 (or (null (vm-mail-mode-get-header-contents "MIME-Version:"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2858 (error "Message is already MIME encoded."))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2859 (let ((8bit nil)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2860 (just-one nil)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2861 (boundary-positions nil)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2862 (enriched (and (boundp 'enriched-mode) enriched-mode))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2863 already-mimed layout o o-list boundary
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2864 type encoding charset params description disposition object
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2865 opoint-min)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2866 (mail-text)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2867 (setq o-list (vm-mime-fake-attachment-overlays (point) (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2868 o-list (vm-delete (function
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2869 (lambda (o)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2870 (overlay-get o 'vm-mime-object)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2871 o-list t)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2872 o-list (sort o-list (function
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2873 (lambda (e1 e2)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2874 (< (overlay-end e1)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2875 (overlay-end e2))))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2876 ;; If there's just one attachment and no other readable
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2877 ;; text in the buffer then make the message type just be
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2878 ;; the attachment type rather than sending a multipart
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2879 ;; message with one attachment
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2880 (setq just-one (and (= (length o-list) 1)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2881 (looking-at "[ \t\n]*")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2882 (= (match-end 0)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2883 (overlay-start (car o-list)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2884 (save-excursion
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2885 (goto-char (overlay-end (car o-list)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2886 (looking-at "[ \t\n]*\\'"))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2887 (if (null o-list)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2888 (progn
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2889 (narrow-to-region (point) (point-max))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2890 ;; support enriched-mode for text/enriched composition
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2891 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2892 (let ((enriched-initial-annotation ""))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2893 (enriched-encode (point-min) (point-max))))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2894 (setq charset (vm-determine-proper-charset (point-min)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2895 (point-max)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2896 (setq encoding (vm-determine-proper-content-transfer-encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2897 (point-min)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2898 (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2899 encoding (vm-mime-transfer-encode-region encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2900 (point-min)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2901 (point-max)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2902 t))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2903 (widen)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2904 (vm-remove-mail-mode-header-separator)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2905 (goto-char (point-min))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2906 (vm-reorder-message-headers
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2907 nil nil "\\(Content-Type:\\|Content-Transfer-Encoding\\|MIME-Version:\\)")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2908 (insert "MIME-Version: 1.0\n")
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2909 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2910 (insert "Content-Type: text/enriched; charset=" charset "\n")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2911 (insert "Content-Type: text/plain; charset=" charset "\n"))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2912 (insert "Content-Transfer-Encoding: " encoding "\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2913 (vm-add-mail-mode-header-separator))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2914 (while o-list
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2915 (setq o (car o-list))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2916 (if (or just-one (= (point) (overlay-start o)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2917 nil
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2918 (narrow-to-region (point) (overlay-start o))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2919 ;; support enriched-mode for text/enriched composition
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2920 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2921 (let ((enriched-initial-annotation ""))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2922 (save-excursion
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2923 ;; insert/delete trick needed to avoid
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2924 ;; enriched-mode tags from seeping into the
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2925 ;; attachment overlays. I really wish
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
2926 ;; front-advance / rear-advance overlay
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2927 ;; endpoint properties actually worked.
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2928 (goto-char (point-max))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2929 (insert-before-markers "\n")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2930 (enriched-encode (point-min) (1- (point)))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2931 (goto-char (point-max))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2932 (delete-char -1)
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2933 '(goto-char (point-min)))))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2934 (setq charset (vm-determine-proper-charset (point-min)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2935 (point-max)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2936 (setq encoding (vm-determine-proper-content-transfer-encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2937 (point-min)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2938 (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2939 encoding (vm-mime-transfer-encode-region encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2940 (point-min)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2941 (point-max)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2942 t))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2943 (setq boundary-positions (cons (point-marker) boundary-positions))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2944 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2945 (insert "Content-Type: text/enriched; charset=" charset "\n")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
2946 (insert "Content-Type: text/plain; charset=" charset "\n"))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2947 (insert "Content-Transfer-Encoding: " encoding "\n\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2948 (widen))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2949 (goto-char (overlay-start o))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2950 (narrow-to-region (point) (point))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2951 (setq object (overlay-get o 'vm-mime-object))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2952 ;; insert the object
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2953 (cond ((bufferp object)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2954 ;; as of FSF Emacs 19.34, even with the hooks
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2955 ;; we've attached to the attachment overlays,
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2956 ;; text STILL can be inserted into them when
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2957 ;; font-lock is enabled. Explaining why is
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2958 ;; beyond the scope of this comment and I
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2959 ;; don't know the answer anyway. This works
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2960 ;; to prevent it.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2961 (insert-before-markers " ")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2962 (forward-char -1)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2963 (insert-buffer-substring object)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2964 (delete-char 1))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2965 ((stringp object)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2966 (insert-before-markers " ")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2967 (forward-char -1)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2968 (insert-file-contents object)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2969 (goto-char (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2970 (delete-char -1)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2971 ;; gather information about the object from the extent.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2972 (if (setq already-mimed (overlay-get o 'vm-mime-encoded))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2973 (setq layout (vm-mime-parse-entity
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2974 nil (list "text/plain" "charset=us-ascii")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2975 "7bit")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2976 type (or (overlay-get o 'vm-mime-type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2977 (car (vm-mm-layout-type layout)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2978 params (or (overlay-get o 'vm-mime-parameters)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2979 (cdr (vm-mm-layout-qtype layout)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2980 description (overlay-get o 'vm-mime-description)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2981 disposition
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2982 (if (not
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2983 (equal
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2984 (car (overlay-get o 'vm-mime-disposition))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2985 "unspecified"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2986 (overlay-get o 'vm-mime-disposition)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2987 (vm-mm-layout-qdisposition layout)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2988 (setq type (overlay-get o 'vm-mime-type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2989 params (overlay-get o 'vm-mime-parameters)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2990 description (overlay-get o 'vm-mime-description)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2991 disposition
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2992 (if (not (equal
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2993 (car (overlay-get o 'vm-mime-disposition))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2994 "unspecified"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2995 (overlay-get o 'vm-mime-disposition)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2996 nil)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2997 (cond ((vm-mime-types-match "text" type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2998 (setq encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
2999 (vm-determine-proper-content-transfer-encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3000 (if already-mimed
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3001 (vm-mm-layout-body-start layout)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3002 (point-min))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3003 (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3004 encoding (vm-mime-transfer-encode-region
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3005 encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3006 (if already-mimed
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3007 (vm-mm-layout-body-start layout)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3008 (point-min))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3009 (point-max)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3010 t))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3011 (setq 8bit (or 8bit (equal encoding "8bit"))))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3012 ((vm-mime-composite-type-p type)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3013 (setq opoint-min (point-min))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3014 (if (not already-mimed)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3015 (setq layout (vm-mime-parse-entity
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3016 nil (list "text/plain" "charset=us-ascii")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3017 "7bit")))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3018 (setq encoding (vm-mime-transfer-encode-layout layout))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3019 (setq 8bit (or 8bit (equal encoding "8bit")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3020 (goto-char (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3021 (widen)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3022 (narrow-to-region opoint-min (point)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3023 (t
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3024 (vm-mime-base64-encode-region
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3025 (if already-mimed
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3026 (vm-mm-layout-body-start layout)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3027 (point-min))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3028 (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3029 (setq encoding "base64")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3030 (if just-one
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3031 nil
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3032 (goto-char (point-min))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3033 (setq boundary-positions (cons (point-marker) boundary-positions))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3034 (if (not already-mimed)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3035 nil
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3036 ;; trim headers
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3037 (vm-reorder-message-headers
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3038 nil (nconc (list "Content-Disposition:" "Content-ID:")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3039 (if description
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3040 (list "Content-Description:")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3041 nil))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3042 nil)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3043 ;; remove header/text separator
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3044 (goto-char (1- (vm-mm-layout-body-start layout)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3045 (if (looking-at "\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3046 (delete-char 1)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3047 (insert "Content-Type: " type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3048 (if params
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3049 (if vm-mime-avoid-folding-content-type
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3050 (insert "; " (mapconcat 'identity params "; ") "\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3051 (insert ";\n\t" (mapconcat 'identity params ";\n\t") "\n"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3052 (insert "\n"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3053 (and description
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3054 (insert "Content-Description: " description "\n"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3055 (if disposition
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3056 (progn
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3057 (insert "Content-Disposition: " (car disposition))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3058 (if (cdr disposition)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3059 (insert ";\n\t" (mapconcat 'identity
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3060 (cdr disposition)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3061 ";\n\t")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3062 (insert "\n")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3063 (insert "Content-Transfer-Encoding: " encoding "\n\n"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3064 (goto-char (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3065 (widen)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3066 (save-excursion
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3067 (goto-char (overlay-start o))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3068 (vm-assert (looking-at "\\[ATTACHMENT")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3069 (delete-region (overlay-start o)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3070 (overlay-end o))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3071 (delete-overlay o)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3072 (if (looking-at "\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3073 (delete-char 1))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3074 (setq o-list (cdr o-list)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3075 ;; handle the remaining chunk of text after the last
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3076 ;; extent, if any.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3077 (if (or just-one (= (point) (point-max)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3078 nil
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
3079 ;; support enriched-mode for text/enriched composition
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
3080 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
3081 (let ((enriched-initial-annotation ""))
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
3082 (enriched-encode (point) (point-max))))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3083 (setq charset (vm-determine-proper-charset (point)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3084 (point-max)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3085 (setq encoding (vm-determine-proper-content-transfer-encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3086 (point)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3087 (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3088 encoding (vm-mime-transfer-encode-region encoding
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3089 (point)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3090 (point-max)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3091 t))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3092 (setq 8bit (or 8bit (equal encoding "8bit")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3093 (setq boundary-positions (cons (point-marker) boundary-positions))
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
3094 (if enriched
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
3095 (insert "Content-Type: text/enriched; charset=" charset "\n")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 136
diff changeset
3096 (insert "Content-Type: text/plain; charset=" charset "\n"))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3097 (insert "Content-Transfer-Encoding: " encoding "\n\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3098 (goto-char (point-max)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3099 (setq boundary (vm-mime-make-multipart-boundary))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3100 (mail-text)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3101 (while (re-search-forward (concat "^--"
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3102 (regexp-quote boundary)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3103 "\\(--\\)?$")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3104 nil t)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3105 (setq boundary (vm-mime-make-multipart-boundary))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3106 (mail-text))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3107 (goto-char (point-max))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3108 (or just-one (insert "\n--" boundary "--\n"))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3109 (while boundary-positions
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3110 (goto-char (car boundary-positions))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3111 (insert "\n--" boundary "\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3112 (setq boundary-positions (cdr boundary-positions)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3113 (if (and just-one already-mimed)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3114 (progn
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3115 (goto-char (vm-mm-layout-header-start layout))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3116 ;; trim headers
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3117 (vm-reorder-message-headers
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3118 nil '("Content-Description:" "Content-ID:") nil)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3119 ;; remove header/text separator
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3120 (goto-char (1- (vm-mm-layout-body-start layout)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3121 (if (looking-at "\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3122 (delete-char 1))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3123 ;; copy remainder to enclosing entity's header section
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3124 (insert-buffer-substring (current-buffer)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3125 (vm-mm-layout-header-start layout)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3126 (vm-mm-layout-body-start layout))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3127 (delete-region (vm-mm-layout-header-start layout)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3128 (vm-mm-layout-body-start layout))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3129 (goto-char (point-min))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3130 (vm-remove-mail-mode-header-separator)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3131 (vm-reorder-message-headers
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3132 nil nil "\\(Content-Type:\\|MIME-Version:\\|Content-Transfer-Encoding\\)")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3133 (vm-add-mail-mode-header-separator)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3134 (insert "MIME-Version: 1.0\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3135 (if (not just-one)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3136 (insert (if vm-mime-avoid-folding-content-type
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3137 "Content-Type: multipart/mixed; boundary=\""
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3138 "Content-Type: multipart/mixed;\n\tboundary=\"")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3139 boundary "\"\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3140 (insert "Content-Type: " type)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3141 (if params
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3142 (if vm-mime-avoid-folding-content-type
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3143 (insert "; " (mapconcat 'identity params "; ") "\n")
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3144 (insert ";\n\t" (mapconcat 'identity params ";\n\t") "\n"))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3145 (insert "\n")))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3146 (if just-one
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3147 (and description
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3148 (insert "Content-Description: " description "\n")))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3149 (if (and just-one disposition)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3150 (progn
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3151 (insert "Content-Disposition: " (car disposition))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3152 (if (cdr disposition)
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3153 (if vm-mime-avoid-folding-content-type
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3154 (insert "; " (mapconcat 'identity (cdr disposition) "; ")
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3155 "\n")
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3156 (insert ";\n\t" (mapconcat 'identity (cdr disposition)
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3157 ";\n\t")))
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3158 (insert "\n"))))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3159 (if just-one
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3160 (insert "Content-Transfer-Encoding: " encoding "\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3161 (if 8bit
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3162 (insert "Content-Transfer-Encoding: 8bit\n")
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3163 (insert "Content-Transfer-Encoding: 7bit\n")))))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3164
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3165 (defun vm-mime-fragment-composition (size)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3166 (save-restriction
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3167 (widen)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
3168 (message "Fragmenting message...")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3169 (let ((buffers nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3170 (id (vm-mime-make-multipart-boundary))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3171 (n 1)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3172 (the-end nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3173 b header-start header-end master-buffer start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3174 (vm-remove-mail-mode-header-separator)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3175 ;; message/partial must have "7bit" content transfer
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3176 ;; encoding, so force everything to be encoded for
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3177 ;; 7bit transmission.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3178 (let ((vm-mime-8bit-text-transfer-encoding
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3179 (if (eq vm-mime-8bit-text-transfer-encoding '8bit)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3180 'quoted-printable
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3181 vm-mime-8bit-text-transfer-encoding)))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3182 (vm-mime-transfer-encode-layout
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3183 (vm-mime-parse-entity nil (list "text/plain" "charset=us-ascii")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3184 "7bit")))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3185 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3186 (setq header-start (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3187 (search-forward "\n\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3188 (setq header-end (1- (point)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3189 (setq master-buffer (current-buffer))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3190 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3191 (setq start (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3192 (while (not (eobp))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3193 (condition-case nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3194 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3195 (forward-char (max (- size 150) 2000))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3196 (beginning-of-line))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3197 (end-of-buffer (setq the-end t)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3198 (setq end (point))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3199 (setq b (generate-new-buffer (concat (buffer-name) " part "
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3200 (int-to-string n))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3201 (setq buffers (cons b buffers))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3202 (set-buffer b)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3203 (make-local-variable 'vm-send-using-mime)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3204 (setq vm-send-using-mime nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3205 (insert-buffer-substring master-buffer header-start header-end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3206 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3207 (vm-reorder-message-headers nil nil
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3208 "\\(Content-Type:\\|MIME-Version:\\|Content-Transfer-Encoding\\)")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3209 (insert "MIME-Version: 1.0\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3210 (insert (format
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3211 (if vm-mime-avoid-folding-content-type
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3212 "Content-Type: message/partial; id=%s; number=%d"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3213 "Content-Type: message/partial;\n\tid=%s;\n\tnumber=%d")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3214 id n))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3215 (if the-end
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3216 (if vm-mime-avoid-folding-content-type
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3217 (insert (format "; total=%d\n" n))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3218 (insert (format ";\n\ttotal=%d\n" n)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3219 (insert "\n"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3220 (insert "Content-Transfer-Encoding: 7bit\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3221 (goto-char (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3222 (insert mail-header-separator "\n")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3223 (insert-buffer-substring master-buffer start end)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3224 (vm-increment n)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3225 (set-buffer master-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3226 (setq start (point)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
3227 (vm-add-mail-mode-header-separator)
26
441bb1e64a06 Import from CVS: tag r19-15b96
cvs
parents: 24
diff changeset
3228 (message "Fragmenting message... done")
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3229 (nreverse buffers))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3230
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3231 (defun vm-mime-preview-composition ()
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3232 "Show how the current composition buffer might be displayed
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3233 in a MIME-aware mail reader. VM copies and encodes the current
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3234 mail composition buffer and displays it as a mail folder.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3235 Type `q' to quit this temp folder and return to composing your
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3236 message."
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3237 (interactive)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3238 (if (not (eq major-mode 'mail-mode))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3239 (error "Command must be used in a VM Mail mode buffer."))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3240 (let ((temp-buffer nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3241 (mail-buffer (current-buffer))
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
3242 (enriched (and (boundp 'enriched-mode) enriched-mode))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3243 e-list)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3244 (unwind-protect
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3245 (progn
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3246 (setq temp-buffer (generate-new-buffer "composition preview"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3247 (set-buffer temp-buffer)
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3248 ;; so vm-mime-xxxx-encode-composition won't complain
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3249 (setq major-mode 'mail-mode)
146
2af401a6ecca Import from CVS: tag r20-2p1
cvs
parents: 140
diff changeset
3250 (set (make-local-variable 'enriched-mode) enriched)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3251 (vm-insert-region-from-buffer mail-buffer)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3252 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3253 (or (vm-mail-mode-get-header-contents "From")
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 110
diff changeset
3254 (insert "From: " (user-login-name) "\n"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3255 (or (vm-mail-mode-get-header-contents "Message-ID")
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 20
diff changeset
3256 (insert "Message-ID: <fake@fake.fake>\n"))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3257 (or (vm-mail-mode-get-header-contents "Date")
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3258 (insert "Date: "
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3259 (format-time-string "%a, %d %b %Y %H%M%S %Z"
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3260 (current-time))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3261 "\n"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3262 (and vm-send-using-mime
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3263 (null (vm-mail-mode-get-header-contents "MIME-Version:"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3264 (vm-mime-encode-composition))
126
1370575f1259 Import from CVS: tag xemacs-20-1p1
cvs
parents: 120
diff changeset
3265 (vm-remove-mail-mode-header-separator)
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3266 (goto-char (point-min))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3267 (insert (vm-leading-message-separator 'From_))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3268 (goto-char (point-max))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3269 (insert (vm-trailing-message-separator 'From_))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3270 (set-buffer-modified-p nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3271 ;; point of no return, don't kill it if the user quits
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3272 (setq temp-buffer nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3273 (let ((vm-auto-decode-mime-messages t)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3274 (vm-auto-displayed-mime-content-types t))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3275 (vm-save-buffer-excursion
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3276 (vm-goto-new-folder-frame-maybe 'folder)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3277 (vm-mode)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3278 (message
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3279 (substitute-command-keys
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3280 "Type \\[vm-quit] to continue composing your message"))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3281 ;; temp buffer, don't offer to save it.
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3282 (setq buffer-offer-save nil)
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3283 (vm-display (or vm-presentation-buffer (current-buffer)) t
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3284 (list this-command) '(vm-mode startup)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3285 (and temp-buffer (kill-buffer temp-buffer)))))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3286
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3287 (defun vm-mime-composite-type-p (type)
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3288 (or (and (vm-mime-types-match "message" type)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3289 (not (vm-mime-types-match "message/partial" type))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3290 (not (vm-mime-types-match "message/external-body" type)))
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3291 (vm-mime-types-match "multipart" type)))
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents:
diff changeset
3292
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3293 ;; Unused currrently.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3294 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3295 ;;(defun vm-mime-map-atomic-layouts (function list)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3296 ;; (while list
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3297 ;; (if (vm-mime-composite-type-p (car (vm-mm-layout-type (car list))))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3298 ;; (vm-mime-map-atomic-layouts function (vm-mm-layout-parts (car list)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3299 ;; (funcall function (car list)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 131
diff changeset
3300 ;; (setq list (cdr list))))