Commit | Line | Data |
---|---|---|
eec82323 | 1 | ;;; gnus-int.el --- backend interface functions for Gnus |
16409b0b GM |
2 | ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 |
3 | ;; Free Software Foundation, Inc. | |
eec82323 | 4 | |
6748645f | 5 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
eec82323 LMI |
6 | ;; Keywords: news |
7 | ||
8 | ;; This file is part of GNU Emacs. | |
9 | ||
10 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 | ;; it under the terms of the GNU General Public License as published by | |
12 | ;; the Free Software Foundation; either version 2, or (at your option) | |
13 | ;; any later version. | |
14 | ||
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ;; GNU General Public License for more details. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
21 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | ;; Boston, MA 02111-1307, USA. | |
24 | ||
25 | ;;; Commentary: | |
26 | ||
27 | ;;; Code: | |
28 | ||
249ffa67 RS |
29 | (eval-when-compile (require 'cl)) |
30 | ||
eec82323 LMI |
31 | (require 'gnus) |
32 | ||
33 | (defcustom gnus-open-server-hook nil | |
34 | "Hook called just before opening connection to the news server." | |
35 | :group 'gnus-start | |
36 | :type 'hook) | |
37 | ||
38 | ;;; | |
39 | ;;; Server Communication | |
40 | ;;; | |
41 | ||
42 | (defun gnus-start-news-server (&optional confirm) | |
43 | "Open a method for getting news. | |
44 | If CONFIRM is non-nil, the user will be asked for an NNTP server." | |
45 | (let (how) | |
46 | (if gnus-current-select-method | |
47 | ;; Stream is already opened. | |
48 | nil | |
49 | ;; Open NNTP server. | |
50 | (unless gnus-nntp-service | |
51 | (setq gnus-nntp-server nil)) | |
52 | (when confirm | |
53 | ;; Read server name with completion. | |
54 | (setq gnus-nntp-server | |
55 | (completing-read "NNTP server: " | |
56 | (mapcar (lambda (server) (list server)) | |
57 | (cons (list gnus-nntp-server) | |
58 | gnus-secondary-servers)) | |
59 | nil nil gnus-nntp-server))) | |
60 | ||
61 | (when (and gnus-nntp-server | |
62 | (stringp gnus-nntp-server) | |
63 | (not (string= gnus-nntp-server ""))) | |
64 | (setq gnus-select-method | |
65 | (cond ((or (string= gnus-nntp-server "") | |
66 | (string= gnus-nntp-server "::")) | |
67 | (list 'nnspool (system-name))) | |
68 | ((string-match "^:" gnus-nntp-server) | |
69 | (list 'nnmh gnus-nntp-server | |
70 | (list 'nnmh-directory | |
71 | (file-name-as-directory | |
72 | (expand-file-name | |
73 | (concat "~/" (substring | |
74 | gnus-nntp-server 1))))) | |
75 | (list 'nnmh-get-new-mail nil))) | |
76 | (t | |
77 | (list 'nntp gnus-nntp-server))))) | |
78 | ||
79 | (setq how (car gnus-select-method)) | |
80 | (cond | |
81 | ((eq how 'nnspool) | |
82 | (require 'nnspool) | |
83 | (gnus-message 5 "Looking up local news spool...")) | |
84 | ((eq how 'nnmh) | |
85 | (require 'nnmh) | |
86 | (gnus-message 5 "Looking up mh spool...")) | |
87 | (t | |
88 | (require 'nntp))) | |
89 | (setq gnus-current-select-method gnus-select-method) | |
6748645f | 90 | (gnus-run-hooks 'gnus-open-server-hook) |
eec82323 LMI |
91 | (or |
92 | ;; gnus-open-server-hook might have opened it | |
93 | (gnus-server-opened gnus-select-method) | |
94 | (gnus-open-server gnus-select-method) | |
16409b0b | 95 | gnus-batch-mode |
eec82323 LMI |
96 | (gnus-y-or-n-p |
97 | (format | |
98 | "%s (%s) open error: '%s'. Continue? " | |
99 | (car gnus-select-method) (cadr gnus-select-method) | |
100 | (gnus-status-message gnus-select-method))) | |
101 | (gnus-error 1 "Couldn't open server on %s" | |
102 | (nth 1 gnus-select-method)))))) | |
103 | ||
104 | (defun gnus-check-group (group) | |
105 | "Try to make sure that the server where GROUP exists is alive." | |
106 | (let ((method (gnus-find-method-for-group group))) | |
107 | (or (gnus-server-opened method) | |
108 | (gnus-open-server method)))) | |
109 | ||
110 | (defun gnus-check-server (&optional method silent) | |
111 | "Check whether the connection to METHOD is down. | |
112 | If METHOD is nil, use `gnus-select-method'. | |
113 | If it is down, start it up (again)." | |
114 | (let ((method (or method gnus-select-method))) | |
115 | ;; Transform virtual server names into select methods. | |
116 | (when (stringp method) | |
117 | (setq method (gnus-server-to-method method))) | |
118 | (if (gnus-server-opened method) | |
119 | ;; The stream is already opened. | |
120 | t | |
121 | ;; Open the server. | |
122 | (unless silent | |
123 | (gnus-message 5 "Opening %s server%s..." (car method) | |
124 | (if (equal (nth 1 method) "") "" | |
125 | (format " on %s" (nth 1 method))))) | |
6748645f | 126 | (gnus-run-hooks 'gnus-open-server-hook) |
eec82323 LMI |
127 | (prog1 |
128 | (gnus-open-server method) | |
129 | (unless silent | |
130 | (message "")))))) | |
131 | ||
132 | (defun gnus-get-function (method function &optional noerror) | |
133 | "Return a function symbol based on METHOD and FUNCTION." | |
134 | ;; Translate server names into methods. | |
135 | (unless method | |
136 | (error "Attempted use of a nil select method")) | |
137 | (when (stringp method) | |
138 | (setq method (gnus-server-to-method method))) | |
6748645f LMI |
139 | ;; Check cache of constructed names. |
140 | (let* ((method-sym (if gnus-agent | |
141 | (gnus-agent-get-function method) | |
142 | (car method))) | |
143 | (method-fns (get method-sym 'gnus-method-functions)) | |
144 | (func (let ((method-fnlist-elt (assq function method-fns))) | |
145 | (unless method-fnlist-elt | |
146 | (setq method-fnlist-elt | |
147 | (cons function | |
148 | (intern (format "%s-%s" method-sym function)))) | |
149 | (put method-sym 'gnus-method-functions | |
150 | (cons method-fnlist-elt method-fns))) | |
151 | (cdr method-fnlist-elt)))) | |
152 | ;; Maybe complain if there is no function. | |
eec82323 | 153 | (unless (fboundp func) |
6748645f LMI |
154 | (unless (car method) |
155 | (error "Trying to require a method that doesn't exist")) | |
eec82323 | 156 | (require (car method)) |
6748645f LMI |
157 | (when (not (fboundp func)) |
158 | (if noerror | |
159 | (setq func nil) | |
160 | (error "No such function: %s" func)))) | |
eec82323 LMI |
161 | func)) |
162 | ||
163 | \f | |
164 | ;;; | |
165 | ;;; Interface functions to the backends. | |
166 | ;;; | |
167 | ||
6748645f LMI |
168 | (defun gnus-open-server (gnus-command-method) |
169 | "Open a connection to GNUS-COMMAND-METHOD." | |
170 | (when (stringp gnus-command-method) | |
171 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
172 | (let ((elem (assoc gnus-command-method gnus-opened-servers))) | |
eec82323 LMI |
173 | ;; If this method was previously denied, we just return nil. |
174 | (if (eq (nth 1 elem) 'denied) | |
175 | (progn | |
176 | (gnus-message 1 "Denied server") | |
177 | nil) | |
178 | ;; Open the server. | |
179 | (let ((result | |
6748645f LMI |
180 | (funcall (gnus-get-function gnus-command-method 'open-server) |
181 | (nth 1 gnus-command-method) | |
182 | (nthcdr 2 gnus-command-method)))) | |
eec82323 LMI |
183 | ;; If this hasn't been opened before, we add it to the list. |
184 | (unless elem | |
6748645f | 185 | (setq elem (list gnus-command-method nil) |
eec82323 LMI |
186 | gnus-opened-servers (cons elem gnus-opened-servers))) |
187 | ;; Set the status of this server. | |
188 | (setcar (cdr elem) (if result 'ok 'denied)) | |
189 | ;; Return the result from the "open" call. | |
190 | result)))) | |
191 | ||
6748645f LMI |
192 | (defun gnus-close-server (gnus-command-method) |
193 | "Close the connection to GNUS-COMMAND-METHOD." | |
194 | (when (stringp gnus-command-method) | |
195 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
196 | (funcall (gnus-get-function gnus-command-method 'close-server) | |
197 | (nth 1 gnus-command-method))) | |
198 | ||
199 | (defun gnus-request-list (gnus-command-method) | |
200 | "Request the active file from GNUS-COMMAND-METHOD." | |
201 | (when (stringp gnus-command-method) | |
202 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
203 | (funcall (gnus-get-function gnus-command-method 'request-list) | |
204 | (nth 1 gnus-command-method))) | |
205 | ||
206 | (defun gnus-request-list-newsgroups (gnus-command-method) | |
207 | "Request the newsgroups file from GNUS-COMMAND-METHOD." | |
208 | (when (stringp gnus-command-method) | |
209 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
210 | (funcall (gnus-get-function gnus-command-method 'request-list-newsgroups) | |
211 | (nth 1 gnus-command-method))) | |
212 | ||
213 | (defun gnus-request-newgroups (date gnus-command-method) | |
214 | "Request all new groups since DATE from GNUS-COMMAND-METHOD." | |
215 | (when (stringp gnus-command-method) | |
216 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
217 | (let ((func (gnus-get-function gnus-command-method 'request-newgroups t))) | |
eec82323 | 218 | (when func |
6748645f LMI |
219 | (funcall func date (nth 1 gnus-command-method))))) |
220 | ||
221 | (defun gnus-server-opened (gnus-command-method) | |
222 | "Check whether a connection to GNUS-COMMAND-METHOD has been opened." | |
16409b0b GM |
223 | (unless (eq (gnus-server-status gnus-command-method) |
224 | 'denied) | |
225 | (when (stringp gnus-command-method) | |
226 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
227 | (funcall (inline (gnus-get-function gnus-command-method 'server-opened)) | |
228 | (nth 1 gnus-command-method)))) | |
6748645f LMI |
229 | |
230 | (defun gnus-status-message (gnus-command-method) | |
231 | "Return the status message from GNUS-COMMAND-METHOD. | |
232 | If GNUS-COMMAND-METHOD is a string, it is interpreted as a group name. The method | |
eec82323 | 233 | this group uses will be queried." |
6748645f LMI |
234 | (let ((gnus-command-method |
235 | (if (stringp gnus-command-method) | |
236 | (gnus-find-method-for-group gnus-command-method) | |
237 | gnus-command-method))) | |
238 | (funcall (gnus-get-function gnus-command-method 'status-message) | |
239 | (nth 1 gnus-command-method)))) | |
240 | ||
241 | (defun gnus-request-regenerate (gnus-command-method) | |
242 | "Request a data generation from GNUS-COMMAND-METHOD." | |
243 | (when (stringp gnus-command-method) | |
244 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
245 | (funcall (gnus-get-function gnus-command-method 'request-regenerate) | |
246 | (nth 1 gnus-command-method))) | |
247 | ||
248 | (defun gnus-request-group (group &optional dont-check gnus-command-method) | |
eec82323 | 249 | "Request GROUP. If DONT-CHECK, no information is required." |
6748645f LMI |
250 | (let ((gnus-command-method |
251 | (or gnus-command-method (inline (gnus-find-method-for-group group))))) | |
252 | (when (stringp gnus-command-method) | |
253 | (setq gnus-command-method | |
254 | (inline (gnus-server-to-method gnus-command-method)))) | |
255 | (funcall (inline (gnus-get-function gnus-command-method 'request-group)) | |
256 | (gnus-group-real-name group) (nth 1 gnus-command-method) | |
257 | dont-check))) | |
eec82323 LMI |
258 | |
259 | (defun gnus-list-active-group (group) | |
260 | "Request active information on GROUP." | |
6748645f | 261 | (let ((gnus-command-method (gnus-find-method-for-group group)) |
eec82323 LMI |
262 | (func 'list-active-group)) |
263 | (when (gnus-check-backend-function func group) | |
6748645f LMI |
264 | (funcall (gnus-get-function gnus-command-method func) |
265 | (gnus-group-real-name group) (nth 1 gnus-command-method))))) | |
eec82323 LMI |
266 | |
267 | (defun gnus-request-group-description (group) | |
268 | "Request a description of GROUP." | |
6748645f | 269 | (let ((gnus-command-method (gnus-find-method-for-group group)) |
eec82323 LMI |
270 | (func 'request-group-description)) |
271 | (when (gnus-check-backend-function func group) | |
6748645f LMI |
272 | (funcall (gnus-get-function gnus-command-method func) |
273 | (gnus-group-real-name group) (nth 1 gnus-command-method))))) | |
eec82323 | 274 | |
16409b0b GM |
275 | (defun gnus-request-group-articles (group) |
276 | "Request a list of existing articles in GROUP." | |
277 | (let ((gnus-command-method (gnus-find-method-for-group group)) | |
278 | (func 'request-group-articles)) | |
279 | (when (gnus-check-backend-function func group) | |
280 | (funcall (gnus-get-function gnus-command-method func) | |
281 | (gnus-group-real-name group) (nth 1 gnus-command-method))))) | |
282 | ||
eec82323 LMI |
283 | (defun gnus-close-group (group) |
284 | "Request the GROUP be closed." | |
6748645f LMI |
285 | (let ((gnus-command-method (inline (gnus-find-method-for-group group)))) |
286 | (funcall (gnus-get-function gnus-command-method 'close-group) | |
287 | (gnus-group-real-name group) (nth 1 gnus-command-method)))) | |
eec82323 LMI |
288 | |
289 | (defun gnus-retrieve-headers (articles group &optional fetch-old) | |
290 | "Request headers for ARTICLES in GROUP. | |
291 | If FETCH-OLD, retrieve all headers (or some subset thereof) in the group." | |
6748645f | 292 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
eec82323 LMI |
293 | (if (and gnus-use-cache (numberp (car articles))) |
294 | (gnus-cache-retrieve-headers articles group fetch-old) | |
6748645f LMI |
295 | (funcall (gnus-get-function gnus-command-method 'retrieve-headers) |
296 | articles (gnus-group-real-name group) | |
297 | (nth 1 gnus-command-method) fetch-old)))) | |
298 | ||
299 | (defun gnus-retrieve-articles (articles group) | |
300 | "Request ARTICLES in GROUP." | |
301 | (let ((gnus-command-method (gnus-find-method-for-group group))) | |
302 | (funcall (gnus-get-function gnus-command-method 'retrieve-articles) | |
303 | articles (gnus-group-real-name group) | |
304 | (nth 1 gnus-command-method)))) | |
305 | ||
306 | (defun gnus-retrieve-groups (groups gnus-command-method) | |
307 | "Request active information on GROUPS from GNUS-COMMAND-METHOD." | |
308 | (when (stringp gnus-command-method) | |
309 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
310 | (funcall (gnus-get-function gnus-command-method 'retrieve-groups) | |
311 | groups (nth 1 gnus-command-method))) | |
eec82323 LMI |
312 | |
313 | (defun gnus-request-type (group &optional article) | |
314 | "Return the type (`post' or `mail') of GROUP (and ARTICLE)." | |
6748645f LMI |
315 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
316 | (if (not (gnus-check-backend-function | |
317 | 'request-type (car gnus-command-method))) | |
eec82323 | 318 | 'unknown |
6748645f | 319 | (funcall (gnus-get-function gnus-command-method 'request-type) |
eec82323 LMI |
320 | (gnus-group-real-name group) article)))) |
321 | ||
16409b0b GM |
322 | (defun gnus-request-set-mark (group action) |
323 | "Set marks on articles in the backend." | |
324 | (let ((gnus-command-method (gnus-find-method-for-group group))) | |
325 | (if (not (gnus-check-backend-function | |
326 | 'request-set-mark (car gnus-command-method))) | |
327 | action | |
328 | (funcall (gnus-get-function gnus-command-method 'request-set-mark) | |
329 | (gnus-group-real-name group) action | |
330 | (nth 1 gnus-command-method))))) | |
331 | ||
eec82323 | 332 | (defun gnus-request-update-mark (group article mark) |
6748645f LMI |
333 | "Allow the backend to change the mark the user tries to put on an article." |
334 | (let ((gnus-command-method (gnus-find-method-for-group group))) | |
335 | (if (not (gnus-check-backend-function | |
336 | 'request-update-mark (car gnus-command-method))) | |
eec82323 | 337 | mark |
6748645f | 338 | (funcall (gnus-get-function gnus-command-method 'request-update-mark) |
eec82323 LMI |
339 | (gnus-group-real-name group) article mark)))) |
340 | ||
341 | (defun gnus-request-article (article group &optional buffer) | |
342 | "Request the ARTICLE in GROUP. | |
343 | ARTICLE can either be an article number or an article Message-ID. | |
344 | If BUFFER, insert the article in that group." | |
6748645f LMI |
345 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
346 | (funcall (gnus-get-function gnus-command-method 'request-article) | |
347 | article (gnus-group-real-name group) | |
348 | (nth 1 gnus-command-method) buffer))) | |
eec82323 LMI |
349 | |
350 | (defun gnus-request-head (article group) | |
351 | "Request the head of ARTICLE in GROUP." | |
6748645f LMI |
352 | (let* ((gnus-command-method (gnus-find-method-for-group group)) |
353 | (head (gnus-get-function gnus-command-method 'request-head t)) | |
eec82323 LMI |
354 | res clean-up) |
355 | (cond | |
356 | ;; Check the cache. | |
357 | ((and gnus-use-cache | |
358 | (numberp article) | |
359 | (gnus-cache-request-article article group)) | |
360 | (setq res (cons group article) | |
361 | clean-up t)) | |
362 | ;; Use `head' function. | |
363 | ((fboundp head) | |
364 | (setq res (funcall head article (gnus-group-real-name group) | |
6748645f | 365 | (nth 1 gnus-command-method)))) |
eec82323 LMI |
366 | ;; Use `article' function. |
367 | (t | |
368 | (setq res (gnus-request-article article group) | |
369 | clean-up t))) | |
370 | (when clean-up | |
371 | (save-excursion | |
372 | (set-buffer nntp-server-buffer) | |
373 | (goto-char (point-min)) | |
374 | (when (search-forward "\n\n" nil t) | |
375 | (delete-region (1- (point)) (point-max))) | |
376 | (nnheader-fold-continuation-lines))) | |
377 | res)) | |
378 | ||
379 | (defun gnus-request-body (article group) | |
380 | "Request the body of ARTICLE in GROUP." | |
6748645f LMI |
381 | (let* ((gnus-command-method (gnus-find-method-for-group group)) |
382 | (head (gnus-get-function gnus-command-method 'request-body t)) | |
383 | res clean-up) | |
384 | (cond | |
385 | ;; Check the cache. | |
386 | ((and gnus-use-cache | |
387 | (numberp article) | |
388 | (gnus-cache-request-article article group)) | |
389 | (setq res (cons group article) | |
390 | clean-up t)) | |
391 | ;; Use `head' function. | |
392 | ((fboundp head) | |
393 | (setq res (funcall head article (gnus-group-real-name group) | |
394 | (nth 1 gnus-command-method)))) | |
395 | ;; Use `article' function. | |
396 | (t | |
397 | (setq res (gnus-request-article article group) | |
398 | clean-up t))) | |
399 | (when clean-up | |
400 | (save-excursion | |
401 | (set-buffer nntp-server-buffer) | |
402 | (goto-char (point-min)) | |
403 | (when (search-forward "\n\n" nil t) | |
404 | (delete-region (point-min) (1- (point)))))) | |
405 | res)) | |
eec82323 | 406 | |
6748645f LMI |
407 | (defun gnus-request-post (gnus-command-method) |
408 | "Post the current buffer using GNUS-COMMAND-METHOD." | |
409 | (when (stringp gnus-command-method) | |
410 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
411 | (funcall (gnus-get-function gnus-command-method 'request-post) | |
412 | (nth 1 gnus-command-method))) | |
413 | ||
414 | (defun gnus-request-scan (group gnus-command-method) | |
415 | "Request a SCAN being performed in GROUP from GNUS-COMMAND-METHOD. | |
416 | If GROUP is nil, all groups on GNUS-COMMAND-METHOD are scanned." | |
16409b0b GM |
417 | (let ((gnus-command-method |
418 | (if group (gnus-find-method-for-group group) gnus-command-method)) | |
419 | (gnus-inhibit-demon t) | |
420 | (mail-source-plugged gnus-plugged)) | |
421 | (if (or gnus-plugged (not (gnus-agent-method-p gnus-command-method))) | |
422 | (funcall (gnus-get-function gnus-command-method 'request-scan) | |
423 | (and group (gnus-group-real-name group)) | |
424 | (nth 1 gnus-command-method))))) | |
6748645f LMI |
425 | |
426 | (defsubst gnus-request-update-info (info gnus-command-method) | |
427 | "Request that GNUS-COMMAND-METHOD update INFO." | |
428 | (when (stringp gnus-command-method) | |
429 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
430 | (when (gnus-check-backend-function | |
431 | 'request-update-info (car gnus-command-method)) | |
432 | (funcall (gnus-get-function gnus-command-method 'request-update-info) | |
eec82323 | 433 | (gnus-group-real-name (gnus-info-group info)) |
6748645f | 434 | info (nth 1 gnus-command-method)))) |
eec82323 LMI |
435 | |
436 | (defun gnus-request-expire-articles (articles group &optional force) | |
6748645f LMI |
437 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
438 | (funcall (gnus-get-function gnus-command-method 'request-expire-articles) | |
439 | articles (gnus-group-real-name group) (nth 1 gnus-command-method) | |
eec82323 LMI |
440 | force))) |
441 | ||
442 | (defun gnus-request-move-article | |
443 | (article group server accept-function &optional last) | |
6748645f LMI |
444 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
445 | (funcall (gnus-get-function gnus-command-method 'request-move-article) | |
eec82323 | 446 | article (gnus-group-real-name group) |
6748645f | 447 | (nth 1 gnus-command-method) accept-function last))) |
eec82323 | 448 | |
16409b0b GM |
449 | (defun gnus-request-accept-article (group &optional gnus-command-method last |
450 | no-encode) | |
eec82323 | 451 | ;; Make sure there's a newline at the end of the article. |
6748645f LMI |
452 | (when (stringp gnus-command-method) |
453 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
454 | (when (and (not gnus-command-method) | |
eec82323 | 455 | (stringp group)) |
6748645f | 456 | (setq gnus-command-method (gnus-group-name-to-method group))) |
eec82323 LMI |
457 | (goto-char (point-max)) |
458 | (unless (bolp) | |
459 | (insert "\n")) | |
16409b0b GM |
460 | (unless no-encode |
461 | (save-restriction | |
462 | (message-narrow-to-head) | |
463 | (let ((mail-parse-charset message-default-charset)) | |
464 | (mail-encode-encoded-word-buffer))) | |
465 | (message-encode-message-body)) | |
6748645f LMI |
466 | (let ((func (car (or gnus-command-method |
467 | (gnus-find-method-for-group group))))) | |
eec82323 LMI |
468 | (funcall (intern (format "%s-request-accept-article" func)) |
469 | (if (stringp group) (gnus-group-real-name group) group) | |
6748645f | 470 | (cadr gnus-command-method) |
eec82323 LMI |
471 | last))) |
472 | ||
16409b0b GM |
473 | (defun gnus-request-replace-article (article group buffer &optional no-encode) |
474 | (unless no-encode | |
475 | (save-restriction | |
476 | (message-narrow-to-head) | |
477 | (let ((mail-parse-charset message-default-charset)) | |
478 | (mail-encode-encoded-word-buffer))) | |
479 | (message-encode-message-body)) | |
a8151ef7 | 480 | (let ((func (car (gnus-group-name-to-method group)))) |
eec82323 LMI |
481 | (funcall (intern (format "%s-request-replace-article" func)) |
482 | article (gnus-group-real-name group) buffer))) | |
483 | ||
484 | (defun gnus-request-associate-buffer (group) | |
6748645f LMI |
485 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
486 | (funcall (gnus-get-function gnus-command-method 'request-associate-buffer) | |
eec82323 LMI |
487 | (gnus-group-real-name group)))) |
488 | ||
489 | (defun gnus-request-restore-buffer (article group) | |
490 | "Request a new buffer restored to the state of ARTICLE." | |
6748645f LMI |
491 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
492 | (funcall (gnus-get-function gnus-command-method 'request-restore-buffer) | |
493 | article (gnus-group-real-name group) | |
494 | (nth 1 gnus-command-method)))) | |
eec82323 | 495 | |
6748645f LMI |
496 | (defun gnus-request-create-group (group &optional gnus-command-method args) |
497 | (when (stringp gnus-command-method) | |
498 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
499 | (let ((gnus-command-method | |
500 | (or gnus-command-method (gnus-find-method-for-group group)))) | |
501 | (funcall (gnus-get-function gnus-command-method 'request-create-group) | |
502 | (gnus-group-real-name group) (nth 1 gnus-command-method) args))) | |
eec82323 LMI |
503 | |
504 | (defun gnus-request-delete-group (group &optional force) | |
6748645f LMI |
505 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
506 | (funcall (gnus-get-function gnus-command-method 'request-delete-group) | |
507 | (gnus-group-real-name group) force (nth 1 gnus-command-method)))) | |
eec82323 LMI |
508 | |
509 | (defun gnus-request-rename-group (group new-name) | |
6748645f LMI |
510 | (let ((gnus-command-method (gnus-find-method-for-group group))) |
511 | (funcall (gnus-get-function gnus-command-method 'request-rename-group) | |
eec82323 | 512 | (gnus-group-real-name group) |
6748645f | 513 | (gnus-group-real-name new-name) (nth 1 gnus-command-method)))) |
eec82323 LMI |
514 | |
515 | (defun gnus-close-backends () | |
516 | ;; Send a close request to all backends that support such a request. | |
517 | (let ((methods gnus-valid-select-methods) | |
518 | (gnus-inhibit-demon t) | |
6748645f LMI |
519 | func gnus-command-method) |
520 | (while (setq gnus-command-method (pop methods)) | |
eec82323 | 521 | (when (fboundp (setq func (intern |
6748645f LMI |
522 | (concat (car gnus-command-method) |
523 | "-request-close")))) | |
eec82323 LMI |
524 | (funcall func))))) |
525 | ||
6748645f LMI |
526 | (defun gnus-asynchronous-p (gnus-command-method) |
527 | (let ((func (gnus-get-function gnus-command-method 'asynchronous-p t))) | |
eec82323 LMI |
528 | (when (fboundp func) |
529 | (funcall func)))) | |
530 | ||
6748645f LMI |
531 | (defun gnus-remove-denial (gnus-command-method) |
532 | (when (stringp gnus-command-method) | |
533 | (setq gnus-command-method (gnus-server-to-method gnus-command-method))) | |
534 | (let* ((elem (assoc gnus-command-method gnus-opened-servers)) | |
eec82323 LMI |
535 | (status (cadr elem))) |
536 | ;; If this hasn't been opened before, we add it to the list. | |
537 | (when (eq status 'denied) | |
538 | ;; Set the status of this server. | |
539 | (setcar (cdr elem) 'closed)))) | |
540 | ||
541 | (provide 'gnus-int) | |
542 | ||
543 | ;;; gnus-int.el ends here |