[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: smtpmail and starttls improvement when starttls program is missing
From: |
Katsumi Yamaoka |
Subject: |
Re: smtpmail and starttls improvement when starttls program is missing |
Date: |
Tue, 04 Nov 2008 09:53:17 +0900 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) |
>>>>> Ted Zlatanov <address@hidden> wrote:
> Currently, smtpmail-open-stream will quietly fail if the starttls /
> gnutls program is not available. The changes below (starttls diff is
> against the Gnus trunk but it shouldn't matter) introduce the function
> starttls-any-program-available which will return either starttls-program
> or starttls-gnutls-program, whichever is usable. It also shows a
> message, so a user can see in *Messages* that no STARTTLS protocol
> transport is available. smtpmail-open-stream then uses the function,
> simplifying the logic flow.
> The message will only be shown when starttls-any-program-available is
> called, but note that it is called by smtpmail-open-stream iff there is
> a match for the server in smtpmail-starttls-credentials. This means the
> user won't see the message unless he has an entry for the server that
> implies he wants STARTTLS.
> Let me know what you think... Thanks
> Ted
> Index: starttls.el
> ===================================================================
> RCS file: /usr/local/cvsroot/gnus/lisp/starttls.el,v
> retrieving revision 7.19
> diff -c -r7.19 starttls.el
> *** starttls.el 19 May 2008 08:47:42 -0000 7.19
> --- starttls.el 29 Oct 2008 21:15:29 -0000
> ***************
> *** 295,300 ****
> --- 295,314 ----
> (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
I think `with-no-warnings' and `(require 'starttls)' are unnecessary.
For `with-no-warnings', it binds `byte-compile-warnings' to nil
when compiling. It is for making the byte compiler silent on any
form, however there seems nothing to be warned when compiling.
In addition, `with-no-warnings' is not available in Emacs 21 and
XEmacs that Gnus supports, so the warning like the following is
issued when compiling Gnus:
While compiling the end of the data in file gnus/lisp/starttls.el:
** The function `with-no-warnings' is not known to be defined.
It is not serious since the function will not be used with those
versions of Emacsen, though.
For `(require 'starttls)', the reason I say it is unnecessary is
that the function is defined in starttls.el that provides the
`starttls' feature. ;-) Therefore the function can be rewritten
like the following, isn't it?
--8<---------------cut here---------------start------------->8---
(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)))))
--8<---------------cut here---------------end--------------->8---
> Index: lisp/mail/smtpmail.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/mail/smtpmail.el,v
> retrieving revision 1.105
> diff -c -r1.105 smtpmail.el
> *** lisp/mail/smtpmail.el 7 Jun 2008 02:41:06 -0000 1.105
> --- lisp/mail/smtpmail.el 29 Oct 2008 21:16:26 -0000
> ***************
> *** 503,515 ****
> (defun smtpmail-open-stream (process-buffer host port)
> (let ((cred (smtpmail-find-credentials
> smtpmail-starttls-credentials host port)))
> ! (if (null (and cred (condition-case ()
> ! (with-no-warnings
> ! (require 'starttls)
> ! (call-process (if starttls-use-gnutls
> ! starttls-gnutls-program
> ! starttls-program)))
> ! (error nil))))
> ;; The normal case.
> (open-network-stream "SMTP" process-buffer host port)
> (let* ((cred-key (smtpmail-cred-key cred))
> --- 503,509 ----
> (defun smtpmail-open-stream (process-buffer host port)
> (let ((cred (smtpmail-find-credentials
> smtpmail-starttls-credentials host port)))
> ! (if (null (and cred (starttls-any-program-available)))
> ;; The normal case.
> (open-network-stream "SMTP" process-buffer host port)
> (let* ((cred-key (smtpmail-cred-key cred))
Regards,
- Re: smtpmail and starttls improvement when starttls program is missing,
Katsumi Yamaoka <=