Mercurial > emacs
annotate lisp/gnus/nnagent.el @ 42811:cf0c0ef57504
*** empty log message ***
| author | Jason Rumney <jasonr@gnu.org> |
|---|---|
| date | Thu, 17 Jan 2002 19:29:24 +0000 |
| parents | 9968f55ad26e |
| children | 0d8b17d428b5 |
| rev | line source |
|---|---|
| 24358 | 1 ;;; nnagent.el --- offline backend for Gnus |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
2 ;; Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
| 24358 | 3 |
| 4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
| 5 ;; Keywords: news, mail | |
| 6 | |
| 7 ;; This file is part of GNU Emacs. | |
| 8 | |
| 9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 10 ;; it under the terms of the GNU General Public License as published by | |
| 11 ;; the Free Software Foundation; either version 2, or (at your option) | |
| 12 ;; any later version. | |
| 13 | |
| 14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 ;; GNU General Public License for more details. | |
| 18 | |
| 19 ;; You should have received a copy of the GNU General Public License | |
| 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
| 21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 22 ;; Boston, MA 02111-1307, USA. | |
| 23 | |
| 24 ;;; Commentary: | |
| 25 | |
| 26 ;;; Code: | |
| 27 | |
| 28 (require 'nnheader) | |
| 29 (require 'nnoo) | |
| 30 (eval-when-compile (require 'cl)) | |
| 31 (require 'gnus-agent) | |
| 32 (require 'nnml) | |
| 33 | |
| 34 (nnoo-declare nnagent | |
| 35 nnml) | |
| 36 | |
| 37 | |
| 38 | |
| 39 (defconst nnagent-version "nnagent 1.0") | |
| 40 | |
| 41 (defvoo nnagent-directory nil | |
| 42 "Internal variable." | |
| 43 nnml-directory) | |
| 44 | |
| 45 (defvoo nnagent-active-file nil | |
| 46 "Internal variable." | |
| 47 nnml-active-file) | |
| 48 | |
| 49 (defvoo nnagent-newsgroups-file nil | |
| 50 "Internal variable." | |
| 51 nnml-newsgroups-file) | |
| 52 | |
| 53 (defvoo nnagent-get-new-mail nil | |
| 54 "Internal variable." | |
| 55 nnml-get-new-mail) | |
| 56 | |
| 57 ;;; Interface functions. | |
| 58 | |
| 59 (nnoo-define-basics nnagent) | |
| 60 | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
61 (defun nnagent-server (server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
62 (and server (format "%s+%s" (car gnus-command-method) server))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
63 |
| 24358 | 64 (deffoo nnagent-open-server (server &optional defs) |
| 65 (setq defs | |
| 66 `((nnagent-directory ,(gnus-agent-directory)) | |
| 67 (nnagent-active-file ,(gnus-agent-lib-file "active")) | |
| 68 (nnagent-newsgroups-file ,(gnus-agent-lib-file "newsgroups")) | |
| 69 (nnagent-get-new-mail nil))) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
70 (nnoo-change-server 'nnagent |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
71 (nnagent-server server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
72 defs) |
| 24358 | 73 (let ((dir (gnus-agent-directory)) |
| 74 err) | |
| 75 (cond | |
| 76 ((not (condition-case arg | |
| 77 (file-exists-p dir) | |
| 78 (ftp-error (setq err (format "%s" arg))))) | |
| 79 (nnagent-close-server) | |
| 80 (nnheader-report | |
| 81 'nnagent (or err | |
| 82 (format "No such file or directory: %s" dir)))) | |
| 83 ((not (file-directory-p (file-truename dir))) | |
| 84 (nnagent-close-server) | |
| 85 (nnheader-report 'nnagent "Not a directory: %s" dir)) | |
| 86 (t | |
| 87 (nnheader-report 'nnagent "Opened server %s using directory %s" | |
| 88 server dir) | |
| 89 t)))) | |
| 90 | |
| 91 (deffoo nnagent-retrieve-groups (groups &optional server) | |
| 92 (save-excursion | |
| 93 (cond | |
| 94 ((file-exists-p (gnus-agent-lib-file "groups")) | |
| 95 (nnmail-find-file (gnus-agent-lib-file "groups")) | |
| 96 'groups) | |
| 97 ((file-exists-p (gnus-agent-lib-file "active")) | |
| 98 (nnmail-find-file (gnus-agent-lib-file "active")) | |
| 99 'active) | |
| 100 (t nil)))) | |
| 101 | |
| 102 (defun nnagent-request-type (group article) | |
| 103 (unless (stringp article) | |
| 104 (let ((gnus-plugged t)) | |
| 105 (if (not (gnus-check-backend-function | |
| 106 'request-type (car gnus-command-method))) | |
| 107 'unknown | |
| 108 (funcall (gnus-get-function gnus-command-method 'request-type) | |
| 109 (gnus-group-real-name group) article))))) | |
| 110 | |
| 111 (deffoo nnagent-request-newgroups (date server) | |
| 112 nil) | |
| 113 | |
| 114 (deffoo nnagent-request-update-info (group info &optional server) | |
| 115 nil) | |
| 116 | |
| 117 (deffoo nnagent-request-post (&optional server) | |
| 118 (gnus-agent-insert-meta-information 'news gnus-command-method) | |
|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
119 (gnus-request-accept-article "nndraft:queue" nil t t)) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
120 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
121 (deffoo nnagent-request-set-mark (group action server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
122 (with-temp-buffer |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
123 (insert (format "(%s-request-set-mark \"%s\" '%s \"%s\")\n" |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
124 (nth 0 gnus-command-method) group action |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
125 (or server (nth 1 gnus-command-method)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
126 (append-to-file (point-min) (point-max) (gnus-agent-lib-file "flags"))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
127 nil) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
128 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
129 (deffoo nnagent-request-group (group &optional server dont-check) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
130 (nnoo-parent-function 'nnagent 'nnml-request-group |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
131 (list group (nnagent-server server) dont-check))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
132 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
133 (deffoo nnagent-close-group (group &optional server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
134 (nnoo-parent-function 'nnagent 'nnml-close-group |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
135 (list group (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
136 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
137 (deffoo nnagent-request-accept-article (group &optional server last) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
138 (nnoo-parent-function 'nnagent 'nnml-request-accept-article |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
139 (list group (nnagent-server server) last))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
140 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
141 (deffoo nnagent-request-article (id &optional group server buffer) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
142 (nnoo-parent-function 'nnagent 'nnml-request-article |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
143 (list id group (nnagent-server server) buffer))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
144 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
145 (deffoo nnagent-request-create-group (group &optional server args) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
146 (nnoo-parent-function 'nnagent 'nnml-request-create-group |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
147 (list group (nnagent-server server) args))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
148 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
149 (deffoo nnagent-request-delete-group (group &optional force server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
150 (nnoo-parent-function 'nnagent 'nnml-request-delete-group |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
151 (list group force (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
152 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
153 (deffoo nnagent-request-expire-articles (articles group &optional server force) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
154 (nnoo-parent-function 'nnagent 'nnml-request-expire-articles |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
155 (list articles group (nnagent-server server) force))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
156 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
157 (deffoo nnagent-request-list (&optional server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
158 (nnoo-parent-function 'nnagent 'nnml-request-list |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
159 (list (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
160 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
161 (deffoo nnagent-request-list-newsgroups (&optional server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
162 (nnoo-parent-function 'nnagent 'nnml-request-list-newsgroups |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
163 (list (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
164 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
165 (deffoo nnagent-request-move-article |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
166 (article group server accept-form &optional last) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
167 (nnoo-parent-function 'nnagent 'nnml-request-move-article |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
168 (list article group (nnagent-server server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
169 accept-form last))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
170 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
171 (deffoo nnagent-request-rename-group (group new-name &optional server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
172 (nnoo-parent-function 'nnagent 'nnml-request-rename-group |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
173 (list group new-name (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
174 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
175 (deffoo nnagent-request-scan (&optional group server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
176 (nnoo-parent-function 'nnagent 'nnml-request-scan |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
177 (list group (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
178 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
179 (deffoo nnagent-retrieve-headers (sequence &optional group server fetch-old) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
180 (nnoo-parent-function 'nnagent 'nnml-retrieve-headers |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
181 (list sequence group (nnagent-server server) fetch-old))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
182 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
183 (deffoo nnagent-set-status (article name value &optional group server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
184 (nnoo-parent-function 'nnagent 'nnml-set-status |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
185 (list article name value group (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
186 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
187 (deffoo nnagent-server-opened (&optional server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
188 (nnoo-parent-function 'nnagent 'nnml-server-opened |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
189 (list (nnagent-server server)))) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
190 |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
191 (deffoo nnagent-status-message (&optional server) |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
192 (nnoo-parent-function 'nnagent 'nnml-status-message |
|
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24358
diff
changeset
|
193 (list (nnagent-server server)))) |
| 24358 | 194 |
| 195 ;; Use nnml functions for just about everything. | |
| 196 (nnoo-import nnagent | |
| 197 (nnml)) | |
| 198 | |
| 199 | |
| 200 ;;; Internal functions. | |
| 201 | |
| 202 (provide 'nnagent) | |
| 203 | |
| 204 ;;; nnagent.el ends here |
