Mercurial > emacs
annotate lisp/mail/hashcash.el @ 110682:ba6a1c230532
gnus-html.el (gnus-html-prefetch-images): Adjust regexp to avoid regexp backtrace overflows.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Fri, 01 Oct 2010 13:33:03 +0000 |
parents | 650122532cd3 |
children | 236342431786 |
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 |
107413
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
3 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 ;; Free Software Foundation |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
5 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
6 ;; 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
|
7 ;; 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
|
8 ;; Keywords: mail, hashcash |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
9 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
10 ;; 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
|
11 |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; 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
|
13 ;; 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
|
14 ;; 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
|
15 ;; (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
|
16 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
17 ;; 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
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
22 ;; 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
|
23 ;; 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
|
24 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
25 ;;; Commentary: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
26 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
27 ;; 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
|
28 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
29 ;; 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
|
30 ;; in the current buffer. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
31 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
32 ;; 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
|
33 ;; 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
|
34 ;; asynchronously. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
35 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
36 ;; 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
|
37 ;; 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
|
38 ;; control, try the following hooks. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
39 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
40 ;; 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
|
41 ;; (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
|
42 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
43 ;; 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
|
44 ;; (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
|
45 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
46 ;; 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
|
47 ;; (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
|
48 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
49 ;;; Code: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
50 |
87186
b37f01064ecf
* mail/hashcash.el (declare-function):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86503
diff
changeset
|
51 (eval-and-compile |
b37f01064ecf
* mail/hashcash.el (declare-function):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86503
diff
changeset
|
52 (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
|
53 |
96184 | 54 (eval-when-compile (require 'cl)) ; for case |
55 | |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
56 (defgroup hashcash nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
57 "Hashcash configuration." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
58 :group 'mail) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
59 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
60 (defcustom hashcash-default-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
61 "*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
|
62 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
|
63 See `hashcash-payment-alist'." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
64 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
65 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
66 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
67 (defcustom hashcash-payment-alist '() |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
68 "*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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 :type '(repeat (choice (list :tag "Normal" |
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 (integer :name "Amount")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
76 (list :tag "Replace hash input" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
77 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
78 (string :name "Hash input") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
79 (integer :name "Amount")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
80 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
81 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
82 (defcustom hashcash-default-accept-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
83 "*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
|
84 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
85 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
86 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
87 (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
|
88 "*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
|
89 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
|
90 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
|
91 is used instead." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
92 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
93 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
94 (defcustom hashcash-path (executable-find "hashcash") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
95 "*The path to the hashcash binary." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
96 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
97 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
98 (defcustom hashcash-extra-generate-parameters nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
99 "*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
|
100 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
|
101 :type '(repeat string) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
102 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
103 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
104 (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
|
105 "*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
|
106 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
107 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
108 (defcustom hashcash-in-news nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
109 "*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
|
110 :type 'boolean |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
111 :group 'hashcash) |
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 (defvar hashcash-process-alist nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
114 "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
|
115 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
116 (require 'mail-utils) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
117 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
118 (eval-and-compile |
87209 | 119 (if (fboundp 'point-at-bol) |
120 (defalias 'hashcash-point-at-bol 'point-at-bol) | |
121 (defalias 'hashcash-point-at-bol 'line-beginning-position)) | |
122 | |
123 (if (fboundp 'point-at-eol) | |
124 (defalias 'hashcash-point-at-eol 'point-at-eol) | |
125 (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
|
126 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
127 (defun hashcash-strip-quoted-names (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
128 (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
|
129 (if (and addr (string-match "\\`\\([^+@]+\\)\\+[^@]*\\(@.+\\)" addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
130 (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
|
131 addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
132 |
107413
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
133 (declare-function message-narrow-to-headers-or-head "message" ()) |
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
134 (declare-function message-fetch-field "message" (header &optional not-all)) |
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
135 (declare-function message-goto-eoh "message" ()) |
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
136 (declare-function message-narrow-to-headers "message" ()) |
86503
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
137 |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
138 (defun hashcash-token-substring () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
139 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
140 (let ((token "")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
141 (loop |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
142 (setq token |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
143 (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
|
144 (goto-char (hashcash-point-at-eol)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
145 (forward-char 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
146 (unless (looking-at "[ \t]") (return token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
147 (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
|
148 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
149 (defun hashcash-payment-required (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
150 "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
|
151 (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
|
152 (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
|
153 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
154 (defun hashcash-payment-to (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
155 "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
|
156 (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
|
157 (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
|
158 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
159 (defun hashcash-generate-payment (str val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
160 "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
|
161 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
162 hashcash-path) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
163 (with-current-buffer (get-buffer-create " *hashcash*") |
86351
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)) |
110257
650122532cd3
nntp.el (nntp-wait-for-string): Supply a timeout for accept-process-output to ensure progress.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110102
diff
changeset
|
279 (accept-process-output (car entry) 1)))) |
86351
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)) |
107413
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
289 (if (y-or-n-p |
86351
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 |
110102
8d09094063d0
Remove arch-tags from all files, since these are no longer needed.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107413
diff
changeset
|
378 ;;; hashcash.el ends here |