(starttls-any-program-available): Get the name of the available TLS
authorTeodor Zlatanov <tzz@lifelogs.com>
Mon, 3 Nov 2008 20:50:37 +0000 (20:50 +0000)
committerTeodor Zlatanov <tzz@lifelogs.com>
Mon, 3 Nov 2008 20:50:37 +0000 (20:50 +0000)
layer program.
(starttls-open-steam-gnutls, starttls-open-stream): Put port number as
well as the host name in the "opening" message.

lisp/ChangeLog
lisp/starttls.el

index 8b689dc..5acaa2d 100644 (file)
@@ -1,5 +1,10 @@
 2008-11-03  Teodor Zlatanov  <tzz@lifelogs.com>
 
+       * starttls.el (starttls-any-program-available): Get the name of the
+       available TLS layer program.
+       (starttls-open-steam-gnutls, starttls-open-stream): Put port number as
+       well as the host name in the "opening" message.
+
        * auth-source.el (auth-source-cache, auth-source-do-cache)
        (auth-source-user-or-password): Cache passwords and logins by default,
        allow override with `auth-source-do-cache'.
index 7aa13c2..d47daff 100644 (file)
@@ -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)
@@ -266,8 +266,8 @@ 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))
 
 (defun starttls-open-stream (name buffer host port)
@@ -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,6 +296,20 @@ 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 ()
+       (with-no-warnings
+         (require 'starttls)
+         (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