Mercurial > emacs
annotate lisp/mail/hashcash.el @ 104522:2a2b8ae24b17
* cedet/semantic/symref/list.el: Require semantic/complete.
(semantic-symref-symbol): Use
semantic-complete-read-tag-buffer-deep.
* cedet/semantic/ia.el (semantic-ia-complete-symbol-menu): Remove.
(semantic-ia-complete-symbol): Use semantic-complete-symbol.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 27 Sep 2009 03:59:51 +0000 |
parents | a9dc0e7c3f2b |
children | 328150f0cf76 |
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 |
100908 | 3 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 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 |
96184 | 53 (eval-when-compile (require 'cl)) ; for case |
54 | |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
55 (defgroup hashcash nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
56 "Hashcash configuration." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
57 :group 'mail) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
58 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
59 (defcustom hashcash-default-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
60 "*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
|
61 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
|
62 See `hashcash-payment-alist'." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
63 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
64 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
65 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
66 (defcustom hashcash-payment-alist '() |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
67 "*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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 :type '(repeat (choice (list :tag "Normal" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
73 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
74 (integer :name "Amount")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
75 (list :tag "Replace hash input" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
76 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
77 (string :name "Hash input") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
78 (integer :name "Amount")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
79 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
80 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
81 (defcustom hashcash-default-accept-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
82 "*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
|
83 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
84 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
85 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
86 (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
|
87 "*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
|
88 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
|
89 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
|
90 is used instead." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
91 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
92 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
93 (defcustom hashcash-path (executable-find "hashcash") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
94 "*The path to the hashcash binary." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
95 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
96 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
97 (defcustom hashcash-extra-generate-parameters nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
98 "*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
|
99 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
|
100 :type '(repeat string) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
101 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
102 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
103 (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
|
104 "*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
|
105 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
106 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
107 (defcustom hashcash-in-news nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
108 "*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
|
109 :type 'boolean |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
110 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
111 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
112 (defvar hashcash-process-alist nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
113 "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
|
114 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
115 (require 'mail-utils) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
116 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
117 (eval-and-compile |
87209 | 118 (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
|
119 |
87209 | 120 (if (fboundp 'point-at-bol) |
121 (defalias 'hashcash-point-at-bol 'point-at-bol) | |
122 (defalias 'hashcash-point-at-bol 'line-beginning-position)) | |
123 | |
124 (if (fboundp 'point-at-eol) | |
125 (defalias 'hashcash-point-at-eol 'point-at-eol) | |
126 (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
|
127 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
128 (defun hashcash-strip-quoted-names (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
129 (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
|
130 (if (and addr (string-match "\\`\\([^+@]+\\)\\+[^@]*\\(@.+\\)" addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
131 (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
|
132 addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
133 |
86503
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
134 (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
|
135 (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
|
136 (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
|
137 (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
|
138 |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
139 (defun hashcash-token-substring () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
140 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
141 (let ((token "")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
142 (loop |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
143 (setq token |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
144 (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
|
145 (goto-char (hashcash-point-at-eol)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
146 (forward-char 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
147 (unless (looking-at "[ \t]") (return token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
148 (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
|
149 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
150 (defun hashcash-payment-required (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
151 "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
|
152 (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
|
153 (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
|
154 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
155 (defun hashcash-payment-to (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
156 "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
|
157 (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
|
158 (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
|
159 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
160 (defun hashcash-generate-payment (str val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
161 "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
|
162 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
163 hashcash-path) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
164 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
165 (set-buffer (get-buffer-create " *hashcash*")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
166 (erase-buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
167 (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
|
168 "-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
|
169 hashcash-extra-generate-parameters) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
170 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
171 (hashcash-token-substring)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
172 (error "No `hashcash' binary found"))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
173 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
174 (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
|
175 "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
|
176 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
|
177 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
178 hashcash-path) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
179 (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
|
180 hashcash-path "-m" "-q" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
181 "-b" (number-to-string val) str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
182 hashcash-extra-generate-parameters))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
183 (setq hashcash-process-alist (cons |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
184 (cons process (current-buffer)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
185 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
186 (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
|
187 (funcall ,callback process output)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
188 (funcall callback nil nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
189 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
190 (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
|
191 "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
|
192 (if hashcash-path |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
193 (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
|
194 "-d" "-f" hashcash-double-spend-database |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
195 "-b" (number-to-string val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
196 "-r" str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
197 token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
198 (progn |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
199 (message "No hashcash binary found") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
200 (sleep-for 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
201 nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
202 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
203 (defun hashcash-version (token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
204 "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
|
205 ;; 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
|
206 ;; 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
|
207 ;; 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
|
208 ;; in the X-Payment header. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
209 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
210 ;; 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
|
211 ;; 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
|
212 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
213 ;; Version 1.0 looked like nnnnnrrrrrxxxxxxxxxxxxxxxx |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
214 ;; This is no longer supported. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
215 (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
|
216 ((equal (aref token 6) ?:) 1.1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
217 (t (error "Unknown hashcash format version")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
218 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
219 (defun hashcash-already-paid-p (recipient) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
220 "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
|
221 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
222 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
223 (message-narrow-to-headers-or-head) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
224 (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
|
225 (case-fold-search t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
226 (and (stringp token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
227 (string-match (regexp-quote recipient) token)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
228 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
229 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
230 (defun hashcash-insert-payment (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
231 "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
|
232 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
233 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
234 (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
|
235 (hashcash-payment-required arg)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
236 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
237 (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
|
238 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
239 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
240 (defun hashcash-insert-payment-async (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
241 "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
|
242 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
|
243 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
244 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
245 (hashcash-generate-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
246 (hashcash-payment-to arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
247 (hashcash-payment-required arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
248 `(lambda (process payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
249 (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
|
250 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
251 (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
|
252 (when (buffer-live-p buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
253 (with-current-buffer buffer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
254 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
255 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
256 (setq hashcash-process-alist (delq |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
257 (assq process hashcash-process-alist) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
258 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
259 (message-goto-eoh) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
260 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
261 (insert-before-markers "X-Hashcash: " pay))))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
262 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
263 (defun hashcash-cancel-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
264 "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
|
265 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
266 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
267 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
268 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
269 (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
|
270 (delete-process (car entry)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
271 (setq hashcash-process-alist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
272 (delq entry hashcash-process-alist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
273 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
274 (defun hashcash-wait-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
275 "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
|
276 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
277 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
278 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
279 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
280 (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
|
281 (accept-process-output (car entry))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
282 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
283 (defun hashcash-processes-running-p (buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
284 "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
|
285 (rassq buffer hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
286 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
287 (defun hashcash-wait-or-cancel () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
288 "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
|
289 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
290 (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
|
291 (if (y-or-n-p |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
292 "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
|
293 (hashcash-wait-async) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
294 (hashcash-cancel-async)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
295 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
296 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
297 (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
|
298 "Verify a hashcash payment" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
299 (let* ((split (split-string token ":")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
300 (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
|
301 (nth 1 split) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
302 (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
|
303 (0 (nth 2 split)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
304 (1 (nth 3 split)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
305 (cond ((null resource) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
306 (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
|
307 (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
|
308 (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
|
309 ((equal token key) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
310 (hashcash-check-payment token resource |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
311 (or amount hashcash-default-accept-payment))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
312 (t nil)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
313 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
314 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
315 (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
|
316 "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
|
317 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
|
318 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
|
319 `mail-add-payment-async')." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
320 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
321 (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
|
322 hashcash-default-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
323 (addrlist nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
324 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
325 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
326 (message-narrow-to-headers) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
327 (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
|
328 (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
|
329 (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
|
330 nil t)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
331 (when to |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
332 (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
|
333 (when cc |
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 cc ",[ \t\n]*")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
335 (when (and hashcash-in-news ng) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
336 (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
|
337 (when addrlist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
338 (mapc (if async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
339 #'hashcash-insert-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
340 #'hashcash-insert-payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
341 addrlist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
342 t) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
343 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
344 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
345 (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
|
346 "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
|
347 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
|
348 Calculation is asynchronous." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
349 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
350 (mail-add-payment arg t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
351 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
352 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
353 (defun mail-check-payment (&optional arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
354 "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
|
355 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
|
356 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
357 (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
|
358 hashcash-default-accept-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
359 (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
|
360 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
361 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
362 (search-forward "\n\n") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
363 (beginning-of-line) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
364 (let ((end (point)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
365 (ok nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
366 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
367 (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
|
368 (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
|
369 (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
|
370 (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
|
371 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
372 (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
|
373 (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
|
374 (when ok |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
375 (message "Payment valid")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
376 ok)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
377 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
378 (provide 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
379 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87665
diff
changeset
|
380 ;; arch-tag: 0e7fe983-a124-4392-9788-0dbcbd2c4d62 |