nntp.el: Use proto-streams for the relevant connections types.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 27 Nov 2010 15:09:11 +0000 (16:09 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sat, 27 Nov 2010 15:09:11 +0000 (16:09 +0100)
lisp/ChangeLog
lisp/nntp.el
lisp/proto-stream.el

index e3ddf75..ae3c30c 100644 (file)
@@ -1,5 +1,14 @@
 2010-11-27  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
+       * proto-stream.el (open-proto-stream): Use network, not stream.
+
+       * nntp.el (nntp-open-connection): Use proto-streams for the relevant
+       connections types.
+       (nntp-open-network-stream): Removed.
+       (nntp-open-ssl-stream): Removed.
+       (nntp-open-tls-stream): Removed.
+       (nntp-ssl-program): Removed.
+
        * nnimap.el (nnimap-open-connection): Check for "OK" from the greeting.
 
 2010-11-27  Andrew Cohen  <cohen@andy.bu.edu>
index f37a1c8..f201d35 100644 (file)
@@ -34,6 +34,7 @@
 (require 'nnoo)
 (require 'gnus-util)
 (require 'gnus)
+(require 'proto-stream)
 (require 'gnus-group) ;; gnus-group-name-charset
 
 (nnoo-declare nntp)
@@ -305,13 +306,6 @@ update their active files often, this can help.")
 (defvar nntp-async-timer nil)
 (defvar nntp-async-process-list nil)
 
-(defvar nntp-ssl-program
-  "openssl s_client -quiet -ssl3 -connect %s:%p"
-"A string containing commands for SSL connections.
-Within a string, %s is replaced with the server address and %p with
-port number on server.  The program should accept IMAP commands on
-stdin and return responses to stdout.")
-
 (defvar nntp-authinfo-rejected nil
 "A custom error condition used to report 'Authentication Rejected' errors.
 Condition handlers that match just this condition ensure that the nntp
@@ -1270,8 +1264,16 @@ password contained in '~/.nntp-authinfo'."
         (process
          (condition-case ()
              (let ((coding-system-for-read nntp-coding-system-for-read)
-                   (coding-system-for-write nntp-coding-system-for-write))
-               (funcall nntp-open-connection-function pbuffer))
+                   (coding-system-for-write nntp-coding-system-for-write)
+                   (map '((nntp-open-network-stream network)
+                          (nntp-open-ssl-stream tls)
+                          (nntp-open-tls-stream tls))))
+               (if (assoc nntp-open-connection-function map)
+                   (car (open-proto-stream
+                         "nntpd" pbuffer nntp-address nntp-port-number
+                         :type (cadr
+                                (assoc nntp-open-connection-function map))))
+                 (funcall nntp-open-connection-function pbuffer)))
            (error nil)
            (quit
             (message "Quit opening connection to %s" nntp-address)
@@ -1300,40 +1302,6 @@ password contained in '~/.nntp-authinfo'."
        (nntp-kill-buffer (process-buffer process))
        nil))))
 
-(defun nntp-open-network-stream (buffer)
-  (open-network-stream "nntpd" buffer nntp-address nntp-port-number))
-
-(autoload 'format-spec "format-spec")
-(autoload 'format-spec-make "format-spec")
-(autoload 'open-tls-stream "tls")
-
-(defun nntp-open-ssl-stream (buffer)
-  (let* ((process-connection-type nil)
-        (proc (start-process "nntpd" buffer
-                             shell-file-name
-                             shell-command-switch
-                             (format-spec nntp-ssl-program
-                                          (format-spec-make
-                                           ?s nntp-address
-                                           ?p nntp-port-number)))))
-    (gnus-set-process-query-on-exit-flag proc nil)
-    (with-current-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)))
-
-(defun nntp-open-tls-stream (buffer)
-  (let ((proc (open-tls-stream "nntpd" buffer nntp-address nntp-port-number)))
-    (gnus-set-process-query-on-exit-flag proc nil)
-    (with-current-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)))
-
 (defun nntp-read-server-type ()
   "Find out what the name of the server we have connected to is."
   ;; Wait for the status string to arrive.
index 226157a..b1f2818 100644 (file)
@@ -80,7 +80,7 @@ query server for capabilities.  For instance, for IMAP this is
 is the response to the capaibility command.  It should return nil
 if it turns out that the server doesn't support STARTTLS, or the
 command to switch on STARTTLS otherwise."
-  (let ((type (or (cadr (memq :type parameters)) 'stream)))
+  (let ((type (or (cadr (memq :type parameters)) 'network)))
     (when (and (eq type 'starttls)
               (fboundp 'open-gnutls-stream))
       (setq type 'network))