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 (defcustom gnus-nntp-server nil
67 "The name of the host running the NNTP server."
69 :type
'(choice (const :tag
"disable" nil
)
71 (make-obsolete-variable 'gnus-nntp-server
'gnus-select-method
"24.1")
73 (defvar gnus-internal-registry-spool-current-method nil
74 "The current method, for the registry.")
77 (defun gnus-server-opened (gnus-command-method)
78 "Check whether a connection to GNUS-COMMAND-METHOD has been opened."
79 (unless (eq (gnus-server-status gnus-command-method
)
81 (when (stringp gnus-command-method
)
82 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
83 (funcall (inline (gnus-get-function gnus-command-method
'server-opened
))
84 (nth 1 gnus-command-method
))))
86 (defun gnus-status-message (gnus-command-method)
87 "Return the status message from GNUS-COMMAND-METHOD.
88 If GNUS-COMMAND-METHOD is a string, it is interpreted as a group
89 name. The method this group uses will be queried."
90 (let ((gnus-command-method
91 (if (stringp gnus-command-method
)
92 (gnus-find-method-for-group gnus-command-method
)
93 gnus-command-method
)))
94 (funcall (gnus-get-function gnus-command-method
'status-message
)
95 (nth 1 gnus-command-method
))))
98 ;;; Server Communication
101 (defun gnus-start-news-server (&optional confirm
)
102 "Open a method for getting news.
103 If CONFIRM is non-nil, the user will be asked for an NNTP server."
105 (if gnus-current-select-method
106 ;; Stream is already opened.
110 ;; Read server name with completion.
111 (setq gnus-nntp-server
112 (gnus-completing-read "NNTP server"
113 (cons gnus-nntp-server
114 gnus-secondary-servers
)
115 nil gnus-nntp-server
)))
117 (when (and gnus-nntp-server
118 (stringp gnus-nntp-server
)
119 (not (string= gnus-nntp-server
"")))
120 (setq gnus-select-method
121 (cond ((or (string= gnus-nntp-server
"")
122 (string= gnus-nntp-server
"::"))
123 (list 'nnspool
(system-name)))
124 ((string-match "^:" gnus-nntp-server
)
125 (list 'nnmh gnus-nntp-server
126 (list 'nnmh-directory
127 (file-name-as-directory
129 (substring gnus-nntp-server
1) "~/")))
130 (list 'nnmh-get-new-mail nil
)))
132 (list 'nntp gnus-nntp-server
)))))
134 (setq how
(car gnus-select-method
))
138 (gnus-message 5 "Looking up local news spool..."))
141 (gnus-message 5 "Looking up mh spool..."))
144 (setq gnus-current-select-method gnus-select-method
)
145 (gnus-run-hooks 'gnus-open-server-hook
)
147 ;; Partially validate agent covered methods now that the
148 ;; gnus-select-method is known.
151 ;; NOTE: This is here for one purpose only. By validating
152 ;; the current select method, it converts the old 5.10.3,
153 ;; and earlier, format to the current format. That enables
154 ;; the agent code within gnus-open-server to function
156 (gnus-agent-read-servers-validate-native gnus-select-method
))
159 ;; gnus-open-server-hook might have opened it
160 (gnus-server-opened gnus-select-method
)
161 (gnus-open-server gnus-select-method
)
165 "%s (%s) open error: '%s'. Continue? "
166 (car gnus-select-method
) (cadr gnus-select-method
)
167 (gnus-status-message gnus-select-method
)))
168 (gnus-error 1 "Couldn't open server on %s"
169 (nth 1 gnus-select-method
))))))
171 (defun gnus-check-group (group)
172 "Try to make sure that the server where GROUP exists is alive."
173 (let ((method (gnus-find-method-for-group group
)))
174 (or (gnus-server-opened method
)
175 (gnus-open-server method
))))
177 (defun gnus-check-server (&optional method silent
)
178 "Check whether the connection to METHOD is down.
179 If METHOD is nil, use `gnus-select-method'.
180 If it is down, start it up (again)."
181 (let ((method (or method gnus-select-method
))
183 ;; Transform virtual server names into select methods.
184 (when (stringp method
)
185 (setq method
(gnus-server-to-method method
)))
186 (if (gnus-server-opened method
)
187 ;; The stream is already opened.
191 (gnus-message 5 "Opening %s server%s..." (car method
)
192 (if (equal (nth 1 method
) "") ""
193 (format " on %s" (nth 1 method
)))))
194 (gnus-run-hooks 'gnus-open-server-hook
)
196 (setq result
(gnus-open-server method
))
200 "Opening %s server%s...%s" (car method
)
201 (if (equal (nth 1 method
) "") ""
202 (format " on %s" (nth 1 method
)))
206 (nnheader-get-report-string (car method
))))))))))
208 (defun gnus-get-function (method function
&optional noerror
)
209 "Return a function symbol based on METHOD and FUNCTION."
210 ;; Translate server names into methods.
212 (error "Attempted use of a nil select method"))
213 (when (stringp method
)
214 (setq method
(gnus-server-to-method method
)))
215 ;; Check cache of constructed names.
216 (let* ((method-sym (if gnus-agent
217 (inline (gnus-agent-get-function method
))
219 (method-fns (get method-sym
'gnus-method-functions
))
220 (func (let ((method-fnlist-elt (assq function method-fns
)))
221 (unless method-fnlist-elt
222 (setq method-fnlist-elt
224 (intern (format "%s-%s" method-sym function
))))
225 (put method-sym
'gnus-method-functions
226 (cons method-fnlist-elt method-fns
)))
227 (cdr method-fnlist-elt
))))
228 ;; Maybe complain if there is no function.
229 (unless (fboundp func
)
231 (error "Trying to require a method that doesn't exist"))
232 (require (car method
))
233 (when (not (fboundp func
))
236 (error "No such function: %s" func
))))
241 ;;; Interface functions to the backends.
244 (defun gnus-method-denied-p (method)
245 (eq (nth 1 (assoc method gnus-opened-servers
))
248 (defvar gnus-backend-trace t
)
250 (defun gnus-open-server (gnus-command-method)
251 "Open a connection to GNUS-COMMAND-METHOD."
252 (when (stringp gnus-command-method
)
253 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
254 (when gnus-backend-trace
255 (with-current-buffer (get-buffer-create "*gnus trace*")
256 (buffer-disable-undo)
257 (goto-char (point-max))
258 (insert (format-time-string "%H:%M:%S")
259 (format " %S\n" gnus-command-method
))))
260 (let ((elem (assoc gnus-command-method gnus-opened-servers
))
261 (server (gnus-method-to-server-name gnus-command-method
)))
262 ;; If this method was previously denied, we just return nil.
263 (if (eq (nth 1 elem
) 'denied
)
266 1 "Server %s previously determined to be down; not retrying" server
)
269 (let* ((open-server-function
270 (gnus-get-function gnus-command-method
'open-server
))
273 (funcall open-server-function
274 (nth 1 gnus-command-method
)
275 (nthcdr 2 gnus-command-method
))
277 (gnus-message 1 "Unable to open server %s due to: %s"
278 server
(error-message-string err
))
283 (gnus-message 1 "Quit trying to open server %s" server
))
286 ;; If this hasn't been opened before, we add it to the list.
288 (setq elem
(list gnus-command-method nil
)
289 gnus-opened-servers
(cons elem gnus-opened-servers
)))
290 ;; Set the status of this server.
294 (if (eq open-server-function
#'nnagent-open-server
)
295 ;; The agent's backend has a "special" status
299 (gnus-agent-method-p gnus-command-method
))
301 (gnus-server-unopen-status
302 ;; Set the server's status to the unopen
303 ;; status. If that status is offline,
304 ;; recurse to open the agent's backend.
305 (setq open-offline
(eq gnus-server-unopen-status
'offline
))
306 gnus-server-unopen-status
)
307 ((not gnus-batch-mode
)
308 (setq open-offline t
)
311 ;; This agentized server was still denied
314 ;; This unagentized server must be denied
317 ;; NOTE: I MUST set the server's status to offline before this
318 ;; recursive call as this status will drive the
319 ;; gnus-get-function (called above) to return the agent's
322 ;; Recursively open this offline server to perform the
323 ;; open-server function of the agent's backend.
324 (let ((gnus-server-unopen-status 'denied
))
325 ;; Bind gnus-server-unopen-status to avoid recursively
326 ;; prompting with "go offline?". This is only a concern
327 ;; when the agent's backend fails to open the server.
328 (gnus-open-server gnus-command-method
))
329 (when (and (eq (cadr elem
) 'ok
) gnus-agent
330 (gnus-agent-method-p gnus-command-method
))
332 (gnus-agent-possibly-synchronize-flags-server
333 gnus-command-method
)))
336 (defun gnus-close-server (gnus-command-method)
337 "Close the connection to 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
'close-server
)
341 (nth 1 gnus-command-method
)))
343 (defun gnus-request-list (gnus-command-method)
344 "Request the active file 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
'request-list
)
348 (nth 1 gnus-command-method
)))
350 (defun gnus-finish-retrieve-group-infos (gnus-command-method infos data
)
351 "Read and update infos 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
'finish-retrieve-group-infos
)
355 (nth 1 gnus-command-method
)
358 (defun gnus-retrieve-group-data-early (gnus-command-method infos
)
359 "Start early async retrival of data from GNUS-COMMAND-METHOD."
360 (when (stringp gnus-command-method
)
361 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
362 (funcall (gnus-get-function gnus-command-method
'retrieve-group-data-early
)
363 (nth 1 gnus-command-method
)
366 (defun gnus-request-list-newsgroups (gnus-command-method)
367 "Request the newsgroups file from GNUS-COMMAND-METHOD."
368 (when (stringp gnus-command-method
)
369 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
370 (funcall (gnus-get-function gnus-command-method
'request-list-newsgroups
)
371 (nth 1 gnus-command-method
)))
373 (defun gnus-request-newgroups (date gnus-command-method
)
374 "Request all new groups since DATE from GNUS-COMMAND-METHOD."
375 (when (stringp gnus-command-method
)
376 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
377 (let ((func (gnus-get-function gnus-command-method
'request-newgroups t
)))
379 (funcall func date
(nth 1 gnus-command-method
)))))
381 (defun gnus-request-regenerate (gnus-command-method)
382 "Request a data generation from GNUS-COMMAND-METHOD."
383 (when (stringp gnus-command-method
)
384 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
385 (funcall (gnus-get-function gnus-command-method
'request-regenerate
)
386 (nth 1 gnus-command-method
)))
388 (defun gnus-request-compact-group (group)
389 (let* ((method (gnus-find-method-for-group group
))
390 (gnus-command-method method
)
392 (funcall (gnus-get-function gnus-command-method
393 'request-compact-group
)
394 (gnus-group-real-name group
)
395 (nth 1 gnus-command-method
) t
)))
398 (defun gnus-request-compact (gnus-command-method)
399 "Request groups compaction from GNUS-COMMAND-METHOD."
400 (when (stringp gnus-command-method
)
401 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
402 (funcall (gnus-get-function gnus-command-method
'request-compact
)
403 (nth 1 gnus-command-method
)))
405 (defun gnus-request-group (group &optional dont-check gnus-command-method info
)
406 "Request GROUP. If DONT-CHECK, no information is required."
407 (let ((gnus-command-method
408 (or gnus-command-method
(inline (gnus-find-method-for-group group
)))))
409 (when (stringp gnus-command-method
)
410 (setq gnus-command-method
411 (inline (gnus-server-to-method gnus-command-method
))))
412 (funcall (inline (gnus-get-function gnus-command-method
'request-group
))
413 (gnus-group-real-name group
) (nth 1 gnus-command-method
)
417 (defun gnus-list-active-group (group)
418 "Request active information on GROUP."
419 (let ((gnus-command-method (gnus-find-method-for-group group
))
420 (func 'list-active-group
))
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-request-group-description (group)
426 "Request a description of GROUP."
427 (let ((gnus-command-method (gnus-find-method-for-group group
))
428 (func 'request-group-description
))
429 (when (gnus-check-backend-function func group
)
430 (funcall (gnus-get-function gnus-command-method func
)
431 (gnus-group-real-name group
) (nth 1 gnus-command-method
)))))
433 (defun gnus-request-group-articles (group)
434 "Request a list of existing articles in GROUP."
435 (let ((gnus-command-method (gnus-find-method-for-group group
))
436 (func 'request-group-articles
))
437 (when (gnus-check-backend-function func group
)
438 (funcall (gnus-get-function gnus-command-method func
)
439 (gnus-group-real-name group
) (nth 1 gnus-command-method
)))))
441 (defun gnus-close-group (group)
442 "Request the GROUP be closed."
443 (let ((gnus-command-method (inline (gnus-find-method-for-group group
))))
444 (funcall (gnus-get-function gnus-command-method
'close-group
)
445 (gnus-group-real-name group
) (nth 1 gnus-command-method
))))
447 (defun gnus-retrieve-headers (articles group
&optional fetch-old
)
448 "Request headers for ARTICLES in GROUP.
449 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
450 (let ((gnus-command-method (gnus-find-method-for-group group
)))
452 ((and gnus-use-cache
(numberp (car articles
)))
453 (gnus-cache-retrieve-headers articles group fetch-old
))
454 ((and gnus-agent
(gnus-online gnus-command-method
)
455 (gnus-agent-method-p gnus-command-method
))
456 (gnus-agent-retrieve-headers articles group fetch-old
))
458 (funcall (gnus-get-function gnus-command-method
'retrieve-headers
)
459 articles
(gnus-group-real-name group
)
460 (nth 1 gnus-command-method
) fetch-old
)))))
462 (defun gnus-retrieve-articles (articles group
)
463 "Request ARTICLES in GROUP."
464 (let ((gnus-command-method (gnus-find-method-for-group group
)))
465 (funcall (gnus-get-function gnus-command-method
'retrieve-articles
)
466 articles
(gnus-group-real-name group
)
467 (nth 1 gnus-command-method
))))
469 (defun gnus-retrieve-groups (groups gnus-command-method
)
470 "Request active information on GROUPS from GNUS-COMMAND-METHOD."
471 (when (stringp gnus-command-method
)
472 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
473 (funcall (gnus-get-function gnus-command-method
'retrieve-groups
)
474 groups
(nth 1 gnus-command-method
)))
476 (defun gnus-request-type (group &optional article
)
477 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
478 (let ((gnus-command-method (gnus-find-method-for-group group
)))
479 (if (not (gnus-check-backend-function
480 'request-type
(car gnus-command-method
)))
482 (funcall (gnus-get-function gnus-command-method
'request-type
)
483 (gnus-group-real-name group
) article
))))
485 (defun gnus-request-update-group-status (group status
)
486 "Change the status of a group.
487 Valid statuses include `subscribe' and `unsubscribe'."
488 (let ((gnus-command-method (gnus-find-method-for-group group
)))
489 (if (not (gnus-check-backend-function
490 'request-update-group-status
(car gnus-command-method
)))
493 (gnus-get-function gnus-command-method
'request-update-group-status
)
494 (gnus-group-real-name group
) status
495 (nth 1 gnus-command-method
)))))
497 (defun gnus-request-set-mark (group action
)
498 "Set marks on articles in the back end."
499 (let ((gnus-command-method (gnus-find-method-for-group group
)))
500 (if (not (gnus-check-backend-function
501 'request-set-mark
(car gnus-command-method
)))
503 (funcall (gnus-get-function gnus-command-method
'request-set-mark
)
504 (gnus-group-real-name group
) action
505 (nth 1 gnus-command-method
))
506 (gnus-run-hook-with-args gnus-after-set-mark-hook group action
))))
508 (defun gnus-request-update-mark (group article mark
)
509 "Allow the back end to change the mark the user tries to put on an article."
510 (let ((gnus-command-method (gnus-find-method-for-group group
)))
511 (if (not (gnus-check-backend-function
512 'request-update-mark
(car gnus-command-method
)))
514 (gnus-run-hook-with-args gnus-before-update-mark-hook group article mark
)
515 (funcall (gnus-get-function gnus-command-method
'request-update-mark
)
516 (gnus-group-real-name group
) article mark
))))
518 (defun gnus-request-article (article group
&optional buffer
)
519 "Request the ARTICLE in GROUP.
520 ARTICLE can either be an article number or an article Message-ID.
521 If BUFFER, insert the article in that group."
522 (let ((gnus-command-method (gnus-find-method-for-group group
)))
523 (funcall (gnus-get-function gnus-command-method
'request-article
)
524 article
(gnus-group-real-name group
)
525 (nth 1 gnus-command-method
) buffer
)))
527 (defun gnus-request-thread (header group
)
528 "Request the headers in the thread containing the article specified by HEADER."
529 (let ((gnus-command-method (gnus-find-method-for-group group
)))
530 (funcall (gnus-get-function gnus-command-method
'request-thread
)
532 (gnus-group-real-name group
))))
534 (defun gnus-warp-to-article ()
535 "Warps from an article in a virtual group to the article in its
536 real group. Does nothing on a real group."
538 (let ((gnus-command-method
539 (gnus-find-method-for-group gnus-newsgroup-name
)))
540 (when (gnus-check-backend-function
541 'warp-to-article
(car gnus-command-method
))
542 (funcall (gnus-get-function gnus-command-method
'warp-to-article
)))))
544 (defun gnus-request-head (article group
)
545 "Request the head of ARTICLE in GROUP."
546 (let* ((gnus-command-method (gnus-find-method-for-group group
))
547 (head (gnus-get-function gnus-command-method
'request-head t
))
553 (gnus-cache-request-article article group
))
554 (setq res
(cons group article
)
556 ;; Check the agent cache.
557 ((gnus-agent-request-article article group
)
558 (setq res
(cons group article
)
560 ;; Use `head' function.
562 (setq res
(funcall head article
(gnus-group-real-name group
)
563 (nth 1 gnus-command-method
))))
564 ;; Use `article' function.
566 (setq res
(gnus-request-article article group
)
569 (with-current-buffer nntp-server-buffer
570 (goto-char (point-min))
571 (when (search-forward "\n\n" nil t
)
572 (delete-region (1- (point)) (point-max)))
573 (nnheader-fold-continuation-lines)))
576 (defun gnus-request-body (article group
)
577 "Request the body of ARTICLE in GROUP."
578 (let* ((gnus-command-method (gnus-find-method-for-group group
))
579 (head (gnus-get-function gnus-command-method
'request-body t
))
585 (gnus-cache-request-article article group
))
586 (setq res
(cons group article
)
588 ;; Check the agent cache.
589 ((gnus-agent-request-article article group
)
590 (setq res
(cons group article
)
592 ;; Use `head' function.
594 (setq res
(funcall head article
(gnus-group-real-name group
)
595 (nth 1 gnus-command-method
))))
596 ;; Use `article' function.
598 (setq res
(gnus-request-article article group
)
601 (with-current-buffer nntp-server-buffer
602 (goto-char (point-min))
603 (when (search-forward "\n\n" nil t
)
604 (delete-region (point-min) (1- (point))))))
607 (defun gnus-request-post (gnus-command-method)
608 "Post the current buffer using GNUS-COMMAND-METHOD."
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-post
)
612 (nth 1 gnus-command-method
)))
614 (defun gnus-request-expunge-group (group gnus-command-method
)
615 "Expunge GROUP, which is removing articles that have been marked as deleted."
616 (when (stringp gnus-command-method
)
617 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
618 (funcall (gnus-get-function gnus-command-method
'request-expunge-group
)
619 (gnus-group-real-name group
)
620 (nth 1 gnus-command-method
)))
622 (defun gnus-request-scan (group gnus-command-method
)
623 "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD.
624 If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned."
625 (let ((gnus-command-method
626 (if group
(gnus-find-method-for-group group
) gnus-command-method
))
627 (gnus-inhibit-demon t
)
628 (mail-source-plugged gnus-plugged
))
629 (when (or gnus-plugged
630 (not (gnus-agent-method-p gnus-command-method
)))
631 (setq gnus-internal-registry-spool-current-method gnus-command-method
)
632 (funcall (gnus-get-function gnus-command-method
'request-scan
)
633 (and group
(gnus-group-real-name group
))
634 (nth 1 gnus-command-method
)))))
636 (defun gnus-request-update-info (info gnus-command-method
)
637 (when (gnus-check-backend-function
638 'request-update-info
(car gnus-command-method
))
639 (when (stringp gnus-command-method
)
640 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
641 (funcall (gnus-get-function gnus-command-method
'request-update-info
)
642 (gnus-group-real-name (gnus-info-group info
)) info
643 (nth 1 gnus-command-method
))))
645 (defsubst gnus-request-marks
(info gnus-command-method
)
646 "Request that GNUS-COMMAND-METHOD update INFO."
647 (when (stringp gnus-command-method
)
648 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
649 (when (gnus-check-backend-function
650 'request-marks
(car gnus-command-method
))
651 (let ((group (gnus-info-group info
)))
652 (and (funcall (gnus-get-function gnus-command-method
'request-marks
)
653 (gnus-group-real-name group
)
654 info
(nth 1 gnus-command-method
))
655 ;; If the minimum article number is greater than 1, then all
656 ;; smaller article numbers are known not to exist; we'll
657 ;; artificially add those to the 'read range.
658 (let* ((active (gnus-active group
))
661 (let* ((range (if (= min
2) 1 (cons 1 (1- min
))))
662 (read (gnus-info-read info
))
663 (new-read (gnus-range-add read
(list range
))))
664 (gnus-info-set-read info new-read
)))
667 (defun gnus-request-expire-articles (articles group
&optional force
)
668 (let* ((gnus-command-method (gnus-find-method-for-group group
))
669 (gnus-inhibit-demon t
)
672 (gnus-get-function gnus-command-method
'request-expire-articles
)
673 articles
(gnus-group-real-name group
) (nth 1 gnus-command-method
)
675 (when (and gnus-agent
676 (gnus-agent-method-p gnus-command-method
))
677 (let ((expired-articles (gnus-sorted-difference articles not-deleted
)))
678 (when expired-articles
679 (gnus-agent-expire expired-articles group
'force
))))
682 (defun gnus-request-move-article (article group server accept-function
683 &optional last move-is-internal
)
684 (let* ((gnus-command-method (gnus-find-method-for-group group
))
685 (result (funcall (gnus-get-function gnus-command-method
686 'request-move-article
)
687 article
(gnus-group-real-name group
)
688 (nth 1 gnus-command-method
) accept-function
689 last move-is-internal
)))
690 (when (and result gnus-agent
691 (gnus-agent-method-p gnus-command-method
))
692 (gnus-agent-unfetch-articles group
(list article
)))
695 (defun gnus-request-accept-article (group &optional gnus-command-method last
697 ;; Make sure there's a newline at the end of the article.
698 (when (stringp gnus-command-method
)
699 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
700 (when (and (not gnus-command-method
)
702 (setq gnus-command-method
(or (gnus-find-method-for-group group
)
703 (gnus-group-name-to-method group
))))
704 (goto-char (point-max))
708 (let ((message-options message-options
))
709 (message-options-set-recipient)
711 (message-narrow-to-head)
712 (let ((mail-parse-charset message-default-charset
))
713 (mail-encode-encoded-word-buffer)))
714 (message-encode-message-body)))
715 (let ((gnus-command-method (or gnus-command-method
716 (gnus-find-method-for-group group
)))
719 (gnus-get-function gnus-command-method
'request-accept-article
)
720 (if (stringp group
) (gnus-group-real-name group
) group
)
721 (cadr gnus-command-method
)
723 (when (and gnus-agent
724 (gnus-agent-method-p gnus-command-method
)
726 (gnus-agent-regenerate-group group
(list (cdr result
))))
729 (defun gnus-request-replace-article (article group buffer
&optional no-encode
)
731 (let ((message-options message-options
))
732 (message-options-set-recipient)
734 (message-narrow-to-head)
735 (let ((mail-parse-charset message-default-charset
))
736 (mail-encode-encoded-word-buffer)))
737 (message-encode-message-body)))
738 (let* ((func (car (gnus-group-name-to-method group
)))
739 (result (funcall (intern (format "%s-request-replace-article" func
))
740 article
(gnus-group-real-name group
) buffer
)))
741 (when (and gnus-agent
(gnus-agent-method-p gnus-command-method
))
742 (gnus-agent-regenerate-group group
(list article
)))
745 (defun gnus-request-associate-buffer (group)
746 (let ((gnus-command-method (gnus-find-method-for-group group
)))
747 (funcall (gnus-get-function gnus-command-method
'request-associate-buffer
)
748 (gnus-group-real-name group
))))
750 (defun gnus-request-restore-buffer (article group
)
751 "Request a new buffer restored to the state of ARTICLE."
752 (let ((gnus-command-method (gnus-find-method-for-group group
)))
753 (funcall (gnus-get-function gnus-command-method
'request-restore-buffer
)
754 article
(gnus-group-real-name group
)
755 (nth 1 gnus-command-method
))))
757 (defun gnus-request-create-group (group &optional gnus-command-method args
)
758 (when (stringp gnus-command-method
)
759 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
760 (let ((gnus-command-method
761 (or gnus-command-method
(gnus-find-method-for-group group
))))
762 (funcall (gnus-get-function gnus-command-method
'request-create-group
)
763 (gnus-group-real-name group
) (nth 1 gnus-command-method
) args
)))
765 (defun gnus-request-delete-group (group &optional force
)
766 (let* ((gnus-command-method (gnus-find-method-for-group group
))
768 (funcall (gnus-get-function gnus-command-method
'request-delete-group
)
769 (gnus-group-real-name group
) force
(nth 1 gnus-command-method
))))
771 (gnus-cache-delete-group group
)
772 (gnus-agent-delete-group group
))
775 (defun gnus-request-rename-group (group new-name
)
776 (let* ((gnus-command-method (gnus-find-method-for-group group
))
778 (funcall (gnus-get-function gnus-command-method
'request-rename-group
)
779 (gnus-group-real-name group
)
780 (gnus-group-real-name new-name
) (nth 1 gnus-command-method
))))
782 (gnus-cache-rename-group group new-name
)
783 (gnus-agent-rename-group group new-name
))
786 (defun gnus-close-backends ()
787 ;; Send a close request to all backends that support such a request.
788 (let ((methods gnus-valid-select-methods
)
789 (gnus-inhibit-demon t
)
790 func gnus-command-method
)
791 (while (setq gnus-command-method
(pop methods
))
792 (when (fboundp (setq func
(intern
793 (concat (car gnus-command-method
)
797 (defun gnus-asynchronous-p (gnus-command-method)
798 (let ((func (gnus-get-function gnus-command-method
'asynchronous-p t
)))
802 (defun gnus-remove-denial (gnus-command-method)
803 (when (stringp gnus-command-method
)
804 (setq gnus-command-method
(gnus-server-to-method gnus-command-method
)))
805 (let* ((elem (assoc gnus-command-method gnus-opened-servers
))
806 (status (cadr elem
)))
807 ;; If this hasn't been opened before, we add it to the list.
808 (when (eq status
'denied
)
809 ;; Set the status of this server.
810 (setcar (cdr elem
) 'closed
))))
814 ;;; gnus-int.el ends here