X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fnntp.el;h=d452a981e0b6040ed1f55fe4e0bf378e87e4a884;hb=a77dd35f2d1dc13eb88e5b153d4c03b83f7eb2c7;hp=2927dc67db28efa565b636e6cc83db8c67f33daa;hpb=aec51be27a1d5f815bf7eba9e6eca7e400f912cb;p=gnus diff --git a/lisp/nntp.el b/lisp/nntp.el index 2927dc67d..d452a981e 100644 --- a/lisp/nntp.el +++ b/lisp/nntp.el @@ -75,6 +75,7 @@ host. Direct connections: - `nntp-open-network-stream' (the default), - `nntp-open-ssl-stream', +- `nntp-open-tls-stream', - `nntp-open-telnet-stream'. Indirect connections: @@ -106,8 +107,8 @@ The default is \"rsh\", but \"ssh\" is a popular alternative.") "*Switches given to the rlogin command `nntp-via-rlogin-command'. If you use \"ssh\" for `nntp-via-rlogin-command', you may set this to \(\"-C\") in order to compress all data connections, otherwise set this -to \(\"-t\") or (\"-C\" \"-t\") if the telnet command requires a pseudo-tty -allocation on an intermediate host.") +to \(\"-t\" \"-e\" \"none\") or (\"-C\" \"-t\" \"-e\" \"none\") if the telnet +command requires a pseudo-tty allocation on an intermediate host.") (defvoo nntp-via-telnet-command "telnet" "*Telnet command used to connect to an intermediate host. @@ -138,8 +139,8 @@ If non-nil, there will be no prompt for a login name.") This variable is used by the `nntp-open-via-telnet-and-telnet' method.") (defvoo nntp-large-newsgroup 50 - "*The number of the articles which indicates a large newsgroup. -If the number of the articles is greater than the value, verbose + "*The number of articles which indicates a large newsgroup. +If the number of articles is greater than the value, verbose messages will be shown to indicate the current status.") (defvoo nntp-maximum-request 400 @@ -207,13 +208,6 @@ NOTE: This variable is never seen to work in Emacs 20 and XEmacs 21.") "*Hook run just before posting an article. It is supposed to be used to insert Cancel-Lock headers.") -(defvoo nntp-read-timeout (if (string-match "windows-nt\\|os/2\\|emx\\|cygwin" - (symbol-name system-type)) - 1.0 - 0.1) - "How long nntp should wait between checking for the end of output. -Shorter values mean quicker response, but is more CPU intensive.") - ;;; Internal variables. (defvar nntp-record-commands nil @@ -451,7 +445,7 @@ be restored and the command retried." (goto-char pos) (if (looking-at (regexp-quote command)) (delete-region pos (progn (forward-line 1) - (gnus-point-at-bol)))) + (point-at-bol)))) ))) (nnheader-report 'nntp "Couldn't open connection to %s." nntp-address)))) @@ -476,8 +470,7 @@ be restored and the command retried." (goto-char pos) (if (looking-at (regexp-quote command)) (delete-region pos (progn (forward-line 1) - (gnus-point-at-bol)))) - ))) + (point-at-bol))))))) (nnheader-report 'nntp "Couldn't open connection to %s." nntp-address)))) @@ -505,7 +498,7 @@ be restored and the command retried." (set-buffer buffer) (goto-char pos) (if (looking-at (regexp-quote command)) - (delete-region pos (progn (forward-line 1) (gnus-point-at-bol)))) + (delete-region pos (progn (forward-line 1) (point-at-bol)))) ))) (nnheader-report 'nntp "Couldn't open connection to %s." nntp-address)))) @@ -1070,7 +1063,7 @@ password contained in '~/.nntp-authinfo'." (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" (user-login-name)) (nntp-send-command "^2.*\r?\n" "AUTHINFO PASS" - (buffer-substring (point) (gnus-point-at-eol)))))) + (buffer-substring (point) (point-at-eol)))))) ;;; Internal functions. @@ -1149,6 +1142,10 @@ password contained in '~/.nntp-authinfo'." (defun nntp-open-network-stream (buffer) (open-network-stream "nntpd" buffer nntp-address nntp-port-number)) +(autoload 'format-spec "format") +(autoload 'format-spec-make "format") +(autoload 'open-tls-stream "tls") + (defun nntp-open-ssl-stream (buffer) (let* ((process-connection-type nil) (proc (start-process "nntpd" buffer @@ -1161,7 +1158,19 @@ password contained in '~/.nntp-authinfo'." (process-kill-without-query proc) (save-excursion (set-buffer buffer) - (nntp-wait-for-string "^\r*20[01]") + (let ((nntp-connection-alist (list proc buffer nil))) + (nntp-wait-for-string "^\r*20[01]")) + (beginning-of-line) + (delete-region (point-min) (point)) + proc))) + +(defun nntp-open-tls-stream (buffer) + (let ((proc (open-tls-stream "nntpd" buffer nntp-address nntp-port-number))) + (process-kill-without-query proc) + (save-excursion + (set-buffer buffer) + (let ((nntp-connection-alist (list proc buffer nil))) + (nntp-wait-for-string "^\r*20[01]")) (beginning-of-line) (delete-region (point-min) (point)) proc))) @@ -1295,12 +1304,7 @@ password contained in '~/.nntp-authinfo'." (unless (< len 10) (setq nntp-have-messaged t) (nnheader-message 7 "nntp read: %dk" len))) - (accept-process-output - process - (truncate nntp-read-timeout) - (truncate (* (- nntp-read-timeout - (truncate nntp-read-timeout)) - 1000))) + (nnheader-accept-process-output process) ;; accept-process-output may update status of process to indicate ;; that the server has closed the connection. This MUST be ;; handled here as the buffer restored by the save-excursion may @@ -1420,8 +1424,7 @@ password contained in '~/.nntp-authinfo'." in-process-buffer-p (buf nntp-server-buffer) (process-buffer (nntp-find-connection-buffer nntp-server-buffer)) - first - last) + first last status) ;; We have to check `nntp-server-xover'. If it gets set to nil, ;; that means that the server does not understand XOVER, but we ;; won't know that until we try. @@ -1455,15 +1458,22 @@ password contained in '~/.nntp-authinfo'." (while (progn (goto-char (or last-point (point-min))) ;; Count replies. - (while (re-search-forward "^[0-9][0-9][0-9] .*\n" nil t) - (incf received)) + (while (re-search-forward "^\\([0-9][0-9][0-9]\\) .*\n" + nil t) + (incf received) + (setq status (match-string 1)) + (if (string-match "^[45]" status) + (setq status 'error) + (setq status 'ok))) (setq last-point (point)) (or (< received count) - ;; I haven't started reading the final response - (progn - (goto-char (point-max)) - (forward-line -1) - (not (looking-at "^\\.\r?\n"))))) + (if (eq status 'error) + nil + ;; I haven't started reading the final response + (progn + (goto-char (point-max)) + (forward-line -1) + (not (looking-at "^\\.\r?\n")))))) ;; I haven't read the end of the final response (nntp-accept-response) (set-buffer process-buffer)))) @@ -1781,7 +1791,15 @@ Please refer to the following variables to customize the connection: (nntp-wait-for-string "^\r*20[01]") (beginning-of-line) (delete-region (point-min) (point)) - proc))) + (process-send-string proc "\^]") + (nntp-wait-for-string "^r?telnet") + (process-send-string proc "mode character\n") + (accept-process-output proc 1) + (sit-for 1) + (goto-char (point-min)) + (forward-line 1) + (delete-region (point) (point-max))) + proc)) (defun nntp-open-via-telnet-and-telnet (buffer) "Open a connection to an nntp server through an intermediate host.