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 (defvar gnus-backend-trace t)
231 (defun gnus-open-server (gnus-command-method)
232 "Open a connection to GNUS-COMMAND-METHOD."
233 (when (stringp gnus-command-method)
234 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
235 (when gnus-backend-trace
236 (with-current-buffer (get-buffer-create "*gnus trace*")
237 (buffer-disable-undo)
238 (goto-char (point-max))
239 (insert (format-time-string "%H:%M:%S")
240 (format " %S\n" gnus-command-method))))
241 (let ((elem (assoc gnus-command-method gnus-opened-servers))
242 (server (gnus-method-to-server-name gnus-command-method)))
243 ;; If this method was previously denied, we just return nil.
244 (if (eq (nth 1 elem) 'denied)
246 (gnus-message 1 "Denied server %s" server)
249 (let* ((open-server-function (gnus-get-function gnus-command-method 'open-server))
252 (funcall open-server-function
253 (nth 1 gnus-command-method)
254 (nthcdr 2 gnus-command-method))
256 (gnus-message 1 "Unable to open server %s due to: %s"
257 server (error-message-string err))
260 (gnus-message 1 "Quit trying to open server %s" server)
263 ;; If this hasn't been opened before, we add it to the list.
265 (setq elem (list gnus-command-method nil)
266 gnus-opened-servers (cons elem gnus-opened-servers)))
267 ;; Set the status of this server.
271 (if (eq open-server-function #'nnagent-open-server)
272 ;; The agent's backend has a "special" status
276 (gnus-agent-method-p gnus-command-method))
278 (gnus-server-unopen-status
279 ;; Set the server's status to the unopen
280 ;; status. If that status is offline,
281 ;; recurse to open the agent's backend.
282 (setq open-offline (eq gnus-server-unopen-status 'offline))
283 gnus-server-unopen-status)
285 (not gnus-batch-mode)
288 "Unable to open server %s (%s), go offline? "
291 (car gnus-command-method)))))
292 (setq open-offline t)
295 ;; This agentized server was still denied
298 ;; This unagentized server must be denied
301 ;; NOTE: I MUST set the server's status to offline before this
302 ;; recursive call as this status will drive the
303 ;; gnus-get-function (called above) to return the agent's
306 ;; Recursively open this offline server to perform the
307 ;; open-server function of the agent's backend.
308 (let ((gnus-server-unopen-status 'denied))
309 ;; Bind gnus-server-unopen-status to avoid recursively
310 ;; prompting with "go offline?". This is only a concern
311 ;; when the agent's backend fails to open the server.
312 (gnus-open-server gnus-command-method))
313 (when (and (eq (cadr elem) 'ok) gnus-agent
314 (gnus-agent-method-p gnus-command-method))
316 (gnus-agent-possibly-synchronize-flags-server
317 gnus-command-method)))
320 (defun gnus-close-server (gnus-command-method)
321 "Close the connection to GNUS-COMMAND-METHOD."
322 (when (stringp gnus-command-method)
323 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
324 (funcall (gnus-get-function gnus-command-method 'close-server)
325 (nth 1 gnus-command-method)))
327 (defun gnus-request-list (gnus-command-method)
328 "Request the active file from GNUS-COMMAND-METHOD."
329 (when (stringp gnus-command-method)
330 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
331 (funcall (gnus-get-function gnus-command-method 'request-list)
332 (nth 1 gnus-command-method)))
334 (defun gnus-finish-retrieve-group-infos (gnus-command-method infos data)
335 "Read and update infos from GNUS-COMMAND-METHOD."
336 (when (stringp gnus-command-method)
337 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
338 (funcall (gnus-get-function gnus-command-method 'finish-retrieve-group-infos)
339 (nth 1 gnus-command-method)
342 (defun gnus-retrieve-group-data-early (gnus-command-method infos)
343 "Start early async retrival of data from GNUS-COMMAND-METHOD."
344 (when (stringp gnus-command-method)
345 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
346 (funcall (gnus-get-function gnus-command-method 'retrieve-group-data-early)
347 (nth 1 gnus-command-method)
350 (defun gnus-request-list-newsgroups (gnus-command-method)
351 "Request the newsgroups file from GNUS-COMMAND-METHOD."
352 (when (stringp gnus-command-method)
353 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
354 (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups)
355 (nth 1 gnus-command-method)))
357 (defun gnus-request-newgroups (date gnus-command-method)
358 "Request all new groups since DATE from GNUS-COMMAND-METHOD."
359 (when (stringp gnus-command-method)
360 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
361 (let ((func (gnus-get-function gnus-command-method 'request-newgroups t)))
363 (funcall func date (nth 1 gnus-command-method)))))
365 (defun gnus-request-regenerate (gnus-command-method)
366 "Request a data generation from GNUS-COMMAND-METHOD."
367 (when (stringp gnus-command-method)
368 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
369 (funcall (gnus-get-function gnus-command-method 'request-regenerate)
370 (nth 1 gnus-command-method)))
372 (defun gnus-request-compact-group (group)
373 (let* ((method (gnus-find-method-for-group group))
374 (gnus-command-method method)
376 (funcall (gnus-get-function gnus-command-method
377 'request-compact-group)
378 (gnus-group-real-name group)
379 (nth 1 gnus-command-method) t)))
382 (defun gnus-request-compact (gnus-command-method)
383 "Request groups compaction from GNUS-COMMAND-METHOD."
384 (when (stringp gnus-command-method)
385 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
386 (funcall (gnus-get-function gnus-command-method 'request-compact)
387 (nth 1 gnus-command-method)))
389 (defun gnus-request-group (group &optional dont-check gnus-command-method info)
390 "Request GROUP. If DONT-CHECK, no information is required."
391 (let ((gnus-command-method
392 (or gnus-command-method (inline (gnus-find-method-for-group group)))))
393 (when (stringp gnus-command-method)
394 (setq gnus-command-method
395 (inline (gnus-server-to-method gnus-command-method))))
396 (funcall (inline (gnus-get-function gnus-command-method 'request-group))
397 (gnus-group-real-name group) (nth 1 gnus-command-method)
401 (defun gnus-list-active-group (group)
402 "Request active information on GROUP."
403 (let ((gnus-command-method (gnus-find-method-for-group group))
404 (func 'list-active-group))
405 (when (gnus-check-backend-function func group)
406 (funcall (gnus-get-function gnus-command-method func)
407 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
409 (defun gnus-request-group-description (group)
410 "Request a description of GROUP."
411 (let ((gnus-command-method (gnus-find-method-for-group group))
412 (func 'request-group-description))
413 (when (gnus-check-backend-function func group)
414 (funcall (gnus-get-function gnus-command-method func)
415 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
417 (defun gnus-request-group-articles (group)
418 "Request a list of existing articles in GROUP."
419 (let ((gnus-command-method (gnus-find-method-for-group group))
420 (func 'request-group-articles))
421 (when (gnus-check-backend-function func group)
422 (funcall (gnus-get-function gnus-command-method func)
423 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
425 (defun gnus-close-group (group)
426 "Request the GROUP be closed."
427 (let ((gnus-command-method (inline (gnus-find-method-for-group group))))
428 (funcall (gnus-get-function gnus-command-method 'close-group)
429 (gnus-group-real-name group) (nth 1 gnus-command-method))))
431 (defun gnus-retrieve-headers (articles group &optional fetch-old)
432 "Request headers for ARTICLES in GROUP.
433 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
434 (let ((gnus-command-method (gnus-find-method-for-group group)))
436 ((and gnus-use-cache (numberp (car articles)))
437 (gnus-cache-retrieve-headers articles group fetch-old))
438 ((and gnus-agent (gnus-online gnus-command-method)
439 (gnus-agent-method-p gnus-command-method))
440 (gnus-agent-retrieve-headers articles group fetch-old))
442 (funcall (gnus-get-function gnus-command-method 'retrieve-headers)
443 articles (gnus-group-real-name group)
444 (nth 1 gnus-command-method) fetch-old)))))
446 (defun gnus-retrieve-articles (articles group)
447 "Request ARTICLES in GROUP."
448 (let ((gnus-command-method (gnus-find-method-for-group group)))
449 (funcall (gnus-get-function gnus-command-method 'retrieve-articles)
450 articles (gnus-group-real-name group)
451 (nth 1 gnus-command-method))))
453 (defun gnus-retrieve-groups (groups gnus-command-method)
454 "Request active information on GROUPS from GNUS-COMMAND-METHOD."
455 (when (stringp gnus-command-method)
456 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
457 (funcall (gnus-get-function gnus-command-method 'retrieve-groups)
458 groups (nth 1 gnus-command-method)))
460 (defun gnus-request-type (group &optional article)
461 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
462 (let ((gnus-command-method (gnus-find-method-for-group group)))
463 (if (not (gnus-check-backend-function
464 'request-type (car gnus-command-method)))
466 (funcall (gnus-get-function gnus-command-method 'request-type)
467 (gnus-group-real-name group) article))))
469 (defun gnus-request-set-mark (group action)
470 "Set marks on articles in the back end."
471 (let ((gnus-command-method (gnus-find-method-for-group group)))
472 (if (not (gnus-check-backend-function
473 'request-set-mark (car gnus-command-method)))
475 (funcall (gnus-get-function gnus-command-method 'request-set-mark)
476 (gnus-group-real-name group) action
477 (nth 1 gnus-command-method)))))
479 (defun gnus-request-update-mark (group article mark)
480 "Allow the back end to change the mark the user tries to put on an article."
481 (let ((gnus-command-method (gnus-find-method-for-group group)))
482 (if (not (gnus-check-backend-function
483 'request-update-mark (car gnus-command-method)))
485 (funcall (gnus-get-function gnus-command-method 'request-update-mark)
486 (gnus-group-real-name group) article mark))))
488 (defun gnus-request-article (article group &optional buffer)
489 "Request the ARTICLE in GROUP.
490 ARTICLE can either be an article number or an article Message-ID.
491 If BUFFER, insert the article in that group."
492 (let ((gnus-command-method (gnus-find-method-for-group group)))
493 (funcall (gnus-get-function gnus-command-method 'request-article)
494 article (gnus-group-real-name group)
495 (nth 1 gnus-command-method) buffer)))
497 (defun gnus-request-head (article group)
498 "Request the head of ARTICLE in GROUP."
499 (let* ((gnus-command-method (gnus-find-method-for-group group))
500 (head (gnus-get-function gnus-command-method 'request-head t))
506 (gnus-cache-request-article article group))
507 (setq res (cons group article)
509 ;; Check the agent cache.
510 ((gnus-agent-request-article article group)
511 (setq res (cons group article)
513 ;; Use `head' function.
515 (setq res (funcall head article (gnus-group-real-name group)
516 (nth 1 gnus-command-method))))
517 ;; Use `article' function.
519 (setq res (gnus-request-article article group)
522 (with-current-buffer nntp-server-buffer
523 (goto-char (point-min))
524 (when (search-forward "\n\n" nil t)
525 (delete-region (1- (point)) (point-max)))
526 (nnheader-fold-continuation-lines)))
529 (defun gnus-request-body (article group)
530 "Request the body of ARTICLE in GROUP."
531 (let* ((gnus-command-method (gnus-find-method-for-group group))
532 (head (gnus-get-function gnus-command-method 'request-body t))
538 (gnus-cache-request-article article group))
539 (setq res (cons group article)
541 ;; Check the agent cache.
542 ((gnus-agent-request-article article group)
543 (setq res (cons group article)
545 ;; Use `head' function.
547 (setq res (funcall head article (gnus-group-real-name group)
548 (nth 1 gnus-command-method))))
549 ;; Use `article' function.
551 (setq res (gnus-request-article article group)
554 (with-current-buffer nntp-server-buffer
555 (goto-char (point-min))
556 (when (search-forward "\n\n" nil t)
557 (delete-region (point-min) (1- (point))))))
560 (defun gnus-request-post (gnus-command-method)
561 "Post the current buffer using GNUS-COMMAND-METHOD."
562 (when (stringp gnus-command-method)
563 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
564 (funcall (gnus-get-function gnus-command-method 'request-post)
565 (nth 1 gnus-command-method)))
567 (defun gnus-request-expunge-group (group gnus-command-method)
568 "Expunge GROUP, which is removing articles that have been marked as deleted."
569 (when (stringp gnus-command-method)
570 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
571 (funcall (gnus-get-function gnus-command-method 'request-expunge-group)
572 (gnus-group-real-name group)
573 (nth 1 gnus-command-method)))
575 (defun gnus-request-scan (group gnus-command-method)
576 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
577 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
578 (let ((gnus-command-method
579 (if group (gnus-find-method-for-group group) gnus-command-method))
580 (gnus-inhibit-demon t)
581 (mail-source-plugged gnus-plugged))
582 (when (or gnus-plugged
583 (not (gnus-agent-method-p gnus-command-method)))
584 (setq gnus-internal-registry-spool-current-method gnus-command-method)
585 (funcall (gnus-get-function gnus-command-method 'request-scan)
586 (and group (gnus-group-real-name group))
587 (nth 1 gnus-command-method)))))
589 (defun gnus-request-update-info (info gnus-command-method)
590 (when (gnus-check-backend-function
591 'request-update-info (car gnus-command-method))
592 (when (stringp gnus-command-method)
593 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
594 (funcall (gnus-get-function gnus-command-method 'request-update-info)
595 (gnus-group-real-name (gnus-info-group info)) info
596 (nth 1 gnus-command-method))))
598 (defsubst gnus-request-marks (info gnus-command-method)
599 "Request that GNUS-COMMAND-METHOD update INFO."
600 (when (stringp gnus-command-method)
601 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
602 (when (gnus-check-backend-function
603 'request-marks (car gnus-command-method))
604 (let ((group (gnus-info-group info)))
605 (and (funcall (gnus-get-function gnus-command-method
606 'request-update-info)
607 (gnus-group-real-name group)
608 info (nth 1 gnus-command-method))
609 ;; If the minimum article number is greater than 1, then all
610 ;; smaller article numbers are known not to exist; we'll
611 ;; artificially add those to the 'read range.
612 (let* ((active (gnus-active group))
615 (let* ((range (if (= min 2) 1 (cons 1 (1- min))))
616 (read (gnus-info-read info))
617 (new-read (gnus-range-add read (list range))))
618 (gnus-info-set-read info new-read)))
621 (defun gnus-request-expire-articles (articles group &optional force)
622 (let* ((gnus-command-method (gnus-find-method-for-group group))
623 (gnus-inhibit-demon t)
626 (gnus-get-function gnus-command-method 'request-expire-articles)
627 articles (gnus-group-real-name group) (nth 1 gnus-command-method)
629 (when (and gnus-agent
630 (gnus-agent-method-p gnus-command-method))
631 (let ((expired-articles (gnus-sorted-difference articles not-deleted)))
632 (when expired-articles
633 (gnus-agent-expire expired-articles group 'force))))
636 (defun gnus-request-move-article (article group server accept-function
637 &optional last move-is-internal)
638 (let* ((gnus-command-method (gnus-find-method-for-group group))
639 (result (funcall (gnus-get-function gnus-command-method
640 'request-move-article)
641 article (gnus-group-real-name group)
642 (nth 1 gnus-command-method) accept-function last move-is-internal)))
643 (when (and result gnus-agent
644 (gnus-agent-method-p gnus-command-method))
645 (gnus-agent-unfetch-articles group (list article)))
648 (defun gnus-request-accept-article (group &optional gnus-command-method last
650 ;; Make sure there's a newline at the end of the article.
651 (when (stringp gnus-command-method)
652 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
653 (when (and (not gnus-command-method)
655 (setq gnus-command-method (or (gnus-find-method-for-group group)
656 (gnus-group-name-to-method group))))
657 (goto-char (point-max))
661 (let ((message-options message-options))
662 (message-options-set-recipient)
664 (message-narrow-to-head)
665 (let ((mail-parse-charset message-default-charset))
666 (mail-encode-encoded-word-buffer)))
667 (message-encode-message-body)))
668 (let ((gnus-command-method (or gnus-command-method
669 (gnus-find-method-for-group group)))
672 (gnus-get-function gnus-command-method 'request-accept-article)
673 (if (stringp group) (gnus-group-real-name group) group)
674 (cadr gnus-command-method)
676 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
677 (gnus-agent-regenerate-group group (list (cdr result))))
680 (defun gnus-request-replace-article (article group buffer &optional no-encode)
682 (let ((message-options message-options))
683 (message-options-set-recipient)
685 (message-narrow-to-head)
686 (let ((mail-parse-charset message-default-charset))
687 (mail-encode-encoded-word-buffer)))
688 (message-encode-message-body)))
689 (let* ((func (car (gnus-group-name-to-method group)))
690 (result (funcall (intern (format "%s-request-replace-article" func))
691 article (gnus-group-real-name group) buffer)))
692 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
693 (gnus-agent-regenerate-group group (list article)))
696 (defun gnus-request-associate-buffer (group)
697 (let ((gnus-command-method (gnus-find-method-for-group group)))
698 (funcall (gnus-get-function gnus-command-method 'request-associate-buffer)
699 (gnus-group-real-name group))))
701 (defun gnus-request-restore-buffer (article group)
702 "Request a new buffer restored to the state of ARTICLE."
703 (let ((gnus-command-method (gnus-find-method-for-group group)))
704 (funcall (gnus-get-function gnus-command-method 'request-restore-buffer)
705 article (gnus-group-real-name group)
706 (nth 1 gnus-command-method))))
708 (defun gnus-request-create-group (group &optional gnus-command-method args)
709 (when (stringp gnus-command-method)
710 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
711 (let ((gnus-command-method
712 (or gnus-command-method (gnus-find-method-for-group group))))
713 (funcall (gnus-get-function gnus-command-method 'request-create-group)
714 (gnus-group-real-name group) (nth 1 gnus-command-method) args)))
716 (defun gnus-request-delete-group (group &optional force)
717 (let* ((gnus-command-method (gnus-find-method-for-group group))
719 (funcall (gnus-get-function gnus-command-method 'request-delete-group)
720 (gnus-group-real-name group) force (nth 1 gnus-command-method))))
722 (gnus-cache-delete-group group)
723 (gnus-agent-delete-group group))
726 (defun gnus-request-rename-group (group new-name)
727 (let* ((gnus-command-method (gnus-find-method-for-group group))
729 (funcall (gnus-get-function gnus-command-method 'request-rename-group)
730 (gnus-group-real-name group)
731 (gnus-group-real-name new-name) (nth 1 gnus-command-method))))
733 (gnus-cache-rename-group group new-name)
734 (gnus-agent-rename-group group new-name))
737 (defun gnus-close-backends ()
738 ;; Send a close request to all backends that support such a request.
739 (let ((methods gnus-valid-select-methods)
740 (gnus-inhibit-demon t)
741 func gnus-command-method)
742 (while (setq gnus-command-method (pop methods))
743 (when (fboundp (setq func (intern
744 (concat (car gnus-command-method)
748 (defun gnus-asynchronous-p (gnus-command-method)
749 (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t)))
753 (defun gnus-remove-denial (gnus-command-method)
754 (when (stringp gnus-command-method)
755 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
756 (let* ((elem (assoc gnus-command-method gnus-opened-servers))
757 (status (cadr elem)))
758 ;; If this hasn't been opened before, we add it to the list.
759 (when (eq status 'denied)
760 ;; Set the status of this server.
761 (setcar (cdr elem) 'closed))))
765 ;;; gnus-int.el ends here