annotate lisp/mailcrypt/mc-remail.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +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-remail.el --- Remailer support for Mailcrypt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is intended to be used with GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;{{{ Load required packages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (require 'mail-utils)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (require 'sendmail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'mailcrypt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (if (not mc-xemacs-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (autoload 'mc-cleanup-recipient-headers "mc-toplev")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (autoload 'mc-encrypt-message "mc-toplev"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (condition-case nil (require 'mailalias) (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;{{{ Functions dealing with remailer structures
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defsubst mc-remailer-create (addr id props pre-encr post-encr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "Create a remailer structure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ADDR is the remailer's Email address, a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ID is the remailer's public key ID (a string) or nil if the same as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ADDR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 PROPS is a list of properties, as strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 PRE-ENCR is a list of pre-encryption functions. Its elements will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 called with the remailer structure itself as argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 POST-ENCR is similar, but for post-encryption functions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (list 'remailer addr id props pre-encr post-encr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defsubst mc-remailerp (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "Test whether REMAILER is a valid remailer struct."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (and (listp remailer) (eq 'remailer (car-safe remailer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defsubst mc-remailer-address (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "Return the Email address of REMAILER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (nth 1 remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defsubst mc-remailer-userid (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "Return the userid with which to look up the public key for REMAILER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (or (nth 2 remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (mc-strip-address (mc-remailer-address remailer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defsubst mc-remailer-properties (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Return the property list for REMAILER"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (nth 3 remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defsubst mc-remailer-pre-encrypt-hooks (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "Return the list of pre-encryption hooks for REMAILER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (nth 4 remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defsubst mc-remailer-post-encrypt-hooks (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "Return the list of post-encryption hooks for REMAILER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (nth 5 remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defun mc-remailer-remove-property (remailer prop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (let ((props (append (mc-remailer-properties remailer) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq props (delete prop props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (mc-remailer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (mc-remailer-address remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (mc-remailer-userid remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 props
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (mc-remailer-pre-encrypt-hooks remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (mc-remailer-post-encrypt-hooks remailer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;{{{ User variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defvar mc-response-block-included-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 '("From" "To" "Newsgroups")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 "List of header fields to include in response blocks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 These will be copied into the deepest layer of the response block to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 help you identify it when it is used to Email you.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defvar mc-remailer-tag "(*REMAILER*)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "A string which marks an Email address as belonging to a remailer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defvar mc-levien-file-name "~/.remailers"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "The file containing a Levien format list of remailers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 The file is read by `mc-read-levien-file' and `mc-reread-levien-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 The file should include lines of the following form (other lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 are ignored):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 $remailer{\"NAME\"} = \"<EMAIL ADDRESS> PROPERTIES\";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 PROPERTIES is a space-separated set of strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 This format is named after Raphael Levien, who maintains a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 active remailers. Do \"finger remailer-list@kiwi.cs.berkeley.edu\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 for the latest copy of his list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defvar mc-remailer-user-chains nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 "An alist of remailer chains defined by the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 Format is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ((NAME . REMAILER-LIST)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (NAME . REMAILER-LIST)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 NAME must be a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 REMAILER-LIST may be an arbitrary sequence, not just a list. Its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 elements may be any of the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 1) A remailer structure created by `mc-remailer-create'. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 the base case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 2) A string naming another remailer chain to be spliced in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 at this point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 3) A positive integer N representing a chain to be spliced in at this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 point and consisting of a random permutation of the top N remailers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 as ordered in the file `mc-levien-file-name'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 4) An arbitrary Lisp form to be evaluated, which should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 return another REMAILER-LIST to be recursively processed and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 spliced in at this point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 The complete alist of chains is given by the union of the two lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 `mc-remailer-internal-chains' and `mc-remailer-user-chains'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defvar mc-remailer-internal-chains nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "List of \"internal\" remailer chains.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 This variable is normally generated automatically from a human-readable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 list of remailers; see, for example, the function `mc-reread-levien-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 To define your own chains, you probably want to use the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 `mc-remailer-user-chains'. See that variable's documentation for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 format information.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar mc-remailer-internal-ranking nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "Ordered list of remailers, most reliable first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 This variable is normally generated automatically from a human-readable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 list of remailers; see, for example, the function `mc-reread-levien-file'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (defvar mc-remailer-user-response-block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (lambda (addr lines block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ";;;\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "To reply to this message, take the following %d-line block, remove\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "leading \"- \" constructs (if any), and place it at the top of a\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (format "message to %s :\n" addr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 block)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "A function called to generate response block text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 Value should be a function taking three arguments (ADDR LINES BLOCK).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ADDR is the address to which the response should be sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 LINES is the number of lines in the encrypted response block.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 BLOCK is the response block itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 Function should return a string to be inserted into the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 by mc-remailer-insert-response-block.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (defvar mc-remailer-pseudonyms nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 "*A list of your pseudonyms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 This is a list of strings. Completion against it will be available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 when you are prompted for your pseudonym.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (defvar mc-remailer-preserved-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 '("References" "Followup-to" "In-reply-to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 "*Header fields which are preserved as hashmark headers when rewriting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 This is a list of strings naming the preserved headers. Note that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 \"Subject\", \"Newsgroups\", and \"To\" are handled specially and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 should not be included in this list.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;{{{ Handling Levien format remailer lists
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun mc-parse-levien-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; Parse a buffer in Levien format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (let (chains remailer remailer-name ranking)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "^\\$remailer{\"\\(.+\\)\"}[ \t]*=[ \t]*\"\\(.*\\)\";"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (let ((name (buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 property-list address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (value-start (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (value-end (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (goto-char value-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (while (re-search-forward "[^ \t]+" value-end 'no-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (setq property-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 property-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (list (buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (match-beginning 0) (match-end 0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (setq address (car property-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 property-list (cdr property-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 remailer-name name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (if (not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (or (member "mix" property-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (and (or (member "pgp" property-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (member "pgp." property-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (or (member "cpunk" property-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (member "eric" property-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq remailer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (setq remailer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (mc-remailer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 address ; Address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (if (member "pgp." property-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 name) ; User ID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 property-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 '(mc-generic-pre-encrypt-function) ; Pre-encrypt hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 '(mc-generic-post-encrypt-function) ; Post-encrypt hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (if (not (null remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq chains (cons (list remailer-name remailer) chains))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if (re-search-forward "----------" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (while (re-search-forward "^\\([a-zA-Z0-9\\-]+\\) " nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq remailer-name (buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (assoc remailer-name chains)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq ranking (append ranking (list remailer-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (cons chains ranking)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defun mc-read-levien-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 "Read the Levien format file specified in `mc-levien-file-name'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 Return an alist of length-1 chains, one for each remailer, named
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 after the remailer. Only include remailers supporting PGP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 encryption."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (if (file-readable-p mc-levien-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (prog2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (find-file-read-only mc-levien-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (mc-parse-levien-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (bury-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (defun mc-reread-levien-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "Read the Levien format file specified in `mc-levien-file-name'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 Place result in `mc-remailer-internal-chains' and `mc-remailer-internal-ranking'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 See the documentation for the variable `mc-levien-file-name' for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 a description of Levien file format."
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 ((parsed-levien-file (mc-read-levien-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setq mc-remailer-internal-chains (car parsed-levien-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 mc-remailer-internal-ranking (cdr parsed-levien-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;;{{{ Arbitrary chain choice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defun mc-remailer-choose-first (n &optional l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ((= n 0) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ((null l) (mc-remailer-choose-first n mc-remailer-internal-ranking))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (t (cons (car l) (mc-remailer-choose-first (1- n) (cdr l))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defun mc-remailer-choose-chain (n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (if (null mc-remailer-internal-ranking)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (error "No ranking information, cannot choose the %d best remailer%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 n (if (> n 1) "s" "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (append (shuffle-vector (vconcat (mc-remailer-choose-first n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;;{{{ Canonicalization function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (defun mc-remailer-canonicalize-elmt (elmt chains-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ((mc-remailerp elmt) (list elmt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ((stringp elmt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (mc-remailer-canonicalize-chain (cdr (assoc elmt chains-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 chains-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ((integerp elmt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (mc-remailer-canonicalize-chain (mc-remailer-choose-chain elmt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 chains-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (t (mc-remailer-canonicalize-chain (eval elmt) chains-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (defun mc-remailer-canonicalize-chain (chain &optional chains-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; Canonicalize a remailer chain with respect to CHAINS-ALIST.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; That is, use CHAINS-ALIST to resolve strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;; Here is where we implement the functionality described in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; the documentation for the variable `mc-remailer-user-chains'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (if (null chains-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq chains-alist (mc-remailer-make-chains-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ((null chain) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;; Handle case where chain is actually a string or a single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; remailer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ((or (stringp chain) (mc-remailerp chain) (integerp chain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (mc-remailer-canonicalize-elmt chain chains-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (let ((first (elt chain 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (rest (cdr (append chain nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (mc-remailer-canonicalize-elmt first chains-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (mc-remailer-canonicalize-chain rest chains-alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;;{{{ Auxiliaries for mail header munging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defsubst mc-nuke-field (field &optional bounds)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; Delete all fields exactly matching regexp FIELD from header,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; bounded by BOUNDS. Default is entire visible region of buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (mc-get-fields field bounds t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (defun mc-replace-field (field-name replacement header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (if (not (string-match "^[ \t]" replacement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (setq replacement (concat " " replacement)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (if (not (string-match "\n$" replacement))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (setq replacement (concat replacement "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (field-regexp (regexp-quote field-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (narrow-to-region (car header) (cdr header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (concat "^" field-regexp ":" mc-field-body-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (mc-nuke-field field-regexp header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (insert field-name ":" replacement)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defun mc-find-main-header (&optional ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; Find the main header of the mail message; return as a pair of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;; markers (START . END).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (cons (copy-marker (point-min)) (copy-marker (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (defun mc-find-colon-header (&optional insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; Find the header with a "::" immediately after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; mail-header-separator. Return region enclosing header. Optional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; arg INSERT means insert the header if it does not exist already.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (if (or (and (looking-at "::\n") (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (and insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (insert-before-markers "::\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (forward-line -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (re-search-forward "^$" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (cons (copy-marker start) (copy-marker (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defun mc-find-hash-header (&optional insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (concat "^" (regexp-quote mail-header-separator) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (if (or (and (looking-at "##\n") (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (and (looking-at "::\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (re-search-forward "^\n" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (looking-at "##\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (and insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (insert-before-markers "##\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (forward-line -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (re-search-forward "^$" nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (cons (copy-marker start) (copy-marker (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defsubst mc-replace-main-field (field replacement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (mc-replace-field field replacement (mc-find-main-header t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (defsubst mc-replace-hash-field (field replacement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (mc-replace-field field replacement (mc-find-hash-header t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (defsubst mc-replace-colon-field (field replacement)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (mc-replace-field field replacement (mc-find-colon-header t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (defun mc-recipient-is-remailerp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (let ((to (mc-get-fields "To" (mc-find-main-header))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (and to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (string-match (regexp-quote mc-remailer-tag) (cdr (car to))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;;{{{ Pre-encryption and post-encryption hook defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (defun mc-generic-post-encrypt-function (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (let ((main-header (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (colon-header (mc-find-colon-header t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (mc-replace-field "Encrypted" "PGP" colon-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (mc-replace-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "To"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (concat (mc-remailer-address remailer) " " mc-remailer-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 main-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun mc-generic-pre-encrypt-function (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (let ((addr (mc-remailer-address remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (props (mc-remailer-properties remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (main-header (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (colon-header (mc-find-colon-header t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 to to-field preserved-regexp preserved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (setq preserved-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (mc-disjunction-regexp mc-remailer-preserved-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq preserved (mc-get-fields preserved-regexp main-header t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (if preserved (goto-char (cdr (mc-find-hash-header t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (lambda (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (insert (car c) ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (mc-eliminate-continuation-lines (cdr c)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 preserved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (if (and (mc-find-hash-header) (not (member "hash" props)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (error "Remailer %s does not support hashmarks" addr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (if (mc-get-fields "Newsgroups" main-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (cond ((not (member "post" props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (error "Remailer %s does not support posting" addr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ((not (member "hash" props))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (error "Remailer %s does not support hashmarks" addr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (t (mc-rewrite-news-to-mail remailer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (and (featurep 'mailalias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (not (featurep 'mail-abbrevs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (expand-mail-aliases (car main-header) (cdr main-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (setq to (mc-strip-addresses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (mapcar 'cdr (mc-get-fields "To" main-header))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (if (string-match "," to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (error "Remailer %s does not support multiple recipients." addr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (setq to-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (if (mc-get-fields "From" colon-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 "Send-To"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ((member "eric" props) "Anon-Send-To")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ((member "cpunk" props) "Request-Remailing-To")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (t (error "Remailer %s is not type-1" addr)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (mc-replace-field to-field to colon-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (mc-nuke-field "Reply-to" main-header))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;;{{{ Misc. random
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defun mc-disjunction-regexp (regexps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;; Take a list of regular expressions and return a single
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; regular expression which matches anything that any of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; original regexps match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (concat "\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (mapconcat 'identity regexps "\\)\\|\\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 "\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (defun mc-user-mail-address ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 "Figure out the user's Email address as best we can."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (mc-strip-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (cond ((and (boundp 'gnus-user-from-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (stringp gnus-user-from-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 gnus-user-from-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ((stringp mail-default-reply-to) mail-default-reply-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ((boundp 'user-mail-address) user-mail-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (t (concat (user-login-name) "@" (system-name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (defun mc-eliminate-continuation-lines (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (while (string-match "\n[\t ]+" string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (setq string (replace-match " " t nil string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (defun mc-remailer-make-chains-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (if (null mc-remailer-internal-chains)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (mc-reread-levien-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (append mc-remailer-internal-chains mc-remailer-user-chains))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (defun mc-remailer-insert-pseudonym ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 "Insert pseudonym as a From field in the hash-mark header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 See the documentation for the variable `mc-remailer-pseudonyms' for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 more information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (let ((completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 pseudonym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (setq pseudonym
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (cond ((null mc-remailer-pseudonyms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (read-from-minibuffer "Pseudonym: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (completing-read "Pseudonym: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (mapcar 'list mc-remailer-pseudonyms)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (if (not (string-match "\\S +@\\S +" pseudonym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (setq pseudonym (concat pseudonym " <x@x.x>")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (mc-replace-colon-field "From" pseudonym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;;{{{ Mixmaster support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (defvar mc-mixmaster-path nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 "*Path to the Mixmaster binary. If defined, Mixmaster chains will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 be passed to this program for rewriting.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (defvar mc-mixmaster-list-path nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "*Path to the Mixmaster type2.list file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (defun mc-demix (&rest chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 "Use arguments as a remailer-list and return a new list with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 \"mix\" property removed from all the elements."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (mapcar (function (lambda (r) (mc-remailer-remove-property r "mix")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (mc-remailer-canonicalize-chain chain)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (defun mc-mixmaster-process (beg end recipients preserved mix-chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; Run a region through Mixmaster.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (let (ret)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (if (not (markerp end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (setq end (copy-marker end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (mapcar (function (lambda (x) (insert x ?\n))) recipients)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (mapcar (function (lambda (x) (insert x))) preserved)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (setq mix-chain (mapcar (function (lambda (x) (format "%d" x))) mix-chain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;; Handle case of empty message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (if (< end (point)) (setq end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (setq ret
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (apply 'call-process-region beg end mc-mixmaster-path t t nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 "-f" "-o" "stdout" "-l" mix-chain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (if (not (eq ret 0)) (error "Mixmaster barfed."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (re-search-forward "^::$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (delete-region beg (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defun mc-mixmaster-build-alist (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;; Construct an alist mapping Mixmaster Email addresses to integers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ;; FIXME; this is terrible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (let (buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (setq n (or n 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (setq buf (find-file-noselect mc-mixmaster-list-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (if (re-search-forward "^[^ \t]+[ \t]+\\([^ \t]+\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (cons (cons (buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (mc-mixmaster-build-alist (+ n 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (if buf (kill-buffer buf))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (defvar mc-mixmaster-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (defsubst mc-mixmaster-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (or mc-mixmaster-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq mc-mixmaster-alist (mc-mixmaster-build-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defun mc-mixmaster-translate-chain (chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;; Take a chain of Mixmaster remailers and convert it to the list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; of integers which represents them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (if (or (null chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (not (member "mix" (mc-remailer-properties (car chain)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (cons (cdr (assoc (mc-strip-address (mc-remailer-address (car chain)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (mc-mixmaster-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (mc-mixmaster-translate-chain (cdr chain)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun mc-mixmaster-skip (chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;; Return the largest possible suffix of CHAIN whose first element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; is not a Mixmaster.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (cond ((null chain) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ((not (member "mix" (mc-remailer-properties (car chain))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (t (mc-mixmaster-skip (cdr chain)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (defun mc-rewrite-for-mixmaster (chain &optional pause)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;; Rewrite the current mail buffer for a chain of Mixmasters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (let ((mix-chain (mc-mixmaster-translate-chain chain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (main-header (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (colon-header (mc-find-colon-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (hash-header (mc-find-hash-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 recipients preserved newsgroups first last rest preserved-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 ;; Figure out FIRST and LAST. FIRST is the first Mixmaster in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; chain. LAST is the last.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (setq first (car chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 rest chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (while (and rest (member "mix" (mc-remailer-properties (car rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (setq last (car rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 rest (cdr rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;; If recipient is not a remailer, deal with hashmark and colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;; headers and get rid of them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (if (mc-recipient-is-remailerp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (if hash-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (setq preserved (mc-get-fields nil hash-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (goto-char (car hash-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (delete-region (point) (+ (cdr hash-header) 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;; Preserve pseduonym line...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (if colon-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (setq preserved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (append (mc-get-fields "From" colon-header) preserved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (goto-char (car colon-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (delete-region (point) (+ (cdr colon-header) 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; Expand aliases and get recipients.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (and (featurep 'mailalias)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (not (featurep 'mail-abbrevs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 mail-aliases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (expand-mail-aliases (car main-header) (cdr main-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (setq recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (mc-cleanup-recipient-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (mapconcat 'cdr (mc-get-fields "To" main-header t) ", ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (setq newsgroups (mc-get-fields "Newsgroups" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;; Mixmaster does not support posting...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;;; (if (and newsgroups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;;; (not (member "post" (mc-remailer-properties last))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (if newsgroups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (error "Remailer %s does not support posting"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (mc-remailer-address last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 recipients
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (append (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (function (lambda (c) (concat "Post:" (cdr c)))) newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 recipients))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 preserved-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (mc-disjunction-regexp (cons "Subject" mc-remailer-preserved-headers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (setq preserved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (append (mc-get-fields preserved-regexp main-header t) preserved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ;; Convert preserved header alist to simple list of strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (setq preserved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (lambda (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (concat (car c) ":"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (mc-eliminate-continuation-lines (cdr c)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 preserved))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ;; Do the conversion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (goto-char (cdr main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (mc-mixmaster-process (point) (point-max) recipients preserved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 mix-chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (mc-replace-field "To"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (mc-remailer-address first) " " mc-remailer-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 main-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;;{{{ High level message rewriting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (defun mc-rewrite-news-to-mail (remailer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (let ((main-header (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 newsgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (setq newsgroups (mc-get-fields "Newsgroups" main-header t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (mc-replace-colon-field "Post-To" (cdr (car newsgroups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (mail-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (defun mc-rewrite-for-remailer (remailer &optional pause)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;; Rewrite the current mail buffer for a single remailer. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;; includes running the pre-encryption hooks, modifying the To:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; field, encrypting with the remailer's public key, and running the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; post-encryption hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (let ((addr (mc-remailer-address remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (main-header (mc-find-main-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;; If recipient is already a remailer, make sure the "::" and "##"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ;; headers get to it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (if (mc-recipient-is-remailerp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (goto-char (cdr main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (insert "::\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (function (lambda (hook) (funcall hook remailer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (mc-remailer-pre-encrypt-hooks remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;; Move "Subject" lines down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (goto-char (car (mc-find-colon-header t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (function (lambda (f) (insert (car f) ":" (cdr f))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (mc-get-fields "Subject" main-header t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (if pause
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (let ((cursor-in-echo-area t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (message "SPC to encrypt for %s : " addr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (read-char-exclusive)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (setq main-header (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (goto-char (cdr main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (if (let ((mc-pgp-always-sign 'never)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (mc-encrypt-for-me nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (mc-encrypt-message (mc-remailer-userid remailer) nil (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (function (lambda (hook) (funcall hook remailer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 (mc-remailer-post-encrypt-hooks remailer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (mc-nuke-field "Comment")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (mc-nuke-field "From"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (error "Unable to encrypt message to %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (mc-remailer-userid remailer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (defun mc-rewrite-for-chain (chain &optional pause)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;; Rewrite the current buffer for a chain of remailers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;; CHAIN must be in canonical form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (let (rest)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (if mc-mixmaster-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (setq rest (mc-mixmaster-skip chain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (setq rest chain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (if (null chain) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (mc-rewrite-for-chain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (if (eq rest chain) (cdr rest) rest) pause)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (if (eq rest chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (mc-rewrite-for-remailer (car chain) pause)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (mc-rewrite-for-mixmaster chain pause)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (defun mc-unparse-chain (chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ;; Unparse CHAIN into a string suitable for printing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (if (null chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (concat (mc-remailer-address (car chain)) "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (mc-unparse-chain (cdr chain)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (defun mc-disallow-field (field &optional header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if (null header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (setq header (mc-find-main-header)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (goto-char (car header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (if (re-search-forward (concat "^" (regexp-quote field) ":")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (cdr header) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (error "Cannot use a %s field." field)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (defun mc-remailer-encrypt-for-chain (&optional pause)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 "Encrypt message for a remailer chain, prompting for chain to use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 With \\[universal-argument], pause before each encryption."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (let ((chains (mc-remailer-make-chains-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (buffer (get-buffer-create mc-buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 chain-name chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (mc-disallow-field "CC")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (mc-disallow-field "FCC")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (mc-disallow-field "BCC")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (setq chain-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 "Choose a remailer or chain: " chains nil 'strict-match))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (setq chain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (mc-remailer-canonicalize-chain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (cdr (assoc chain-name chains))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 chains))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (mc-rewrite-for-chain chain pause)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (if chain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (insert "Rewritten for chain `" chain-name "':\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (mc-unparse-chain chain))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (message "Done. See %s buffer for details." mc-buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 ;;}}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 ;;{{{ Response block generation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (defun mc-remailer-insert-response-block (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 "Insert response block at point, prompting for chain to use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 With \\[universal-argument], enter a recursive edit of the innermost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 layer of the block before encrypting it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (let (buf main-header to addr block lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (setq buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (mc-remailer-make-response-block (if (> arg 1) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (setq main-header (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (setq to (cdr (car (mc-get-fields "To" main-header))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (setq addr (concat "<" (mc-strip-address to) ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (goto-char (cdr main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (setq block (buffer-substring-no-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 lines (count-lines (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (kill-buffer buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (let ((opoint (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (insert (funcall mc-remailer-user-response-block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 addr lines block))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (goto-char opoint))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (mc-nuke-field "Reply-to" (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (mc-replace-hash-field "Reply-to" addr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defun mc-remailer-make-response-block (&optional recurse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; Return a buffer which contains a response block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; for the user, and a To: header for the remailer to use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (let ((buf (generate-new-buffer " *Remailer Response Block*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (original-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (mc-mixmaster-path nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 all-headers included-regexp included)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (setq all-headers (mc-find-main-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (setcdr all-headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (max
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (cdr all-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (or (cdr-safe (mc-find-colon-header)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (or (cdr-safe (mc-find-hash-header)) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 included-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (mc-disjunction-regexp mc-response-block-included-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (setq included (mc-get-fields included-regexp all-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (insert "To: " (mc-user-mail-address) "\n" mail-header-separator "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (insert ";; Response block created " (current-time-string) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (mapcar (function (lambda (c) (insert "; " (car c) ":" (cdr c))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 included)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (if recurse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (switch-to-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (message "Editing response block ; %s when done."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (substitute-command-keys "\\[exit-recursive-edit]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (recursive-edit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (mc-remailer-encrypt-for-chain)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (switch-to-buffer original-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;;}}}