1 ;;; gnus-int.el --- backend interface functions for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 (eval-when-compile (require 'cl))
34 (autoload 'gnus-agent-expire "gnus-agent")
35 (autoload 'gnus-agent-regenerate-group "gnus-agent")
36 (autoload 'gnus-agent-read-servers-validate-native "gnus-agent")
37 (autoload 'gnus-agent-possibly-synchronize-flags-server "gnus-agent")
39 (defcustom gnus-open-server-hook nil
40 "Hook called just before opening connection to the news server."
44 (defcustom gnus-server-unopen-status nil
45 "The default status if the server is not able to open.
46 If the server is covered by Gnus agent, the possible values are
47 `denied', set the server denied; `offline', set the server offline;
48 nil, ask user. If the server is not covered by Gnus agent, set the
52 :type '(choice (const :tag "Ask" nil)
53 (const :tag "Deny server" denied)
54 (const :tag "Unplug Agent" offline)))
56 (defvar gnus-internal-registry-spool-current-method nil
57 "The current method, for the registry.")
60 (defun gnus-server-opened (gnus-command-method)
61 "Check whether a connection to GNUS-COMMAND-METHOD has been opened."
62 (unless (eq (gnus-server-status gnus-command-method)
64 (when (stringp gnus-command-method)
65 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
66 (funcall (inline (gnus-get-function gnus-command-method 'server-opened))
67 (nth 1 gnus-command-method))))
69 (defun gnus-status-message (gnus-command-method)
70 "Return the status message from GNUS-COMMAND-METHOD.
71 If GNUS-COMMAND-METHOD is a string, it is interpreted as a group
72 name. The method this group uses will be queried."
73 (let ((gnus-command-method
74 (if (stringp gnus-command-method)
75 (gnus-find-method-for-group gnus-command-method)
76 gnus-command-method)))
77 (funcall (gnus-get-function gnus-command-method 'status-message)
78 (nth 1 gnus-command-method))))
81 ;;; Server Communication
84 (defun gnus-start-news-server (&optional confirm)
85 "Open a method for getting news.
86 If CONFIRM is non-nil, the user will be asked for an NNTP server."
88 (if gnus-current-select-method
89 ;; Stream is already opened.
92 (unless gnus-nntp-service
93 (setq gnus-nntp-server nil))
95 ;; Read server name with completion.
96 (setq gnus-nntp-server
97 (completing-read "NNTP server: "
99 (cons (list gnus-nntp-server)
100 gnus-secondary-servers))
101 nil nil gnus-nntp-server)))
103 (when (and gnus-nntp-server
104 (stringp gnus-nntp-server)
105 (not (string= gnus-nntp-server "")))
106 (setq gnus-select-method
107 (cond ((or (string= gnus-nntp-server "")
108 (string= gnus-nntp-server "::"))
109 (list 'nnspool (system-name)))
110 ((string-match "^:" gnus-nntp-server)
111 (list 'nnmh gnus-nntp-server
112 (list 'nnmh-directory
113 (file-name-as-directory
115 (substring gnus-nntp-server 1) "~/")))
116 (list 'nnmh-get-new-mail nil)))
118 (list 'nntp gnus-nntp-server)))))
120 (setq how (car gnus-select-method))
124 (gnus-message 5 "Looking up local news spool..."))
127 (gnus-message 5 "Looking up mh spool..."))
130 (setq gnus-current-select-method gnus-select-method)
131 (gnus-run-hooks 'gnus-open-server-hook)
133 ;; Partially validate agent covered methods now that the
134 ;; gnus-select-method is known.
137 ;; NOTE: This is here for one purpose only. By validating
138 ;; the current select method, it converts the old 5.10.3,
139 ;; and earlier, format to the current format. That enables
140 ;; the agent code within gnus-open-server to function
142 (gnus-agent-read-servers-validate-native gnus-select-method))
145 ;; gnus-open-server-hook might have opened it
146 (gnus-server-opened gnus-select-method)
147 (gnus-open-server gnus-select-method)
151 "%s (%s) open error: '%s'. Continue? "
152 (car gnus-select-method) (cadr gnus-select-method)
153 (gnus-status-message gnus-select-method)))
154 (gnus-error 1 "Couldn't open server on %s"
155 (nth 1 gnus-select-method))))))
157 (defun gnus-check-group (group)
158 "Try to make sure that the server where GROUP exists is alive."
159 (let ((method (gnus-find-method-for-group group)))
160 (or (gnus-server-opened method)
161 (gnus-open-server method))))
163 (defun gnus-check-server (&optional method silent)
164 "Check whether the connection to METHOD is down.
165 If METHOD is nil, use `gnus-select-method'.
166 If it is down, start it up (again)."
167 (let ((method (or method gnus-select-method))
169 ;; Transform virtual server names into select methods.
170 (when (stringp method)
171 (setq method (gnus-server-to-method method)))
172 (if (gnus-server-opened method)
173 ;; The stream is already opened.
177 (gnus-message 5 "Opening %s server%s..." (car method)
178 (if (equal (nth 1 method) "") ""
179 (format " on %s" (nth 1 method)))))
180 (gnus-run-hooks 'gnus-open-server-hook)
182 (setq result (gnus-open-server method))
184 (gnus-message 5 "Opening %s server%s...%s" (car method)
185 (if (equal (nth 1 method) "") ""
186 (format " on %s" (nth 1 method)))
187 (if result "done" "failed")))))))
189 (defun gnus-get-function (method function &optional noerror)
190 "Return a function symbol based on METHOD and FUNCTION."
191 ;; Translate server names into methods.
193 (error "Attempted use of a nil select method"))
194 (when (stringp method)
195 (setq method (gnus-server-to-method method)))
196 ;; Check cache of constructed names.
197 (let* ((method-sym (if gnus-agent
198 (inline (gnus-agent-get-function method))
200 (method-fns (get method-sym 'gnus-method-functions))
201 (func (let ((method-fnlist-elt (assq function method-fns)))
202 (unless method-fnlist-elt
203 (setq method-fnlist-elt
205 (intern (format "%s-%s" method-sym function))))
206 (put method-sym 'gnus-method-functions
207 (cons method-fnlist-elt method-fns)))
208 (cdr method-fnlist-elt))))
209 ;; Maybe complain if there is no function.
210 (unless (fboundp func)
212 (error "Trying to require a method that doesn't exist"))
213 (require (car method))
214 (when (not (fboundp func))
217 (error "No such function: %s" func))))
222 ;;; Interface functions to the backends.
225 (defun gnus-method-denied-p (method)
226 (eq (nth 1 (assoc method gnus-opened-servers))
229 (defun gnus-open-server (gnus-command-method)
230 "Open a connection to GNUS-COMMAND-METHOD."
231 (when (stringp gnus-command-method)
232 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
233 (let ((elem (assoc gnus-command-method gnus-opened-servers))
234 (server (gnus-method-to-server-name gnus-command-method)))
235 ;; If this method was previously denied, we just return nil.
236 (if (eq (nth 1 elem) 'denied)
238 (gnus-message 1 "Denied server %s" server)
241 (let* ((open-server-function (gnus-get-function gnus-command-method 'open-server))
244 (funcall open-server-function
245 (nth 1 gnus-command-method)
246 (nthcdr 2 gnus-command-method))
248 (gnus-message 1 "Unable to open server %s due to: %s"
249 server (error-message-string err))
252 (gnus-message 1 "Quit trying to open server %s" server)
255 ;; If this hasn't been opened before, we add it to the list.
257 (setq elem (list gnus-command-method nil)
258 gnus-opened-servers (cons elem gnus-opened-servers)))
259 ;; Set the status of this server.
262 (if (eq open-server-function #'nnagent-open-server)
263 ;; The agent's backend has a "special" status
267 (gnus-agent-method-p gnus-command-method))
268 (cond (gnus-server-unopen-status
269 ;; Set the server's status to the unopen
270 ;; status. If that status is offline,
271 ;; recurse to open the agent's backend.
272 (setq open-offline (eq gnus-server-unopen-status 'offline))
273 gnus-server-unopen-status)
275 (not gnus-batch-mode)
278 "Unable to open server %s (%s), go offline? "
281 (car gnus-command-method)))))
282 (setq open-offline t)
285 ;; This agentized server was still denied
288 ;; This unagentized server must be denied
291 ;; NOTE: I MUST set the server's status to offline before this
292 ;; recursive call as this status will drive the
293 ;; gnus-get-function (called above) to return the agent's
296 ;; Recursively open this offline server to perform the
297 ;; open-server function of the agent's backend.
298 (let ((gnus-server-unopen-status 'denied))
299 ;; Bind gnus-server-unopen-status to avoid recursively
300 ;; prompting with "go offline?". This is only a concern
301 ;; when the agent's backend fails to open the server.
302 (gnus-open-server gnus-command-method))
303 (when (and (eq (cadr elem) 'ok) gnus-agent
304 (gnus-agent-method-p gnus-command-method))
306 (gnus-agent-possibly-synchronize-flags-server
307 gnus-command-method)))
310 (defun gnus-close-server (gnus-command-method)
311 "Close the connection to GNUS-COMMAND-METHOD."
312 (when (stringp gnus-command-method)
313 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
314 (funcall (gnus-get-function gnus-command-method 'close-server)
315 (nth 1 gnus-command-method)))
317 (defun gnus-request-list (gnus-command-method)
318 "Request the active file from GNUS-COMMAND-METHOD."
319 (when (stringp gnus-command-method)
320 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
321 (funcall (gnus-get-function gnus-command-method 'request-list)
322 (nth 1 gnus-command-method)))
324 (defun gnus-finish-retrieve-group-infos (gnus-command-method infos data)
325 "Read and update infos from GNUS-COMMAND-METHOD."
326 (when (stringp gnus-command-method)
327 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
328 (funcall (gnus-get-function gnus-command-method 'finish-retrieve-group-infos)
329 (nth 1 gnus-command-method)
332 (defun gnus-retrieve-group-data-early (gnus-command-method infos)
333 "Start early async retrival of data from GNUS-COMMAND-METHOD."
334 (when (stringp gnus-command-method)
335 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
336 (funcall (gnus-get-function gnus-command-method 'retrieve-group-data-early)
337 (nth 1 gnus-command-method)
340 (defun gnus-request-list-newsgroups (gnus-command-method)
341 "Request the newsgroups file from GNUS-COMMAND-METHOD."
342 (when (stringp gnus-command-method)
343 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
344 (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups)
345 (nth 1 gnus-command-method)))
347 (defun gnus-request-newgroups (date gnus-command-method)
348 "Request all new groups since DATE from GNUS-COMMAND-METHOD."
349 (when (stringp gnus-command-method)
350 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
351 (let ((func (gnus-get-function gnus-command-method 'request-newgroups t)))
353 (funcall func date (nth 1 gnus-command-method)))))
355 (defun gnus-request-regenerate (gnus-command-method)
356 "Request a data generation from GNUS-COMMAND-METHOD."
357 (when (stringp gnus-command-method)
358 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
359 (funcall (gnus-get-function gnus-command-method 'request-regenerate)
360 (nth 1 gnus-command-method)))
362 (defun gnus-request-compact-group (group)
363 (let* ((method (gnus-find-method-for-group group))
364 (gnus-command-method method)
366 (funcall (gnus-get-function gnus-command-method
367 'request-compact-group)
368 (gnus-group-real-name group)
369 (nth 1 gnus-command-method) t)))
372 (defun gnus-request-compact (gnus-command-method)
373 "Request groups compaction from GNUS-COMMAND-METHOD."
374 (when (stringp gnus-command-method)
375 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
376 (funcall (gnus-get-function gnus-command-method 'request-compact)
377 (nth 1 gnus-command-method)))
379 (defun gnus-request-group (group &optional dont-check gnus-command-method info)
380 "Request GROUP. If DONT-CHECK, no information is required."
381 (let ((gnus-command-method
382 (or gnus-command-method (inline (gnus-find-method-for-group group)))))
383 (when (stringp gnus-command-method)
384 (setq gnus-command-method
385 (inline (gnus-server-to-method gnus-command-method))))
386 (funcall (inline (gnus-get-function gnus-command-method 'request-group))
387 (gnus-group-real-name group) (nth 1 gnus-command-method)
391 (defun gnus-list-active-group (group)
392 "Request active information on GROUP."
393 (let ((gnus-command-method (gnus-find-method-for-group group))
394 (func 'list-active-group))
395 (when (gnus-check-backend-function func group)
396 (funcall (gnus-get-function gnus-command-method func)
397 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
399 (defun gnus-request-group-description (group)
400 "Request a description of GROUP."
401 (let ((gnus-command-method (gnus-find-method-for-group group))
402 (func 'request-group-description))
403 (when (gnus-check-backend-function func group)
404 (funcall (gnus-get-function gnus-command-method func)
405 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
407 (defun gnus-request-group-articles (group)
408 "Request a list of existing articles in GROUP."
409 (let ((gnus-command-method (gnus-find-method-for-group group))
410 (func 'request-group-articles))
411 (when (gnus-check-backend-function func group)
412 (funcall (gnus-get-function gnus-command-method func)
413 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
415 (defun gnus-close-group (group)
416 "Request the GROUP be closed."
417 (let ((gnus-command-method (inline (gnus-find-method-for-group group))))
418 (funcall (gnus-get-function gnus-command-method 'close-group)
419 (gnus-group-real-name group) (nth 1 gnus-command-method))))
421 (defun gnus-retrieve-headers (articles group &optional fetch-old)
422 "Request headers for ARTICLES in GROUP.
423 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
424 (let ((gnus-command-method (gnus-find-method-for-group group)))
426 ((and gnus-use-cache (numberp (car articles)))
427 (gnus-cache-retrieve-headers articles group fetch-old))
428 ((and gnus-agent (gnus-online gnus-command-method)
429 (gnus-agent-method-p gnus-command-method))
430 (gnus-agent-retrieve-headers articles group fetch-old))
432 (funcall (gnus-get-function gnus-command-method 'retrieve-headers)
433 articles (gnus-group-real-name group)
434 (nth 1 gnus-command-method) fetch-old)))))
436 (defun gnus-retrieve-articles (articles group)
437 "Request ARTICLES in GROUP."
438 (let ((gnus-command-method (gnus-find-method-for-group group)))
439 (funcall (gnus-get-function gnus-command-method 'retrieve-articles)
440 articles (gnus-group-real-name group)
441 (nth 1 gnus-command-method))))
443 (defun gnus-retrieve-groups (groups gnus-command-method)
444 "Request active information on GROUPS from GNUS-COMMAND-METHOD."
445 (when (stringp gnus-command-method)
446 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
447 (funcall (gnus-get-function gnus-command-method 'retrieve-groups)
448 groups (nth 1 gnus-command-method)))
450 (defun gnus-request-type (group &optional article)
451 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
452 (let ((gnus-command-method (gnus-find-method-for-group group)))
453 (if (not (gnus-check-backend-function
454 'request-type (car gnus-command-method)))
456 (funcall (gnus-get-function gnus-command-method 'request-type)
457 (gnus-group-real-name group) article))))
459 (defun gnus-request-set-mark (group action)
460 "Set marks on articles in the back end."
461 (let ((gnus-command-method (gnus-find-method-for-group group)))
462 (if (not (gnus-check-backend-function
463 'request-set-mark (car gnus-command-method)))
465 (funcall (gnus-get-function gnus-command-method 'request-set-mark)
466 (gnus-group-real-name group) action
467 (nth 1 gnus-command-method)))))
469 (defun gnus-request-update-mark (group article mark)
470 "Allow the back end to change the mark the user tries to put on an article."
471 (let ((gnus-command-method (gnus-find-method-for-group group)))
472 (if (not (gnus-check-backend-function
473 'request-update-mark (car gnus-command-method)))
475 (funcall (gnus-get-function gnus-command-method 'request-update-mark)
476 (gnus-group-real-name group) article mark))))
478 (defun gnus-request-article (article group &optional buffer)
479 "Request the ARTICLE in GROUP.
480 ARTICLE can either be an article number or an article Message-ID.
481 If BUFFER, insert the article in that group."
482 (let ((gnus-command-method (gnus-find-method-for-group group)))
483 (funcall (gnus-get-function gnus-command-method 'request-article)
484 article (gnus-group-real-name group)
485 (nth 1 gnus-command-method) buffer)))
487 (defun gnus-request-head (article group)
488 "Request the head of ARTICLE in GROUP."
489 (let* ((gnus-command-method (gnus-find-method-for-group group))
490 (head (gnus-get-function gnus-command-method 'request-head t))
496 (gnus-cache-request-article article group))
497 (setq res (cons group article)
499 ;; Check the agent cache.
500 ((gnus-agent-request-article article group)
501 (setq res (cons group article)
503 ;; Use `head' function.
505 (setq res (funcall head article (gnus-group-real-name group)
506 (nth 1 gnus-command-method))))
507 ;; Use `article' function.
509 (setq res (gnus-request-article article group)
512 (with-current-buffer nntp-server-buffer
513 (goto-char (point-min))
514 (when (search-forward "\n\n" nil t)
515 (delete-region (1- (point)) (point-max)))
516 (nnheader-fold-continuation-lines)))
519 (defun gnus-request-body (article group)
520 "Request the body of ARTICLE in GROUP."
521 (let* ((gnus-command-method (gnus-find-method-for-group group))
522 (head (gnus-get-function gnus-command-method 'request-body t))
528 (gnus-cache-request-article article group))
529 (setq res (cons group article)
531 ;; Check the agent cache.
532 ((gnus-agent-request-article article group)
533 (setq res (cons group article)
535 ;; Use `head' function.
537 (setq res (funcall head article (gnus-group-real-name group)
538 (nth 1 gnus-command-method))))
539 ;; Use `article' function.
541 (setq res (gnus-request-article article group)
544 (with-current-buffer nntp-server-buffer
545 (goto-char (point-min))
546 (when (search-forward "\n\n" nil t)
547 (delete-region (point-min) (1- (point))))))
550 (defun gnus-request-post (gnus-command-method)
551 "Post the current buffer using GNUS-COMMAND-METHOD."
552 (when (stringp gnus-command-method)
553 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
554 (funcall (gnus-get-function gnus-command-method 'request-post)
555 (nth 1 gnus-command-method)))
557 (defun gnus-request-expunge-group (group gnus-command-method)
558 "Expunge GROUP, which is removing articles that have been marked as deleted."
559 (when (stringp gnus-command-method)
560 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
561 (funcall (gnus-get-function gnus-command-method 'request-expunge-group)
562 (gnus-group-real-name group)
563 (nth 1 gnus-command-method)))
565 (defun gnus-request-scan (group gnus-command-method)
566 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
567 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
568 (let ((gnus-command-method
569 (if group (gnus-find-method-for-group group) gnus-command-method))
570 (gnus-inhibit-demon t)
571 (mail-source-plugged gnus-plugged))
572 (when (or gnus-plugged
573 (not (gnus-agent-method-p gnus-command-method)))
574 (setq gnus-internal-registry-spool-current-method gnus-command-method)
575 (funcall (gnus-get-function gnus-command-method 'request-scan)
576 (and group (gnus-group-real-name group))
577 (nth 1 gnus-command-method)))))
579 (defsubst gnus-request-update-info (info gnus-command-method)
580 "Request that GNUS-COMMAND-METHOD update INFO."
581 (when (stringp gnus-command-method)
582 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
583 (when (gnus-check-backend-function
584 'request-update-info (car gnus-command-method))
585 (let ((group (gnus-info-group info)))
586 (and (funcall (gnus-get-function gnus-command-method
587 'request-update-info)
588 (gnus-group-real-name group)
589 info (nth 1 gnus-command-method))
590 ;; If the minimum article number is greater than 1, then all
591 ;; smaller article numbers are known not to exist; we'll
592 ;; artificially add those to the 'read range.
593 (let* ((active (gnus-active group))
596 (let* ((range (if (= min 2) 1 (cons 1 (1- min))))
597 (read (gnus-info-read info))
598 (new-read (gnus-range-add read (list range))))
599 (gnus-info-set-read info new-read)))
602 (defun gnus-request-expire-articles (articles group &optional force)
603 (let* ((gnus-command-method (gnus-find-method-for-group group))
606 (gnus-get-function gnus-command-method 'request-expire-articles)
607 articles (gnus-group-real-name group) (nth 1 gnus-command-method)
609 (when (and gnus-agent
610 (gnus-agent-method-p gnus-command-method))
611 (let ((expired-articles (gnus-sorted-difference articles not-deleted)))
612 (when expired-articles
613 (gnus-agent-expire expired-articles group 'force))))
616 (defun gnus-request-move-article (article group server accept-function
617 &optional last move-is-internal)
618 (let* ((gnus-command-method (gnus-find-method-for-group group))
619 (result (funcall (gnus-get-function gnus-command-method
620 'request-move-article)
621 article (gnus-group-real-name group)
622 (nth 1 gnus-command-method) accept-function last move-is-internal)))
623 (when (and result gnus-agent
624 (gnus-agent-method-p gnus-command-method))
625 (gnus-agent-unfetch-articles group (list article)))
628 (defun gnus-request-accept-article (group &optional gnus-command-method last
630 ;; Make sure there's a newline at the end of the article.
631 (when (stringp gnus-command-method)
632 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
633 (when (and (not gnus-command-method)
635 (setq gnus-command-method (or (gnus-find-method-for-group group)
636 (gnus-group-name-to-method group))))
637 (goto-char (point-max))
641 (let ((message-options message-options))
642 (message-options-set-recipient)
644 (message-narrow-to-head)
645 (let ((mail-parse-charset message-default-charset))
646 (mail-encode-encoded-word-buffer)))
647 (message-encode-message-body)))
648 (let ((gnus-command-method (or gnus-command-method
649 (gnus-find-method-for-group group)))
652 (gnus-get-function gnus-command-method 'request-accept-article)
653 (if (stringp group) (gnus-group-real-name group) group)
654 (cadr gnus-command-method)
656 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
657 (gnus-agent-regenerate-group group (list (cdr result))))
660 (defun gnus-request-replace-article (article group buffer &optional no-encode)
662 (let ((message-options message-options))
663 (message-options-set-recipient)
665 (message-narrow-to-head)
666 (let ((mail-parse-charset message-default-charset))
667 (mail-encode-encoded-word-buffer)))
668 (message-encode-message-body)))
669 (let* ((func (car (gnus-group-name-to-method group)))
670 (result (funcall (intern (format "%s-request-replace-article" func))
671 article (gnus-group-real-name group) buffer)))
672 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
673 (gnus-agent-regenerate-group group (list article)))
676 (defun gnus-request-associate-buffer (group)
677 (let ((gnus-command-method (gnus-find-method-for-group group)))
678 (funcall (gnus-get-function gnus-command-method 'request-associate-buffer)
679 (gnus-group-real-name group))))
681 (defun gnus-request-restore-buffer (article group)
682 "Request a new buffer restored to the state of ARTICLE."
683 (let ((gnus-command-method (gnus-find-method-for-group group)))
684 (funcall (gnus-get-function gnus-command-method 'request-restore-buffer)
685 article (gnus-group-real-name group)
686 (nth 1 gnus-command-method))))
688 (defun gnus-request-create-group (group &optional gnus-command-method args)
689 (when (stringp gnus-command-method)
690 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
691 (let ((gnus-command-method
692 (or gnus-command-method (gnus-find-method-for-group group))))
693 (funcall (gnus-get-function gnus-command-method 'request-create-group)
694 (gnus-group-real-name group) (nth 1 gnus-command-method) args)))
696 (defun gnus-request-delete-group (group &optional force)
697 (let* ((gnus-command-method (gnus-find-method-for-group group))
699 (funcall (gnus-get-function gnus-command-method 'request-delete-group)
700 (gnus-group-real-name group) force (nth 1 gnus-command-method))))
702 (gnus-cache-delete-group group)
703 (gnus-agent-delete-group group))
706 (defun gnus-request-rename-group (group new-name)
707 (let* ((gnus-command-method (gnus-find-method-for-group group))
709 (funcall (gnus-get-function gnus-command-method 'request-rename-group)
710 (gnus-group-real-name group)
711 (gnus-group-real-name new-name) (nth 1 gnus-command-method))))
713 (gnus-cache-rename-group group new-name)
714 (gnus-agent-rename-group group new-name))
717 (defun gnus-close-backends ()
718 ;; Send a close request to all backends that support such a request.
719 (let ((methods gnus-valid-select-methods)
720 (gnus-inhibit-demon t)
721 func gnus-command-method)
722 (while (setq gnus-command-method (pop methods))
723 (when (fboundp (setq func (intern
724 (concat (car gnus-command-method)
728 (defun gnus-asynchronous-p (gnus-command-method)
729 (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t)))
733 (defun gnus-remove-denial (gnus-command-method)
734 (when (stringp gnus-command-method)
735 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
736 (let* ((elem (assoc gnus-command-method gnus-opened-servers))
737 (status (cadr elem)))
738 ;; If this hasn't been opened before, we add it to the list.
739 (when (eq status 'denied)
740 ;; Set the status of this server.
741 (setcar (cdr elem) 'closed))))
745 ;;; gnus-int.el ends here