]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-int.el
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
[gnu-emacs] / lisp / gnus / gnus-int.el
1 ;;; gnus-int.el --- backend interface functions for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (eval-when-compile (require 'cl))
30
31 (require 'gnus)
32 (require 'message)
33 (require 'gnus-range)
34
35 (autoload 'gnus-agent-expire "gnus-agent")
36 (autoload 'gnus-agent-read-servers-validate-native "gnus-agent")
37
38 (defcustom gnus-open-server-hook nil
39 "Hook called just before opening connection to the news server."
40 :group 'gnus-start
41 :type 'hook)
42
43 (defcustom gnus-server-unopen-status nil
44 "The default status if the server is not able to open.
45 If the server is covered by Gnus agent, the possible values are
46 `denied', set the server denied; `offline', set the server offline;
47 nil, ask user. If the server is not covered by Gnus agent, set the
48 server denied."
49 :group 'gnus-start
50 :type '(choice (const :tag "Ask" nil)
51 (const :tag "Deny server" denied)
52 (const :tag "Unplug Agent" offline)))
53
54 (defvar gnus-internal-registry-spool-current-method nil
55 "The current method, for the registry.")
56
57 ;;;
58 ;;; Server Communication
59 ;;;
60
61 (defun gnus-start-news-server (&optional confirm)
62 "Open a method for getting news.
63 If CONFIRM is non-nil, the user will be asked for an NNTP server."
64 (let (how)
65 (if gnus-current-select-method
66 ;; Stream is already opened.
67 nil
68 ;; Open NNTP server.
69 (unless gnus-nntp-service
70 (setq gnus-nntp-server nil))
71 (when confirm
72 ;; Read server name with completion.
73 (setq gnus-nntp-server
74 (completing-read "NNTP server: "
75 (mapcar (lambda (server) (list server))
76 (cons (list gnus-nntp-server)
77 gnus-secondary-servers))
78 nil nil gnus-nntp-server)))
79
80 (when (and gnus-nntp-server
81 (stringp gnus-nntp-server)
82 (not (string= gnus-nntp-server "")))
83 (setq gnus-select-method
84 (cond ((or (string= gnus-nntp-server "")
85 (string= gnus-nntp-server "::"))
86 (list 'nnspool (system-name)))
87 ((string-match "^:" gnus-nntp-server)
88 (list 'nnmh gnus-nntp-server
89 (list 'nnmh-directory
90 (file-name-as-directory
91 (expand-file-name
92 (substring gnus-nntp-server 1) "~/")))
93 (list 'nnmh-get-new-mail nil)))
94 (t
95 (list 'nntp gnus-nntp-server)))))
96
97 (setq how (car gnus-select-method))
98 (cond
99 ((eq how 'nnspool)
100 (require 'nnspool)
101 (gnus-message 5 "Looking up local news spool..."))
102 ((eq how 'nnmh)
103 (require 'nnmh)
104 (gnus-message 5 "Looking up mh spool..."))
105 (t
106 (require 'nntp)))
107 (setq gnus-current-select-method gnus-select-method)
108 (gnus-run-hooks 'gnus-open-server-hook)
109
110 ;; Partially validate agent covered methods now that the
111 ;; gnus-select-method is known.
112
113 (if gnus-agent
114 ;; NOTE: This is here for one purpose only. By validating
115 ;; the current select method, it converts the old 5.10.3,
116 ;; and earlier, format to the current format. That enables
117 ;; the agent code within gnus-open-server to function
118 ;; correctly.
119 (gnus-agent-read-servers-validate-native gnus-select-method))
120
121 (or
122 ;; gnus-open-server-hook might have opened it
123 (gnus-server-opened gnus-select-method)
124 (gnus-open-server gnus-select-method)
125 gnus-batch-mode
126 (gnus-y-or-n-p
127 (format
128 "%s (%s) open error: '%s'. Continue? "
129 (car gnus-select-method) (cadr gnus-select-method)
130 (gnus-status-message gnus-select-method)))
131 (gnus-error 1 "Couldn't open server on %s"
132 (nth 1 gnus-select-method))))))
133
134 (defun gnus-check-group (group)
135 "Try to make sure that the server where GROUP exists is alive."
136 (let ((method (gnus-find-method-for-group group)))
137 (or (gnus-server-opened method)
138 (gnus-open-server method))))
139
140 (defun gnus-check-server (&optional method silent)
141 "Check whether the connection to METHOD is down.
142 If METHOD is nil, use `gnus-select-method'.
143 If it is down, start it up (again)."
144 (let ((method (or method gnus-select-method))
145 result)
146 ;; Transform virtual server names into select methods.
147 (when (stringp method)
148 (setq method (gnus-server-to-method method)))
149 (if (gnus-server-opened method)
150 ;; The stream is already opened.
151 t
152 ;; Open the server.
153 (unless silent
154 (gnus-message 5 "Opening %s server%s..." (car method)
155 (if (equal (nth 1 method) "") ""
156 (format " on %s" (nth 1 method)))))
157 (gnus-run-hooks 'gnus-open-server-hook)
158 (prog1
159 (condition-case ()
160 (setq result (gnus-open-server method))
161 (quit (message "Quit gnus-check-server")
162 nil))
163 (unless silent
164 (gnus-message 5 "Opening %s server%s...%s" (car method)
165 (if (equal (nth 1 method) "") ""
166 (format " on %s" (nth 1 method)))
167 (if result "done" "failed")))))))
168
169 (defun gnus-get-function (method function &optional noerror)
170 "Return a function symbol based on METHOD and FUNCTION."
171 ;; Translate server names into methods.
172 (unless method
173 (error "Attempted use of a nil select method"))
174 (when (stringp method)
175 (setq method (gnus-server-to-method method)))
176 ;; Check cache of constructed names.
177 (let* ((method-sym (if gnus-agent
178 (gnus-agent-get-function method)
179 (car method)))
180 (method-fns (get method-sym 'gnus-method-functions))
181 (func (let ((method-fnlist-elt (assq function method-fns)))
182 (unless method-fnlist-elt
183 (setq method-fnlist-elt
184 (cons function
185 (intern (format "%s-%s" method-sym function))))
186 (put method-sym 'gnus-method-functions
187 (cons method-fnlist-elt method-fns)))
188 (cdr method-fnlist-elt))))
189 ;; Maybe complain if there is no function.
190 (unless (fboundp func)
191 (unless (car method)
192 (error "Trying to require a method that doesn't exist"))
193 (require (car method))
194 (when (not (fboundp func))
195 (if noerror
196 (setq func nil)
197 (error "No such function: %s" func))))
198 func))
199
200 \f
201 ;;;
202 ;;; Interface functions to the backends.
203 ;;;
204
205 (defun gnus-open-server (gnus-command-method)
206 "Open a connection to GNUS-COMMAND-METHOD."
207 (when (stringp gnus-command-method)
208 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
209 (let ((elem (assoc gnus-command-method gnus-opened-servers)))
210 ;; If this method was previously denied, we just return nil.
211 (if (eq (nth 1 elem) 'denied)
212 (progn
213 (gnus-message 1 "Denied server")
214 nil)
215 ;; Open the server.
216 (let* ((open-server-function (gnus-get-function gnus-command-method 'open-server))
217 (result
218 (condition-case err
219 (funcall open-server-function
220 (nth 1 gnus-command-method)
221 (nthcdr 2 gnus-command-method))
222 (error
223 (gnus-message 1 (format
224 "Unable to open server due to: %s"
225 (error-message-string err)))
226 nil)
227 (quit
228 (gnus-message 1 "Quit trying to open server")
229 nil)))
230 open-offline)
231 ;; If this hasn't been opened before, we add it to the list.
232 (unless elem
233 (setq elem (list gnus-command-method nil)
234 gnus-opened-servers (cons elem gnus-opened-servers)))
235 ;; Set the status of this server.
236 (setcar (cdr elem)
237 (cond (result
238 (if (eq open-server-function #'nnagent-open-server)
239 ;; The agent's backend has a "special" status
240 'offline
241 'ok))
242 ((and gnus-agent
243 (gnus-agent-method-p gnus-command-method))
244 (cond (gnus-server-unopen-status
245 ;; Set the server's status to the unopen
246 ;; status. If that status is offline,
247 ;; recurse to open the agent's backend.
248 (setq open-offline (eq gnus-server-unopen-status 'offline))
249 gnus-server-unopen-status)
250 ((gnus-y-or-n-p
251 (format "Unable to open %s:%s, go offline? "
252 (car gnus-command-method)
253 (cadr gnus-command-method)))
254 (setq open-offline t)
255 'offline)
256 (t
257 ;; This agentized server was still denied
258 'denied)))
259 (t
260 ;; This unagentized server must be denied
261 'denied)))
262
263 ;; NOTE: I MUST set the server's status to offline before this
264 ;; recursive call as this status will drive the
265 ;; gnus-get-function (called above) to return the agent's
266 ;; backend.
267 (if open-offline
268 ;; Recursively open this offline server to perform the
269 ;; open-server function of the agent's backend.
270 (let ((gnus-server-unopen-status 'denied))
271 ;; Bind gnus-server-unopen-status to avoid recursively
272 ;; prompting with "go offline?". This is only a concern
273 ;; when the agent's backend fails to open the server.
274 (gnus-open-server gnus-command-method))
275 result)))))
276
277 (defun gnus-close-server (gnus-command-method)
278 "Close the connection to GNUS-COMMAND-METHOD."
279 (when (stringp gnus-command-method)
280 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
281 (funcall (gnus-get-function gnus-command-method 'close-server)
282 (nth 1 gnus-command-method)))
283
284 (defun gnus-request-list (gnus-command-method)
285 "Request the active file from GNUS-COMMAND-METHOD."
286 (when (stringp gnus-command-method)
287 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
288 (funcall (gnus-get-function gnus-command-method 'request-list)
289 (nth 1 gnus-command-method)))
290
291 (defun gnus-request-list-newsgroups (gnus-command-method)
292 "Request the newsgroups file from GNUS-COMMAND-METHOD."
293 (when (stringp gnus-command-method)
294 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
295 (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups)
296 (nth 1 gnus-command-method)))
297
298 (defun gnus-request-newgroups (date gnus-command-method)
299 "Request all new groups since DATE from GNUS-COMMAND-METHOD."
300 (when (stringp gnus-command-method)
301 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
302 (let ((func (gnus-get-function gnus-command-method 'request-newgroups t)))
303 (when func
304 (funcall func date (nth 1 gnus-command-method)))))
305
306 (defun gnus-server-opened (gnus-command-method)
307 "Check whether a connection to GNUS-COMMAND-METHOD has been opened."
308 (unless (eq (gnus-server-status gnus-command-method)
309 'denied)
310 (when (stringp gnus-command-method)
311 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
312 (funcall (inline (gnus-get-function gnus-command-method 'server-opened))
313 (nth 1 gnus-command-method))))
314
315 (defun gnus-status-message (gnus-command-method)
316 "Return the status message from GNUS-COMMAND-METHOD.
317 If GNUS-COMMAND-METHOD is a string, it is interpreted as a group
318 name. The method this group uses will be queried."
319 (let ((gnus-command-method
320 (if (stringp gnus-command-method)
321 (gnus-find-method-for-group gnus-command-method)
322 gnus-command-method)))
323 (funcall (gnus-get-function gnus-command-method 'status-message)
324 (nth 1 gnus-command-method))))
325
326 (defun gnus-request-regenerate (gnus-command-method)
327 "Request a data generation from GNUS-COMMAND-METHOD."
328 (when (stringp gnus-command-method)
329 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
330 (funcall (gnus-get-function gnus-command-method 'request-regenerate)
331 (nth 1 gnus-command-method)))
332
333 (defun gnus-request-group (group &optional dont-check gnus-command-method)
334 "Request GROUP. If DONT-CHECK, no information is required."
335 (let ((gnus-command-method
336 (or gnus-command-method (inline (gnus-find-method-for-group group)))))
337 (when (stringp gnus-command-method)
338 (setq gnus-command-method
339 (inline (gnus-server-to-method gnus-command-method))))
340 (funcall (inline (gnus-get-function gnus-command-method 'request-group))
341 (gnus-group-real-name group) (nth 1 gnus-command-method)
342 dont-check)))
343
344 (defun gnus-list-active-group (group)
345 "Request active information on GROUP."
346 (let ((gnus-command-method (gnus-find-method-for-group group))
347 (func 'list-active-group))
348 (when (gnus-check-backend-function func group)
349 (funcall (gnus-get-function gnus-command-method func)
350 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
351
352 (defun gnus-request-group-description (group)
353 "Request a description of GROUP."
354 (let ((gnus-command-method (gnus-find-method-for-group group))
355 (func 'request-group-description))
356 (when (gnus-check-backend-function func group)
357 (funcall (gnus-get-function gnus-command-method func)
358 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
359
360 (defun gnus-request-group-articles (group)
361 "Request a list of existing articles in GROUP."
362 (let ((gnus-command-method (gnus-find-method-for-group group))
363 (func 'request-group-articles))
364 (when (gnus-check-backend-function func group)
365 (funcall (gnus-get-function gnus-command-method func)
366 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
367
368 (defun gnus-close-group (group)
369 "Request the GROUP be closed."
370 (let ((gnus-command-method (inline (gnus-find-method-for-group group))))
371 (funcall (gnus-get-function gnus-command-method 'close-group)
372 (gnus-group-real-name group) (nth 1 gnus-command-method))))
373
374 (defun gnus-retrieve-headers (articles group &optional fetch-old)
375 "Request headers for ARTICLES in GROUP.
376 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
377 (let ((gnus-command-method (gnus-find-method-for-group group)))
378 (cond
379 ((and gnus-use-cache (numberp (car articles)))
380 (gnus-cache-retrieve-headers articles group fetch-old))
381 ((and gnus-agent (gnus-online gnus-command-method)
382 (gnus-agent-method-p gnus-command-method))
383 (gnus-agent-retrieve-headers articles group fetch-old))
384 (t
385 (funcall (gnus-get-function gnus-command-method 'retrieve-headers)
386 articles (gnus-group-real-name group)
387 (nth 1 gnus-command-method) fetch-old)))))
388
389 (defun gnus-retrieve-articles (articles group)
390 "Request ARTICLES in GROUP."
391 (let ((gnus-command-method (gnus-find-method-for-group group)))
392 (funcall (gnus-get-function gnus-command-method 'retrieve-articles)
393 articles (gnus-group-real-name group)
394 (nth 1 gnus-command-method))))
395
396 (defun gnus-retrieve-groups (groups gnus-command-method)
397 "Request active information on GROUPS from GNUS-COMMAND-METHOD."
398 (when (stringp gnus-command-method)
399 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
400 (funcall (gnus-get-function gnus-command-method 'retrieve-groups)
401 groups (nth 1 gnus-command-method)))
402
403 (defun gnus-request-type (group &optional article)
404 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
405 (let ((gnus-command-method (gnus-find-method-for-group group)))
406 (if (not (gnus-check-backend-function
407 'request-type (car gnus-command-method)))
408 'unknown
409 (funcall (gnus-get-function gnus-command-method 'request-type)
410 (gnus-group-real-name group) article))))
411
412 (defun gnus-request-set-mark (group action)
413 "Set marks on articles in the back end."
414 (let ((gnus-command-method (gnus-find-method-for-group group)))
415 (if (not (gnus-check-backend-function
416 'request-set-mark (car gnus-command-method)))
417 action
418 (funcall (gnus-get-function gnus-command-method 'request-set-mark)
419 (gnus-group-real-name group) action
420 (nth 1 gnus-command-method)))))
421
422 (defun gnus-request-update-mark (group article mark)
423 "Allow the back end to change the mark the user tries to put on an article."
424 (let ((gnus-command-method (gnus-find-method-for-group group)))
425 (if (not (gnus-check-backend-function
426 'request-update-mark (car gnus-command-method)))
427 mark
428 (funcall (gnus-get-function gnus-command-method 'request-update-mark)
429 (gnus-group-real-name group) article mark))))
430
431 (defun gnus-request-article (article group &optional buffer)
432 "Request the ARTICLE in GROUP.
433 ARTICLE can either be an article number or an article Message-ID.
434 If BUFFER, insert the article in that group."
435 (let ((gnus-command-method (gnus-find-method-for-group group)))
436 (funcall (gnus-get-function gnus-command-method 'request-article)
437 article (gnus-group-real-name group)
438 (nth 1 gnus-command-method) buffer)))
439
440 (defun gnus-request-head (article group)
441 "Request the head of ARTICLE in GROUP."
442 (let* ((gnus-command-method (gnus-find-method-for-group group))
443 (head (gnus-get-function gnus-command-method 'request-head t))
444 res clean-up)
445 (cond
446 ;; Check the cache.
447 ((and gnus-use-cache
448 (numberp article)
449 (gnus-cache-request-article article group))
450 (setq res (cons group article)
451 clean-up t))
452 ;; Check the agent cache.
453 ((gnus-agent-request-article article group)
454 (setq res (cons group article)
455 clean-up t))
456 ;; Use `head' function.
457 ((fboundp head)
458 (setq res (funcall head article (gnus-group-real-name group)
459 (nth 1 gnus-command-method))))
460 ;; Use `article' function.
461 (t
462 (setq res (gnus-request-article article group)
463 clean-up t)))
464 (when clean-up
465 (save-excursion
466 (set-buffer nntp-server-buffer)
467 (goto-char (point-min))
468 (when (search-forward "\n\n" nil t)
469 (delete-region (1- (point)) (point-max)))
470 (nnheader-fold-continuation-lines)))
471 res))
472
473 (defun gnus-request-body (article group)
474 "Request the body of ARTICLE in GROUP."
475 (let* ((gnus-command-method (gnus-find-method-for-group group))
476 (head (gnus-get-function gnus-command-method 'request-body t))
477 res clean-up)
478 (cond
479 ;; Check the cache.
480 ((and gnus-use-cache
481 (numberp article)
482 (gnus-cache-request-article article group))
483 (setq res (cons group article)
484 clean-up t))
485 ;; Check the agent cache.
486 ((gnus-agent-request-article article group)
487 (setq res (cons group article)
488 clean-up t))
489 ;; Use `head' function.
490 ((fboundp head)
491 (setq res (funcall head article (gnus-group-real-name group)
492 (nth 1 gnus-command-method))))
493 ;; Use `article' function.
494 (t
495 (setq res (gnus-request-article article group)
496 clean-up t)))
497 (when clean-up
498 (save-excursion
499 (set-buffer nntp-server-buffer)
500 (goto-char (point-min))
501 (when (search-forward "\n\n" nil t)
502 (delete-region (point-min) (1- (point))))))
503 res))
504
505 (defun gnus-request-post (gnus-command-method)
506 "Post the current buffer using GNUS-COMMAND-METHOD."
507 (when (stringp gnus-command-method)
508 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
509 (funcall (gnus-get-function gnus-command-method 'request-post)
510 (nth 1 gnus-command-method)))
511
512 (defun gnus-request-scan (group gnus-command-method)
513 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
514 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
515 (let ((gnus-command-method
516 (if group (gnus-find-method-for-group group) gnus-command-method))
517 (gnus-inhibit-demon t)
518 (mail-source-plugged gnus-plugged))
519 (if (or gnus-plugged (not (gnus-agent-method-p gnus-command-method)))
520 (progn
521 (setq gnus-internal-registry-spool-current-method gnus-command-method)
522 (funcall (gnus-get-function gnus-command-method 'request-scan)
523 (and group (gnus-group-real-name group))
524 (nth 1 gnus-command-method))))))
525
526 (defsubst gnus-request-update-info (info gnus-command-method)
527 "Request that GNUS-COMMAND-METHOD update INFO."
528 (when (stringp gnus-command-method)
529 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
530 (when (gnus-check-backend-function
531 'request-update-info (car gnus-command-method))
532 (let ((group (gnus-info-group info)))
533 (and (funcall (gnus-get-function gnus-command-method
534 'request-update-info)
535 (gnus-group-real-name group)
536 info (nth 1 gnus-command-method))
537 ;; If the minimum article number is greater than 1, then all
538 ;; smaller article numbers are known not to exist; we'll
539 ;; artificially add those to the 'read range.
540 (let* ((active (gnus-active group))
541 (min (car active)))
542 (when (> min 1)
543 (let* ((range (if (= min 2) 1 (cons 1 (1- min))))
544 (read (gnus-info-read info))
545 (new-read (gnus-range-add read (list range))))
546 (gnus-info-set-read info new-read)))
547 info)))))
548
549 (defun gnus-request-expire-articles (articles group &optional force)
550 (let* ((gnus-command-method (gnus-find-method-for-group group))
551 (not-deleted
552 (funcall
553 (gnus-get-function gnus-command-method 'request-expire-articles)
554 articles (gnus-group-real-name group) (nth 1 gnus-command-method)
555 force)))
556 (when (and gnus-agent
557 (gnus-agent-method-p gnus-command-method))
558 (let ((expired-articles (gnus-sorted-difference articles not-deleted)))
559 (when expired-articles
560 (gnus-agent-expire expired-articles group 'force))))
561 not-deleted))
562
563 (defun gnus-request-move-article (article group server accept-function
564 &optional last)
565 (let* ((gnus-command-method (gnus-find-method-for-group group))
566 (result (funcall (gnus-get-function gnus-command-method
567 'request-move-article)
568 article (gnus-group-real-name group)
569 (nth 1 gnus-command-method) accept-function last)))
570 (when (and result gnus-agent
571 (gnus-agent-method-p gnus-command-method))
572 (gnus-agent-expire (list article) group 'force))
573 result))
574
575 (defun gnus-request-accept-article (group &optional gnus-command-method last
576 no-encode)
577 ;; Make sure there's a newline at the end of the article.
578 (when (stringp gnus-command-method)
579 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
580 (when (and (not gnus-command-method)
581 (stringp group))
582 (setq gnus-command-method (gnus-group-name-to-method group)))
583 (goto-char (point-max))
584 (unless (bolp)
585 (insert "\n"))
586 (unless no-encode
587 (let ((message-options message-options))
588 (message-options-set-recipient)
589 (save-restriction
590 (message-narrow-to-head)
591 (let ((mail-parse-charset message-default-charset))
592 (mail-encode-encoded-word-buffer)))
593 (message-encode-message-body)))
594 (let ((gnus-command-method (or gnus-command-method
595 (gnus-find-method-for-group group))))
596 (funcall (gnus-get-function gnus-command-method 'request-accept-article)
597 (if (stringp group) (gnus-group-real-name group) group)
598 (cadr gnus-command-method)
599 last)))
600
601 (defun gnus-request-replace-article (article group buffer &optional no-encode)
602 (unless no-encode
603 (let ((message-options message-options))
604 (message-options-set-recipient)
605 (save-restriction
606 (message-narrow-to-head)
607 (let ((mail-parse-charset message-default-charset))
608 (mail-encode-encoded-word-buffer)))
609 (message-encode-message-body)))
610 (let ((func (car (gnus-group-name-to-method group))))
611 (funcall (intern (format "%s-request-replace-article" func))
612 article (gnus-group-real-name group) buffer)))
613
614 (defun gnus-request-associate-buffer (group)
615 (let ((gnus-command-method (gnus-find-method-for-group group)))
616 (funcall (gnus-get-function gnus-command-method 'request-associate-buffer)
617 (gnus-group-real-name group))))
618
619 (defun gnus-request-restore-buffer (article group)
620 "Request a new buffer restored to the state of ARTICLE."
621 (let ((gnus-command-method (gnus-find-method-for-group group)))
622 (funcall (gnus-get-function gnus-command-method 'request-restore-buffer)
623 article (gnus-group-real-name group)
624 (nth 1 gnus-command-method))))
625
626 (defun gnus-request-create-group (group &optional gnus-command-method args)
627 (when (stringp gnus-command-method)
628 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
629 (let ((gnus-command-method
630 (or gnus-command-method (gnus-find-method-for-group group))))
631 (funcall (gnus-get-function gnus-command-method 'request-create-group)
632 (gnus-group-real-name group) (nth 1 gnus-command-method) args)))
633
634 (defun gnus-request-delete-group (group &optional force)
635 (let ((gnus-command-method (gnus-find-method-for-group group)))
636 (funcall (gnus-get-function gnus-command-method 'request-delete-group)
637 (gnus-group-real-name group) force (nth 1 gnus-command-method))))
638
639 (defun gnus-request-rename-group (group new-name)
640 (let ((gnus-command-method (gnus-find-method-for-group group)))
641 (funcall (gnus-get-function gnus-command-method 'request-rename-group)
642 (gnus-group-real-name group)
643 (gnus-group-real-name new-name) (nth 1 gnus-command-method))))
644
645 (defun gnus-close-backends ()
646 ;; Send a close request to all backends that support such a request.
647 (let ((methods gnus-valid-select-methods)
648 (gnus-inhibit-demon t)
649 func gnus-command-method)
650 (while (setq gnus-command-method (pop methods))
651 (when (fboundp (setq func (intern
652 (concat (car gnus-command-method)
653 "-request-close"))))
654 (funcall func)))))
655
656 (defun gnus-asynchronous-p (gnus-command-method)
657 (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t)))
658 (when (fboundp func)
659 (funcall func))))
660
661 (defun gnus-remove-denial (gnus-command-method)
662 (when (stringp gnus-command-method)
663 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
664 (let* ((elem (assoc gnus-command-method gnus-opened-servers))
665 (status (cadr elem)))
666 ;; If this hasn't been opened before, we add it to the list.
667 (when (eq status 'denied)
668 ;; Set the status of this server.
669 (setcar (cdr elem) 'closed))))
670
671 (provide 'gnus-int)
672
673 ;;; arch-tag: bbc90087-9b7f-4017-a92c-3abf180ac86d
674 ;;; gnus-int.el ends here