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