X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fstarttls.el;h=a4d33b81bb5bd459593a14dbd4c4facebee0da0e;hb=6d7b29856941c186ec54e3b8a05d4a10566e3582;hp=7aa13c26dcde251bd6a07609ca065dc3f66e2502;hpb=8b5af94e55ef83ee46b42d32d92fa1ce95dcacf5;p=gnus diff --git a/lisp/starttls.el b/lisp/starttls.el index 7aa13c26d..a4d33b81b 100644 --- a/lisp/starttls.el +++ b/lisp/starttls.el @@ -1,7 +1,7 @@ ;;; starttls.el --- STARTTLS functions ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Daiki Ueno ;; Author: Simon Josefsson @@ -241,7 +241,7 @@ handshake, or nil on failure." 'process-kill-without-query))) (defun starttls-open-stream-gnutls (name buffer host port) - (message "Opening STARTTLS connection to `%s'..." host) + (message "Opening STARTTLS connection to `%s:%s'..." host port) (let* (done (old-max (with-current-buffer buffer (point-max))) (process-connection-type starttls-process-connection-type) @@ -254,8 +254,7 @@ handshake, or nil on failure." (starttls-set-process-query-on-exit-flag process nil) (while (and (processp process) (eq (process-status process) 'run) - (save-excursion - (set-buffer buffer) + (with-current-buffer buffer (goto-char old-max) (not (setq done (re-search-forward starttls-connect nil t))))) @@ -266,10 +265,11 @@ handshake, or nil on failure." (delete-region old-max done)) (delete-process process) (setq process nil)) - (message "Opening STARTTLS connection to `%s'...%s" - host (if done "done" "failed")) + (message "Opening STARTTLS connection to `%s:%s'...%s" + host port (if done "done" "failed")) process)) +;;;###autoload (defun starttls-open-stream (name buffer host port) "Open a TLS connection for a port to a host. Returns a subprocess object to represent the connection. @@ -287,6 +287,7 @@ If `starttls-use-gnutls' is nil, this may also be a service name, but GNUTLS requires a port number." (if starttls-use-gnutls (starttls-open-stream-gnutls name buffer host port) + (message "Opening STARTTLS connection to `%s:%s'" host (format "%s" port)) (let* ((process-connection-type starttls-process-connection-type) (process (apply #'start-process name buffer starttls-program @@ -295,7 +296,19 @@ GNUTLS requires a port number." (starttls-set-process-query-on-exit-flag process nil) process))) +(defun starttls-any-program-available () + (let ((program (if starttls-use-gnutls + starttls-gnutls-program + starttls-program))) + (condition-case () + (progn + (call-process program) + program) + (error (progn + (message "No STARTTLS program was available (tried '%s')" + program) + nil))))) + (provide 'starttls) -;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297 ;;; starttls.el ends here