Mercurial > emacs
annotate lisp/mail/hashcash.el @ 110936:6cad4a8e7c9f
lisp/cedet/ChangeLog: Move entries for emacs-lisp/ files back to lisp/ChangeLog.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 12 Oct 2010 04:31:16 +0200 |
parents | 236342431786 |
children | 417b1e4d63cd |
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 |
110918
236342431786
nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110257
diff
changeset
|
51 ;; For Emacs <22.2 and XEmacs. |
87186
b37f01064ecf
* mail/hashcash.el (declare-function):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86503
diff
changeset
|
52 (eval-and-compile |
b37f01064ecf
* mail/hashcash.el (declare-function):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86503
diff
changeset
|
53 (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
|
54 |
96184 | 55 (eval-when-compile (require 'cl)) ; for case |
56 | |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
57 (defgroup hashcash nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
58 "Hashcash configuration." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
59 :group 'mail) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
60 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
61 (defcustom hashcash-default-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
62 "*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
|
63 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
|
64 See `hashcash-payment-alist'." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
65 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
66 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
67 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
68 (defcustom hashcash-payment-alist '() |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
69 "*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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 :type '(repeat (choice (list :tag "Normal" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
75 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
76 (integer :name "Amount")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
77 (list :tag "Replace hash input" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
78 (string :name "Address") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
79 (string :name "Hash input") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
80 (integer :name "Amount")))) |
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-default-accept-payment 20 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
84 "*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
|
85 :type 'integer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
86 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
87 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
88 (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
|
89 "*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
|
90 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
|
91 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
|
92 is used instead." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
93 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
94 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
95 (defcustom hashcash-path (executable-find "hashcash") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
96 "*The path to the hashcash binary." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
97 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
98 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
99 (defcustom hashcash-extra-generate-parameters nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
100 "*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
|
101 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
|
102 :type '(repeat string) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
103 :group 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
104 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
105 (defcustom hashcash-double-spend-database "hashcash.db" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
106 "*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
|
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 (defcustom hashcash-in-news nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
110 "*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
|
111 :type 'boolean |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
112 :group 'hashcash) |
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 (defvar hashcash-process-alist nil |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
115 "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
|
116 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
117 (require 'mail-utils) |
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 (eval-and-compile |
87209 | 120 (if (fboundp 'point-at-bol) |
121 (defalias 'hashcash-point-at-bol 'point-at-bol) | |
122 (defalias 'hashcash-point-at-bol 'line-beginning-position)) | |
123 | |
124 (if (fboundp 'point-at-eol) | |
125 (defalias 'hashcash-point-at-eol 'point-at-eol) | |
126 (defalias 'hashcash-point-at-eol 'line-end-position))) | |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
127 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
128 (defun hashcash-strip-quoted-names (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
129 (setq addr (mail-strip-quoted-names addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
130 (if (and addr (string-match "\\`\\([^+@]+\\)\\+[^@]*\\(@.+\\)" addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
131 (concat (match-string 1 addr) (match-string 2 addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
132 addr)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
133 |
107413
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
134 (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
|
135 (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
|
136 (declare-function message-goto-eoh "message" ()) |
a21a1c5668d6
* mail/hashcash.el (declare-function): Remove duplicate definition.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
137 (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
|
138 |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
139 (defun hashcash-token-substring () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
140 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
141 (let ((token "")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
142 (loop |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
143 (setq token |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
144 (concat token (buffer-substring (point) (hashcash-point-at-eol)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
145 (goto-char (hashcash-point-at-eol)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
146 (forward-char 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
147 (unless (looking-at "[ \t]") (return token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
148 (while (looking-at "[ \t]") (forward-char 1)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
149 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
150 (defun hashcash-payment-required (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
151 "Return the hashcash payment value required for the given address." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
152 (let ((val (assoc addr hashcash-payment-alist))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
153 (or (nth 2 val) (nth 1 val) hashcash-default-payment))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
154 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
155 (defun hashcash-payment-to (addr) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
156 "Return the string with which hashcash payments should collide." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
157 (let ((val (assoc addr hashcash-payment-alist))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
158 (or (nth 1 val) (nth 0 val) addr))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
159 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
160 (defun hashcash-generate-payment (str val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
161 "Generate a hashcash payment by finding a VAL-bit collison on STR." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
162 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
163 hashcash-path) |
105829
328150f0cf76
* url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
100908
diff
changeset
|
164 (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
|
165 (erase-buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
166 (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
|
167 "-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
|
168 hashcash-extra-generate-parameters) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
169 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
170 (hashcash-token-substring)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
171 (error "No `hashcash' binary found"))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
172 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
173 (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
|
174 "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
|
175 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
|
176 (if (and (> val 0) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
177 hashcash-path) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
178 (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
|
179 hashcash-path "-m" "-q" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
180 "-b" (number-to-string val) str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
181 hashcash-extra-generate-parameters))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
182 (setq hashcash-process-alist (cons |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
183 (cons process (current-buffer)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
184 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
185 (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
|
186 (funcall ,callback process output)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
187 (funcall callback nil nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
188 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
189 (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
|
190 "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
|
191 (if hashcash-path |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
192 (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
|
193 "-d" "-f" hashcash-double-spend-database |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
194 "-b" (number-to-string val) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
195 "-r" str |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
196 token)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
197 (progn |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
198 (message "No hashcash binary found") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
199 (sleep-for 1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
200 nil))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
201 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
202 (defun hashcash-version (token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
203 "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
|
204 ;; 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
|
205 ;; 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
|
206 ;; 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
|
207 ;; in the X-Payment header. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
208 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
209 ;; 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
|
210 ;; 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
|
211 ;; |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
212 ;; Version 1.0 looked like nnnnnrrrrrxxxxxxxxxxxxxxxx |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
213 ;; This is no longer supported. |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
214 (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
|
215 ((equal (aref token 6) ?:) 1.1) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
216 (t (error "Unknown hashcash format version")))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
217 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
218 (defun hashcash-already-paid-p (recipient) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
219 "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
|
220 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
221 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
222 (message-narrow-to-headers-or-head) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
223 (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
|
224 (case-fold-search t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
225 (and (stringp token) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
226 (string-match (regexp-quote recipient) token)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
227 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
228 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
229 (defun hashcash-insert-payment (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
230 "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
|
231 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
232 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
233 (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
|
234 (hashcash-payment-required arg)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
235 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
236 (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
|
237 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
238 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
239 (defun hashcash-insert-payment-async (arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
240 "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
|
241 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
|
242 (interactive "sPay to: ") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
243 (unless (hashcash-already-paid-p arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
244 (hashcash-generate-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
245 (hashcash-payment-to arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
246 (hashcash-payment-required arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
247 `(lambda (process payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
248 (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
|
249 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
250 (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
|
251 (when (buffer-live-p buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
252 (with-current-buffer buffer |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
253 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
254 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
255 (setq hashcash-process-alist (delq |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
256 (assq process hashcash-process-alist) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
257 hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
258 (message-goto-eoh) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
259 (when pay |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
260 (insert-before-markers "X-Hashcash: " pay))))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
261 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
262 (defun hashcash-cancel-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
263 "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
|
264 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
265 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
266 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
267 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
268 (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
|
269 (delete-process (car entry)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
270 (setq hashcash-process-alist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
271 (delq entry hashcash-process-alist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
272 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
273 (defun hashcash-wait-async (&optional buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
274 "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
|
275 BUFFER defaults to the current buffer." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
276 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
277 (unless buffer (setq buffer (current-buffer))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
278 (let (entry) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
279 (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
|
280 (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
|
281 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
282 (defun hashcash-processes-running-p (buffer) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
283 "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
|
284 (rassq buffer hashcash-process-alist)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
285 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
286 (defun hashcash-wait-or-cancel () |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
287 "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
|
288 (interactive) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
289 (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
|
290 (if (y-or-n-p |
86351
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
291 "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
|
292 (hashcash-wait-async) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
293 (hashcash-cancel-async)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
294 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
295 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
296 (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
|
297 "Verify a hashcash payment" |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
298 (let* ((split (split-string token ":")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
299 (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
|
300 (nth 1 split) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
301 (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
|
302 (0 (nth 2 split)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
303 (1 (nth 3 split)))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
304 (cond ((null resource) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
305 (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
|
306 (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
|
307 (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
|
308 ((equal token key) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
309 (hashcash-check-payment token resource |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
310 (or amount hashcash-default-accept-payment))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
311 (t nil)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
312 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
313 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
314 (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
|
315 "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
|
316 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
|
317 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
|
318 `mail-add-payment-async')." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
319 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
320 (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
|
321 hashcash-default-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
322 (addrlist nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
323 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
324 (save-restriction |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
325 (message-narrow-to-headers) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
326 (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
|
327 (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
|
328 (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
|
329 nil t)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
330 (when to |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
331 (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
|
332 (when cc |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
333 (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
|
334 (when (and hashcash-in-news ng) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
335 (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
|
336 (when addrlist |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
337 (mapc (if async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
338 #'hashcash-insert-payment-async |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
339 #'hashcash-insert-payment) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
340 addrlist))))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
341 t) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
342 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
343 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
344 (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
|
345 "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
|
346 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
|
347 Calculation is asynchronous." |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
348 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
349 (mail-add-payment arg t)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
350 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
351 ;;;###autoload |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
352 (defun mail-check-payment (&optional arg) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
353 "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
|
354 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
|
355 (interactive "P") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
356 (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
|
357 hashcash-default-accept-payment)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
358 (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
|
359 (save-excursion |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
360 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
361 (search-forward "\n\n") |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
362 (beginning-of-line) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
363 (let ((end (point)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
364 (ok nil)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
365 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
366 (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
|
367 (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
|
368 (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
|
369 (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
|
370 (goto-char (point-min)) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
371 (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
|
372 (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
|
373 (when ok |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
374 (message "Payment valid")) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
375 ok)))) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
376 |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
377 (provide 'hashcash) |
f3c5045fc04b
Move from ../gnus. Add hashcash payments to email.
Reiner Steib <Reiner.Steib@gmx.de>
parents:
diff
changeset
|
378 |
110102
8d09094063d0
Remove arch-tags from all files, since these are no longer needed.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
107413
diff
changeset
|
379 ;;; hashcash.el ends here |