Mercurial > emacs
annotate lisp/mail/hashcash.el @ 94943:9a4044b9c084
Throughout the file, delete all USE_FONT_BACKEND
conditionals. Don't check enable_font_backend. Delete all codes
used only when USE_FONT_BACKEND is not defined. Don't include
ccl.h.
(x_per_char_metric, x_encode_char): Deleted.
(x_set_cursor_gc, x_set_mouse_face_gc): Don't set GCFont.
(x_compute_glyph_string_overhangs): Adjusted for the change of
`struct face'
(x_draw_glyph_string_foreground)
(x_draw_composite_glyph_string_foreground): Likewise.
(x_draw_glyph_string): Likewise. Use font->underline_position and
font->underline_thickness.
(x_new_font): Renamed from x_new_fontset2.
(x_new_fontset, x_get_font_info, x_list_fonts): Deleted.
(x_check_font): Call `check' method of a font driver.
(x_font_min_bounds, x_compute_min_glyph_bounds, x_load_font)
(x_query_font, x_get_font_repertory): Deleted.
(x_find_ccl_program): Renamed and moved to xfont.c.
(x_redisplay_interface): Adjusted for the change of `struct
redisplay_interface'.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 14 May 2008 01:44:51 +0000 |
parents | ef65fa4dca3b |
children | d5afbae3de1f |
rev | line source |
---|---|
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
1 ;;; hashcash.el --- Add hashcash payments to email |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
2 |
87665 | 3 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
4 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
5 ;; Written by: Paul Foley <mycroft@actrix.gen.nz> (1997-2002) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
6 ;; Maintainer: Paul Foley <mycroft@actrix.gen.nz> |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
7 ;; Keywords: mail, hashcash |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
8 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
10 |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
15 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
23 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
24 ;;; Commentary: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
25 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
26 ;; The hashcash binary is at http://www.hashcash.org/. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
27 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
28 ;; Call mail-add-payment to add a hashcash payment to a mail message |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
29 ;; in the current buffer. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
30 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
31 ;; Call mail-add-payment-async after writing the addresses but before |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
32 ;; writing the mail to start calculating the hashcash payment |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
33 ;; asynchronously. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
34 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
35 ;; The easiest way to do this automatically for all outgoing mail |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
36 ;; is to set `message-generate-hashcash' to t. If you want more |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
37 ;; control, try the following hooks. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
38 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
39 ;; To automatically add payments to all outgoing mail when sending: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
40 ;; (add-hook 'message-send-hook 'mail-add-payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
41 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
42 ;; To start calculations automatically when addresses are prefilled: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
43 ;; (add-hook 'message-setup-hook 'mail-add-payment-async) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
44 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
45 ;; To check whether calculations are done before sending: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
46 ;; (add-hook 'message-send-hook 'hashcash-wait-or-cancel) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
47 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
48 ;;; Code: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
49 |
87186
b37f01064ecf
* mail/hashcash.el (declare-function):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86503
diff
changeset
|
50 (eval-and-compile |
b37f01064ecf
* mail/hashcash.el (declare-function):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86503
diff
changeset
|
51 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) |
b37f01064ecf
* mail/hashcash.el (declare-function):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86503
diff
changeset
|
52 |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
53 (defgroup hashcash nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
54 "Hashcash configuration." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
55 :group 'mail) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
56 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
57 (defcustom hashcash-default-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
58 "*The default number of bits to pay to unknown users. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
59 If this is zero, no payment header will be generated. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
60 See `hashcash-payment-alist'." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
61 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
62 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
63 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
64 (defcustom hashcash-payment-alist '() |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
65 "*An association list mapping email addresses to payment amounts. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
66 Elements may consist of (ADDR AMOUNT) or (ADDR STRING AMOUNT), where |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
67 ADDR is the email address of the intended recipient and AMOUNT is |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
68 the value of hashcash payment to be made to that user. STRING, if |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
69 present, is the string to be hashed; if not present ADDR will be used." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
70 :type '(repeat (choice (list :tag "Normal" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
71 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
72 (integer :name "Amount")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
73 (list :tag "Replace hash input" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
74 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
75 (string :name "Hash input") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
76 (integer :name "Amount")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
77 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
78 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
79 (defcustom hashcash-default-accept-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
80 "*The default minimum number of bits to accept on incoming payments." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
81 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
82 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
83 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
84 (defcustom hashcash-accept-resources `((,user-mail-address nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
85 "*An association list mapping hashcash resources to payment amounts. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
86 Resources named here are to be accepted in incoming payments. If the |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
87 corresponding AMOUNT is NIL, the value of `hashcash-default-accept-payment' |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
88 is used instead." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
89 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
90 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
91 (defcustom hashcash-path (executable-find "hashcash") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
92 "*The path to the hashcash binary." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
93 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
94 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
95 (defcustom hashcash-extra-generate-parameters nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
96 "*A list of parameter strings passed to `hashcash-path' when minting. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
97 For example, you may want to set this to '(\"-Z2\") to reduce header length." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
98 :type '(repeat string) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
99 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
100 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
101 (defcustom hashcash-double-spend-database "hashcash.db" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
102 "*The path to the double-spending database." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
103 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
104 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
105 (defcustom hashcash-in-news nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
106 "*Specifies whether or not hashcash payments should be made to newsgroups." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
107 :type 'boolean |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
108 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
109 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
110 (defvar hashcash-process-alist nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
111 "Alist of asynchronous hashcash processes and buffers.") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
112 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
113 (require 'mail-utils) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
114 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
115 (eval-and-compile |
87209 | 116 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))) |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
117 |
87209 | 118 (if (fboundp 'point-at-bol) |
119 (defalias 'hashcash-point-at-bol 'point-at-bol) | |
120 (defalias 'hashcash-point-at-bol 'line-beginning-position)) | |
121 | |
122 (if (fboundp 'point-at-eol) | |
123 (defalias 'hashcash-point-at-eol 'point-at-eol) | |
124 (defalias 'hashcash-point-at-eol 'line-end-position))) | |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
125 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
126 (defun hashcash-strip-quoted-names (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
127 (setq addr (mail-strip-quoted-names addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
128 (if (and addr (string-match "\\`\\([^+@]+\\)\\+[^@]*\\(@.+\\)" addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
129 (concat (match-string 1 addr) (match-string 2 addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
130 addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
131 |
86503
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
132 (declare-function message-narrow-to-headers-or-head "message" ()) |
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
133 (declare-function message-fetch-field "message" (header &optional not-all)) |
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
134 (declare-function message-goto-eoh "message" ()) |
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
135 (declare-function message-narrow-to-headers "message" ()) |
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
136 |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
137 (defun hashcash-token-substring () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
138 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
139 (let ((token "")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
140 (loop |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
141 (setq token |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
142 (concat token (buffer-substring (point) (hashcash-point-at-eol)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
143 (goto-char (hashcash-point-at-eol)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
144 (forward-char 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
145 (unless (looking-at "[ \t]") (return token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
146 (while (looking-at "[ \t]") (forward-char 1)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
147 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
148 (defun hashcash-payment-required (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
149 "Return the hashcash payment value required for the given address." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
150 (let ((val (assoc addr hashcash-payment-alist))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
151 (or (nth 2 val) (nth 1 val) hashcash-default-payment))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
152 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
153 (defun hashcash-payment-to (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
154 "Return the string with which hashcash payments should collide." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
155 (let ((val (assoc addr hashcash-payment-alist))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
156 (or (nth 1 val) (nth 0 val) addr))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
157 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
158 (defun hashcash-generate-payment (str val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
159 "Generate a hashcash payment by finding a VAL-bit collison on STR." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
160 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
161 hashcash-path) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
162 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
163 (set-buffer (get-buffer-create " *hashcash*")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
164 (erase-buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
165 (apply 'call-process hashcash-path nil t nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
166 "-m" "-q" "-b" (number-to-string val) str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
167 hashcash-extra-generate-parameters) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
168 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
169 (hashcash-token-substring)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
170 (error "No `hashcash' binary found"))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
171 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
172 (defun hashcash-generate-payment-async (str val callback) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
173 "Generate a hashcash payment by finding a VAL-bit collison on STR. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
174 Return immediately. Call CALLBACK with process and result when ready." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
175 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
176 hashcash-path) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
177 (let ((process (apply 'start-process "hashcash" nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
178 hashcash-path "-m" "-q" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
179 "-b" (number-to-string val) str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
180 hashcash-extra-generate-parameters))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
181 (setq hashcash-process-alist (cons |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
182 (cons process (current-buffer)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
183 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
184 (set-process-filter process `(lambda (process output) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
185 (funcall ,callback process output)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
186 (funcall callback nil nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
187 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
188 (defun hashcash-check-payment (token str val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
189 "Check the validity of a hashcash payment." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
190 (if hashcash-path |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
191 (zerop (call-process hashcash-path nil nil nil "-c" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
192 "-d" "-f" hashcash-double-spend-database |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
193 "-b" (number-to-string val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
194 "-r" str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
195 token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
196 (progn |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
197 (message "No hashcash binary found") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
198 (sleep-for 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
199 nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
200 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
201 (defun hashcash-version (token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
202 "Find the format version of a hashcash token." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
203 ;; Version 1.2 looks like n:yymmdd:rrrrr:xxxxxxxxxxxxxxxx |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
204 ;; This carries its own version number embedded in the token, |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
205 ;; so no further format number changes should be necessary |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
206 ;; in the X-Payment header. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
207 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
208 ;; Version 1.1 looks like yymmdd:rrrrr:xxxxxxxxxxxxxxxx |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
209 ;; You need to upgrade your hashcash binary. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
210 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
211 ;; Version 1.0 looked like nnnnnrrrrrxxxxxxxxxxxxxxxx |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
212 ;; This is no longer supported. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
213 (cond ((equal (aref token 1) ?:) 1.2) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
214 ((equal (aref token 6) ?:) 1.1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
215 (t (error "Unknown hashcash format version")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
216 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
217 (defun hashcash-already-paid-p (recipient) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
218 "Check for hashcash token to RECIPIENT in current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
219 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
220 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
221 (message-narrow-to-headers-or-head) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
222 (let ((token (message-fetch-field "x-hashcash")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
223 (case-fold-search t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
224 (and (stringp token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
225 (string-match (regexp-quote recipient) token)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
226 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
227 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
228 (defun hashcash-insert-payment (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
229 "Insert X-Payment and X-Hashcash headers with a payment for ARG" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
230 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
231 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
232 (let ((pay (hashcash-generate-payment (hashcash-payment-to arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
233 (hashcash-payment-required arg)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
234 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
235 (insert-before-markers "X-Hashcash: " pay "\n"))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
236 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
237 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
238 (defun hashcash-insert-payment-async (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
239 "Insert X-Payment and X-Hashcash headers with a payment for ARG |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
240 Only start calculation. Results are inserted when ready." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
241 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
242 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
243 (hashcash-generate-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
244 (hashcash-payment-to arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
245 (hashcash-payment-required arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
246 `(lambda (process payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
247 (hashcash-insert-payment-async-2 ,(current-buffer) process payment))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
248 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
249 (defun hashcash-insert-payment-async-2 (buffer process pay) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
250 (when (buffer-live-p buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
251 (with-current-buffer buffer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
252 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
253 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
254 (setq hashcash-process-alist (delq |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
255 (assq process hashcash-process-alist) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
256 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
257 (message-goto-eoh) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
258 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
259 (insert-before-markers "X-Hashcash: " pay))))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
260 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
261 (defun hashcash-cancel-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
262 "Delete any hashcash processes associated with BUFFER. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
263 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
264 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
265 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
266 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
267 (while (setq entry (rassq buffer hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
268 (delete-process (car entry)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
269 (setq hashcash-process-alist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
270 (delq entry hashcash-process-alist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
271 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
272 (defun hashcash-wait-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
273 "Wait for asynchronous hashcash processes in BUFFER to finish. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
274 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
275 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
276 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
277 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
278 (while (setq entry (rassq buffer hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
279 (accept-process-output (car entry))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
280 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
281 (defun hashcash-processes-running-p (buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
282 "Return non-nil if hashcash processes in BUFFER are still running." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
283 (rassq buffer hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
284 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
285 (defun hashcash-wait-or-cancel () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
286 "Ask user whether to wait for hashcash processes to finish." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
287 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
288 (when (hashcash-processes-running-p (current-buffer)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
289 (if (y-or-n-p |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
290 "Hashcash process(es) still running; wait for them to finish? ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
291 (hashcash-wait-async) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
292 (hashcash-cancel-async)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
293 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
294 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
295 (defun hashcash-verify-payment (token &optional resource amount) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
296 "Verify a hashcash payment" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
297 (let* ((split (split-string token ":")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
298 (key (if (< (hashcash-version token) 1.2) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
299 (nth 1 split) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
300 (case (string-to-number (nth 0 split)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
301 (0 (nth 2 split)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
302 (1 (nth 3 split)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
303 (cond ((null resource) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
304 (let ((elt (assoc key hashcash-accept-resources))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
305 (and elt (hashcash-check-payment token (car elt) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
306 (or (cadr elt) hashcash-default-accept-payment))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
307 ((equal token key) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
308 (hashcash-check-payment token resource |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
309 (or amount hashcash-default-accept-payment))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
310 (t nil)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
311 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
312 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
313 (defun mail-add-payment (&optional arg async) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
314 "Add X-Payment: and X-Hashcash: headers with a hashcash payment |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
315 for each recipient address. Prefix arg sets default payment temporarily. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
316 Set ASYNC to t to start asynchronous calculation. (See |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
317 `mail-add-payment-async')." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
318 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
319 (let ((hashcash-default-payment (if arg (prefix-numeric-value arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
320 hashcash-default-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
321 (addrlist nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
322 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
323 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
324 (message-narrow-to-headers) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
325 (let ((to (hashcash-strip-quoted-names (mail-fetch-field "To" nil t))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
326 (cc (hashcash-strip-quoted-names (mail-fetch-field "Cc" nil t))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
327 (ng (hashcash-strip-quoted-names (mail-fetch-field "Newsgroups" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
328 nil t)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
329 (when to |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
330 (setq addrlist (split-string to ",[ \t\n]*"))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
331 (when cc |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
332 (setq addrlist (nconc addrlist (split-string cc ",[ \t\n]*")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
333 (when (and hashcash-in-news ng) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
334 (setq addrlist (nconc addrlist (split-string ng ",[ \t\n]*"))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
335 (when addrlist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
336 (mapc (if async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
337 #'hashcash-insert-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
338 #'hashcash-insert-payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
339 addrlist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
340 t) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
341 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
342 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
343 (defun mail-add-payment-async (&optional arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
344 "Add X-Payment: and X-Hashcash: headers with a hashcash payment |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
345 for each recipient address. Prefix arg sets default payment temporarily. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
346 Calculation is asynchronous." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
347 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
348 (mail-add-payment arg t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
349 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
350 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
351 (defun mail-check-payment (&optional arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
352 "Look for a valid X-Payment: or X-Hashcash: header. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
353 Prefix arg sets default accept amount temporarily." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
354 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
355 (let ((hashcash-default-accept-payment (if arg (prefix-numeric-value arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
356 hashcash-default-accept-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
357 (version (hashcash-version (hashcash-generate-payment "x" 1)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
358 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
359 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
360 (search-forward "\n\n") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
361 (beginning-of-line) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
362 (let ((end (point)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
363 (ok nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
364 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
365 (while (and (not ok) (search-forward "X-Payment: hashcash " end t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
366 (let ((value (split-string (hashcash-token-substring) " "))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
367 (when (equal (car value) (number-to-string version)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
368 (setq ok (hashcash-verify-payment (cadr value)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
369 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
370 (while (and (not ok) (search-forward "X-Hashcash: " end t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
371 (setq ok (hashcash-verify-payment (hashcash-token-substring)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
372 (when ok |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
373 (message "Payment valid")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
374 ok)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
375 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
376 (provide 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
377 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87665
diff
changeset
|
378 ;; arch-tag: 0e7fe983-a124-4392-9788-0dbcbd2c4d62 |