* sieve-manage.el: Autoload `auth-source-search'. (sieve-sasl-auth): Use it.
authorTed Zlatanov <tzz@lifelogs.com>
Thu, 10 Feb 2011 21:33:32 +0000 (15:33 -0600)
committerTed Zlatanov <tzz@lifelogs.com>
Thu, 10 Feb 2011 21:33:32 +0000 (15:33 -0600)
lisp/ChangeLog
lisp/sieve-manage.el

index ec7910e..ab3d157 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-10  Teodor Zlatanov  <tzz@lifelogs.com>
+
+       * sieve-manage.el: Autoload `auth-source-search'.
+       (sieve-sasl-auth): Use it.
+
 2011-02-09  Teodor Zlatanov  <tzz@lifelogs.com>
 
        * nnimap.el: Autoload `auth-source-forget+'.
index d115f40..c9a0df2 100644 (file)
@@ -83,7 +83,7 @@
   (require 'starttls))
 (autoload 'sasl-find-mechanism "sasl")
 (autoload 'starttls-open-stream "starttls")
-(autoload 'auth-source-user-or-password "auth-source")
+(autoload 'auth-source-search "auth-source")
 
 ;; User customizable variables:
 
@@ -273,16 +273,20 @@ Valid states are `closed', `initial', `nonauth', and `auth'.")
   "Login to server using the SASL MECH method."
   (message "sieve: Authenticating using %s..." mech)
   (with-current-buffer buffer
-    (let* ((user-password (auth-source-user-or-password
-                           '("login" "password")
-                           sieve-manage-server
-                           "sieve" nil t))
+    (let* ((auth-info (auth-source-search :host sieve-manage-server
+                                          :port "sieve"
+                                          :max 1))
+           (user-name (plist-get (nth 0 auth-info) :user))
+           (user-password (plist-get (nth 0 auth-info) :secret))
+           (user-password (if (functionp user-password)
+                              (funcall user-password)
+                            user-password))
            (client (sasl-make-client (sasl-find-mechanism (list mech))
-                                     (car user-password) "sieve" sieve-manage-server))
+                                     user-name "sieve" sieve-manage-server))
            (sasl-read-passphrase
             ;; We *need* to copy the password, because sasl will modify it
             ;; somehow.
-            `(lambda (prompt) ,(copy-sequence (cadr user-password))))
+            `(lambda (prompt) ,(copy-sequence user-password)))
            (step (sasl-next-step client nil))
            (tag (sieve-manage-send
                  (concat