1 ;;; gnus-int.el --- backend interface functions for Gnus
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
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 3 of the License, or
13 ;; (at your option) any later version.
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 (eval-when-compile (require 'cl))
33 (autoload 'gnus-run-hook-with-args "gnus-util")
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-after-set-mark-hook nil
45 "Hook called just after marks are set in a group."
49 (defcustom gnus-before-update-mark-hook nil
50 "Hook called just before marks are updated in a group."
54 (defcustom gnus-server-unopen-status nil
55 "The default status if the server is not able to open.
56 If the server is covered by Gnus agent, the possible values are
57 `denied', set the server denied; `offline', set the server offline;
58 nil, ask user. If the server is not covered by Gnus agent, set the
62 :type '(choice (const :tag "Ask" nil)
63 (const :tag "Deny server" denied)
64 (const :tag "Unplug Agent" offline)))
66 (defvar gnus-internal-registry-spool-current-method nil
67 "The current method, for the registry.")
70 (defun gnus-server-opened (gnus-command-method)
71 "Check whether a connection to GNUS-COMMAND-METHOD has been opened."
72 (unless (eq (gnus-server-status gnus-command-method)
74 (when (stringp gnus-command-method)
75 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
76 (funcall (inline (gnus-get-function gnus-command-method 'server-opened))
77 (nth 1 gnus-command-method))))
79 (defun gnus-status-message (gnus-command-method)
80 "Return the status message from GNUS-COMMAND-METHOD.
81 If GNUS-COMMAND-METHOD is a string, it is interpreted as a group
82 name. The method this group uses will be queried."
83 (let ((gnus-command-method
84 (if (stringp gnus-command-method)
85 (gnus-find-method-for-group gnus-command-method)
86 gnus-command-method)))
87 (funcall (gnus-get-function gnus-command-method 'status-message)
88 (nth 1 gnus-command-method))))
91 ;;; Server Communication
94 (defun gnus-start-news-server (&optional confirm)
95 "Open a method for getting news.
96 If CONFIRM is non-nil, the user will be asked for an NNTP server."
98 (if gnus-current-select-method
99 ;; Stream is already opened.
103 ;; Read server name with completion.
104 (setq gnus-nntp-server
105 (gnus-completing-read "NNTP server"
106 (cons gnus-nntp-server
107 gnus-secondary-servers)
108 nil gnus-nntp-server)))
110 (when (and gnus-nntp-server
111 (stringp gnus-nntp-server)
112 (not (string= gnus-nntp-server "")))
113 (setq gnus-select-method
114 (cond ((or (string= gnus-nntp-server "")
115 (string= gnus-nntp-server "::"))
116 (list 'nnspool (system-name)))
117 ((string-match "^:" gnus-nntp-server)
118 (list 'nnmh gnus-nntp-server
119 (list 'nnmh-directory
120 (file-name-as-directory
122 (substring gnus-nntp-server 1) "~/")))
123 (list 'nnmh-get-new-mail nil)))
125 (list 'nntp gnus-nntp-server)))))
127 (setq how (car gnus-select-method))
131 (gnus-message 5 "Looking up local news spool..."))
134 (gnus-message 5 "Looking up mh spool..."))
137 (setq gnus-current-select-method gnus-select-method)
138 (gnus-run-hooks 'gnus-open-server-hook)
140 ;; Partially validate agent covered methods now that the
141 ;; gnus-select-method is known.
144 ;; NOTE: This is here for one purpose only. By validating
145 ;; the current select method, it converts the old 5.10.3,
146 ;; and earlier, format to the current format. That enables
147 ;; the agent code within gnus-open-server to function
149 (gnus-agent-read-servers-validate-native gnus-select-method))
152 ;; gnus-open-server-hook might have opened it
153 (gnus-server-opened gnus-select-method)
154 (gnus-open-server gnus-select-method)
158 "%s (%s) open error: '%s'. Continue? "
159 (car gnus-select-method) (cadr gnus-select-method)
160 (gnus-status-message gnus-select-method)))
161 (gnus-error 1 "Couldn't open server on %s"
162 (nth 1 gnus-select-method))))))
164 (defun gnus-check-group (group)
165 "Try to make sure that the server where GROUP exists is alive."
166 (let ((method (gnus-find-method-for-group group)))
167 (or (gnus-server-opened method)
168 (gnus-open-server method))))
170 (defun gnus-check-server (&optional method silent)
171 "Check whether the connection to METHOD is down.
172 If METHOD is nil, use `gnus-select-method'.
173 If it is down, start it up (again)."
174 (let ((method (or method gnus-select-method))
176 ;; Transform virtual server names into select methods.
177 (when (stringp method)
178 (setq method (gnus-server-to-method method)))
179 (if (gnus-server-opened method)
180 ;; The stream is already opened.
184 (gnus-message 5 "Opening %s server%s..." (car method)
185 (if (equal (nth 1 method) "") ""
186 (format " on %s" (nth 1 method)))))
187 (gnus-run-hooks 'gnus-open-server-hook)
189 (setq result (gnus-open-server method))
193 "Opening %s server%s...%s" (car method)
194 (if (equal (nth 1 method) "") ""
195 (format " on %s" (nth 1 method)))
199 (nnheader-get-report-string (car method))))))))))
201 (defun gnus-get-function (method function &optional noerror)
202 "Return a function symbol based on METHOD and FUNCTION."
203 ;; Translate server names into methods.
205 (error "Attempted use of a nil select method"))
206 (when (stringp method)
207 (setq method (gnus-server-to-method method)))
208 ;; Check cache of constructed names.
209 (let* ((method-sym (if gnus-agent
210 (inline (gnus-agent-get-function method))
212 (method-fns (get method-sym 'gnus-method-functions))
213 (func (let ((method-fnlist-elt (assq function method-fns)))
214 (unless method-fnlist-elt
215 (setq method-fnlist-elt
217 (intern (format "%s-%s" method-sym function))))
218 (put method-sym 'gnus-method-functions
219 (cons method-fnlist-elt method-fns)))
220 (cdr method-fnlist-elt))))
221 ;; Maybe complain if there is no function.
222 (unless (fboundp func)
224 (error "Trying to require a method that doesn't exist"))
225 (require (car method))
226 (when (not (fboundp func))
229 (error "No such function: %s" func))))
234 ;;; Interface functions to the backends.
237 (defun gnus-method-denied-p (method)
238 (eq (nth 1 (assoc method gnus-opened-servers))
241 (defvar gnus-backend-trace t)
243 (defun gnus-open-server (gnus-command-method)
244 "Open a connection to GNUS-COMMAND-METHOD."
245 (when (stringp gnus-command-method)
246 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
247 (when gnus-backend-trace
248 (with-current-buffer (get-buffer-create "*gnus trace*")
249 (buffer-disable-undo)
250 (goto-char (point-max))
251 (insert (format-time-string "%H:%M:%S")
252 (format " %S\n" gnus-command-method))))
253 (let ((elem (assoc gnus-command-method gnus-opened-servers))
254 (server (gnus-method-to-server-name gnus-command-method)))
255 ;; If this method was previously denied, we just return nil.
256 (if (eq (nth 1 elem) 'denied)
259 1 "Server %s previously determined to be down; not retrying" server)
262 (let* ((open-server-function
263 (gnus-get-function gnus-command-method 'open-server))
266 (funcall open-server-function
267 (nth 1 gnus-command-method)
268 (nthcdr 2 gnus-command-method))
270 (gnus-message 1 "Unable to open server %s due to: %s"
271 server (error-message-string err))
276 (gnus-message 1 "Quit trying to open server %s" server))
279 ;; If this hasn't been opened before, we add it to the list.
281 (setq elem (list gnus-command-method nil)
282 gnus-opened-servers (cons elem gnus-opened-servers)))
283 ;; Set the status of this server.
287 (if (eq open-server-function #'nnagent-open-server)
288 ;; The agent's backend has a "special" status
292 (gnus-agent-method-p gnus-command-method))
294 (gnus-server-unopen-status
295 ;; Set the server's status to the unopen
296 ;; status. If that status is offline,
297 ;; recurse to open the agent's backend.
298 (setq open-offline (eq gnus-server-unopen-status 'offline))
299 gnus-server-unopen-status)
300 ((not gnus-batch-mode)
301 (setq open-offline t)
304 ;; This agentized server was still denied
307 ;; This unagentized server must be denied
310 ;; NOTE: I MUST set the server's status to offline before this
311 ;; recursive call as this status will drive the
312 ;; gnus-get-function (called above) to return the agent's
315 ;; Recursively open this offline server to perform the
316 ;; open-server function of the agent's backend.
317 (let ((gnus-server-unopen-status 'denied))
318 ;; Bind gnus-server-unopen-status to avoid recursively
319 ;; prompting with "go offline?". This is only a concern
320 ;; when the agent's backend fails to open the server.
321 (gnus-open-server gnus-command-method))
322 (when (and (eq (cadr elem) 'ok) gnus-agent
323 (gnus-agent-method-p gnus-command-method))
325 (gnus-agent-possibly-synchronize-flags-server
326 gnus-command-method)))
329 (defun gnus-close-server (gnus-command-method)
330 "Close the connection to GNUS-COMMAND-METHOD."
331 (when (stringp gnus-command-method)
332 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
333 (funcall (gnus-get-function gnus-command-method 'close-server)
334 (nth 1 gnus-command-method)))
336 (defun gnus-request-list (gnus-command-method)
337 "Request the active file from GNUS-COMMAND-METHOD."
338 (when (stringp gnus-command-method)
339 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
340 (funcall (gnus-get-function gnus-command-method 'request-list)
341 (nth 1 gnus-command-method)))
343 (defun gnus-finish-retrieve-group-infos (gnus-command-method infos data)
344 "Read and update infos from GNUS-COMMAND-METHOD."
345 (when (stringp gnus-command-method)
346 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
347 (funcall (gnus-get-function gnus-command-method 'finish-retrieve-group-infos)
348 (nth 1 gnus-command-method)
351 (defun gnus-retrieve-group-data-early (gnus-command-method infos)
352 "Start early async retrival of data from GNUS-COMMAND-METHOD."
353 (when (stringp gnus-command-method)
354 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
355 (funcall (gnus-get-function gnus-command-method 'retrieve-group-data-early)
356 (nth 1 gnus-command-method)
359 (defun gnus-request-list-newsgroups (gnus-command-method)
360 "Request the newsgroups file from GNUS-COMMAND-METHOD."
361 (when (stringp gnus-command-method)
362 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
363 (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups)
364 (nth 1 gnus-command-method)))
366 (defun gnus-request-newgroups (date gnus-command-method)
367 "Request all new groups since DATE from GNUS-COMMAND-METHOD."
368 (when (stringp gnus-command-method)
369 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
370 (let ((func (gnus-get-function gnus-command-method 'request-newgroups t)))
372 (funcall func date (nth 1 gnus-command-method)))))
374 (defun gnus-request-regenerate (gnus-command-method)
375 "Request a data generation from GNUS-COMMAND-METHOD."
376 (when (stringp gnus-command-method)
377 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
378 (funcall (gnus-get-function gnus-command-method 'request-regenerate)
379 (nth 1 gnus-command-method)))
381 (defun gnus-request-compact-group (group)
382 (let* ((method (gnus-find-method-for-group group))
383 (gnus-command-method method)
385 (funcall (gnus-get-function gnus-command-method
386 'request-compact-group)
387 (gnus-group-real-name group)
388 (nth 1 gnus-command-method) t)))
391 (defun gnus-request-compact (gnus-command-method)
392 "Request groups compaction from GNUS-COMMAND-METHOD."
393 (when (stringp gnus-command-method)
394 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
395 (funcall (gnus-get-function gnus-command-method 'request-compact)
396 (nth 1 gnus-command-method)))
398 (defun gnus-request-group (group &optional dont-check gnus-command-method info)
399 "Request GROUP. If DONT-CHECK, no information is required."
400 (let ((gnus-command-method
401 (or gnus-command-method (inline (gnus-find-method-for-group group)))))
402 (when (stringp gnus-command-method)
403 (setq gnus-command-method
404 (inline (gnus-server-to-method gnus-command-method))))
405 (funcall (inline (gnus-get-function gnus-command-method 'request-group))
406 (gnus-group-real-name group) (nth 1 gnus-command-method)
410 (defun gnus-list-active-group (group)
411 "Request active information on GROUP."
412 (let ((gnus-command-method (gnus-find-method-for-group group))
413 (func 'list-active-group))
414 (when (gnus-check-backend-function func group)
415 (funcall (gnus-get-function gnus-command-method func)
416 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
418 (defun gnus-request-group-description (group)
419 "Request a description of GROUP."
420 (let ((gnus-command-method (gnus-find-method-for-group group))
421 (func 'request-group-description))
422 (when (gnus-check-backend-function func group)
423 (funcall (gnus-get-function gnus-command-method func)
424 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
426 (defun gnus-request-group-articles (group)
427 "Request a list of existing articles in GROUP."
428 (let ((gnus-command-method (gnus-find-method-for-group group))
429 (func 'request-group-articles))
430 (when (gnus-check-backend-function func group)
431 (funcall (gnus-get-function gnus-command-method func)
432 (gnus-group-real-name group) (nth 1 gnus-command-method)))))
434 (defun gnus-close-group (group)
435 "Request the GROUP be closed."
436 (let ((gnus-command-method (inline (gnus-find-method-for-group group))))
437 (funcall (gnus-get-function gnus-command-method 'close-group)
438 (gnus-group-real-name group) (nth 1 gnus-command-method))))
440 (defun gnus-retrieve-headers (articles group &optional fetch-old)
441 "Request headers for ARTICLES in GROUP.
442 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
443 (let ((gnus-command-method (gnus-find-method-for-group group)))
445 ((and gnus-use-cache (numberp (car articles)))
446 (gnus-cache-retrieve-headers articles group fetch-old))
447 ((and gnus-agent (gnus-online gnus-command-method)
448 (gnus-agent-method-p gnus-command-method))
449 (gnus-agent-retrieve-headers articles group fetch-old))
451 (funcall (gnus-get-function gnus-command-method 'retrieve-headers)
452 articles (gnus-group-real-name group)
453 (nth 1 gnus-command-method) fetch-old)))))
455 (defun gnus-retrieve-articles (articles group)
456 "Request ARTICLES in GROUP."
457 (let ((gnus-command-method (gnus-find-method-for-group group)))
458 (funcall (gnus-get-function gnus-command-method 'retrieve-articles)
459 articles (gnus-group-real-name group)
460 (nth 1 gnus-command-method))))
462 (defun gnus-retrieve-groups (groups gnus-command-method)
463 "Request active information on GROUPS from GNUS-COMMAND-METHOD."
464 (when (stringp gnus-command-method)
465 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
466 (funcall (gnus-get-function gnus-command-method 'retrieve-groups)
467 groups (nth 1 gnus-command-method)))
469 (defun gnus-request-type (group &optional article)
470 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
471 (let ((gnus-command-method (gnus-find-method-for-group group)))
472 (if (not (gnus-check-backend-function
473 'request-type (car gnus-command-method)))
475 (funcall (gnus-get-function gnus-command-method 'request-type)
476 (gnus-group-real-name group) article))))
478 (defun gnus-request-update-group-status (group status)
479 "Change the status of a group.
480 Valid statuses include `subscribe' and `unsubscribe'."
481 (let ((gnus-command-method (gnus-find-method-for-group group)))
482 (if (not (gnus-check-backend-function
483 'request-update-group-status (car gnus-command-method)))
486 (gnus-get-function gnus-command-method 'request-update-group-status)
487 (gnus-group-real-name group) status
488 (nth 1 gnus-command-method)))))
490 (defun gnus-request-set-mark (group action)
491 "Set marks on articles in the back end."
492 (let ((gnus-command-method (gnus-find-method-for-group group)))
493 (if (not (gnus-check-backend-function
494 'request-set-mark (car gnus-command-method)))
496 (funcall (gnus-get-function gnus-command-method 'request-set-mark)
497 (gnus-group-real-name group) action
498 (nth 1 gnus-command-method))
499 (gnus-run-hook-with-args gnus-after-set-mark-hook group action))))
501 (defun gnus-request-update-mark (group article mark)
502 "Allow the back end to change the mark the user tries to put on an article."
503 (let ((gnus-command-method (gnus-find-method-for-group group)))
504 (if (not (gnus-check-backend-function
505 'request-update-mark (car gnus-command-method)))
507 (gnus-run-hook-with-args gnus-before-update-mark-hook group article mark)
508 (funcall (gnus-get-function gnus-command-method 'request-update-mark)
509 (gnus-group-real-name group) article mark))))
511 (defun gnus-request-article (article group &optional buffer)
512 "Request the ARTICLE in GROUP.
513 ARTICLE can either be an article number or an article Message-ID.
514 If BUFFER, insert the article in that group."
515 (let ((gnus-command-method (gnus-find-method-for-group group)))
516 (funcall (gnus-get-function gnus-command-method 'request-article)
517 article (gnus-group-real-name group)
518 (nth 1 gnus-command-method) buffer)))
520 (defun gnus-request-thread (header group)
521 "Request the headers in the thread containing the article specified by HEADER."
522 (let ((gnus-command-method (gnus-find-method-for-group group)))
523 (funcall (gnus-get-function gnus-command-method 'request-thread)
525 (gnus-group-real-name group))))
527 (defun gnus-warp-to-article ()
528 "Warps from an article in a virtual group to the article in its
529 real group. Does nothing on a real group."
531 (let ((gnus-command-method
532 (gnus-find-method-for-group gnus-newsgroup-name)))
533 (when (gnus-check-backend-function
534 'warp-to-article (car gnus-command-method))
535 (funcall (gnus-get-function gnus-command-method 'warp-to-article)))))
537 (defun gnus-request-head (article group)
538 "Request the head of ARTICLE in GROUP."
539 (let* ((gnus-command-method (gnus-find-method-for-group group))
540 (head (gnus-get-function gnus-command-method 'request-head t))
546 (gnus-cache-request-article article group))
547 (setq res (cons group article)
549 ;; Check the agent cache.
550 ((gnus-agent-request-article article group)
551 (setq res (cons group article)
553 ;; Use `head' function.
555 (setq res (funcall head article (gnus-group-real-name group)
556 (nth 1 gnus-command-method))))
557 ;; Use `article' function.
559 (setq res (gnus-request-article article group)
562 (with-current-buffer nntp-server-buffer
563 (goto-char (point-min))
564 (when (search-forward "\n\n" nil t)
565 (delete-region (1- (point)) (point-max)))
566 (nnheader-fold-continuation-lines)))
569 (defun gnus-request-body (article group)
570 "Request the body of ARTICLE in GROUP."
571 (let* ((gnus-command-method (gnus-find-method-for-group group))
572 (head (gnus-get-function gnus-command-method 'request-body t))
578 (gnus-cache-request-article article group))
579 (setq res (cons group article)
581 ;; Check the agent cache.
582 ((gnus-agent-request-article article group)
583 (setq res (cons group article)
585 ;; Use `head' function.
587 (setq res (funcall head article (gnus-group-real-name group)
588 (nth 1 gnus-command-method))))
589 ;; Use `article' function.
591 (setq res (gnus-request-article article group)
594 (with-current-buffer nntp-server-buffer
595 (goto-char (point-min))
596 (when (search-forward "\n\n" nil t)
597 (delete-region (point-min) (1- (point))))))
600 (defun gnus-request-post (gnus-command-method)
601 "Post the current buffer using GNUS-COMMAND-METHOD."
602 (when (stringp gnus-command-method)
603 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
604 (funcall (gnus-get-function gnus-command-method 'request-post)
605 (nth 1 gnus-command-method)))
607 (defun gnus-request-expunge-group (group gnus-command-method)
608 "Expunge GROUP, which is removing articles that have been marked as deleted."
609 (when (stringp gnus-command-method)
610 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
611 (funcall (gnus-get-function gnus-command-method 'request-expunge-group)
612 (gnus-group-real-name group)
613 (nth 1 gnus-command-method)))
615 (defun gnus-request-scan (group gnus-command-method)
616 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
617 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
618 (let ((gnus-command-method
619 (if group (gnus-find-method-for-group group) gnus-command-method))
620 (gnus-inhibit-demon t)
621 (mail-source-plugged gnus-plugged))
622 (when (or gnus-plugged
623 (not (gnus-agent-method-p gnus-command-method)))
624 (setq gnus-internal-registry-spool-current-method gnus-command-method)
625 (funcall (gnus-get-function gnus-command-method 'request-scan)
626 (and group (gnus-group-real-name group))
627 (nth 1 gnus-command-method)))))
629 (defun gnus-request-update-info (info gnus-command-method)
630 (when (gnus-check-backend-function
631 'request-update-info (car gnus-command-method))
632 (when (stringp gnus-command-method)
633 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
634 (funcall (gnus-get-function gnus-command-method 'request-update-info)
635 (gnus-group-real-name (gnus-info-group info)) info
636 (nth 1 gnus-command-method))))
638 (defsubst gnus-request-marks (info gnus-command-method)
639 "Request that GNUS-COMMAND-METHOD update INFO."
640 (when (stringp gnus-command-method)
641 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
642 (when (gnus-check-backend-function
643 'request-marks (car gnus-command-method))
644 (let ((group (gnus-info-group info)))
645 (and (funcall (gnus-get-function gnus-command-method 'request-marks)
646 (gnus-group-real-name group)
647 info (nth 1 gnus-command-method))
648 ;; If the minimum article number is greater than 1, then all
649 ;; smaller article numbers are known not to exist; we'll
650 ;; artificially add those to the 'read range.
651 (let* ((active (gnus-active group))
654 (let* ((range (if (= min 2) 1 (cons 1 (1- min))))
655 (read (gnus-info-read info))
656 (new-read (gnus-range-add read (list range))))
657 (gnus-info-set-read info new-read)))
660 (defun gnus-request-expire-articles (articles group &optional force)
661 (let* ((gnus-command-method (gnus-find-method-for-group group))
662 (gnus-inhibit-demon t)
665 (gnus-get-function gnus-command-method 'request-expire-articles)
666 articles (gnus-group-real-name group) (nth 1 gnus-command-method)
668 (when (and gnus-agent
669 (gnus-agent-method-p gnus-command-method))
670 (let ((expired-articles (gnus-sorted-difference articles not-deleted)))
671 (when expired-articles
672 (gnus-agent-expire expired-articles group 'force))))
675 (defun gnus-request-move-article (article group server accept-function
676 &optional last move-is-internal)
677 (let* ((gnus-command-method (gnus-find-method-for-group group))
678 (result (funcall (gnus-get-function gnus-command-method
679 'request-move-article)
680 article (gnus-group-real-name group)
681 (nth 1 gnus-command-method) accept-function
682 last move-is-internal)))
683 (when (and result gnus-agent
684 (gnus-agent-method-p gnus-command-method))
685 (gnus-agent-unfetch-articles group (list article)))
688 (defun gnus-request-accept-article (group &optional gnus-command-method last
690 ;; Make sure there's a newline at the end of the article.
691 (when (stringp gnus-command-method)
692 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
693 (when (and (not gnus-command-method)
695 (setq gnus-command-method (or (gnus-find-method-for-group group)
696 (gnus-group-name-to-method group))))
697 (goto-char (point-max))
701 (let ((message-options message-options))
702 (message-options-set-recipient)
704 (message-narrow-to-head)
705 (let ((mail-parse-charset message-default-charset))
706 (mail-encode-encoded-word-buffer)))
707 (message-encode-message-body)))
708 (let ((gnus-command-method (or gnus-command-method
709 (gnus-find-method-for-group group)))
712 (gnus-get-function gnus-command-method 'request-accept-article)
713 (if (stringp group) (gnus-group-real-name group) group)
714 (cadr gnus-command-method)
716 (when (and gnus-agent
717 (gnus-agent-method-p gnus-command-method)
719 (gnus-agent-regenerate-group group (list (cdr result))))
722 (defun gnus-request-replace-article (article group buffer &optional no-encode)
724 (let ((message-options message-options))
725 (message-options-set-recipient)
727 (message-narrow-to-head)
728 (let ((mail-parse-charset message-default-charset))
729 (mail-encode-encoded-word-buffer)))
730 (message-encode-message-body)))
731 (let* ((func (car (gnus-group-name-to-method group)))
732 (result (funcall (intern (format "%s-request-replace-article" func))
733 article (gnus-group-real-name group) buffer)))
734 (when (and gnus-agent (gnus-agent-method-p gnus-command-method))
735 (gnus-agent-regenerate-group group (list article)))
738 (defun gnus-request-associate-buffer (group)
739 (let ((gnus-command-method (gnus-find-method-for-group group)))
740 (funcall (gnus-get-function gnus-command-method 'request-associate-buffer)
741 (gnus-group-real-name group))))
743 (defun gnus-request-restore-buffer (article group)
744 "Request a new buffer restored to the state of ARTICLE."
745 (let ((gnus-command-method (gnus-find-method-for-group group)))
746 (funcall (gnus-get-function gnus-command-method 'request-restore-buffer)
747 article (gnus-group-real-name group)
748 (nth 1 gnus-command-method))))
750 (defun gnus-request-create-group (group &optional gnus-command-method args)
751 (when (stringp gnus-command-method)
752 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
753 (let ((gnus-command-method
754 (or gnus-command-method (gnus-find-method-for-group group))))
755 (funcall (gnus-get-function gnus-command-method 'request-create-group)
756 (gnus-group-real-name group) (nth 1 gnus-command-method) args)))
758 (defun gnus-request-delete-group (group &optional force)
759 (let* ((gnus-command-method (gnus-find-method-for-group group))
761 (funcall (gnus-get-function gnus-command-method 'request-delete-group)
762 (gnus-group-real-name group) force (nth 1 gnus-command-method))))
764 (gnus-cache-delete-group group)
765 (gnus-agent-delete-group group))
768 (defun gnus-request-rename-group (group new-name)
769 (let* ((gnus-command-method (gnus-find-method-for-group group))
771 (funcall (gnus-get-function gnus-command-method 'request-rename-group)
772 (gnus-group-real-name group)
773 (gnus-group-real-name new-name) (nth 1 gnus-command-method))))
775 (gnus-cache-rename-group group new-name)
776 (gnus-agent-rename-group group new-name))
779 (defun gnus-close-backends ()
780 ;; Send a close request to all backends that support such a request.
781 (let ((methods gnus-valid-select-methods)
782 (gnus-inhibit-demon t)
783 func gnus-command-method)
784 (while (setq gnus-command-method (pop methods))
785 (when (fboundp (setq func (intern
786 (concat (car gnus-command-method)
790 (defun gnus-asynchronous-p (gnus-command-method)
791 (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t)))
795 (defun gnus-remove-denial (gnus-command-method)
796 (when (stringp gnus-command-method)
797 (setq gnus-command-method (gnus-server-to-method gnus-command-method)))
798 (let* ((elem (assoc gnus-command-method gnus-opened-servers))
799 (status (cadr elem)))
800 ;; If this hasn't been opened before, we add it to the list.
801 (when (eq status 'denied)
802 ;; Set the status of this server.
803 (setcar (cdr elem) 'closed))))
807 ;;; gnus-int.el ends here