Allow TLS (and more)

Set the :connect-function parameter in rcirc-server-alist to anything
that takes the same arguments as open-network-stream.  For example,
open-tls-stream.
This commit is contained in:
Neale Pickett 2010-10-01 12:42:49 -06:00
parent 1bf3dac9e9
commit aeab4c5009
1 changed files with 14 additions and 4 deletions

View File

@ -322,6 +322,12 @@ and the cdr part is used for encoding."
:type 'function :type 'function
:group 'rcirc) :group 'rcirc)
(defcustom rcirc-default-connect-function 'open-network-stream
"Function used to initiate a connection.
It should take the same arguments as `open-network-stream' does."
:group 'rcirc
:type 'function)
(defvar rcirc-nick nil) (defvar rcirc-nick nil)
(defvar rcirc-prompt-start-marker nil) (defvar rcirc-prompt-start-marker nil)
@ -429,6 +435,7 @@ If ARG is non-nil, instead prompt for connection parameters."
rcirc-default-user-name)) rcirc-default-user-name))
(full-name (or (plist-get (cdr c) :full-name) (full-name (or (plist-get (cdr c) :full-name)
rcirc-default-full-name)) rcirc-default-full-name))
(connect-function (plist-get (cdr c) :connect-function))
(channels (plist-get (cdr c) :channels)) (channels (plist-get (cdr c) :channels))
(password (plist-get (cdr c) :password))) (password (plist-get (cdr c) :password)))
(when server (when server
@ -439,7 +446,8 @@ If ARG is non-nil, instead prompt for connection parameters."
(if (not connected) (if (not connected)
(condition-case e (condition-case e
(rcirc-connect server port nick user-name (rcirc-connect server port nick user-name
full-name channels password) full-name channels password
connect-function)
(quit (message "Quit connecting to %s" server))) (quit (message "Quit connecting to %s" server)))
(with-current-buffer (process-buffer connected) (with-current-buffer (process-buffer connected)
(setq connected-servers (setq connected-servers
@ -471,7 +479,8 @@ If ARG is non-nil, instead prompt for connection parameters."
;;;###autoload ;;;###autoload
(defun rcirc-connect (server &optional port nick user-name (defun rcirc-connect (server &optional port nick user-name
full-name startup-channels password) full-name startup-channels password
connect-function)
(save-excursion (save-excursion
(message "Connecting to %s..." server) (message "Connecting to %s..." server)
(let* ((inhibit-eol-conversion) (let* ((inhibit-eol-conversion)
@ -483,8 +492,9 @@ If ARG is non-nil, instead prompt for connection parameters."
(nick (or nick rcirc-default-nick)) (nick (or nick rcirc-default-nick))
(user-name (or user-name rcirc-default-user-name)) (user-name (or user-name rcirc-default-user-name))
(full-name (or full-name rcirc-default-full-name)) (full-name (or full-name rcirc-default-full-name))
(connect-function (or connect-function rcirc-default-connect-function))
(startup-channels startup-channels) (startup-channels startup-channels)
(process (make-network-process :name server :host server :service port-number))) (process (funcall connect-function server nil server port-number)))
;; set up process ;; set up process
(set-process-coding-system process 'raw-text 'raw-text) (set-process-coding-system process 'raw-text 'raw-text)
(switch-to-buffer (rcirc-generate-new-buffer-name process nil)) (switch-to-buffer (rcirc-generate-new-buffer-name process nil))
@ -698,7 +708,7 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.")
"Send PROCESS a STRING plus a newline." "Send PROCESS a STRING plus a newline."
(let ((string (concat (encode-coding-string string rcirc-encode-coding-system) (let ((string (concat (encode-coding-string string rcirc-encode-coding-system)
"\n"))) "\n")))
(unless (eq (process-status process) 'open) (unless (member (process-status process) '(open run))
(error "Network connection to %s is not open" (error "Network connection to %s is not open"
(process-name process))) (process-name process)))
(rcirc-debug process string) (rcirc-debug process string)