From: Julien Danjou Date: Wed, 6 Oct 2010 14:02:39 +0000 (+0000) Subject: sieve-manage.el: Add authenticate function. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~438^2~46^2~153 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd9ba500f5f58549e0210a2334c38ba0916257d9;p=emacs.git sieve-manage.el: Add authenticate function. sieve-manage.el (sieve-manage-open): Use sieve-manage-default-port. --- diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog index fb0b7a7851b..02a4d3e5bcb 100644 --- a/doc/misc/ChangeLog +++ b/doc/misc/ChangeLog @@ -1,5 +1,7 @@ 2010-10-06 Julien Danjou + * sieve.texi (Manage Sieve API): Document sieve-manage-authenticate. + * message.texi (PGP Compatibility): Remove reference to gpg-2comp, broken link. diff --git a/doc/misc/sieve.texi b/doc/misc/sieve.texi index b17c262b757..b8f09904858 100644 --- a/doc/misc/sieve.texi +++ b/doc/misc/sieve.texi @@ -292,6 +292,10 @@ Check if a server is open or not. @findex sieve-manage-close Close a server connection. +@item sieve-manage-authenticate +@findex sieve-manage-authenticate +Authenticate to the server. + @item sieve-manage-capability @findex sieve-manage-capability Return a list of capabilities the server supports. diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 08c5282728e..0ffc7599cba 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,13 @@ +2010-10-06 Julien Danjou + + * sieve-manage.el: Update example in `Commentary'. + + * sieve.el (sieve-open-server): Use sieve-manage-authenticate. + + * sieve-manage.el (sieve-manage-open): Use sieve-manage-default-port, + not 2000. + (sieve-manage-authenticate): Re-add function. + 2010-10-06 Lars Magne Ingebrigtsen * shr.el (shr-insert): Get 'space transition right. diff --git a/lisp/gnus/sieve-manage.el b/lisp/gnus/sieve-manage.el index 370a53d4ac9..c542632a5a0 100644 --- a/lisp/gnus/sieve-manage.el +++ b/lisp/gnus/sieve-manage.el @@ -50,9 +50,11 @@ ;; ;; and that's it. Example of a managesieve session in *scratch*: ;; +;; (with-current-buffer (sieve-manage-open "mail.example.com") +;; (sieve-manage-authenticate) +;; (sieve-manage-listscripts)) ;; -;; (sieve-manage-listscripts my-buf) -;; ("vacation" "testscript" ("splitmail") "badscript") +;; => ((active . "main") "vacation") ;; ;; References: ;; @@ -387,7 +389,7 @@ Optional argument AUTH indicates authenticator to use, see If nil, chooses the best stream the server is capable of. Optional argument BUFFER is buffer (buffer, or string naming buffer) to work in." - (setq buffer (or buffer (format " *sieve* %s:%d" server (or port 2000)))) + (setq buffer (or buffer (format " *sieve* %s:%d" server (or port sieve-manage-default-port)))) (with-current-buffer (get-buffer-create buffer) (mapc 'make-local-variable sieve-manage-local-variables) (sieve-manage-disable-multibyte) @@ -444,6 +446,17 @@ to work in." (sieve-manage-erase) buffer))) +(defun sieve-manage-authenticate (&optional buffer) + "Authenticate on server in BUFFER. +Return `sieve-manage-state' value." + (with-current-buffer (or buffer (current-buffer)) + (if (eq sieve-manage-state 'nonauth) + (when (funcall (nth 2 (assq sieve-manage-auth + sieve-manage-authenticator-alist)) + (current-buffer)) + (setq sieve-manage-state 'auth)) + sieve-manage-state))) + (defun sieve-manage-opened (&optional buffer) "Return non-nil if connection to managesieve server in BUFFER is open. If BUFFER is nil then the current buffer is used." diff --git a/lisp/gnus/sieve.el b/lisp/gnus/sieve.el index e988cb759de..ca181c2e7b3 100644 --- a/lisp/gnus/sieve.el +++ b/lisp/gnus/sieve.el @@ -320,17 +320,12 @@ Server : " server ":" (or port "2000") " (insert "\n")))) (defun sieve-open-server (server &optional port) + "Open SERVER (on PORT) and authenticate." (with-current-buffer ;; open server (set (make-local-variable 'sieve-manage-buffer) (sieve-manage-open server)) - ;; authenticate - (if (eq sieve-manage-state 'nonauth) - (if (funcall (nth 2 (assq sieve-manage-auth - sieve-manage-authenticator-alist)) - (current-buffer)) - (setq sieve-manage-state 'auth)) - (eq sieve-manage-state 'auth)))) + (sieve-manage-authenticate))) (defun sieve-refresh-scriptlist () (interactive)