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