Mercurial > emacs
annotate lisp/mail/hashcash.el @ 87114:a4e9022bb904
Re-fill copyright.
Remove directory part from filenames in function declarations.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 06 Dec 2007 04:06:27 +0000 |
parents | 2c08ad76fc1f |
children | b37f01064ecf |
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 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
3 ;; Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation |
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 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
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 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
14 ;; any later version. |
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 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
24 ;; Boston, MA 02110-1301, USA. |
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 ;;; Commentary: |
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 ;; 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
|
29 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
30 ;; 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
|
31 ;; in the current buffer. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
32 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
33 ;; 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
|
34 ;; 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
|
35 ;; asynchronously. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
36 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
37 ;; 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
|
38 ;; 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
|
39 ;; control, try the following hooks. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
40 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
41 ;; 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
|
42 ;; (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
|
43 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
44 ;; 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
|
45 ;; (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
|
46 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
47 ;; 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
|
48 ;; (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
|
49 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
50 ;;; Code: |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
51 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
52 (defgroup hashcash nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
53 "Hashcash configuration." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
54 :group 'mail) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
55 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
56 (defcustom hashcash-default-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
57 "*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
|
58 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
|
59 See `hashcash-payment-alist'." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
60 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
61 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
62 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
63 (defcustom hashcash-payment-alist '() |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
64 "*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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 :type '(repeat (choice (list :tag "Normal" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
70 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
71 (integer :name "Amount")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
72 (list :tag "Replace hash input" |
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 (string :name "Hash input") |
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 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
77 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
78 (defcustom hashcash-default-accept-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
79 "*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
|
80 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
81 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
82 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
83 (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
|
84 "*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
|
85 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
|
86 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
|
87 is used instead." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
88 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
89 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
90 (defcustom hashcash-path (executable-find "hashcash") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
91 "*The path to the hashcash binary." |
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-extra-generate-parameters nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
95 "*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
|
96 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
|
97 :type '(repeat string) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
98 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
99 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
100 (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
|
101 "*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
|
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-in-news nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
105 "*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
|
106 :type 'boolean |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
107 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
108 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
109 (defvar hashcash-process-alist nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
110 "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
|
111 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
112 (require 'mail-utils) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
113 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
114 (eval-and-compile |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
115 (if (fboundp 'point-at-bol) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
116 (defalias 'hashcash-point-at-bol 'point-at-bol) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
117 (defalias 'hashcash-point-at-bol 'line-beginning-position)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
118 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
119 (if (fboundp 'point-at-eol) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
120 (defalias 'hashcash-point-at-eol 'point-at-eol) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
121 (defalias 'hashcash-point-at-eol 'line-end-position))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
122 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
123 (defun hashcash-strip-quoted-names (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
124 (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
|
125 (if (and addr (string-match "\\`\\([^+@]+\\)\\+[^@]*\\(@.+\\)" addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
126 (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
|
127 addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
128 |
86503
2c08ad76fc1f
* progmodes/cperl-mode.el (compilation-error-regexp-alist): Pacify
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86351
diff
changeset
|
129 (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
|
130 (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
|
131 (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
|
132 (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
|
133 |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
134 (defun hashcash-token-substring () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
135 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
136 (let ((token "")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
137 (loop |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
138 (setq token |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
139 (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
|
140 (goto-char (hashcash-point-at-eol)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
141 (forward-char 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
142 (unless (looking-at "[ \t]") (return token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
143 (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
|
144 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
145 (defun hashcash-payment-required (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
146 "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
|
147 (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
|
148 (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
|
149 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
150 (defun hashcash-payment-to (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
151 "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
|
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 1 val) (nth 0 val) addr))) |
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-generate-payment (str val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
156 "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
|
157 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
158 hashcash-path) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
159 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
160 (set-buffer (get-buffer-create " *hashcash*")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
161 (erase-buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
162 (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
|
163 "-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
|
164 hashcash-extra-generate-parameters) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
165 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
166 (hashcash-token-substring)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
167 (error "No `hashcash' binary found"))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
168 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
169 (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
|
170 "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
|
171 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
|
172 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
173 hashcash-path) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
174 (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
|
175 hashcash-path "-m" "-q" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
176 "-b" (number-to-string val) str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
177 hashcash-extra-generate-parameters))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
178 (setq hashcash-process-alist (cons |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
179 (cons process (current-buffer)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
180 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
181 (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
|
182 (funcall ,callback process output)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
183 (funcall callback nil nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
184 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
185 (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
|
186 "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
|
187 (if hashcash-path |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
188 (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
|
189 "-d" "-f" hashcash-double-spend-database |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
190 "-b" (number-to-string val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
191 "-r" str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
192 token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
193 (progn |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
194 (message "No hashcash binary found") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
195 (sleep-for 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
196 nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
197 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
198 (defun hashcash-version (token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
199 "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
|
200 ;; 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
|
201 ;; 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
|
202 ;; 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
|
203 ;; in the X-Payment header. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
204 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
205 ;; 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
|
206 ;; 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
|
207 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
208 ;; Version 1.0 looked like nnnnnrrrrrxxxxxxxxxxxxxxxx |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
209 ;; This is no longer supported. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
210 (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
|
211 ((equal (aref token 6) ?:) 1.1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
212 (t (error "Unknown hashcash format version")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
213 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
214 (defun hashcash-already-paid-p (recipient) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
215 "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
|
216 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
217 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
218 (message-narrow-to-headers-or-head) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
219 (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
|
220 (case-fold-search t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
221 (and (stringp token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
222 (string-match (regexp-quote recipient) token)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
223 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
224 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
225 (defun hashcash-insert-payment (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
226 "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
|
227 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
228 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
229 (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
|
230 (hashcash-payment-required arg)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
231 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
232 (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
|
233 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
234 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
235 (defun hashcash-insert-payment-async (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
236 "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
|
237 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
|
238 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
239 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
240 (hashcash-generate-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
241 (hashcash-payment-to arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
242 (hashcash-payment-required arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
243 `(lambda (process payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
244 (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
|
245 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
246 (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
|
247 (when (buffer-live-p buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
248 (with-current-buffer buffer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
249 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
250 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
251 (setq hashcash-process-alist (delq |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
252 (assq process hashcash-process-alist) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
253 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
254 (message-goto-eoh) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
255 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
256 (insert-before-markers "X-Hashcash: " pay))))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
257 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
258 (defun hashcash-cancel-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
259 "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
|
260 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
261 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
262 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
263 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
264 (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
|
265 (delete-process (car entry)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
266 (setq hashcash-process-alist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
267 (delq entry hashcash-process-alist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
268 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
269 (defun hashcash-wait-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
270 "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
|
271 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
272 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
273 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
274 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
275 (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
|
276 (accept-process-output (car entry))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
277 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
278 (defun hashcash-processes-running-p (buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
279 "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
|
280 (rassq buffer hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
281 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
282 (defun hashcash-wait-or-cancel () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
283 "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
|
284 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
285 (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
|
286 (if (y-or-n-p |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
287 "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
|
288 (hashcash-wait-async) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
289 (hashcash-cancel-async)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
290 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
291 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
292 (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
|
293 "Verify a hashcash payment" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
294 (let* ((split (split-string token ":")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
295 (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
|
296 (nth 1 split) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
297 (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
|
298 (0 (nth 2 split)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
299 (1 (nth 3 split)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
300 (cond ((null resource) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
301 (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
|
302 (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
|
303 (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
|
304 ((equal token key) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
305 (hashcash-check-payment token resource |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
306 (or amount hashcash-default-accept-payment))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
307 (t nil)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
308 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
309 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
310 (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
|
311 "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
|
312 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
|
313 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
|
314 `mail-add-payment-async')." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
315 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
316 (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
|
317 hashcash-default-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
318 (addrlist nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
319 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
320 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
321 (message-narrow-to-headers) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
322 (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
|
323 (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
|
324 (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
|
325 nil t)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
326 (when to |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
327 (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
|
328 (when cc |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
329 (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
|
330 (when (and hashcash-in-news ng) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
331 (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
|
332 (when addrlist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
333 (mapc (if async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
334 #'hashcash-insert-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
335 #'hashcash-insert-payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
336 addrlist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
337 t) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
338 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
339 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
340 (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
|
341 "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
|
342 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
|
343 Calculation is asynchronous." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
344 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
345 (mail-add-payment arg t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
346 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
347 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
348 (defun mail-check-payment (&optional arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
349 "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
|
350 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
|
351 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
352 (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
|
353 hashcash-default-accept-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
354 (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
|
355 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
356 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
357 (search-forward "\n\n") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
358 (beginning-of-line) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
359 (let ((end (point)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
360 (ok nil)) |
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 (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
|
363 (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
|
364 (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
|
365 (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
|
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-Hashcash: " end t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
368 (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
|
369 (when ok |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
370 (message "Payment valid")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
371 ok)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
372 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
373 (provide 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
374 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
375 ;;; arch-tag: 0e7fe983-a124-4392-9788-0dbcbd2c4d62 |