annotate lisp/mailcrypt/mc-toplev.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; mc-toplev.el, entry point functions for Mailcrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1995 Jin Choi <jsc@mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Patrick LoPresti <patl@lcs.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;{{{ Licensing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; This file is intended to be used with GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;{{{ Load some required packages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (require 'mailcrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (require 'mail-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; RMAIL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (condition-case nil (require 'rmail) (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (autoload 'rmail-abort-edit "rmailedit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (autoload 'rmail-cease-edit "rmailedit")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; Is this a good idea?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar rmail-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (condition-case nil (require 'vm) (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; GNUS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (condition-case nil (require 'gnus) (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; MH-E
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (condition-case nil (require 'mh-e) (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (condition-case nil (require 'mailalias) (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (if (not mc-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (autoload 'mc-scheme-pgp "mc-pgp" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;{{{ Encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defun mc-cleanup-recipient-headers (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; Takes a comma separated string of recipients to encrypt for and,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; assuming they were possibly extracted from the headers of a reply,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; returns a list of the address components.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (mapcar 'mc-strip-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (mc-split "\\([ \t\n]*,[ \t\n]*\\)+" str)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defun mc-find-headers-end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (looking-at "^::\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (re-search-forward "^\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if (looking-at "^##\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (re-search-forward "^\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defun mc-encrypt (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 "*Encrypt the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 Exact behavior depends on current major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 With \\[universal-argument], prompt for User ID to sign as.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 With \\[universal-argument] \\[universal-argument], prompt for encryption scheme to use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (mc-encrypt-region arg nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun mc-encrypt-region (arg start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "*Encrypt the current region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (interactive "p\nr")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (let* ((mode-alist (cdr-safe (assq major-mode mc-modes-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (func (or (cdr-safe (assq 'encrypt mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 'mc-encrypt-generic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 sign scheme from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (if (>= arg 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (setq from (read-string "User ID: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 sign t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (>= arg 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (setq scheme
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (cdr (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (completing-read "Encryption Scheme: " mc-schemes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 mc-schemes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (funcall func nil scheme start end from sign)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun mc-encrypt-generic (&optional recipients scheme start end from sign)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "*Generic function to encrypt a region of data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (or start (setq start (point-min-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (or (markerp start) (setq start (copy-marker start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (or end (setq end (point-max-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (or (markerp end) (setq end (copy-marker end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (run-hooks 'mc-pre-encryption-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (cond ((stringp recipients)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (mc-split "\\([ \t\n]*,[ \t\n]*\\)+" recipients)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ((null recipients)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (mc-cleanup-recipient-headers (read-string "Recipients: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (t (error "mc-encrypt-generic: recipients not string or nil")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (or scheme (setq scheme mc-default-scheme))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if (funcall (cdr (assoc 'encryption-func (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 recipients start end from sign)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (run-hooks 'mc-post-encryption-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defun mc-encrypt-message (&optional recipients scheme start end from sign)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "*Encrypt a message for RECIPIENTS using the given encryption SCHEME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 RECIPIENTS is a comma separated string. If SCHEME is nil, use the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 of `mc-default-scheme'. Returns t on success, nil otherwise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (let ((headers-end (mc-find-headers-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 default-recipients)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (setq default-recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (concat "^" (regexp-quote mail-header-separator) "$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (narrow-to-region (point-min) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (and (featurep 'mailalias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (not (featurep 'mail-abbrevs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (expand-mail-aliases (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (mc-strip-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (mapcar 'cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (mc-get-fields "to\\|cc\\|bcc")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (not from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (narrow-to-region (point) headers-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (setq from (mail-fetch-field "From"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if (not recipients)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (if mc-use-default-recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 default-recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (read-from-minibuffer "Recipients: " default-recipients))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (or start (setq start headers-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (or end (setq end (point-max-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (mc-encrypt-generic recipients scheme start end from sign))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;{{{ Decryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defun mc-decrypt ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "*Decrypt a message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 Exact behavior depends on current major mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (let* ((mode-alist (cdr-safe (assq major-mode mc-modes-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (func (or (cdr-safe (assq 'decrypt mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 'mc-decrypt-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (funcall func)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defun mc-decrypt-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 "Decrypt whatever message is in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 Returns a pair (SUCCEEDED . VERIFIED) where SUCCEEDED is t if the encryption
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 succeeded and VERIFIED is t if it had a valid signature."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (let ((schemes mc-schemes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 limits scheme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (while (and schemes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (setq scheme (cdr (car schemes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (not (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 limits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (mc-message-delimiter-positions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (cdr (assoc 'msg-begin-line (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (cdr (assoc 'msg-end-line (funcall scheme)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq schemes (cdr schemes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (if (null limits)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (error "Found no encrypted message in this buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (run-hooks 'mc-pre-decryption-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (let ((resultval (funcall (cdr (assoc 'decryption-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (car limits) (cdr limits))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (if (car resultval) ; decryption succeeded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (run-hooks 'mc-post-decryption-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 resultval)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;{{{ Signing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defun mc-sign (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "*Sign a message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 Exact behavior depends on current major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 With one prefix arg, prompts for private key to use, with two prefix args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 also prompts for encryption scheme to use. With negative prefix arg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 inhibits clearsigning (pgp)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (mc-sign-region arg nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun mc-sign-region (arg start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "*Sign the current region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (interactive "p\nr")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (let* ((mode-alist (cdr-safe (assq major-mode mc-modes-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (func (or (cdr-safe (assq 'sign mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 'mc-sign-generic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 from scheme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (if (>= arg 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (setq scheme
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (cdr (assoc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (completing-read "Encryption Scheme: " mc-schemes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 mc-schemes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (if (>= arg 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (setq from (read-string "User ID: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (funcall func from scheme start end (< arg 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun mc-sign-generic (withkey scheme start end unclearsig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (or scheme (setq scheme mc-default-scheme))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (or start (setq start (point-min-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (or (markerp start) (setq start (copy-marker start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (or end (setq end (point-max-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (or (markerp end) (setq end (copy-marker end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (run-hooks 'mc-pre-signature-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (funcall (cdr (assoc 'signing-func (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 start end withkey unclearsig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (run-hooks 'mc-post-signature-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (defun mc-sign-message (&optional withkey scheme start end unclearsig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 "Clear sign the message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (let ((headers-end (mc-find-headers-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (or withkey
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (narrow-to-region (point) headers-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setq withkey (mail-fetch-field "From")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (or start (setq start headers-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (or end (setq end (point-max-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (mc-sign-generic withkey scheme start end unclearsig))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;{{{ Signature verification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (defun mc-verify ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 "*Verify a message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 Exact behavior depends on current major mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (let* ((mode-alist (cdr-safe (assq major-mode mc-modes-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (func (or (cdr-safe (assq 'verify mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 'mc-verify-signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (funcall func)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defun mc-verify-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "*Verify the signature of the signed message in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 Show the result as a message in the minibuffer. Returns t if the signature
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 is verified."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (let ((schemes mc-schemes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 limits scheme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (while (and schemes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq scheme (cdr (car schemes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 limits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (mc-message-delimiter-positions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (cdr (assoc 'signed-begin-line (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (cdr (assoc 'signed-end-line (funcall scheme)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq schemes (cdr schemes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (if (null limits)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (error "Found no signed message in this buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (funcall (cdr (assoc 'verification-func (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (car limits) (cdr limits))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;;{{{ Key management
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;;{{{ mc-insert-public-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (defun mc-insert-public-key (&optional userid scheme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 "*Insert your public key at point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 With one prefix arg, prompts for user id to use. With two prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 args, prompts for encryption scheme."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (let (arglist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (if (not (and (listp current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (numberp (car current-prefix-arg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (if (>= (car current-prefix-arg) 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (setq arglist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (cons (cdr (assoc (completing-read "Encryption Scheme: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 mc-schemes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 mc-schemes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 arglist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if (>= (car current-prefix-arg) 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (setq arglist (cons (read-string "User ID: ") arglist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 arglist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ; (if (< (point) (mc-find-headers-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ; (error "Can't insert key inside message header"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (or scheme (setq scheme mc-default-scheme))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (or userid (setq userid (cdr (assoc 'user-id (funcall scheme)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (funcall (cdr (assoc 'key-insertion-func (funcall scheme))) userid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;;{{{ mc-snarf-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defun mc-snarf ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 "*Add all public keys in the buffer to your keyring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 Exact behavior depends on current major mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (let* ((mode-alist (cdr-safe (assq major-mode mc-modes-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (func (or (cdr-safe (assq 'snarf mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 'mc-snarf-keys)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (funcall func)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defun mc-snarf-keys ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "*Add all public keys in the buffer to your keyring."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (let ((schemes mc-schemes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (start (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (found 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 limits scheme)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (while (and schemes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (setq scheme (cdr (car schemes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 limits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (mc-message-delimiter-positions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (cdr (assoc 'key-begin-line (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (cdr (assoc 'key-end-line (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq schemes (cdr schemes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (if (null limits)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (throw 'done found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (setq start (cdr limits))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (setq found (+ found (funcall (cdr (assoc 'snarf-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (funcall scheme)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (car limits) (cdr limits)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (message (format "%d new key%s found" found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if (eq 1 found) "" "s"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;;{{{ Mode specific functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;;{{{ RMAIL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defun mc-rmail-summary-verify-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "*Verify the signature in the current message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if (not (eq major-mode 'rmail-summary-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "mc-rmail-summary-verify-signature called in inappropriate buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (set-buffer rmail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (mc-verify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (defun mc-rmail-summary-decrypt-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 "*Decrypt the contents of this message"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (if (not (eq major-mode 'rmail-summary-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 "mc-rmail-summary-decrypt-message called in inappropriate buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (set-buffer rmail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (mc-decrypt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (defun mc-rmail-summary-snarf-keys ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 "*Adds keys from current message to public key ring"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (not (eq major-mode 'rmail-summary-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 "mc-rmail-summary-snarf-keys called in inappropriate buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (set-buffer rmail-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (mc-snarf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (defun mc-rmail-verify-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "*Verify the signature in the current message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (if (not (equal mode-name "RMAIL"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (error "mc-rmail-verify-signature called in a non-RMAIL buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; Hack to load rmailkwd before verifying sig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (rmail-add-label "verified")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (rmail-kill-label "verified")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (if (mc-verify-signature)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (rmail-add-label "verified")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (defun mc-rmail-decrypt-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 "*Decrypt the contents of this message"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (let (decryption-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if (not (equal mode-name "RMAIL"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (error "mc-rmail-decrypt-message called in a non-RMAIL buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (rmail-edit-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq decryption-result (mc-decrypt-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (cond ((not (car decryption-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (rmail-abort-edit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ((and (not (eq mc-always-replace 'never))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (or mc-always-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "Replace encrypted message with decrypted? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (rmail-cease-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (rmail-kill-label "edited")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (rmail-add-label "decrypted")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (if (cdr decryption-result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (rmail-add-label "verified")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (let ((tmp (generate-new-buffer "*Mailcrypt Viewing*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (copy-to-buffer tmp (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (rmail-abort-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (switch-to-buffer tmp t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (insert "From Mailcrypt-" mc-version " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (current-time-string) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (rmail-convert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (rmail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (use-local-map (copy-keymap (current-local-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (local-set-key "q" 'mc-rmail-view-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (set-buffer-modified-p nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (if (eq major-mode 'rmail-edit-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (rmail-abort-edit)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (defun mc-rmail-view-quit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (let ((buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (rmail-quit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (kill-buffer buf)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;;{{{ VM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (defun mc-vm-verify-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 "*Verify the signature in the current VM message"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (vm-follow-summary-cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (vm-widen-page)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (mc-verify-signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (defun mc-vm-decrypt-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 "*Decrypt the contents of the current VM message"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (let ((vm-frame-per-edit nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 from-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (vm-follow-summary-cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (vm-error-if-folder-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; store away a valid "From " line for possible later use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (setq from-line (vm-leading-message-separator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (vm-edit-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (cond ((not (condition-case condition-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (car (mc-decrypt-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (vm-edit-message-abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (error (message "Decryption failed: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (car (cdr condition-data)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (vm-edit-message-abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (error "Decryption failed."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ((and (not (eq mc-always-replace 'never))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (or mc-always-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (y-or-n-p "Replace encrypted message with decrypted? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (let ((this-command 'vm-edit-message-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (vm-edit-message-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (let ((tmp (generate-new-buffer "*Mailcrypt Viewing*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (copy-to-buffer tmp (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (vm-edit-message-abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (switch-to-buffer tmp t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (insert from-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (vm-mode t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defun mc-vm-snarf-keys ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "*Snarf public key from the contents of the current VM message"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (vm-follow-summary-cursor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (vm-select-folder-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (vm-check-for-killed-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (vm-error-if-folder-empty)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (vm-widen-page)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (mc-snarf-keys)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;;{{{ GNUS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (defun mc-gnus-verify-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (gnus-summary-select-article)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
553 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
554 (set-buffer gnus-original-article-buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (save-restriction (widen) (mc-verify-signature))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defun mc-gnus-snarf-keys ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (gnus-summary-select-article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (gnus-eval-in-buffer-window gnus-article-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (save-restriction (widen) (mc-snarf-keys))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defun mc-gnus-decrypt-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (gnus-summary-select-article)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; Gnus 5 has the string "Gnus" instead of "GNUS" in gnus-version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (if (not (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (string-match "Gnus" gnus-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (gnus-eval-in-buffer-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 gnus-article-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (save-restriction (widen) (mc-decrypt-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;; Gnus 5 allows editing of articles. (Actually, it makes a great
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; mail reader.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (gnus-eval-in-buffer-window gnus-article-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (gnus-summary-edit-article t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (cond ((not (car (mc-decrypt-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (gnus-summary-edit-article-postpone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ((and (not (gnus-group-read-only-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (not (eq mc-always-replace 'never))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (or mc-always-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 "Replace encrypted message on disk? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (gnus-summary-edit-article-done))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (gnus-summary-edit-article-postpone)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;;{{{ MH
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (defun mc-mh-decrypt-message ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 "Decrypt the contents of the current MH message in the show buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (let* ((msg (mh-get-msg-num t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (msg-filename (mh-msg-filename msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (show-buffer (get-buffer mh-show-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 decrypt-okay decrypt-on-disk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 decrypt-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (and (not (eq mc-always-replace 'never))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (or mc-always-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (y-or-n-p "Replace encrypted message on disk? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (if decrypt-on-disk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (set-buffer (create-file-buffer msg-filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (insert-file-contents msg-filename t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (if (setq decrypt-okay (car (mc-decrypt-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (message "Decryption failed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (kill-buffer nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (if decrypt-okay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (if (and show-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (equal msg-filename (buffer-file-name show-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (mh-invalidate-show-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (mh-show msg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (mh-show msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (set-buffer mh-show-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (if (setq decrypt-okay (car (mc-decrypt-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (message "Decryption failed.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (if (not decrypt-okay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (mh-invalidate-show-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (mh-show msg))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (defun mc-mh-verify-signature ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 "*Verify the signature in the current MH message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (mh-show)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (mh-in-show-buffer (mh-show-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (mc-verify-signature)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (defun mc-mh-snarf-keys ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (mh-show)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (mh-in-show-buffer (mh-show-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (mc-snarf-keys)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;;}}}