]> git.eshelyaron.com Git - emacs.git/commitdiff
sieve-manage.el: Add authenticate function.
authorJulien Danjou <julien@danjou.info>
Wed, 6 Oct 2010 14:02:39 +0000 (14:02 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Wed, 6 Oct 2010 14:02:39 +0000 (14:02 +0000)
sieve-manage.el (sieve-manage-open): Use sieve-manage-default-port.

doc/misc/ChangeLog
doc/misc/sieve.texi
lisp/gnus/ChangeLog
lisp/gnus/sieve-manage.el
lisp/gnus/sieve.el

index fb0b7a7851b79cfa7327ea5118137f0524bbdbc3..02a4d3e5bcbf084ff98e41e8651de044a9be4516 100644 (file)
@@ -1,5 +1,7 @@
 2010-10-06  Julien Danjou  <julien@danjou.info>
 
+       * sieve.texi (Manage Sieve API): Document sieve-manage-authenticate.
+
        * message.texi (PGP Compatibility): Remove reference to gpg-2comp,
        broken link.
 
index b17c262b75760f2a9518b884588bc7737afc5d5d..b8f09904858d3915ea418e48528cf7ab40eacf47 100644 (file)
@@ -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.
index 08c5282728e775a6fdf4ead5ff6d0527860f9f47..0ffc7599cba2ddc35f6483e6d7309497fb3870f6 100644 (file)
@@ -1,3 +1,13 @@
+2010-10-06  Julien Danjou  <julien@danjou.info>
+
+       * 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  <larsi@gnus.org>
 
        * shr.el (shr-insert): Get 'space transition right.
index 370a53d4ac9af1175e350b09ea53a982ac8768f2..c542632a5a0a526a284b79ac22b9f3d1f95c7082 100644 (file)
 ;;
 ;; 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."
index e988cb759de449f4b4637ed2cf26e68a88835664..ca181c2e7b30d4a55c301b8a72f7632bf49ff9a3 100644 (file)
@@ -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)