Mercurial > emacs
annotate lisp/gnus/nntp.el @ 88242:a64eb026ac9e
*** empty log message ***
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Fri, 20 Jan 2006 18:50:02 +0000 |
parents | d7ddb3e565de |
children |
rev | line source |
---|---|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1 ;;; nntp.el --- nntp access for Gnus |
88155 | 2 |
3 ;; Copyright (C) 1987, 1988, 1989, 1990, 1992, 1993, | |
4 ;; 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, | |
5 ;; 2003, 2004, 2005 Free Software Foundation, Inc. | |
17493 | 6 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
7 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 8 ;; Keywords: news |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
88155 | 13 ;; it under the terms of the GNU General Public License as published |
14 ;; by the Free Software Foundation; either version 2, or (at your | |
15 ;; option) any later version. | |
17493 | 16 |
88155 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, but |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
17493 | 21 |
22 ;; You should have received a copy of the GNU General Public License | |
88155 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, | |
25 ;; MA 02110-1301, USA. | |
17493 | 26 |
27 ;;; Commentary: | |
28 | |
29 ;;; Code: | |
30 | |
31 (require 'nnheader) | |
32 (require 'nnoo) | |
33 (require 'gnus-util) | |
34 | |
35 (nnoo-declare nntp) | |
36 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
37 (eval-when-compile (require 'cl)) |
17493 | 38 |
88155 | 39 (defgroup nntp nil |
40 "NNTP access for Gnus." | |
41 :group 'gnus) | |
42 | |
17493 | 43 (defvoo nntp-address nil |
44 "Address of the physical nntp server.") | |
45 | |
46 (defvoo nntp-port-number "nntp" | |
47 "Port number on the physical nntp server.") | |
48 | |
49 (defvoo nntp-server-opened-hook '(nntp-send-mode-reader) | |
50 "*Hook used for sending commands to the server at startup. | |
51 The default value is `nntp-send-mode-reader', which makes an innd | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
52 server spawn an nnrpd server.") |
17493 | 53 |
54 (defvoo nntp-authinfo-function 'nntp-send-authinfo | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
55 "Function used to send AUTHINFO to the server. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
56 It is called with no parameters.") |
17493 | 57 |
58 (defvoo nntp-server-action-alist | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
59 '(("nntpd 1\\.5\\.11t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
60 (remove-hook 'nntp-server-opened-hook 'nntp-send-mode-reader)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
61 ("NNRP server Netscape" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
62 (setq nntp-server-list-active-group nil))) |
17493 | 63 "Alist of regexps to match on server types and actions to be taken. |
64 For instance, if you want Gnus to beep every time you connect | |
65 to innd, you could say something like: | |
66 | |
67 \(setq nntp-server-action-alist | |
68 '((\"innd\" (ding)))) | |
69 | |
70 You probably don't want to do that, though.") | |
71 | |
72 (defvoo nntp-open-connection-function 'nntp-open-network-stream | |
73 "*Function used for connecting to a remote system. | |
88155 | 74 It will be called with the buffer to output in as argument. |
75 | |
76 Currently, five such functions are provided (please refer to their | |
77 respective doc string for more information), three of them establishing | |
78 direct connections to the nntp server, and two of them using an indirect | |
79 host. | |
80 | |
81 Direct connections: | |
82 - `nntp-open-network-stream' (the default), | |
83 - `nntp-open-ssl-stream', | |
84 - `nntp-open-tls-stream', | |
85 - `nntp-open-telnet-stream'. | |
86 | |
87 Indirect connections: | |
88 - `nntp-open-via-rlogin-and-telnet', | |
89 - `nntp-open-via-telnet-and-telnet'.") | |
17493 | 90 |
88155 | 91 (defvoo nntp-pre-command nil |
92 "*Pre-command to use with the various nntp-open-via-* methods. | |
93 This is where you would put \"runsocks\" or stuff like that.") | |
94 | |
95 (defvoo nntp-telnet-command "telnet" | |
96 "*Telnet command used to connect to the nntp server. | |
97 This command is used by the various nntp-open-via-* methods.") | |
17493 | 98 |
88155 | 99 (defvoo nntp-telnet-switches '("-8") |
100 "*Switches given to the telnet command `nntp-telnet-command'.") | |
101 | |
102 (defvoo nntp-end-of-line "\r\n" | |
103 "*String to use on the end of lines when talking to the NNTP server. | |
104 This is \"\\r\\n\" by default, but should be \"\\n\" when | |
105 using an indirect connection method (nntp-open-via-*).") | |
106 | |
107 (defvoo nntp-via-rlogin-command "rsh" | |
108 "*Rlogin command used to connect to an intermediate host. | |
109 This command is used by the `nntp-open-via-rlogin-and-telnet' method. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
110 The default is \"rsh\", but \"ssh\" is a popular alternative.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
111 |
88155 | 112 (defvoo nntp-via-rlogin-command-switches nil |
113 "*Switches given to the rlogin command `nntp-via-rlogin-command'. | |
114 If you use \"ssh\" for `nntp-via-rlogin-command', you may set this to | |
115 \(\"-C\") in order to compress all data connections, otherwise set this | |
116 to \(\"-t\" \"-e\" \"none\") or (\"-C\" \"-t\" \"-e\" \"none\") if the telnet | |
117 command requires a pseudo-tty allocation on an intermediate host.") | |
17493 | 118 |
88155 | 119 (defvoo nntp-via-telnet-command "telnet" |
120 "*Telnet command used to connect to an intermediate host. | |
121 This command is used by the `nntp-open-via-telnet-and-telnet' method.") | |
17493 | 122 |
88155 | 123 (defvoo nntp-via-telnet-switches '("-8") |
124 "*Switches given to the telnet command `nntp-via-telnet-command'.") | |
17493 | 125 |
88155 | 126 (defvoo nntp-via-user-name nil |
127 "*User name to log in on an intermediate host with. | |
128 This variable is used by the `nntp-open-via-telnet-and-telnet' method.") | |
17493 | 129 |
88155 | 130 (defvoo nntp-via-user-password nil |
131 "*Password to use to log in on an intermediate host with. | |
132 This variable is used by the `nntp-open-via-telnet-and-telnet' method.") | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
133 |
88155 | 134 (defvoo nntp-via-address nil |
135 "*Address of an intermediate host to connect to. | |
136 This variable is used by the `nntp-open-via-rlogin-and-telnet' and | |
137 `nntp-open-via-telnet-and-telnet' methods.") | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
138 |
88155 | 139 (defvoo nntp-via-envuser nil |
140 "*Whether both telnet client and server support the ENVIRON option. | |
141 If non-nil, there will be no prompt for a login name.") | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
142 |
88155 | 143 (defvoo nntp-via-shell-prompt "bash\\|\$ *\r?$\\|> *\r?" |
144 "*Regular expression to match the shell prompt on an intermediate host. | |
145 This variable is used by the `nntp-open-via-telnet-and-telnet' method.") | |
17493 | 146 |
147 (defvoo nntp-large-newsgroup 50 | |
88155 | 148 "*The number of articles which indicates a large newsgroup. |
149 If the number of articles is greater than the value, verbose | |
17493 | 150 messages will be shown to indicate the current status.") |
151 | |
152 (defvoo nntp-maximum-request 400 | |
153 "*The maximum number of the requests sent to the NNTP server at one time. | |
154 If Emacs hangs up while retrieving headers, set the variable to a | |
155 lower value.") | |
156 | |
157 (defvoo nntp-nov-is-evil nil | |
158 "*If non-nil, nntp will never attempt to use XOVER when talking to the server.") | |
159 | |
160 (defvoo nntp-xover-commands '("XOVER" "XOVERVIEW") | |
161 "*List of strings that are used as commands to fetch NOV lines from a server. | |
162 The strings are tried in turn until a positive response is gotten. If | |
163 none of the commands are successful, nntp will just grab headers one | |
164 by one.") | |
165 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
166 (defvoo nntp-nov-gap 5 |
17493 | 167 "*Maximum allowed gap between two articles. |
168 If the gap between two consecutive articles is bigger than this | |
169 variable, split the XOVER request into two requests.") | |
170 | |
171 (defvoo nntp-prepare-server-hook nil | |
172 "*Hook run before a server is opened. | |
173 If can be used to set up a server remotely, for instance. Say you | |
174 have an account at the machine \"other.machine\". This machine has | |
175 access to an NNTP server that you can't access locally. You could | |
176 then use this hook to rsh to the remote machine and start a proxy NNTP | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
177 server there that you can connect to. See also |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
178 `nntp-open-connection-function'") |
17493 | 179 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
180 (defvoo nntp-coding-system-for-read 'binary |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
181 "*Coding system to read from NNTP.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
182 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
183 (defvoo nntp-coding-system-for-write 'binary |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
184 "*Coding system to write to NNTP.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
185 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
186 (defcustom nntp-authinfo-file "~/.authinfo" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
187 ".netrc-like file that holds nntp authinfo passwords." |
88155 | 188 :group 'nntp |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
189 :type |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
190 '(choice file |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
191 (repeat :tag "Entries" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
192 :menu-tag "Inline" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
193 (list :format "%v" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
194 :value ("" ("login" . "") ("password" . "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
195 (string :tag "Host") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
196 (checklist :inline t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
197 (cons :format "%v" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
198 (const :format "" "login") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
199 (string :format "Login: %v")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
200 (cons :format "%v" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
201 (const :format "" "password") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
202 (string :format "Password: %v"))))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
203 |
17493 | 204 |
205 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
206 (defvoo nntp-connection-timeout nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
207 "*Number of seconds to wait before an nntp connection times out. |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
208 If this variable is nil, which is the default, no timers are set. |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
209 NOTE: This variable is never seen to work in Emacs 20 and XEmacs 21.") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
210 |
88155 | 211 (defvoo nntp-prepare-post-hook nil |
212 "*Hook run just before posting an article. It is supposed to be used | |
213 to insert Cancel-Lock headers.") | |
214 | |
17493 | 215 ;;; Internal variables. |
216 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
217 (defvar nntp-record-commands nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
218 "*If non-nil, nntp will record all commands in the \"*nntp-log*\" buffer.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
219 |
17493 | 220 (defvar nntp-have-messaged nil) |
221 | |
222 (defvar nntp-process-wait-for nil) | |
223 (defvar nntp-process-to-buffer nil) | |
224 (defvar nntp-process-callback nil) | |
225 (defvar nntp-process-decode nil) | |
226 (defvar nntp-process-start-point nil) | |
227 (defvar nntp-inside-change-function nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
228 (defvoo nntp-last-command-time nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
229 (defvoo nntp-last-command nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
230 (defvoo nntp-authinfo-password nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
231 (defvoo nntp-authinfo-user nil) |
17493 | 232 |
233 (defvar nntp-connection-list nil) | |
234 | |
235 (defvoo nntp-server-type nil) | |
236 (defvoo nntp-connection-alist nil) | |
237 (defvoo nntp-status-string "") | |
238 (defconst nntp-version "nntp 5.0") | |
239 (defvoo nntp-inhibit-erase nil) | |
240 (defvoo nntp-inhibit-output nil) | |
241 | |
242 (defvoo nntp-server-xover 'try) | |
243 (defvoo nntp-server-list-active-group 'try) | |
244 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
245 (defvar nntp-async-needs-kluge |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
246 (string-match "^GNU Emacs 20\\.3\\." (emacs-version)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
247 "*When non-nil, nntp will poll asynchronous connections |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
248 once a second. By default, this is turned on only for Emacs |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
249 20.3, which has a bug that breaks nntp's normal method of |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
250 noticing asynchronous data.") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
251 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
252 (defvar nntp-async-timer nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
253 (defvar nntp-async-process-list nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
254 |
88155 | 255 (defvar nntp-ssl-program |
256 "openssl s_client -quiet -ssl3 -connect %s:%p" | |
257 "A string containing commands for SSL connections. | |
258 Within a string, %s is replaced with the server address and %p with | |
259 port number on server. The program should accept IMAP commands on | |
260 stdin and return responses to stdout.") | |
261 | |
262 (defvar nntp-authinfo-rejected nil | |
263 "A custom error condition used to report 'Authentication Rejected' errors. | |
264 Condition handlers that match just this condition ensure that the nntp | |
265 backend doesn't catch this error.") | |
266 (put 'nntp-authinfo-rejected 'error-conditions '(error nntp-authinfo-rejected)) | |
267 (put 'nntp-authinfo-rejected 'error-message "Authorization Rejected") | |
17493 | 268 |
269 | |
270 | |
271 ;;; Internal functions. | |
272 | |
273 (defsubst nntp-send-string (process string) | |
274 "Send STRING to PROCESS." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
275 ;; We need to store the time to provide timeouts, and |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
276 ;; to store the command so the we can replay the command |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
277 ;; if the server gives us an AUTHINFO challenge. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
278 (setq nntp-last-command-time (current-time) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
279 nntp-last-command string) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
280 (when nntp-record-commands |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
281 (nntp-record-command string)) |
88155 | 282 (process-send-string process (concat string nntp-end-of-line)) |
283 (or (memq (process-status process) '(open run)) | |
284 (nntp-report "Server closed connection"))) | |
17493 | 285 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
286 (defun nntp-record-command (string) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
287 "Record the command STRING." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
288 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
289 (set-buffer (get-buffer-create "*nntp-log*")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
290 (goto-char (point-max)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
291 (let ((time (current-time))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
292 (insert (format-time-string "%Y%m%dT%H%M%S" time) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
293 "." (format "%03d" (/ (nth 2 time) 1000)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
294 " " nntp-address " " string "\n")))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
295 |
88155 | 296 (defun nntp-report (&rest args) |
297 "Report an error from the nntp backend. The first string in ARGS | |
298 can be a format string. For some commands, the failed command may be | |
299 retried once before actually displaying the error report." | |
300 | |
301 (when nntp-record-commands | |
302 (nntp-record-command "*** CALLED nntp-report ***")) | |
303 | |
304 (nnheader-report 'nntp args) | |
305 | |
306 (apply 'error args)) | |
307 | |
308 (defun nntp-report-1 (&rest args) | |
309 "Throws out to nntp-with-open-group-error so that the connection may | |
310 be restored and the command retried." | |
311 | |
312 (when nntp-record-commands | |
313 (nntp-record-command "*** CONNECTION LOST ***")) | |
314 | |
315 (throw 'nntp-with-open-group-error t)) | |
316 | |
17493 | 317 (defsubst nntp-wait-for (process wait-for buffer &optional decode discard) |
318 "Wait for WAIT-FOR to arrive from PROCESS." | |
319 (save-excursion | |
320 (set-buffer (process-buffer process)) | |
321 (goto-char (point-min)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
322 (while (and (or (not (memq (char-after (point)) '(?2 ?3 ?4 ?5))) |
88155 | 323 (looking-at "48[02]")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
324 (memq (process-status process) '(open run))) |
88155 | 325 (cond ((looking-at "480") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
326 (nntp-handle-authinfo process)) |
88155 | 327 ((looking-at "482") |
328 (nnheader-report 'nntp (get 'nntp-authinfo-rejected 'error-message)) | |
329 (signal 'nntp-authinfo-rejected nil)) | |
330 ((looking-at "^.*\n") | |
331 (delete-region (point) (progn (forward-line 1) (point))))) | |
17493 | 332 (nntp-accept-process-output process) |
333 (goto-char (point-min))) | |
334 (prog1 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
335 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
336 ((looking-at "[45]") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
337 (progn |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
338 (nntp-snarf-error-message) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
339 nil)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
340 ((not (memq (process-status process) '(open run))) |
88155 | 341 (nntp-report "Server closed connection")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
342 (t |
17493 | 343 (goto-char (point-max)) |
88155 | 344 (let ((limit (point-min)) |
345 response) | |
17493 | 346 (while (not (re-search-backward wait-for limit t)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
347 (nntp-accept-process-output process) |
17493 | 348 ;; We assume that whatever we wait for is less than 1000 |
349 ;; characters long. | |
350 (setq limit (max (- (point-max) 1000) (point-min))) | |
88155 | 351 (goto-char (point-max))) |
352 (setq response (match-string 0)) | |
353 (with-current-buffer nntp-server-buffer | |
354 (setq nntp-process-response response))) | |
17493 | 355 (nntp-decode-text (not decode)) |
356 (unless discard | |
357 (save-excursion | |
88155 | 358 (set-buffer buffer) |
359 (goto-char (point-max)) | |
360 (insert-buffer-substring (process-buffer process)) | |
17493 | 361 ;; Nix out "nntp reading...." message. |
362 (when nntp-have-messaged | |
363 (setq nntp-have-messaged nil) | |
88155 | 364 (nnheader-message 5 "")))) |
365 t)) | |
17493 | 366 (unless discard |
367 (erase-buffer))))) | |
368 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
369 (defun nntp-kill-buffer (buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
370 (when (buffer-name buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
371 (kill-buffer buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
372 (nnheader-init-server-buffer))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
373 |
17493 | 374 (defsubst nntp-find-connection (buffer) |
375 "Find the connection delivering to BUFFER." | |
376 (let ((alist nntp-connection-alist) | |
377 (buffer (if (stringp buffer) (get-buffer buffer) buffer)) | |
378 process entry) | |
88155 | 379 (while (and alist (setq entry (pop alist))) |
17493 | 380 (when (eq buffer (cadr entry)) |
381 (setq process (car entry) | |
382 alist nil))) | |
383 (when process | |
384 (if (memq (process-status process) '(open run)) | |
385 process | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
386 (nntp-kill-buffer (process-buffer process)) |
17493 | 387 (setq nntp-connection-alist (delq entry nntp-connection-alist)) |
388 nil)))) | |
389 | |
390 (defsubst nntp-find-connection-entry (buffer) | |
391 "Return the entry for the connection to BUFFER." | |
392 (assq (nntp-find-connection buffer) nntp-connection-alist)) | |
393 | |
394 (defun nntp-find-connection-buffer (buffer) | |
395 "Return the process connection buffer tied to BUFFER." | |
396 (let ((process (nntp-find-connection buffer))) | |
397 (when process | |
398 (process-buffer process)))) | |
399 | |
400 (defsubst nntp-retrieve-data (command address port buffer | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
401 &optional wait-for callback decode) |
17493 | 402 "Use COMMAND to retrieve data into BUFFER from PORT on ADDRESS." |
403 (let ((process (or (nntp-find-connection buffer) | |
404 (nntp-open-connection buffer)))) | |
88155 | 405 (if process |
406 (progn | |
407 (unless (or nntp-inhibit-erase nnheader-callback-function) | |
408 (save-excursion | |
409 (set-buffer (process-buffer process)) | |
410 (erase-buffer))) | |
411 (condition-case err | |
412 (progn | |
413 (when command | |
414 (nntp-send-string process command)) | |
415 (cond | |
416 ((eq callback 'ignore) | |
417 t) | |
418 ((and callback wait-for) | |
419 (nntp-async-wait process wait-for buffer decode callback) | |
420 t) | |
421 (wait-for | |
422 (nntp-wait-for process wait-for buffer decode)) | |
423 (t t))) | |
424 (nntp-authinfo-rejected | |
425 (signal 'nntp-authinfo-rejected (cdr err))) | |
426 (error | |
427 (nnheader-report 'nntp "Couldn't open connection to %s: %s" | |
428 address err)) | |
429 (quit | |
430 (message "Quit retrieving data from nntp") | |
431 (signal 'quit nil) | |
432 nil))) | |
433 (nnheader-report 'nntp "Couldn't open connection to %s" address)))) | |
17493 | 434 |
435 (defsubst nntp-send-command (wait-for &rest strings) | |
436 "Send STRINGS to server and wait until WAIT-FOR returns." | |
437 (when (and (not nnheader-callback-function) | |
438 (not nntp-inhibit-output)) | |
439 (save-excursion | |
440 (set-buffer nntp-server-buffer) | |
441 (erase-buffer))) | |
88155 | 442 (let* ((command (mapconcat 'identity strings " ")) |
443 (process (nntp-find-connection nntp-server-buffer)) | |
444 (buffer (and process (process-buffer process))) | |
445 (pos (and buffer (with-current-buffer buffer (point))))) | |
446 (if process | |
447 (prog1 | |
448 (nntp-retrieve-data command | |
449 nntp-address nntp-port-number | |
450 nntp-server-buffer | |
451 wait-for nnheader-callback-function) | |
452 ;; If nothing to wait for, still remove possibly echo'ed commands. | |
453 ;; We don't have echos if nntp-open-connection-function | |
454 ;; is `nntp-open-network-stream', so we skip this in that case. | |
455 (unless (or wait-for | |
456 (equal nntp-open-connection-function | |
457 'nntp-open-network-stream)) | |
458 (nntp-accept-response) | |
459 (save-excursion | |
460 (set-buffer buffer) | |
461 (goto-char pos) | |
462 (if (looking-at (regexp-quote command)) | |
463 (delete-region pos (progn (forward-line 1) | |
464 (gnus-point-at-bol)))) | |
465 ))) | |
466 (nnheader-report 'nntp "Couldn't open connection to %s." | |
467 nntp-address)))) | |
17493 | 468 |
469 (defun nntp-send-command-nodelete (wait-for &rest strings) | |
470 "Send STRINGS to server and wait until WAIT-FOR returns." | |
88155 | 471 (let* ((command (mapconcat 'identity strings " ")) |
472 (process (nntp-find-connection nntp-server-buffer)) | |
473 (buffer (and process (process-buffer process))) | |
474 (pos (and buffer (with-current-buffer buffer (point))))) | |
475 (if process | |
476 (prog1 | |
477 (nntp-retrieve-data command | |
478 nntp-address nntp-port-number | |
479 nntp-server-buffer | |
480 wait-for nnheader-callback-function) | |
481 ;; If nothing to wait for, still remove possibly echo'ed commands | |
482 (unless wait-for | |
483 (nntp-accept-response) | |
484 (save-excursion | |
485 (set-buffer buffer) | |
486 (goto-char pos) | |
487 (if (looking-at (regexp-quote command)) | |
488 (delete-region pos (progn (forward-line 1) | |
489 (gnus-point-at-bol))))))) | |
490 (nnheader-report 'nntp "Couldn't open connection to %s." | |
491 nntp-address)))) | |
17493 | 492 |
493 (defun nntp-send-command-and-decode (wait-for &rest strings) | |
494 "Send STRINGS to server and wait until WAIT-FOR returns." | |
495 (when (and (not nnheader-callback-function) | |
496 (not nntp-inhibit-output)) | |
497 (save-excursion | |
498 (set-buffer nntp-server-buffer) | |
499 (erase-buffer))) | |
88155 | 500 (let* ((command (mapconcat 'identity strings " ")) |
501 (process (nntp-find-connection nntp-server-buffer)) | |
502 (buffer (and process (process-buffer process))) | |
503 (pos (and buffer (with-current-buffer buffer (point))))) | |
504 (if process | |
505 (prog1 | |
506 (nntp-retrieve-data command | |
507 nntp-address nntp-port-number | |
508 nntp-server-buffer | |
509 wait-for nnheader-callback-function t) | |
510 ;; If nothing to wait for, still remove possibly echo'ed commands | |
511 (unless wait-for | |
512 (nntp-accept-response) | |
513 (save-excursion | |
514 (set-buffer buffer) | |
515 (goto-char pos) | |
516 (if (looking-at (regexp-quote command)) | |
517 (delete-region pos (progn (forward-line 1) (gnus-point-at-bol)))) | |
518 ))) | |
519 (nnheader-report 'nntp "Couldn't open connection to %s." | |
520 nntp-address)))) | |
521 | |
17493 | 522 |
523 (defun nntp-send-buffer (wait-for) | |
524 "Send the current buffer to server and wait until WAIT-FOR returns." | |
525 (when (and (not nnheader-callback-function) | |
526 (not nntp-inhibit-output)) | |
527 (save-excursion | |
528 (set-buffer (nntp-find-connection-buffer nntp-server-buffer)) | |
529 (erase-buffer))) | |
530 (nntp-encode-text) | |
42500
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
531 (mm-with-unibyte-current-buffer |
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
532 ;; Some encoded unicode text contains character 0x80-0x9f e.g. Euro. |
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
533 (process-send-region (nntp-find-connection nntp-server-buffer) |
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
534 (point-min) (point-max))) |
17493 | 535 (nntp-retrieve-data |
536 nil nntp-address nntp-port-number nntp-server-buffer | |
537 wait-for nnheader-callback-function)) | |
538 | |
539 | |
540 | |
541 ;;; Interface functions. | |
542 | |
543 (nnoo-define-basics nntp) | |
544 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
545 (defsubst nntp-next-result-arrived-p () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
546 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
547 ;; A result that starts with a 2xx code is terminated by |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
548 ;; a line with only a "." on it. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
549 ((eq (char-after) ?2) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
550 (if (re-search-forward "\n\\.\r?\n" nil t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
551 t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
552 nil)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
553 ;; A result that starts with a 3xx or 4xx code is terminated |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
554 ;; by a newline. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
555 ((looking-at "[34]") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
556 (if (search-forward "\n" nil t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
557 t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
558 nil)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
559 ;; No result here. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
560 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
561 nil))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
562 |
88155 | 563 (eval-when-compile |
564 (defvar nntp-with-open-group-internal nil) | |
565 (defvar nntp-report-n nil)) | |
566 | |
567 (defmacro nntp-with-open-group (group server &optional connectionless &rest forms) | |
568 "Protect against servers that don't like clients that keep idle connections opens. | |
569 The problem being that these servers may either close a connection or | |
570 simply ignore any further requests on a connection. Closed | |
571 connections are not detected until accept-process-output has updated | |
572 the process-status. Dropped connections are not detected until the | |
573 connection timeouts (which may be several minutes) or | |
574 nntp-connection-timeout has expired. When these occur | |
575 nntp-with-open-group, opens a new connection then re-issues the NNTP | |
576 command whose response triggered the error." | |
577 (when (and (listp connectionless) | |
578 (not (eq connectionless nil))) | |
579 (setq forms (cons connectionless forms) | |
580 connectionless nil)) | |
581 `(letf ((nntp-report-n (symbol-function 'nntp-report)) | |
582 ((symbol-function 'nntp-report) (symbol-function 'nntp-report-1)) | |
583 (nntp-with-open-group-internal nil)) | |
584 (while (catch 'nntp-with-open-group-error | |
585 ;; Open the connection to the server | |
586 ;; NOTE: Existing connections are NOT tested. | |
587 (nntp-possibly-change-group ,group ,server ,connectionless) | |
588 | |
589 (let ((timer | |
590 (and nntp-connection-timeout | |
591 (nnheader-run-at-time | |
592 nntp-connection-timeout nil | |
593 '(lambda () | |
594 (let ((process (nntp-find-connection | |
595 nntp-server-buffer)) | |
596 (buffer (and process | |
597 (process-buffer process)))) | |
598 ;; When I an able to identify the | |
599 ;; connection to the server AND I've | |
600 ;; received NO reponse for | |
601 ;; nntp-connection-timeout seconds. | |
602 (when (and buffer (eq 0 (buffer-size buffer))) | |
603 ;; Close the connection. Take no | |
604 ;; other action as the accept input | |
605 ;; code will handle the closed | |
606 ;; connection. | |
607 (nntp-kill-buffer buffer)))))))) | |
608 (unwind-protect | |
609 (setq nntp-with-open-group-internal | |
610 (condition-case nil | |
611 (progn ,@forms) | |
612 (quit | |
613 (nntp-close-server) | |
614 (signal 'quit nil)))) | |
615 (when timer | |
616 (nnheader-cancel-timer timer))) | |
617 nil)) | |
618 (setf (symbol-function 'nntp-report) nntp-report-n)) | |
619 nntp-with-open-group-internal)) | |
620 | |
17493 | 621 (deffoo nntp-retrieve-headers (articles &optional group server fetch-old) |
622 "Retrieve the headers of ARTICLES." | |
88155 | 623 (nntp-with-open-group |
624 group server | |
625 (save-excursion | |
626 (set-buffer (nntp-find-connection-buffer nntp-server-buffer)) | |
627 (erase-buffer) | |
628 (if (and (not gnus-nov-is-evil) | |
629 (not nntp-nov-is-evil) | |
630 (nntp-retrieve-headers-with-xover articles fetch-old)) | |
631 ;; We successfully retrieved the headers via XOVER. | |
632 'nov | |
633 ;; XOVER didn't work, so we do it the hard, slow and inefficient | |
634 ;; way. | |
635 (let ((number (length articles)) | |
636 (articles articles) | |
637 (count 0) | |
638 (received 0) | |
639 (last-point (point-min)) | |
640 (buf (nntp-find-connection-buffer nntp-server-buffer)) | |
641 (nntp-inhibit-erase t) | |
642 article) | |
643 ;; Send HEAD commands. | |
644 (while (setq article (pop articles)) | |
645 (nntp-send-command | |
646 nil | |
647 "HEAD" (if (numberp article) | |
648 (int-to-string article) | |
649 ;; `articles' is either a list of article numbers | |
650 ;; or a list of article IDs. | |
651 article)) | |
652 (incf count) | |
653 ;; Every 400 requests we have to read the stream in | |
654 ;; order to avoid deadlocks. | |
655 (when (or (null articles) ;All requests have been sent. | |
656 (zerop (% count nntp-maximum-request))) | |
657 (nntp-accept-response) | |
658 (while (progn | |
659 (set-buffer buf) | |
660 (goto-char last-point) | |
661 ;; Count replies. | |
662 (while (nntp-next-result-arrived-p) | |
663 (setq last-point (point)) | |
664 (incf received)) | |
665 (< received count)) | |
666 ;; If number of headers is greater than 100, give | |
667 ;; informative messages. | |
668 (and (numberp nntp-large-newsgroup) | |
669 (> number nntp-large-newsgroup) | |
670 (zerop (% received 20)) | |
671 (nnheader-message 6 "NNTP: Receiving headers... %d%%" | |
672 (/ (* received 100) number))) | |
673 (nntp-accept-response)))) | |
674 (and (numberp nntp-large-newsgroup) | |
675 (> number nntp-large-newsgroup) | |
676 (nnheader-message 6 "NNTP: Receiving headers...done")) | |
17493 | 677 |
88155 | 678 ;; Now all of replies are received. Fold continuation lines. |
679 (nnheader-fold-continuation-lines) | |
680 ;; Remove all "\r"'s. | |
681 (nnheader-strip-cr) | |
682 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) | |
683 'headers))))) | |
17493 | 684 |
685 (deffoo nntp-retrieve-groups (groups &optional server) | |
686 "Retrieve group info on GROUPS." | |
88155 | 687 (nntp-with-open-group |
688 nil server | |
689 (when (nntp-find-connection-buffer nntp-server-buffer) | |
690 (catch 'done | |
691 (save-excursion | |
692 ;; Erase nntp-server-buffer before nntp-inhibit-erase. | |
693 (set-buffer nntp-server-buffer) | |
694 (erase-buffer) | |
695 (set-buffer (nntp-find-connection-buffer nntp-server-buffer)) | |
696 ;; The first time this is run, this variable is `try'. So we | |
697 ;; try. | |
698 (when (eq nntp-server-list-active-group 'try) | |
699 (nntp-try-list-active (car groups))) | |
700 (erase-buffer) | |
701 (let ((count 0) | |
702 (groups groups) | |
703 (received 0) | |
704 (last-point (point-min)) | |
705 (nntp-inhibit-erase t) | |
706 (buf (nntp-find-connection-buffer nntp-server-buffer)) | |
707 (command (if nntp-server-list-active-group | |
708 "LIST ACTIVE" "GROUP"))) | |
709 (while groups | |
710 ;; Timeout may have killed the buffer. | |
711 (unless (gnus-buffer-live-p buf) | |
712 (nnheader-report 'nntp "Connection to %s is closed." server) | |
713 (throw 'done nil)) | |
714 ;; Send the command to the server. | |
715 (nntp-send-command nil command (pop groups)) | |
716 (incf count) | |
717 ;; Every 400 requests we have to read the stream in | |
718 ;; order to avoid deadlocks. | |
719 (when (or (null groups) ;All requests have been sent. | |
720 (zerop (% count nntp-maximum-request))) | |
721 (nntp-accept-response) | |
722 (while (and (gnus-buffer-live-p buf) | |
723 (progn | |
724 ;; Search `blue moon' in this file for the | |
725 ;; reason why set-buffer here. | |
726 (set-buffer buf) | |
727 (goto-char last-point) | |
728 ;; Count replies. | |
729 (while (re-search-forward "^[0-9]" nil t) | |
730 (incf received)) | |
731 (setq last-point (point)) | |
732 (< received count))) | |
733 (nntp-accept-response)))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
734 |
88155 | 735 ;; Wait for the reply from the final command. |
736 (unless (gnus-buffer-live-p buf) | |
737 (nnheader-report 'nntp "Connection to %s is closed." server) | |
738 (throw 'done nil)) | |
739 (set-buffer buf) | |
740 (goto-char (point-max)) | |
741 (re-search-backward "^[0-9]" nil t) | |
742 (when (looking-at "^[23]") | |
743 (while (and (gnus-buffer-live-p buf) | |
744 (progn | |
745 (set-buffer buf) | |
746 (goto-char (point-max)) | |
747 (if (not nntp-server-list-active-group) | |
748 (not (re-search-backward "\r?\n" | |
749 (- (point) 3) t)) | |
750 (not (re-search-backward "^\\.\r?\n" | |
751 (- (point) 4) t))))) | |
752 (nntp-accept-response))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
753 |
88155 | 754 ;; Now all replies are received. We remove CRs. |
755 (unless (gnus-buffer-live-p buf) | |
756 (nnheader-report 'nntp "Connection to %s is closed." server) | |
757 (throw 'done nil)) | |
758 (set-buffer buf) | |
759 (goto-char (point-min)) | |
760 (while (search-forward "\r" nil t) | |
761 (replace-match "" t t)) | |
17493 | 762 |
88155 | 763 (if (not nntp-server-list-active-group) |
764 (progn | |
765 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) | |
766 'group) | |
767 ;; We have read active entries, so we just delete the | |
768 ;; superfluous gunk. | |
769 (goto-char (point-min)) | |
770 (while (re-search-forward "^[.2-5]" nil t) | |
771 (delete-region (match-beginning 0) | |
772 (progn (forward-line 1) (point)))) | |
773 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) | |
774 'active))))))) | |
17493 | 775 |
776 (deffoo nntp-retrieve-articles (articles &optional group server) | |
88155 | 777 (nntp-with-open-group |
778 group server | |
779 (save-excursion | |
780 (let ((number (length articles)) | |
781 (articles articles) | |
782 (count 0) | |
783 (received 0) | |
784 (last-point (point-min)) | |
785 (buf (nntp-find-connection-buffer nntp-server-buffer)) | |
786 (nntp-inhibit-erase t) | |
787 (map (apply 'vector articles)) | |
788 (point 1) | |
789 article) | |
790 (set-buffer buf) | |
791 (erase-buffer) | |
792 ;; Send ARTICLE command. | |
793 (while (setq article (pop articles)) | |
794 (nntp-send-command | |
795 nil | |
796 "ARTICLE" (if (numberp article) | |
797 (int-to-string article) | |
798 ;; `articles' is either a list of article numbers | |
799 ;; or a list of article IDs. | |
800 article)) | |
801 (incf count) | |
802 ;; Every 400 requests we have to read the stream in | |
803 ;; order to avoid deadlocks. | |
804 (when (or (null articles) ;All requests have been sent. | |
805 (zerop (% count nntp-maximum-request))) | |
806 (nntp-accept-response) | |
807 (while (progn | |
808 (set-buffer buf) | |
809 (goto-char last-point) | |
810 ;; Count replies. | |
811 (while (nntp-next-result-arrived-p) | |
812 (aset map received (cons (aref map received) (point))) | |
813 (setq last-point (point)) | |
814 (incf received)) | |
815 (< received count)) | |
816 ;; If number of headers is greater than 100, give | |
817 ;; informative messages. | |
818 (and (numberp nntp-large-newsgroup) | |
819 (> number nntp-large-newsgroup) | |
820 (zerop (% received 20)) | |
821 (nnheader-message 6 "NNTP: Receiving articles... %d%%" | |
822 (/ (* received 100) number))) | |
823 (nntp-accept-response)))) | |
824 (and (numberp nntp-large-newsgroup) | |
825 (> number nntp-large-newsgroup) | |
826 (nnheader-message 6 "NNTP: Receiving articles...done")) | |
17493 | 827 |
88155 | 828 ;; Now we have all the responses. We go through the results, |
829 ;; wash it and copy it over to the server buffer. | |
830 (set-buffer nntp-server-buffer) | |
831 (erase-buffer) | |
832 (setq last-point (point-min)) | |
833 (mapcar | |
834 (lambda (entry) | |
835 (narrow-to-region | |
836 (setq point (goto-char (point-max))) | |
837 (progn | |
838 (insert-buffer-substring buf last-point (cdr entry)) | |
839 (point-max))) | |
840 (setq last-point (cdr entry)) | |
841 (nntp-decode-text) | |
842 (widen) | |
843 (cons (car entry) point)) | |
844 map))))) | |
17493 | 845 |
846 (defun nntp-try-list-active (group) | |
847 (nntp-list-active-group group) | |
848 (save-excursion | |
849 (set-buffer nntp-server-buffer) | |
850 (goto-char (point-min)) | |
851 (cond ((or (eobp) | |
852 (looking-at "5[0-9]+")) | |
853 (setq nntp-server-list-active-group nil)) | |
854 (t | |
855 (setq nntp-server-list-active-group t))))) | |
856 | |
857 (deffoo nntp-list-active-group (group &optional server) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
858 "Return the active info on GROUP (which can be a regexp)." |
88155 | 859 (nntp-with-open-group |
860 nil server | |
861 (nntp-send-command "^\\.*\r?\n" "LIST ACTIVE" group))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
862 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
863 (deffoo nntp-request-group-articles (group &optional server) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
864 "Return the list of existing articles in GROUP." |
88155 | 865 (nntp-with-open-group |
866 nil server | |
867 (nntp-send-command "^\\.*\r?\n" "LISTGROUP" group))) | |
17493 | 868 |
869 (deffoo nntp-request-article (article &optional group server buffer command) | |
88155 | 870 (nntp-with-open-group |
871 group server | |
872 (when (nntp-send-command-and-decode | |
873 "\r?\n\\.\r?\n" "ARTICLE" | |
874 (if (numberp article) (int-to-string article) article)) | |
875 (if (and buffer | |
876 (not (equal buffer nntp-server-buffer))) | |
877 (save-excursion | |
878 (set-buffer nntp-server-buffer) | |
879 (copy-to-buffer buffer (point-min) (point-max)) | |
880 (nntp-find-group-and-number group)) | |
881 (nntp-find-group-and-number group))))) | |
17493 | 882 |
883 (deffoo nntp-request-head (article &optional group server) | |
88155 | 884 (nntp-with-open-group |
885 group server | |
886 (when (nntp-send-command | |
887 "\r?\n\\.\r?\n" "HEAD" | |
888 (if (numberp article) (int-to-string article) article)) | |
889 (prog1 | |
890 (nntp-find-group-and-number group) | |
891 (nntp-decode-text))))) | |
17493 | 892 |
893 (deffoo nntp-request-body (article &optional group server) | |
88155 | 894 (nntp-with-open-group |
895 group server | |
896 (nntp-send-command-and-decode | |
897 "\r?\n\\.\r?\n" "BODY" | |
898 (if (numberp article) (int-to-string article) article)))) | |
17493 | 899 |
900 (deffoo nntp-request-group (group &optional server dont-check) | |
88155 | 901 (nntp-with-open-group |
902 nil server | |
903 (when (nntp-send-command "^[245].*\n" "GROUP" group) | |
904 (let ((entry (nntp-find-connection-entry nntp-server-buffer))) | |
905 (setcar (cddr entry) group))))) | |
17493 | 906 |
907 (deffoo nntp-close-group (group &optional server) | |
908 t) | |
909 | |
910 (deffoo nntp-server-opened (&optional server) | |
911 "Say whether a connection to SERVER has been opened." | |
912 (and (nnoo-current-server-p 'nntp server) | |
913 nntp-server-buffer | |
914 (gnus-buffer-live-p nntp-server-buffer) | |
915 (nntp-find-connection nntp-server-buffer))) | |
916 | |
917 (deffoo nntp-open-server (server &optional defs connectionless) | |
918 (nnheader-init-server-buffer) | |
919 (if (nntp-server-opened server) | |
920 t | |
921 (when (or (stringp (car defs)) | |
922 (numberp (car defs))) | |
923 (setq defs (cons (list 'nntp-port-number (car defs)) (cdr defs)))) | |
924 (unless (assq 'nntp-address defs) | |
925 (setq defs (append defs (list (list 'nntp-address server))))) | |
926 (nnoo-change-server 'nntp server defs) | |
927 (unless connectionless | |
928 (or (nntp-find-connection nntp-server-buffer) | |
929 (nntp-open-connection nntp-server-buffer))))) | |
930 | |
931 (deffoo nntp-close-server (&optional server) | |
932 (nntp-possibly-change-group nil server t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
933 (let ((process (nntp-find-connection nntp-server-buffer))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
934 (while process |
17493 | 935 (when (memq (process-status process) '(open run)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
936 (ignore-errors |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
937 (nntp-send-string process "QUIT") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
938 (unless (eq nntp-open-connection-function 'nntp-open-network-stream) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
939 ;; Ok, this is evil, but when using telnet and stuff |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
940 ;; as the connection method, it's important that the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
941 ;; QUIT command actually is sent out before we kill |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
942 ;; the process. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
943 (sleep-for 1)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
944 (nntp-kill-buffer (process-buffer process)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
945 (setq process (car (pop nntp-connection-alist)))) |
17493 | 946 (nnoo-close-server 'nntp))) |
947 | |
948 (deffoo nntp-request-close () | |
949 (let (process) | |
950 (while (setq process (pop nntp-connection-list)) | |
951 (when (memq (process-status process) '(open run)) | |
952 (ignore-errors | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
953 (nntp-send-string process "QUIT") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
954 (unless (eq nntp-open-connection-function 'nntp-open-network-stream) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
955 ;; Ok, this is evil, but when using telnet and stuff |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
956 ;; as the connection method, it's important that the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
957 ;; QUIT command actually is sent out before we kill |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
958 ;; the process. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
959 (sleep-for 1)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
960 (nntp-kill-buffer (process-buffer process))))) |
17493 | 961 |
962 (deffoo nntp-request-list (&optional server) | |
88155 | 963 (nntp-with-open-group |
964 nil server | |
965 (nntp-send-command-and-decode "\r?\n\\.\r?\n" "LIST"))) | |
17493 | 966 |
967 (deffoo nntp-request-list-newsgroups (&optional server) | |
88155 | 968 (nntp-with-open-group |
969 nil server | |
970 (nntp-send-command "\r?\n\\.\r?\n" "LIST NEWSGROUPS"))) | |
17493 | 971 |
972 (deffoo nntp-request-newgroups (date &optional server) | |
88155 | 973 (nntp-with-open-group |
974 nil server | |
975 (save-excursion | |
976 (set-buffer nntp-server-buffer) | |
977 (let* ((time (date-to-time date)) | |
978 (ls (- (cadr time) (nth 8 (decode-time time))))) | |
979 (cond ((< ls 0) | |
980 (setcar time (1- (car time))) | |
981 (setcar (cdr time) (+ ls 65536))) | |
982 ((>= ls 65536) | |
983 (setcar time (1+ (car time))) | |
984 (setcar (cdr time) (- ls 65536))) | |
985 (t | |
986 (setcar (cdr time) ls))) | |
987 (prog1 | |
988 (nntp-send-command | |
989 "^\\.\r?\n" "NEWGROUPS" | |
990 (format-time-string "%y%m%d %H%M%S" time) | |
991 "GMT") | |
992 (nntp-decode-text)))))) | |
17493 | 993 |
994 (deffoo nntp-request-post (&optional server) | |
88155 | 995 (nntp-with-open-group |
996 nil server | |
997 (when (nntp-send-command "^[23].*\r?\n" "POST") | |
998 (let ((response (with-current-buffer nntp-server-buffer | |
999 nntp-process-response)) | |
1000 server-id) | |
1001 (when (and response | |
1002 (string-match "^[23].*\\(<[^\t\n @<>]+@[^\t\n @<>]+>\\)" | |
1003 response)) | |
1004 (setq server-id (match-string 1 response)) | |
1005 (narrow-to-region (goto-char (point-min)) | |
1006 (if (search-forward "\n\n" nil t) | |
1007 (1- (point)) | |
1008 (point-max))) | |
1009 (unless (mail-fetch-field "Message-ID") | |
1010 (goto-char (point-min)) | |
1011 (insert "Message-ID: " server-id "\n")) | |
1012 (widen)) | |
1013 (run-hooks 'nntp-prepare-post-hook) | |
1014 (nntp-send-buffer "^[23].*\n"))))) | |
17493 | 1015 |
1016 (deffoo nntp-request-type (group article) | |
1017 'news) | |
1018 | |
1019 (deffoo nntp-asynchronous-p () | |
1020 t) | |
1021 | |
1022 ;;; Hooky functions. | |
1023 | |
1024 (defun nntp-send-mode-reader () | |
1025 "Send the MODE READER command to the nntp server. | |
1026 This function is supposed to be called from `nntp-server-opened-hook'. | |
1027 It will make innd servers spawn an nnrpd process to allow actual article | |
1028 reading." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1029 (nntp-send-command "^.*\n" "MODE READER")) |
17493 | 1030 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1031 (defun nntp-send-authinfo (&optional send-if-force) |
17493 | 1032 "Send the AUTHINFO to the nntp server. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1033 It will look in the \"~/.authinfo\" file for matching entries. If |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1034 nothing suitable is found there, it will prompt for a user name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1035 and a password. |
17493 | 1036 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1037 If SEND-IF-FORCE, only send authinfo to the server if the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1038 .authinfo file has the FORCE token." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1039 (let* ((list (gnus-parse-netrc nntp-authinfo-file)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1040 (alist (gnus-netrc-machine list nntp-address "nntp")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1041 (force (gnus-netrc-get alist "force")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1042 (user (or (gnus-netrc-get alist "login") nntp-authinfo-user)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1043 (passwd (gnus-netrc-get alist "password"))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1044 (when (or (not send-if-force) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1045 force) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1046 (unless user |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1047 (setq user (read-string (format "NNTP (%s) user name: " nntp-address)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1048 nntp-authinfo-user user)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1049 (unless (member user '(nil "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1050 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" user) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1051 (when t ;???Should check if AUTHINFO succeeded |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1052 (nntp-send-command |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1053 "^2.*\r?\n" "AUTHINFO PASS" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1054 (or passwd |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1055 nntp-authinfo-password |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1056 (setq nntp-authinfo-password |
88155 | 1057 (read-passwd (format "NNTP (%s@%s) password: " |
1058 user nntp-address)))))))))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1059 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1060 (defun nntp-send-nosy-authinfo () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1061 "Send the AUTHINFO to the nntp server." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1062 (let ((user (read-string (format "NNTP (%s) user name: " nntp-address)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1063 (unless (member user '(nil "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1064 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" user) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1065 (when t ;???Should check if AUTHINFO succeeded |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1066 (nntp-send-command "^2.*\r?\n" "AUTHINFO PASS" |
88155 | 1067 (read-passwd (format "NNTP (%s@%s) password: " |
1068 user nntp-address))))))) | |
17493 | 1069 |
1070 (defun nntp-send-authinfo-from-file () | |
1071 "Send the AUTHINFO to the nntp server. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1072 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1073 The authinfo login name is taken from the user's login name and the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1074 password contained in '~/.nntp-authinfo'." |
17493 | 1075 (when (file-exists-p "~/.nntp-authinfo") |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1076 (with-temp-buffer |
17493 | 1077 (insert-file-contents "~/.nntp-authinfo") |
1078 (goto-char (point-min)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1079 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" (user-login-name)) |
17493 | 1080 (nntp-send-command |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1081 "^2.*\r?\n" "AUTHINFO PASS" |
88155 | 1082 (buffer-substring (point) (gnus-point-at-eol)))))) |
17493 | 1083 |
1084 ;;; Internal functions. | |
1085 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1086 (defun nntp-handle-authinfo (process) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1087 "Take care of an authinfo response from the server." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1088 (let ((last nntp-last-command)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1089 (funcall nntp-authinfo-function) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1090 ;; We have to re-send the function that was interrupted by |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1091 ;; the authinfo request. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1092 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1093 (set-buffer nntp-server-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1094 (erase-buffer)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1095 (nntp-send-string process last))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1096 |
17493 | 1097 (defun nntp-make-process-buffer (buffer) |
1098 "Create a new, fresh buffer usable for nntp process connections." | |
1099 (save-excursion | |
1100 (set-buffer | |
1101 (generate-new-buffer | |
1102 (format " *server %s %s %s*" | |
1103 nntp-address nntp-port-number | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1104 (gnus-buffer-exists-p buffer)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1105 (mm-enable-multibyte) |
17493 | 1106 (set (make-local-variable 'after-change-functions) nil) |
1107 (set (make-local-variable 'nntp-process-wait-for) nil) | |
1108 (set (make-local-variable 'nntp-process-callback) nil) | |
1109 (set (make-local-variable 'nntp-process-to-buffer) nil) | |
1110 (set (make-local-variable 'nntp-process-start-point) nil) | |
1111 (set (make-local-variable 'nntp-process-decode) nil) | |
1112 (current-buffer))) | |
1113 | |
1114 (defun nntp-open-connection (buffer) | |
1115 "Open a connection to PORT on ADDRESS delivering output to BUFFER." | |
1116 (run-hooks 'nntp-prepare-server-hook) | |
1117 (let* ((pbuffer (nntp-make-process-buffer buffer)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1118 (timer |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1119 (and nntp-connection-timeout |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1120 (nnheader-run-at-time |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1121 nntp-connection-timeout nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1122 `(lambda () |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1123 (nntp-kill-buffer ,pbuffer))))) |
17493 | 1124 (process |
1125 (condition-case () | |
19992
36e81448237d
(nntp-coding-system-for-write): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
1126 (let ((coding-system-for-read nntp-coding-system-for-read) |
88155 | 1127 (coding-system-for-write nntp-coding-system-for-write)) |
19598
611e0de24d43
(nntp-coding-system-for-read): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17493
diff
changeset
|
1128 (funcall nntp-open-connection-function pbuffer)) |
17493 | 1129 (error nil) |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1130 (quit |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1131 (message "Quit opening connection") |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1132 (nntp-kill-buffer pbuffer) |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1133 (signal 'quit nil) |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1134 nil)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1135 (when timer |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1136 (nnheader-cancel-timer timer)) |
88155 | 1137 (unless process |
1138 (nntp-kill-buffer pbuffer)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1139 (when (and (buffer-name pbuffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1140 process) |
88155 | 1141 (gnus-set-process-query-on-exit-flag process nil) |
1142 (if (and (nntp-wait-for process "^2.*\n" buffer nil t) | |
1143 (memq (process-status process) '(open run))) | |
17493 | 1144 (prog1 |
1145 (caar (push (list process buffer nil) nntp-connection-alist)) | |
1146 (push process nntp-connection-list) | |
1147 (save-excursion | |
1148 (set-buffer pbuffer) | |
1149 (nntp-read-server-type) | |
1150 (erase-buffer) | |
1151 (set-buffer nntp-server-buffer) | |
1152 (let ((nnheader-callback-function nil)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1153 (run-hooks 'nntp-server-opened-hook) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1154 (nntp-send-authinfo t)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1155 (nntp-kill-buffer (process-buffer process)) |
17493 | 1156 nil)))) |
1157 | |
1158 (defun nntp-open-network-stream (buffer) | |
1159 (open-network-stream "nntpd" buffer nntp-address nntp-port-number)) | |
1160 | |
88155 | 1161 (eval-and-compile |
1162 (autoload 'format-spec "format-spec") | |
1163 (autoload 'format-spec-make "format-spec") | |
1164 (autoload 'open-tls-stream "tls")) | |
1165 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1166 (defun nntp-open-ssl-stream (buffer) |
88155 | 1167 (let* ((process-connection-type nil) |
1168 (proc (start-process "nntpd" buffer | |
1169 shell-file-name | |
1170 shell-command-switch | |
1171 (format-spec nntp-ssl-program | |
1172 (format-spec-make | |
1173 ?s nntp-address | |
1174 ?p nntp-port-number))))) | |
1175 (gnus-set-process-query-on-exit-flag proc nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1176 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1177 (set-buffer buffer) |
88155 | 1178 (let ((nntp-connection-alist (list proc buffer nil))) |
1179 (nntp-wait-for-string "^\r*20[01]")) | |
1180 (beginning-of-line) | |
1181 (delete-region (point-min) (point)) | |
1182 proc))) | |
1183 | |
1184 (defun nntp-open-tls-stream (buffer) | |
1185 (let ((proc (open-tls-stream "nntpd" buffer nntp-address nntp-port-number))) | |
1186 (gnus-set-process-query-on-exit-flag proc nil) | |
1187 (save-excursion | |
1188 (set-buffer buffer) | |
1189 (let ((nntp-connection-alist (list proc buffer nil))) | |
1190 (nntp-wait-for-string "^\r*20[01]")) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1191 (beginning-of-line) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1192 (delete-region (point-min) (point)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1193 proc))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1194 |
17493 | 1195 (defun nntp-read-server-type () |
1196 "Find out what the name of the server we have connected to is." | |
1197 ;; Wait for the status string to arrive. | |
1198 (setq nntp-server-type (buffer-string)) | |
1199 (let ((alist nntp-server-action-alist) | |
1200 (case-fold-search t) | |
1201 entry) | |
1202 ;; Run server-specific commands. | |
1203 (while alist | |
1204 (setq entry (pop alist)) | |
1205 (when (string-match (car entry) nntp-server-type) | |
1206 (if (and (listp (cadr entry)) | |
1207 (not (eq 'lambda (caadr entry)))) | |
1208 (eval (cadr entry)) | |
1209 (funcall (cadr entry))))))) | |
1210 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1211 (defun nntp-async-wait (process wait-for buffer decode callback) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1212 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1213 (set-buffer (process-buffer process)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1214 (unless nntp-inside-change-function |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1215 (erase-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1216 (setq nntp-process-wait-for wait-for |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1217 nntp-process-to-buffer buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1218 nntp-process-decode decode |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1219 nntp-process-callback callback |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1220 nntp-process-start-point (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1221 (setq after-change-functions '(nntp-after-change-function)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1222 (if nntp-async-needs-kluge |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1223 (nntp-async-kluge process)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1224 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1225 (defun nntp-async-kluge (process) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1226 ;; emacs 20.3 bug: process output with encoding 'binary |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1227 ;; doesn't trigger after-change-functions. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1228 (unless nntp-async-timer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1229 (setq nntp-async-timer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1230 (nnheader-run-at-time 1 1 'nntp-async-timer-handler))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1231 (add-to-list 'nntp-async-process-list process)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1232 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1233 (defun nntp-async-timer-handler () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1234 (mapcar |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1235 (lambda (proc) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1236 (if (memq (process-status proc) '(open run)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1237 (nntp-async-trigger proc) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1238 (nntp-async-stop proc))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1239 nntp-async-process-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1240 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1241 (defun nntp-async-stop (proc) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1242 (setq nntp-async-process-list (delq proc nntp-async-process-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1243 (when (and nntp-async-timer (not nntp-async-process-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1244 (nnheader-cancel-timer nntp-async-timer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1245 (setq nntp-async-timer nil))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1246 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1247 (defun nntp-after-change-function (beg end len) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1248 (unwind-protect |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1249 ;; we only care about insertions at eob |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1250 (when (and (eq 0 len) (eq (point-max) end)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1251 (save-match-data |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1252 (let ((proc (get-buffer-process (current-buffer)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1253 (when proc |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1254 (nntp-async-trigger proc))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1255 ;; any throw from after-change-functions will leave it |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1256 ;; set to nil. so we reset it here, if necessary. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1257 (when quit-flag |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1258 (setq after-change-functions '(nntp-after-change-function))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1259 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1260 (defun nntp-async-trigger (process) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1261 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1262 (set-buffer (process-buffer process)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1263 (when nntp-process-callback |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1264 ;; do we have an error message? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1265 (goto-char nntp-process-start-point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1266 (if (memq (following-char) '(?4 ?5)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1267 ;; wants credentials? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1268 (if (looking-at "480") |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1269 (nntp-handle-authinfo process) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1270 ;; report error message. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1271 (nntp-snarf-error-message) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1272 (nntp-do-callback nil)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1273 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1274 ;; got what we expect? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1275 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1276 (when (re-search-backward |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1277 nntp-process-wait-for nntp-process-start-point t) |
88155 | 1278 (let ((response (match-string 0))) |
1279 (with-current-buffer nntp-server-buffer | |
1280 (setq nntp-process-response response))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1281 (nntp-async-stop process) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1282 ;; convert it. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1283 (when (gnus-buffer-exists-p nntp-process-to-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1284 (let ((buf (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1285 (start nntp-process-start-point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1286 (decode nntp-process-decode)) |
17493 | 1287 (save-excursion |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1288 (set-buffer nntp-process-to-buffer) |
17493 | 1289 (goto-char (point-max)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1290 (save-restriction |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1291 (narrow-to-region (point) (point)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1292 (insert-buffer-substring buf start) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1293 (when decode |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1294 (nntp-decode-text)))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1295 ;; report it. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1296 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1297 (nntp-do-callback |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1298 (buffer-name (get-buffer nntp-process-to-buffer)))))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1299 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1300 (defun nntp-do-callback (arg) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1301 (let ((callback nntp-process-callback) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1302 (nntp-inside-change-function t)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1303 (setq nntp-process-callback nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1304 (funcall callback arg))) |
17493 | 1305 |
1306 (defun nntp-snarf-error-message () | |
1307 "Save the error message in the current buffer." | |
1308 (let ((message (buffer-string))) | |
1309 (while (string-match "[\r\n]+" message) | |
1310 (setq message (replace-match " " t t message))) | |
1311 (nnheader-report 'nntp message) | |
1312 message)) | |
1313 | |
88155 | 1314 (defun nntp-accept-process-output (process) |
17493 | 1315 "Wait for output from PROCESS and message some dots." |
1316 (save-excursion | |
1317 (set-buffer (or (nntp-find-connection-buffer nntp-server-buffer) | |
1318 nntp-server-buffer)) | |
49725
f13275d94b11
(nntp-accept-process-output): Don't use point-max to get the buffer's size.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1319 (let ((len (/ (buffer-size) 1024)) |
17493 | 1320 message-log-max) |
1321 (unless (< len 10) | |
1322 (setq nntp-have-messaged t) | |
1323 (nnheader-message 7 "nntp read: %dk" len))) | |
88155 | 1324 (nnheader-accept-process-output process) |
1325 ;; accept-process-output may update status of process to indicate | |
1326 ;; that the server has closed the connection. This MUST be | |
1327 ;; handled here as the buffer restored by the save-excursion may | |
1328 ;; be the process's former output buffer (i.e. now killed) | |
1329 (or (and process | |
1330 (memq (process-status process) '(open run))) | |
1331 (nntp-report "Server closed connection")))) | |
17493 | 1332 |
1333 (defun nntp-accept-response () | |
1334 "Wait for output from the process that outputs to BUFFER." | |
1335 (nntp-accept-process-output (nntp-find-connection nntp-server-buffer))) | |
1336 | |
1337 (defun nntp-possibly-change-group (group server &optional connectionless) | |
1338 (let ((nnheader-callback-function nil)) | |
1339 (when server | |
1340 (or (nntp-server-opened server) | |
1341 (nntp-open-server server nil connectionless))) | |
1342 | |
1343 (unless connectionless | |
1344 (or (nntp-find-connection nntp-server-buffer) | |
1345 (nntp-open-connection nntp-server-buffer)))) | |
1346 | |
1347 (when group | |
1348 (let ((entry (nntp-find-connection-entry nntp-server-buffer))) | |
88155 | 1349 (cond ((not entry) |
1350 (nntp-report "Server closed connection")) | |
1351 ((not (equal group (caddr entry))) | |
1352 (save-excursion | |
1353 (set-buffer (process-buffer (car entry))) | |
1354 (erase-buffer) | |
1355 (nntp-send-command "^[245].*\n" "GROUP" group) | |
1356 (setcar (cddr entry) group) | |
1357 (erase-buffer) | |
1358 (save-excursion | |
1359 (set-buffer nntp-server-buffer) | |
1360 (erase-buffer)))))))) | |
17493 | 1361 |
1362 (defun nntp-decode-text (&optional cr-only) | |
1363 "Decode the text in the current buffer." | |
1364 (goto-char (point-min)) | |
1365 (while (search-forward "\r" nil t) | |
1366 (delete-char -1)) | |
1367 (unless cr-only | |
1368 ;; Remove trailing ".\n" end-of-transfer marker. | |
1369 (goto-char (point-max)) | |
1370 (forward-line -1) | |
1371 (when (looking-at ".\n") | |
1372 (delete-char 2)) | |
1373 ;; Delete status line. | |
1374 (goto-char (point-min)) | |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1375 (while (looking-at "[1-5][0-9][0-9] .*\n") |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1376 ;; For some unknown reason, there is more than one status line. |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1377 (delete-region (point) (progn (forward-line 1) (point)))) |
17493 | 1378 ;; Remove "." -> ".." encoding. |
1379 (while (search-forward "\n.." nil t) | |
1380 (delete-char -1)))) | |
1381 | |
1382 (defun nntp-encode-text () | |
1383 "Encode the text in the current buffer." | |
1384 (save-excursion | |
1385 ;; Replace "." at beginning of line with "..". | |
1386 (goto-char (point-min)) | |
1387 (while (re-search-forward "^\\." nil t) | |
1388 (insert ".")) | |
1389 (goto-char (point-max)) | |
1390 ;; Insert newline at the end of the buffer. | |
1391 (unless (bolp) | |
1392 (insert "\n")) | |
1393 ;; Insert `.' at end of buffer (end of text mark). | |
1394 (goto-char (point-max)) | |
23010
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1395 (insert ".\n") |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1396 (goto-char (point-min)) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1397 (while (not (eobp)) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1398 (end-of-line) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1399 (delete-char 1) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1400 (insert nntp-end-of-line)))) |
17493 | 1401 |
1402 (defun nntp-retrieve-headers-with-xover (articles &optional fetch-old) | |
1403 (set-buffer nntp-server-buffer) | |
1404 (erase-buffer) | |
1405 (cond | |
1406 | |
1407 ;; This server does not talk NOV. | |
1408 ((not nntp-server-xover) | |
1409 nil) | |
1410 | |
1411 ;; We don't care about gaps. | |
1412 ((or (not nntp-nov-gap) | |
1413 fetch-old) | |
1414 (nntp-send-xover-command | |
1415 (if fetch-old | |
1416 (if (numberp fetch-old) | |
1417 (max 1 (- (car articles) fetch-old)) | |
1418 1) | |
1419 (car articles)) | |
1420 (car (last articles)) 'wait) | |
1421 | |
1422 (goto-char (point-min)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1423 (when (looking-at "[1-5][0-9][0-9] .*\n") |
17493 | 1424 (delete-region (point) (progn (forward-line 1) (point)))) |
1425 (while (search-forward "\r" nil t) | |
1426 (replace-match "" t t)) | |
1427 (goto-char (point-max)) | |
1428 (forward-line -1) | |
1429 (when (looking-at "\\.") | |
1430 (delete-region (point) (progn (forward-line 1) (point))))) | |
1431 | |
1432 ;; We do it the hard way. For each gap, an XOVER command is sent | |
1433 ;; to the server. We do not wait for a reply from the server, we | |
1434 ;; just send them off as fast as we can. That means that we have | |
1435 ;; to count the number of responses we get back to find out when we | |
1436 ;; have gotten all we asked for. | |
1437 ((numberp nntp-nov-gap) | |
1438 (let ((count 0) | |
1439 (received 0) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1440 last-point |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1441 in-process-buffer-p |
17493 | 1442 (buf nntp-server-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1443 (process-buffer (nntp-find-connection-buffer nntp-server-buffer)) |
88155 | 1444 first last status) |
17493 | 1445 ;; We have to check `nntp-server-xover'. If it gets set to nil, |
1446 ;; that means that the server does not understand XOVER, but we | |
1447 ;; won't know that until we try. | |
1448 (while (and nntp-server-xover articles) | |
1449 (setq first (car articles)) | |
1450 ;; Search forward until we find a gap, or until we run out of | |
1451 ;; articles. | |
1452 (while (and (cdr articles) | |
1453 (< (- (nth 1 articles) (car articles)) nntp-nov-gap)) | |
1454 (setq articles (cdr articles))) | |
1455 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1456 (setq in-process-buffer-p (stringp nntp-server-xover)) |
88155 | 1457 (nntp-send-xover-command first (setq last (car articles))) |
1458 (setq articles (cdr articles)) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42628
diff
changeset
|
1459 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1460 (when (and nntp-server-xover in-process-buffer-p) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1461 ;; Don't count tried request. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1462 (setq count (1+ count)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42628
diff
changeset
|
1463 |
17493 | 1464 ;; Every 400 requests we have to read the stream in |
1465 ;; order to avoid deadlocks. | |
1466 (when (or (null articles) ;All requests have been sent. | |
88155 | 1467 (= 1 (% count nntp-maximum-request))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1468 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1469 (nntp-accept-response) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1470 ;; On some Emacs versions the preceding function has a |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1471 ;; tendency to change the buffer. Perhaps. It's quite |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1472 ;; difficult to reproduce, because it only seems to happen |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1473 ;; once in a blue moon. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1474 (set-buffer process-buffer) |
17493 | 1475 (while (progn |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1476 (goto-char (or last-point (point-min))) |
17493 | 1477 ;; Count replies. |
88155 | 1478 (while (re-search-forward "^\\([0-9][0-9][0-9]\\) .*\n" |
1479 nil t) | |
1480 (incf received) | |
1481 (setq status (match-string 1)) | |
1482 (if (string-match "^[45]" status) | |
1483 (setq status 'error) | |
1484 (setq status 'ok))) | |
17493 | 1485 (setq last-point (point)) |
88155 | 1486 (or (< received count) |
1487 (if (eq status 'error) | |
1488 nil | |
1489 ;; I haven't started reading the final response | |
1490 (progn | |
1491 (goto-char (point-max)) | |
1492 (forward-line -1) | |
1493 (not (looking-at "^\\.\r?\n")))))) | |
1494 ;; I haven't read the end of the final response | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1495 (nntp-accept-response) |
88155 | 1496 (set-buffer process-buffer)))) |
1497 | |
1498 ;; Some nntp servers seem to have an extension to the XOVER | |
1499 ;; extension. On these servers, requesting an article range | |
1500 ;; preceeding the active range does not return an error as | |
1501 ;; specified in the RFC. What we instead get is the NOV entry | |
1502 ;; for the first available article. Obviously, a client can | |
1503 ;; use that entry to avoid making unnecessary requests. The | |
1504 ;; only problem is for a client that assumes that the response | |
1505 ;; will always be within the requested ranage. For such a | |
1506 ;; client, we can get N copies of the same entry (one for each | |
1507 ;; XOVER command sent to the server). | |
1508 | |
1509 (when (<= count 1) | |
1510 (goto-char (point-min)) | |
1511 (when (re-search-forward "^[0-9][0-9][0-9] .*\n\\([0-9]+\\)" nil t) | |
1512 (let ((low-limit (string-to-number | |
1513 (buffer-substring (match-beginning 1) | |
1514 (match-end 1))))) | |
1515 (while (and articles (<= (car articles) low-limit)) | |
1516 (setq articles (cdr articles)))))) | |
1517 (set-buffer buf)) | |
17493 | 1518 |
1519 (when nntp-server-xover | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1520 (when in-process-buffer-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1521 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1522 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1523 (insert-buffer-substring process-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1524 (set-buffer process-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1525 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1526 (set-buffer buf)) |
17493 | 1527 |
1528 ;; We remove any "." lines and status lines. | |
1529 (goto-char (point-min)) | |
1530 (while (search-forward "\r" nil t) | |
1531 (delete-char -1)) | |
1532 (goto-char (point-min)) | |
1533 (delete-matching-lines "^\\.$\\|^[1-5][0-9][0-9] ") | |
1534 t)))) | |
1535 | |
1536 nntp-server-xover) | |
1537 | |
1538 (defun nntp-send-xover-command (beg end &optional wait-for-reply) | |
1539 "Send the XOVER command to the server." | |
1540 (let ((range (format "%d-%d" beg end)) | |
1541 (nntp-inhibit-erase t)) | |
1542 (if (stringp nntp-server-xover) | |
1543 ;; If `nntp-server-xover' is a string, then we just send this | |
1544 ;; command. | |
1545 (if wait-for-reply | |
1546 (nntp-send-command-nodelete | |
1547 "\r?\n\\.\r?\n" nntp-server-xover range) | |
1548 ;; We do not wait for the reply. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1549 (nntp-send-command-nodelete nil nntp-server-xover range)) |
17493 | 1550 (let ((commands nntp-xover-commands)) |
1551 ;; `nntp-xover-commands' is a list of possible XOVER commands. | |
1552 ;; We try them all until we get at positive response. | |
1553 (while (and commands (eq nntp-server-xover 'try)) | |
1554 (nntp-send-command-nodelete "\r?\n\\.\r?\n" (car commands) range) | |
1555 (save-excursion | |
1556 (set-buffer nntp-server-buffer) | |
1557 (goto-char (point-min)) | |
1558 (and (looking-at "[23]") ; No error message. | |
1559 ;; We also have to look at the lines. Some buggy | |
1560 ;; servers give back simple lines with just the | |
1561 ;; article number. How... helpful. | |
1562 (progn | |
1563 (forward-line 1) | |
1564 (looking-at "[0-9]+\t...")) ; More text after number. | |
1565 (setq nntp-server-xover (car commands)))) | |
1566 (setq commands (cdr commands))) | |
1567 ;; If none of the commands worked, we disable XOVER. | |
1568 (when (eq nntp-server-xover 'try) | |
1569 (save-excursion | |
1570 (set-buffer nntp-server-buffer) | |
1571 (erase-buffer) | |
1572 (setq nntp-server-xover nil))) | |
88155 | 1573 nntp-server-xover)))) |
17493 | 1574 |
88155 | 1575 (defun nntp-find-group-and-number (&optional group) |
1576 (save-excursion | |
1577 (save-restriction | |
1578 (set-buffer nntp-server-buffer) | |
1579 (narrow-to-region (goto-char (point-min)) | |
1580 (or (search-forward "\n\n" nil t) (point-max))) | |
1581 (goto-char (point-min)) | |
1582 ;; We first find the number by looking at the status line. | |
1583 (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ") | |
1584 (string-to-number | |
1585 (buffer-substring (match-beginning 1) | |
1586 (match-end 1))))) | |
1587 newsgroups xref) | |
1588 (and number (zerop number) (setq number nil)) | |
1589 (if number | |
1590 ;; Then we find the group name. | |
1591 (setq group | |
1592 (cond | |
1593 ;; If there is only one group in the Newsgroups | |
1594 ;; header, then it seems quite likely that this | |
1595 ;; article comes from that group, I'd say. | |
1596 ((and (setq newsgroups | |
1597 (mail-fetch-field "newsgroups")) | |
1598 (not (string-match "," newsgroups))) | |
1599 newsgroups) | |
1600 ;; If there is more than one group in the | |
1601 ;; Newsgroups header, then the Xref header should | |
1602 ;; be filled out. We hazard a guess that the group | |
1603 ;; that has this article number in the Xref header | |
1604 ;; is the one we are looking for. This might very | |
1605 ;; well be wrong if this article happens to have | |
1606 ;; the same number in several groups, but that's | |
1607 ;; life. | |
1608 ((and (setq xref (mail-fetch-field "xref")) | |
1609 number | |
1610 (string-match | |
1611 (format "\\([^ :]+\\):%d" number) xref)) | |
1612 (match-string 1 xref)) | |
1613 (t ""))) | |
1614 (cond | |
1615 ((and (setq xref (mail-fetch-field "xref")) | |
1616 (string-match | |
1617 (if group | |
1618 (concat "\\(" (regexp-quote group) "\\):\\([0-9]+\\)") | |
1619 "\\([^ :]+\\):\\([0-9]+\\)") | |
1620 xref)) | |
1621 (setq group (match-string 1 xref) | |
1622 number (string-to-number (match-string 2 xref)))) | |
1623 ((and (setq newsgroups | |
1624 (mail-fetch-field "newsgroups")) | |
1625 (not (string-match "," newsgroups))) | |
1626 (setq group newsgroups)) | |
1627 (group) | |
1628 (t (setq group "")))) | |
1629 (when (string-match "\r" group) | |
1630 (setq group (substring group 0 (match-beginning 0)))) | |
1631 (cons group number))))) | |
17493 | 1632 |
1633 (defun nntp-wait-for-string (regexp) | |
1634 "Wait until string arrives in the buffer." | |
88155 | 1635 (let ((buf (current-buffer)) |
1636 proc) | |
17493 | 1637 (goto-char (point-min)) |
88155 | 1638 (while (and (setq proc (get-buffer-process buf)) |
1639 (memq (process-status proc) '(open run)) | |
1640 (not (re-search-forward regexp nil t))) | |
1641 (accept-process-output proc) | |
17493 | 1642 (set-buffer buf) |
1643 (goto-char (point-min))))) | |
1644 | |
88155 | 1645 |
1646 ;; ========================================================================== | |
1647 ;; Obsolete nntp-open-* connection methods -- drv | |
1648 ;; ========================================================================== | |
1649 | |
1650 (defvoo nntp-open-telnet-envuser nil | |
1651 "*If non-nil, telnet session (client and server both) will support the ENVIRON option and not prompt for login name.") | |
1652 | |
1653 (defvoo nntp-telnet-shell-prompt "bash\\|\$ *\r?$\\|> *\r?" | |
1654 "*Regular expression to match the shell prompt on the remote machine.") | |
1655 | |
1656 (defvoo nntp-rlogin-program "rsh" | |
1657 "*Program used to log in on remote machines. | |
1658 The default is \"rsh\", but \"ssh\" is a popular alternative.") | |
1659 | |
1660 (defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp") | |
1661 "*Parameters to `nntp-open-rlogin'. | |
1662 That function may be used as `nntp-open-connection-function'. In that | |
1663 case, this list will be used as the parameter list given to rsh.") | |
1664 | |
1665 (defvoo nntp-rlogin-user-name nil | |
1666 "*User name on remote system when using the rlogin connect method.") | |
1667 | |
1668 (defvoo nntp-telnet-parameters | |
1669 '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp") | |
1670 "*Parameters to `nntp-open-telnet'. | |
1671 That function may be used as `nntp-open-connection-function'. In that | |
1672 case, this list will be executed as a command after logging in | |
1673 via telnet.") | |
1674 | |
1675 (defvoo nntp-telnet-user-name nil | |
1676 "User name to log in via telnet with.") | |
1677 | |
1678 (defvoo nntp-telnet-passwd nil | |
1679 "Password to use to log in via telnet with.") | |
1680 | |
17493 | 1681 (defun nntp-open-telnet (buffer) |
1682 (save-excursion | |
1683 (set-buffer buffer) | |
1684 (erase-buffer) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
1685 (let ((proc (apply |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
1686 'start-process |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
1687 "nntpd" buffer nntp-telnet-command nntp-telnet-switches)) |
17493 | 1688 (case-fold-search t)) |
1689 (when (memq (process-status proc) '(open run)) | |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1690 (nntp-wait-for-string "^r?telnet") |
17493 | 1691 (process-send-string proc "set escape \^X\n") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1692 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1693 ((and nntp-open-telnet-envuser nntp-telnet-user-name) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1694 (process-send-string proc (concat "open " "-l" nntp-telnet-user-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1695 nntp-address "\n"))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1696 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1697 (process-send-string proc (concat "open " nntp-address "\n")))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1698 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1699 ((not nntp-open-telnet-envuser) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1700 (nntp-wait-for-string "^\r*.?login:") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1701 (process-send-string |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1702 proc (concat |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1703 (or nntp-telnet-user-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1704 (setq nntp-telnet-user-name (read-string "login: "))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1705 "\n")))) |
17493 | 1706 (nntp-wait-for-string "^\r*.?password:") |
1707 (process-send-string | |
1708 proc (concat | |
1709 (or nntp-telnet-passwd | |
1710 (setq nntp-telnet-passwd | |
88155 | 1711 (read-passwd "Password: "))) |
17493 | 1712 "\n")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1713 (nntp-wait-for-string nntp-telnet-shell-prompt) |
17493 | 1714 (process-send-string |
1715 proc (concat (mapconcat 'identity nntp-telnet-parameters " ") "\n")) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1716 (nntp-wait-for-string "^\r*20[01]") |
17493 | 1717 (beginning-of-line) |
1718 (delete-region (point-min) (point)) | |
1719 (process-send-string proc "\^]") | |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1720 (nntp-wait-for-string "^r?telnet") |
17493 | 1721 (process-send-string proc "mode character\n") |
1722 (accept-process-output proc 1) | |
1723 (sit-for 1) | |
1724 (goto-char (point-min)) | |
1725 (forward-line 1) | |
1726 (delete-region (point) (point-max))) | |
1727 proc))) | |
1728 | |
1729 (defun nntp-open-rlogin (buffer) | |
1730 "Open a connection to SERVER using rsh." | |
1731 (let ((proc (if nntp-rlogin-user-name | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1732 (apply 'start-process |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1733 "nntpd" buffer nntp-rlogin-program |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1734 nntp-address "-l" nntp-rlogin-user-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1735 nntp-rlogin-parameters) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1736 (apply 'start-process |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1737 "nntpd" buffer nntp-rlogin-program nntp-address |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1738 nntp-rlogin-parameters)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1739 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1740 (set-buffer buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1741 (nntp-wait-for-string "^\r*20[01]") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1742 (beginning-of-line) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1743 (delete-region (point-min) (point)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1744 proc))) |
17493 | 1745 |
88155 | 1746 |
1747 ;; ========================================================================== | |
1748 ;; Replacements for the nntp-open-* functions -- drv | |
1749 ;; ========================================================================== | |
1750 | |
1751 (defun nntp-open-telnet-stream (buffer) | |
1752 "Open a nntp connection by telnet'ing the news server. | |
1753 | |
1754 Please refer to the following variables to customize the connection: | |
1755 - `nntp-pre-command', | |
1756 - `nntp-telnet-command', | |
1757 - `nntp-telnet-switches', | |
1758 - `nntp-address', | |
1759 - `nntp-port-number', | |
1760 - `nntp-end-of-line'." | |
1761 (let ((command `(,nntp-telnet-command | |
1762 ,@nntp-telnet-switches | |
1763 ,nntp-address ,nntp-port-number)) | |
1764 proc) | |
1765 (and nntp-pre-command | |
1766 (push nntp-pre-command command)) | |
1767 (setq proc (apply 'start-process "nntpd" buffer command)) | |
1768 (save-excursion | |
1769 (set-buffer buffer) | |
1770 (nntp-wait-for-string "^\r*20[01]") | |
1771 (beginning-of-line) | |
1772 (delete-region (point-min) (point)) | |
1773 proc))) | |
1774 | |
1775 (defun nntp-open-via-rlogin-and-telnet (buffer) | |
1776 "Open a connection to an nntp server through an intermediate host. | |
1777 First rlogin to the remote host, and then telnet the real news server | |
1778 from there. | |
1779 | |
1780 Please refer to the following variables to customize the connection: | |
1781 - `nntp-pre-command', | |
1782 - `nntp-via-rlogin-command', | |
1783 - `nntp-via-rlogin-command-switches', | |
1784 - `nntp-via-user-name', | |
1785 - `nntp-via-address', | |
1786 - `nntp-telnet-command', | |
1787 - `nntp-telnet-switches', | |
1788 - `nntp-address', | |
1789 - `nntp-port-number', | |
1790 - `nntp-end-of-line'." | |
1791 (let ((command `(,nntp-via-address | |
1792 ,nntp-telnet-command | |
1793 ,@nntp-telnet-switches)) | |
1794 proc) | |
1795 (when nntp-via-user-name | |
1796 (setq command `("-l" ,nntp-via-user-name ,@command))) | |
1797 (when nntp-via-rlogin-command-switches | |
1798 (setq command (append nntp-via-rlogin-command-switches command))) | |
1799 (push nntp-via-rlogin-command command) | |
1800 (and nntp-pre-command | |
1801 (push nntp-pre-command command)) | |
1802 (setq proc (apply 'start-process "nntpd" buffer command)) | |
1803 (save-excursion | |
1804 (set-buffer buffer) | |
1805 (nntp-wait-for-string "^r?telnet") | |
1806 (process-send-string proc (concat "open " nntp-address | |
1807 " " nntp-port-number "\n")) | |
1808 (nntp-wait-for-string "^\r*20[01]") | |
1809 (beginning-of-line) | |
1810 (delete-region (point-min) (point)) | |
1811 (process-send-string proc "\^]") | |
1812 (nntp-wait-for-string "^r?telnet") | |
1813 (process-send-string proc "mode character\n") | |
1814 (accept-process-output proc 1) | |
1815 (sit-for 1) | |
17493 | 1816 (goto-char (point-min)) |
88155 | 1817 (forward-line 1) |
1818 (delete-region (point) (point-max))) | |
1819 proc)) | |
1820 | |
1821 (defun nntp-open-via-telnet-and-telnet (buffer) | |
1822 "Open a connection to an nntp server through an intermediate host. | |
1823 First telnet the remote host, and then telnet the real news server | |
1824 from there. | |
1825 | |
1826 Please refer to the following variables to customize the connection: | |
1827 - `nntp-pre-command', | |
1828 - `nntp-via-telnet-command', | |
1829 - `nntp-via-telnet-switches', | |
1830 - `nntp-via-address', | |
1831 - `nntp-via-envuser', | |
1832 - `nntp-via-user-name', | |
1833 - `nntp-via-user-password', | |
1834 - `nntp-via-shell-prompt', | |
1835 - `nntp-telnet-command', | |
1836 - `nntp-telnet-switches', | |
1837 - `nntp-address', | |
1838 - `nntp-port-number', | |
1839 - `nntp-end-of-line'." | |
1840 (save-excursion | |
1841 (set-buffer buffer) | |
1842 (erase-buffer) | |
1843 (let ((command `(,nntp-via-telnet-command ,@nntp-via-telnet-switches)) | |
1844 (case-fold-search t) | |
1845 proc) | |
1846 (and nntp-pre-command (push nntp-pre-command command)) | |
1847 (setq proc (apply 'start-process "nntpd" buffer command)) | |
1848 (when (memq (process-status proc) '(open run)) | |
1849 (nntp-wait-for-string "^r?telnet") | |
1850 (process-send-string proc "set escape \^X\n") | |
1851 (cond | |
1852 ((and nntp-via-envuser nntp-via-user-name) | |
1853 (process-send-string proc (concat "open " "-l" nntp-via-user-name | |
1854 nntp-via-address "\n"))) | |
1855 (t | |
1856 (process-send-string proc (concat "open " nntp-via-address | |
1857 "\n")))) | |
1858 (when (not nntp-via-envuser) | |
1859 (nntp-wait-for-string "^\r*.?login:") | |
1860 (process-send-string proc | |
1861 (concat | |
1862 (or nntp-via-user-name | |
1863 (setq nntp-via-user-name | |
1864 (read-string "login: "))) | |
1865 "\n"))) | |
1866 (nntp-wait-for-string "^\r*.?password:") | |
1867 (process-send-string proc | |
1868 (concat | |
1869 (or nntp-via-user-password | |
1870 (setq nntp-via-user-password | |
1871 (read-passwd "Password: "))) | |
1872 "\n")) | |
1873 (nntp-wait-for-string nntp-via-shell-prompt) | |
1874 (let ((real-telnet-command `("exec" | |
1875 ,nntp-telnet-command | |
1876 ,@nntp-telnet-switches | |
1877 ,nntp-address | |
1878 ,nntp-port-number))) | |
1879 (process-send-string proc | |
1880 (concat (mapconcat 'identity | |
1881 real-telnet-command " ") | |
1882 "\n"))) | |
1883 (nntp-wait-for-string "^\r*20[01]") | |
1884 (beginning-of-line) | |
1885 (delete-region (point-min) (point)) | |
1886 (process-send-string proc "\^]") | |
1887 (nntp-wait-for-string "^r?telnet") | |
1888 (process-send-string proc "mode character\n") | |
1889 (accept-process-output proc 1) | |
1890 (sit-for 1) | |
1891 (goto-char (point-min)) | |
1892 (forward-line 1) | |
1893 (delete-region (point) (point-max))) | |
1894 proc))) | |
17493 | 1895 |
1896 (provide 'nntp) | |
1897 | |
88155 | 1898 ;;; arch-tag: 8655466a-b1b5-4929-9c45-7b1b2e767271 |
17493 | 1899 ;;; nntp.el ends here |