annotate lisp/gnus/nndb.el @ 140:585fb297b004 r20-2b4

Import from CVS: tag r20-2b4
author cvs
date Mon, 13 Aug 2007 09:32:43 +0200
parents b980b6286996
children
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 ;;; nndb.el --- nndb access for Gnus
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
2 ;; Copyright (C) 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
5 ;; Kai Grossjohann <grossjohann@ls6.informatik.uni-dortmund.de>
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
6 ;; Joe Hildebrand <joe.hildebrand@ilg.com>
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
7 ;; David Blacka <davidb@rwhois.net>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
10 ;; This file is NOT part of GNU Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
29 ;;; This was based upon Kai Grossjohan's shamessly snarfed code and
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
30 ;;; further modified by Joe Hildebrand. It has been updated for Red
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
31 ;;; Gnus.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
33 ;; TODO:
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
34 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
35 ;; * Fix bug where server connection can be lost and impossible to regain
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
36 ;; This hasn't happened to me in a while; think it was fixed in Rgnus
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
37 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
38 ;; * make it handle different nndb servers seemlessly
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
39 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
40 ;; * Optimize expire if FORCE
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
41 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
42 ;; * Optimize move (only expire once)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
43 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
44 ;; * Deal with add/deletion of groups
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
45 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
46 ;; * make the backend TOUCH an article when marked as expireable (will
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
47 ;; make article expire 'expiry' days after that moment).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; Register nndb with known select methods.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
52 (gnus-declare-backend "nndb" 'mail 'respool 'address 'prompt-address)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
56 (require 'nnmail)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (require 'nntp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (unless (fboundp 'open-network-stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (require 'tcp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (autoload 'news-setup "rnewspost")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (autoload 'news-reply-mode "rnewspost")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (autoload 'cancel-timer "timer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (autoload 'telnet "telnet" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (autoload 'telnet-send-input "telnet" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (autoload 'timezone-parse-date "timezone"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; Declare nndb as derived from nntp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (nnoo-declare nndb nntp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; Variables specific to nndb
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;- currently not used but just in case...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defvoo nndb-deliver-program "nndel"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 "*The program used to put a message in an NNDB group.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
85 (defvoo nndb-server-side-expiry nil
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
86 "If t, expiry calculation will occur on the server side")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
87
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
88 (defvoo nndb-set-expire-date-on-mark nil
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
89 "If t, the expiry date for a given article will be set to the time
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
90 it was marked as expireable; otherwise the date will be the time the
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
91 article was posted to nndb")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
92
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; Variables copied from nntp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defvoo nndb-server-opened-hook '(nntp-send-authinfo-from-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "Like nntp-server-opened-hook."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 nntp-server-opened-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defvoo nndb-address "localhost"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 "*The name of the NNDB server."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 nntp-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defvoo nndb-port-number 9000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 "*Port number to connect to."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 nntp-port-number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
107 ;; change to 'news if you are actually using nndb for news
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
108 (defvoo nndb-article-type 'mail)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defvoo nndb-status-string nil "" nntp-status-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
114 (defconst nndb-version "nndb 0.7"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "Version numbers of this version of NNDB.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; Interface functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (nnoo-define-basics nndb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
122 ;;------------------------------------------------------------------
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
124 ;; this function turns the lisp list into a string list. There is
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
125 ;; probably a more efficient way to do this.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
126 (defun nndb-build-article-string (articles)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
127 (let (art-string art)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
128 (while articles
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
129 (setq art (pop articles))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
130 (setq art-string (concat art-string art " ")))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
131 art-string))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
133 (defun nndb-build-expire-rest-list (total expire)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
134 (let (art rest)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
135 (while total
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
136 (setq art (pop total))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
137 (if (memq art expire)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
138 ()
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
139 (push art rest)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
140 rest))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
142
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
143 ;;
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
144 (deffoo nndb-request-type (group &optional article)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
145 nndb-article-type)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
147 ;; nndb-request-update-info does not exist and is not needed
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
149 ;; nndb-request-update-mark does not exist; it should be used to TOUCH
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
150 ;; articles as they are marked exipirable
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
151 (defun nndb-touch-article (group article)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
152 (nntp-send-command nil "X-TOUCH" article))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
154 (deffoo nndb-request-update-mark
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
155 (group article mark)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
156 "Sets the expiry date for ARTICLE in GROUP to now, if the mark is 'E'"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
157 (if (and nndb-set-expire-date-on-mark (string-equal mark "E"))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
158 (nndb-touch-article group article))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
159 mark)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
160
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
161 ;; nndb-request-create-group -- currently this isn't necessary; nndb
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
162 ;; creates groups on demand.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
163
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
164 ;; todo -- use some other time than the creation time of the article
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
165 ;; best is time since article has been marked as expirable
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
166
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
167 (defun nndb-request-expire-articles-local
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (articles &optional group server force)
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
169 "Let gnus do the date check and issue the delete commands."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
170 (let (msg art delete-list (num-delete 0) rest)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
171 (nntp-possibly-change-group group server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (while articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (setq art (pop articles))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
174 (nntp-send-command "^\\([23]\\|^423\\).*\n" "X-DATE" art)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq msg (nndb-status-message))
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
176 (if (string-match "^423" msg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ()
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
178 (or (string-match "'\\(.+\\)'" msg)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
179 (error "Not a valid response for X-DATE command: %s"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
180 msg))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
181 (if (nnmail-expired-article-p
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
182 group
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
183 (gnus-encode-date
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
184 (substring msg (match-beginning 1) (match-end 1)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
185 force)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
186 (progn
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
187 (setq delete-list (concat delete-list " " (int-to-string art)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
188 (setq num-delete (1+ num-delete)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
189 (push art rest))))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
190 (if (> (length delete-list) 0)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
191 (progn
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
192 (nnheader-message 5 "Deleting %s article(s) from %s"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
193 (int-to-string num-delete) group)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
194 (nntp-send-command "^[23].*\n" "X-DELETE" delete-list))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
195 )
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
196
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
197 (message "")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
198 (nconc rest articles)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
199
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
200 (defun nndb-get-remote-expire-response ()
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
201 (let (list)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
202 (set-buffer nntp-server-buffer)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
203 (goto-char (point-min))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
204 (if (looking-at "^[34]")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
205 ;; x-expire returned error--presume no articles were expirable)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
206 (setq list nil)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
207 ;; otherwise, pull all of the following numbers into the list
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
208 (re-search-forward "follows\r?\n?" nil t)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
209 (while (re-search-forward "^[0-9]+$" nil t)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
210 (push (string-to-int (match-string 0)) list)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
211 list))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
212
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
213 (defun nndb-request-expire-articles-remote
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
214 (articles &optional group server force)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
215 "Let the nndb backend expire articles"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
216 (let (days art-string delete-list (num-delete 0))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
217 (nntp-possibly-change-group group server)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
218
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
219 ;; first calculate the wait period in days
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
220 (setq days (or (and nnmail-expiry-wait-function
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
221 (funcall nnmail-expiry-wait-function group))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
222 nnmail-expiry-wait))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
223 ;; now handle the special cases
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
224 (cond (force
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
225 (setq days 0))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
226 ((eq days 'never)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
227 ;; This isn't an expirable group.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
228 (setq days -1))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
229 ((eq days 'immediate)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
230 (setq days 0)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
231
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
232
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
233 ;; build article string
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
234 (setq art-string (concat days " " (nndb-build-article-string articles)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
235 (nntp-send-command "^\.\r?\n\\|^[345].*\n" "X-EXPIRE" art-string)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
236
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
237 (setq delete-list (nndb-get-remote-expire-response))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
238 (setq num-delete (length delete-list))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
239 (if (> num-delete 0)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
240 (nnheader-message 5 "Deleting %s article(s) from %s"
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
241 (int-to-string num-delete) group))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
242
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
243 (nndb-build-expire-rest-list articles delete-list)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
244
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
245 (deffoo nndb-request-expire-articles
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
246 (articles &optional group server force)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
247 "Expires ARTICLES from GROUP on SERVER.
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
248 If FORCE, delete regardless of exiration date, otherwise use normal
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
249 expiry mechanism."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
250 (if nndb-server-side-expiry
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
251 (nndb-request-expire-articles-remote articles group server force)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
252 (nndb-request-expire-articles-local articles group server force)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (deffoo nndb-request-move-article
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
255 (article group server accept-form &optional last)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 "Move ARTICLE (a number) from GROUP on SERVER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 Evals ACCEPT-FORM in current buffer, where the article is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 Optional LAST is ignored."
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
259 ;; we guess that the second arg in accept-form is the new group,
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
260 ;; which it will be for nndb, which is all that matters anyway
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
261 (let ((new-group (nth 1 accept-form)) result)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
262 (nntp-possibly-change-group group server)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
263
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
264 ;; use the move command for nndb-to-nndb moves
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
265 (if (string-match "^nndb" new-group)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
266 (let ((new-group-name (gnus-group-real-name new-group)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
267 (nntp-send-command "^[23].*\n" "X-MOVE" article new-group-name)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
268 (cons new-group article))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
269 ;; else move normally
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
270 (let ((artbuf (get-buffer-create " *nndb move*")))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
271 (and
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
272 (nndb-request-article article group server artbuf)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
273 (save-excursion
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
274 (set-buffer artbuf)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
275 (insert-buffer-substring nntp-server-buffer)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
276 (setq result (eval accept-form))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
277 (kill-buffer (current-buffer))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
278 result)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
279 (nndb-request-expire-articles (list article)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
280 group
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
281 server
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
282 t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 result)
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
284 )))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
285
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (deffoo nndb-request-accept-article (group server &optional last)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "The article in the current buffer is put into GROUP."
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
288 (nntp-possibly-change-group group server)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
289 (let (art msg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (when (nntp-send-command "^[23].*\r?\n" "ACCEPT" group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (nnheader-insert "")
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
292 (nntp-send-buffer "^[23].*\n"))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
293
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
294 (set-buffer nntp-server-buffer)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
295 (setq msg (buffer-string (point-min) (point-max)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
296 (or (string-match "^\\([0-9]+\\)" msg)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
297 (error "nndb: %s" msg))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
298 (setq art (substring msg (match-beginning 1) (match-end 1)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
299 (message "nndb: accepted %s" art)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
300 (list art)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (deffoo nndb-request-replace-article (article group buffer)
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
303 "ARTICLE is the number of the article in GROUP to be replaced
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 with the contents of the BUFFER."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (set-buffer buffer)
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
306 (when (nntp-send-command "^[23].*\r?\n" "X-REPLACE" (int-to-string article))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
307 (nnheader-insert "")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
308 (nntp-send-buffer "^[23.*\n")
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
309 (list (int-to-string article))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ; nndb-request-delete-group does not exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ; todo -- maybe later
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ; nndb-request-rename-group does not exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ; todo -- maybe later
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
317 ;; -- standard compatability functions
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
318
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
319 (deffoo nndb-status-message (&optional server)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
320 "Return server status as a string."
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
321 (set-buffer nntp-server-buffer)
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
322 (buffer-string (point-min) (point-max)))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
323
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
324 ;; Import stuff from nntp
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
325
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
326 (nnoo-import nndb
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
327 (nntp))
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
328
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (provide 'nndb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
136
b980b6286996 Import from CVS: tag r20-2b2
cvs
parents: 108
diff changeset
332