annotate lisp/gnus/gnus-nocem.el @ 44:8d2a9b52c682 r19-15prefinal

Import from CVS: tag r19-15prefinal
author cvs
date Mon, 13 Aug 2007 08:55:10 +0200
parents 8b8b7f3559a2
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; gnus-nocem.el --- NoCeM pseudo-cancellation treatment
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'nnmail)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
30 (require 'gnus-art)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
31 (require 'gnus-sum)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
32 (require 'gnus-range)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
34 (defgroup gnus-nocem nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
35 "NoCeM pseudo-cancellation treatment"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
36 :group 'gnus-score)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
37
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
38 (defcustom gnus-nocem-groups
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
39 '("news.lists.filters" "news.admin.net-abuse.bulletins"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
40 "alt.nocem.misc" "news.admin.net-abuse.announce")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
41 "List of groups that will be searched for NoCeM messages."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
42 :group 'gnus-nocem
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
43 :type '(repeat (string :tag "Group")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
45 (defcustom gnus-nocem-issuers
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
46 '("AutoMoose-1" "Automoose-1" ; CancelMoose[tm]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
47 "rbraver@ohww.norman.ok.us" ; Robert Braver
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
48 "clewis@ferret.ocunix.on.ca;" ; Chris Lewis
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
49 "jem@xpat.com;" ; Despammer from Korea
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
50 "snowhare@xmission.com" ; Benjamin "Snowhare" Franz
32
e04119814345 Import from CVS: tag r19-15b99
cvs
parents: 30
diff changeset
51 "red@redpoll.mrfs.oh.us (Richard E. Depew)" ; ARMM! ARMM!
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
52 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
53 "List of NoCeM issuers to pay attention to."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
54 :group 'gnus-nocem
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
55 :type '(repeat string))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
57 (defcustom gnus-nocem-directory
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
58 (nnheader-concat gnus-article-save-directory "NoCeM/")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
59 "*Directory where NoCeM files will be stored."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
60 :group 'gnus-nocem
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
61 :type 'directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
63 (defcustom gnus-nocem-expiry-wait 15
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
64 "*Number of days to keep NoCeM headers in the cache."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
65 :group 'gnus-nocem
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
66 :type 'integer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
68 (defcustom gnus-nocem-verifyer 'mc-verify
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "*Function called to verify that the NoCeM message is valid.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 One likely value is `mc-verify'. If the function in this variable
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
71 isn't bound, the message will be used unconditionally."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
72 :group 'gnus-nocem
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
73 :type '(radio (function-item mc-verify)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
74 (function :tag "other")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
75
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
76 (defcustom gnus-nocem-liberal-fetch nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
77 "*If t try to fetch all messages which have @@NCM in the subject.
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
78 Otherwise don't fetch messages which have references or whose message-id
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
79 matches an previously scanned and verified nocem message."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
80 :group 'gnus-nocem
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
81 :type 'boolean)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;; Internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defvar gnus-nocem-active nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defvar gnus-nocem-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvar gnus-nocem-touched-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defvar gnus-nocem-hashtb nil)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
89 (defvar gnus-nocem-seen-message-ids nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun gnus-nocem-active-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (concat (file-name-as-directory gnus-nocem-directory) "active"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defun gnus-nocem-cache-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (concat (file-name-as-directory gnus-nocem-directory) "cache"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defun gnus-nocem-scan-groups ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 "Scan all NoCeM groups for new NoCeM messages."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (let ((groups gnus-nocem-groups)
42
8b8b7f3559a2 Import from CVS: tag r19-15b104
cvs
parents: 32
diff changeset
103 (gnus-inhibit-demon t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 group active gactive articles)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
105 (gnus-make-directory gnus-nocem-directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; Load any previous NoCeM headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (gnus-nocem-load-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; Read the active file if it hasn't been read yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (and (file-exists-p (gnus-nocem-active-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (not gnus-nocem-active)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
111 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
112 (load (gnus-nocem-active-file) t t t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; Go through all groups and see whether new articles have
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
114 ;; arrived.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (while (setq group (pop groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (if (not (setq gactive (gnus-activate-group group)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
117 () ; This group doesn't exist.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq active (nth 1 (assoc group gnus-nocem-active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (when (and (not (< (cdr gactive) (car gactive))) ; Empty group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (or (not active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (< (cdr active) (cdr gactive))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; Ok, there are new articles in this group, se we fetch the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (let ((dependencies (make-vector 10 nil))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
126 headers header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
127 (nnheader-temp-write nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
128 (setq headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
129 (if (eq 'nov
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
130 (gnus-retrieve-headers
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
131 (setq articles
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
132 (gnus-uncompress-range
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
133 (cons
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
134 (if active (1+ (cdr active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
135 (car gactive))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
136 (cdr gactive))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
137 group))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
138 (gnus-get-newsgroup-headers-xover
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
139 articles nil dependencies)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
140 (gnus-get-newsgroup-headers dependencies)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
141 (while (setq header (pop headers))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
142 ;; We take a closer look on all articles that have
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
143 ;; "@@NCM" in the subject. Unless we already read
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
144 ;; this cross posted message. Nocem messages
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
145 ;; are not allowed to have references, so we can
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
146 ;; ignore scanning followups.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
147 (and (string-match "@@NCM" (mail-header-subject header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
148 (or gnus-nocem-liberal-fetch
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
149 (and (or (string= "" (mail-header-references
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
150 header))
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
151 (null (mail-header-references header)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
152 (not (member (mail-header-message-id header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
153 gnus-nocem-seen-message-ids))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
154 (gnus-nocem-check-article group header)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq gnus-nocem-active
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
156 (cons (list group gactive)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (delq (assoc group gnus-nocem-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 gnus-nocem-active)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; Save the results, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (gnus-nocem-save-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (gnus-nocem-save-active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defun gnus-nocem-check-article (group header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "Check whether the current article is an NCM article and that we want it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; Get the article.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (gnus-message 7 "Checking article %d in %s for NoCeM..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (mail-header-number header) group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (let ((date (mail-header-date header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 issuer b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (when (or (not date)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
171 (nnmail-time-less
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (nnmail-time-since (nnmail-date-to-time date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (nnmail-days-to-time gnus-nocem-expiry-wait)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (gnus-request-article-this-buffer (mail-header-number header) group)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
175 (goto-char (point-min))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
176 (when (re-search-forward "-----BEGIN PGP MESSAGE-----" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
177 (delete-region (point-min) (match-beginning 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
178 (when (re-search-forward "-----END PGP MESSAGE-----\n?" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
179 (delete-region (match-end 0) (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
180 (goto-char (point-min))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; The article has to have proper NoCeM headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (when (and (setq b (search-forward "\n@@BEGIN NCM HEADERS\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (setq e (search-forward "\n@@BEGIN NCM BODY\n" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; We get the name of the issuer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (narrow-to-region b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (setq issuer (mail-fetch-field "issuer"))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
187 (widen)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
188 (and (member issuer gnus-nocem-issuers) ; We like her....
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
189 (gnus-nocem-verify-issuer issuer) ; She is who she says she is...
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
190 (gnus-nocem-enter-article) ; We gobble the message..
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
191 (push (mail-header-message-id header) ; But don't come back for
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
192 gnus-nocem-seen-message-ids)))))) ; second helpings.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
193
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (defun gnus-nocem-verify-issuer (person)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 "Verify using PGP that the canceler is who she says she is."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (if (fboundp gnus-nocem-verifyer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (funcall gnus-nocem-verifyer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
198 ;; If we don't have Mailcrypt, then we use the message anyway.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun gnus-nocem-enter-article ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Enter the current article into the NoCeM cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (let ((b (search-forward "\n@@BEGIN NCM BODY\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (e (search-forward "\n@@END NCM BODY\n" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (buf (current-buffer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
207 ncm id group)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (when (and b e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (narrow-to-region b (1+ (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (while (search-forward "\t" nil t)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
212 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
213 ((not (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
214 (setq group (let ((obarray gnus-active-hashtb)) (read buf)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
215 ;; An error.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
216 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
217 ((not (symbolp group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
218 ;; Ignore invalid entries.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
219 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
220 ((not (boundp group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
221 ;; Make sure all entries in the hashtb are bound.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
222 (set group nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
223 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
224 (when (gnus-gethash (symbol-name group) gnus-newsrc-hashtb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
225 ;; Valid group.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
226 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
227 (while (= (following-char) ?\t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
228 (forward-line -1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
229 (setq id (buffer-substring (point) (1- (search-forward "\t"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
230 (unless (gnus-gethash id gnus-nocem-hashtb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
231 ;; only store if not already present
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
232 (gnus-sethash id t gnus-nocem-hashtb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
233 (push id ncm))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
234 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
235 (while (= (following-char) ?\t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
236 (forward-line 1))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (when ncm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq gnus-nocem-touched-alist t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (push (cons (let ((time (current-time))) (setcdr (cdr time) nil) time)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
240 ncm)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
241 gnus-nocem-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
242 t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defun gnus-nocem-load-cache ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "Load the NoCeM cache."
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
246 (interactive)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (unless gnus-nocem-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; The buffer doesn't exist, so we create it and load the NoCeM
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
249 ;; cache.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (when (file-exists-p (gnus-nocem-cache-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (load (gnus-nocem-cache-file) t t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (gnus-nocem-alist-to-hashtb))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
253
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun gnus-nocem-save-cache ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 "Save the NoCeM cache."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (when (and gnus-nocem-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 gnus-nocem-touched-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (nnheader-temp-write (gnus-nocem-cache-file)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
259 (gnus-prin1 `(setq gnus-nocem-alist ',gnus-nocem-alist)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (setq gnus-nocem-touched-alist nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (defun gnus-nocem-save-active ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "Save the NoCeM active file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (nnheader-temp-write (gnus-nocem-active-file)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
265 (gnus-prin1 `(setq gnus-nocem-active ',gnus-nocem-active))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defun gnus-nocem-alist-to-hashtb ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "Create a hashtable from the Message-IDs we have."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (let* ((alist gnus-nocem-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (pprev (cons nil alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (prev pprev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (expiry (nnmail-days-to-time gnus-nocem-expiry-wait))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq gnus-nocem-hashtb (gnus-make-hashtable (* (length alist) 51)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (while (setq entry (car alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (if (not (nnmail-time-less (nnmail-time-since (car entry)) expiry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; This entry has expired, so we remove it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setcdr prev (cdr alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (setq prev alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; This is ok, so we enter it into the hashtable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (setq entry (cdr entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (while entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (gnus-sethash (car entry) t gnus-nocem-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (setq entry (cdr entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (setq alist (cdr alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (gnus-add-shutdown 'gnus-nocem-close 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (defun gnus-nocem-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "Clear internal NoCeM variables."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq gnus-nocem-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 gnus-nocem-hashtb nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 gnus-nocem-active nil
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
294 gnus-nocem-touched-alist nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
295 gnus-nocem-seen-message-ids nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (defun gnus-nocem-unwanted-article-p (id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 "Say whether article ID in the current group is wanted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (gnus-gethash id gnus-nocem-hashtb))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (provide 'gnus-nocem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;;; gnus-nocem.el ends here