comparison lisp/gnus/starttls.el @ 99402:d0dc678bbb96

Merge from gnus--devo--0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1464
author Miles Bader <miles@gnu.org>
date Thu, 06 Nov 2008 00:49:23 +0000
parents f42ef85caf91
children a9dc0e7c3f2b
comparison
equal deleted inserted replaced
99401:2ac19526bf39 99402:d0dc678bbb96
239 'set-process-query-on-exit-flag) 239 'set-process-query-on-exit-flag)
240 (defalias 'starttls-set-process-query-on-exit-flag 240 (defalias 'starttls-set-process-query-on-exit-flag
241 'process-kill-without-query))) 241 'process-kill-without-query)))
242 242
243 (defun starttls-open-stream-gnutls (name buffer host port) 243 (defun starttls-open-stream-gnutls (name buffer host port)
244 (message "Opening STARTTLS connection to `%s'..." host) 244 (message "Opening STARTTLS connection to `%s:%s'..." host port)
245 (let* (done 245 (let* (done
246 (old-max (with-current-buffer buffer (point-max))) 246 (old-max (with-current-buffer buffer (point-max)))
247 (process-connection-type starttls-process-connection-type) 247 (process-connection-type starttls-process-connection-type)
248 (process (apply #'start-process name buffer 248 (process (apply #'start-process name buffer
249 starttls-gnutls-program "-s" host 249 starttls-gnutls-program "-s" host
264 (if done 264 (if done
265 (with-current-buffer buffer 265 (with-current-buffer buffer
266 (delete-region old-max done)) 266 (delete-region old-max done))
267 (delete-process process) 267 (delete-process process)
268 (setq process nil)) 268 (setq process nil))
269 (message "Opening STARTTLS connection to `%s'...%s" 269 (message "Opening STARTTLS connection to `%s:%s'...%s"
270 host (if done "done" "failed")) 270 host port (if done "done" "failed"))
271 process)) 271 process))
272 272
273 (defun starttls-open-stream (name buffer host port) 273 (defun starttls-open-stream (name buffer host port)
274 "Open a TLS connection for a port to a host. 274 "Open a TLS connection for a port to a host.
275 Returns a subprocess object to represent the connection. 275 Returns a subprocess object to represent the connection.
285 Fourth arg PORT is an integer specifying a port to connect to. 285 Fourth arg PORT is an integer specifying a port to connect to.
286 If `starttls-use-gnutls' is nil, this may also be a service name, but 286 If `starttls-use-gnutls' is nil, this may also be a service name, but
287 GNUTLS requires a port number." 287 GNUTLS requires a port number."
288 (if starttls-use-gnutls 288 (if starttls-use-gnutls
289 (starttls-open-stream-gnutls name buffer host port) 289 (starttls-open-stream-gnutls name buffer host port)
290 (message "Opening STARTTLS connection to `%s:%s'" host (format "%s" port))
290 (let* ((process-connection-type starttls-process-connection-type) 291 (let* ((process-connection-type starttls-process-connection-type)
291 (process (apply #'start-process 292 (process (apply #'start-process
292 name buffer starttls-program 293 name buffer starttls-program
293 host (format "%s" port) 294 host (format "%s" port)
294 starttls-extra-args))) 295 starttls-extra-args)))
295 (starttls-set-process-query-on-exit-flag process nil) 296 (starttls-set-process-query-on-exit-flag process nil)
296 process))) 297 process)))
297 298
299 (defun starttls-any-program-available ()
300 (let ((program (if starttls-use-gnutls
301 starttls-gnutls-program
302 starttls-program)))
303 (condition-case ()
304 (progn
305 (call-process program)
306 program)
307 (error (progn
308 (message "No STARTTLS program was available (tried '%s')"
309 program)
310 nil)))))
311
298 (provide 'starttls) 312 (provide 'starttls)
299 313
300 ;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 314 ;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297
301 ;;; starttls.el ends here 315 ;;; starttls.el ends here