Sync up with wl-2.5.4.
authorteranisi <teranisi>
Fri, 22 Dec 2000 06:24:38 +0000 (06:24 +0000)
committerteranisi <teranisi>
Fri, 22 Dec 2000 06:24:38 +0000 (06:24 +0000)
Plus following changes.

* elmo-msgdb.el (elmo-generic-folder-diff): Moved from elmo2.el
(elmo-generic-list-folder-unread): Ditto.
(elmo-folder-get-info): Ditto.
(elmo-folder-set-info-max-by-numdb): Ditto.
(elmo-folder-get-info-max): Ditto.
(elmo-folder-get-info-length): Ditto.
(elmo-folder-get-info-unread): Ditto.
(elmo-folder-info-make-hashtb): Ditto.

* elmo2.el: Removed above functions.

elmo/ChangeLog
elmo/elmo-imap4.el
elmo/elmo-msgdb.el
elmo/elmo-net.el
elmo/elmo-nntp.el
elmo/elmo-pop3.el
elmo/elmo-util.el
elmo/elmo2.el

index 404136b..917fe49 100644 (file)
@@ -1,3 +1,102 @@
+2000-12-22  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * elmo-msgdb.el (elmo-generic-folder-diff): Moved from elmo2.el
+       (elmo-generic-list-folder-unread): Ditto.
+       (elmo-folder-get-info): Ditto.
+       (elmo-folder-set-info-max-by-numdb): Ditto.
+       (elmo-folder-get-info-max): Ditto.
+       (elmo-folder-get-info-length): Ditto.
+       (elmo-folder-get-info-unread): Ditto.
+       (elmo-folder-info-make-hashtb): Ditto.
+
+       * elmo2.el: Removed above functions.
+
+       * elmo-imap4.el (elmo-network-authenticate-session):
+       Fixed a logic for response checking.
+
+2000-12-15   Daiki Ueno  <ueno@unixuser.org>
+
+       * elmo-net.el: Add autoload settings for `starttls-negotiate',
+       `sasl-find-mechanism', `sasl-make-client', `sasl-mechanism-name',
+       `sasl-next-step', `sasl-step-data' and `sasl-step-set-data'; bind
+       `sasl-mechanisms'.
+
+       * elmo-imap4.el: Don't require `sasl'; remove autoload settings
+       for `starttls-open-stream' and `starttls-negotiate'.
+
+       * elmo-nntp.el: Remove autoload settings for
+       `starttls-open-stream' and `starttls-negotiate'.
+
+       * elmo-pop3.el: Don't require `sasl'; remove autoload settings
+       for `starttls-open-stream' and `starttls-negotiate'; don't enclose
+       `luna-define-class' with `eval-and-compile'.
+
+2000-11-21  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-imap4.el (toplevel): Require 'ssl.
+       Add autoload 'starttls.
+       * elmo-pop3.el (toplevel): Ditto.
+       * elmo-nntp.el (toplevel): Ditto.
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-imap4.el (toplevel): defun at compile time.
+       sasl-find-mechanism, sasl-make-client, sasl-mechanism-name,
+       sasl-next-step, sasl-step-data, sasl-step-set-data.
+       * elmo-pop3.el (toplevel): Ditto.
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-imap4.el (elmo-network-authenticate-session): Use `elmo-imap4-login'
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-pop3.el (elmo-pop3-auth-apop): Signal `elmo-pop-auth-apop'
+       if error.
+       (elmo-network-authenticate-session): Use `elmo-pop-auth-user'
+       and `elmo-pop-auth-apop'.
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-pop3.el (elmo-network-authenticate-session): Fix for `APOP'.
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-pop3.el (elmo-network-authenticate-session): Split
+       encoded response value.
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-pop3.el (elmo-network-authenticate-session): Abolish
+       `elmo-pop3-force-login'.
+       Redefine `sasl-mechanisms'.
+       * elmo-vars.el (elmo-pop3-force-login): Ditto.
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-imap4.el (toplevel): Delete defun-maybe for sasl-*.
+       Delete `elmo-imap4-authenticator-alist'.
+       (elmo-imap4-auth-cram-md5): Delete.
+       (elmo-imap4-auth-digest-md5): Delete.
+
+2000-11-20  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-pop3.el (elmo-pop3-auth-digest-md5): Delete.
+       (elmo-pop3-auth-scram-md5): Ditto.
+       (elmo-pop3-auth-cram-md5): Ditto.
+
+2000-11-19  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-pop3.el (toplevel): Delete defun-maybe for sasl-*.
+       Delete `elmo-pop3-authenticator-alist'.
+
+2000-11-19  Kenichi OKADA  <okada@opaopa.org>
+
+       * elmo-pop3.el (elmo-network-authenticate-session): Rewrite for
+       new SASL API.
+       * elmo-imap4.el (elmo-network-authenticate-session): Ditto.
+
+\f
 2000-12-18  Yuuichi Teranishi  <teranisi@gohome.org>
 
        * elmo-nntp.el (elmo-nntp-get-folders-info): Fixed last change.
index f3da976..a02f91a 100644 (file)
 (require 'utf7)
 
 ;;; Code:
-(condition-case nil
-    (progn
-      (require 'sasl))
-  (error))
-;; silence byte compiler.
-(eval-when-compile
-  (require 'cl)
-  (condition-case nil
-      (progn
-       (require 'starttls)
-       (require 'sasl))
-    (error))
-  (defun-maybe sasl-cram-md5 (username passphrase challenge))
-  (defun-maybe sasl-digest-md5-digest-response
-    (digest-challenge username passwd serv-type host &optional realm))
-  (defun-maybe starttls-negotiate (a))
-  (defun-maybe elmo-generic-list-folder-unread (spec number-alist mark-alist unread-marks))
-  (defun-maybe elmo-generic-folder-diff (spec folder number-list))
-  (defsubst-maybe utf7-decode-string (string &optional imap) string))
+(eval-when-compile (require 'cl))
 
 (defvar elmo-imap4-use-lock t
   "USE IMAP4 with locking process.")
     elmo-imap4-status-callback-data
     elmo-imap4-current-msgdb))
 
-(defvar elmo-imap4-authenticator-alist
-  '((login     elmo-imap4-auth-login)
-    (cram-md5  elmo-imap4-auth-cram-md5)
-    (digest-md5 elmo-imap4-auth-digest-md5)
-    (plain      elmo-imap4-login))
-  "Definition of authenticators.")
-
 ;;;;
 
 (defconst elmo-imap4-quoted-specials-list '(?\\ ?\"))
@@ -1143,64 +1118,6 @@ If optional argument UNMARK is non-nil, unmark."
       (elmo-read
        (concat "(" (downcase (elmo-match-string 1 string)) ")"))))
 
-;; Current buffer is process buffer.
-(defun elmo-imap4-auth-login (session)
-  (let ((tag (elmo-imap4-send-command session "authenticate login"))
-       (elmo-imap4-debug-inhibit-logging t))
-    (or (elmo-imap4-read-continue-req session)
-       (signal 'elmo-authenticate-error '(elmo-imap4-auth-login)))
-    (elmo-imap4-send-string session
-                           (elmo-base64-encode-string
-                            (elmo-network-session-user-internal session)))
-    (or (elmo-imap4-read-continue-req session)
-       (signal 'elmo-authenticate-error '(elmo-imap4-auth-login)))
-    (elmo-imap4-send-string session
-                           (elmo-base64-encode-string
-                            (elmo-get-passwd
-                             (elmo-network-session-password-key session))))
-    (or (elmo-imap4-read-ok session tag)
-       (signal 'elmo-authenticate-error '(elmo-imap4-auth-login)))
-    (setq elmo-imap4-status 'auth)))
-
-(defun elmo-imap4-auth-cram-md5 (session)
-  (let ((tag (elmo-imap4-send-command session "authenticate cram-md5"))
-       (elmo-imap4-debug-inhibit-logging t)
-       response)
-    (or (setq response (elmo-imap4-read-continue-req session))
-       (signal 'elmo-authenticate-error
-               '(elmo-imap4-auth-cram-md5)))
-    (elmo-imap4-send-string
-     session
-     (elmo-base64-encode-string
-      (sasl-cram-md5 (elmo-network-session-user-internal session)
-                    (elmo-get-passwd
-                     (elmo-network-session-password-key session))
-                    (elmo-base64-decode-string response))))
-    (or (elmo-imap4-read-ok session tag)
-       (signal 'elmo-authenticate-error '(elmo-imap4-auth-cram-md5)))))
-
-(defun elmo-imap4-auth-digest-md5 (session)
-  (let ((tag (elmo-imap4-send-command session "authenticate digest-md5"))
-       (elmo-imap4-debug-inhibit-logging t)
-       response)
-    (or (setq response (elmo-imap4-read-continue-req session))
-       (signal 'elmo-authenticate-error '(elmo-imap4-auth-digest-md5)))
-    (elmo-imap4-send-string
-     session
-     (elmo-base64-encode-string
-      (sasl-digest-md5-digest-response
-       (elmo-base64-decode-string response)
-       (elmo-network-session-user-internal session)
-       (elmo-get-passwd (elmo-network-session-password-key session))
-       "imap"
-       (elmo-network-session-password-key session))
-      'no-line-break))
-    (or (setq response (elmo-imap4-read-continue-req session))
-       (signal 'elmo-authenticate-error '(elmo-imap4-auth-digest-md5)))
-    (elmo-imap4-send-string session "")
-    (or (elmo-imap4-read-ok session tag)
-       (signal 'elmo-authenticate-error '(elmo-imap4-auth-digest-md5)))))
-
 (defun elmo-imap4-login (session)
   (let ((elmo-imap4-debug-inhibit-logging t))
     (or
@@ -1259,36 +1176,105 @@ If optional argument UNMARK is non-nil, unmark."
        (starttls-negotiate process)))))
 
 (luna-define-method elmo-network-authenticate-session ((session
-                                                       elmo-imap4-session))
- (with-current-buffer (process-buffer
-                      (elmo-network-session-process-internal session))
-   (unless (eq elmo-imap4-status 'auth)
-     (unless (or (not (elmo-network-session-auth-internal session))
-                (eq (elmo-network-session-auth-internal session) 'plain)
-                (and (memq (intern
-                            (format "auth=%s"
-                                    (elmo-network-session-auth-internal
-                                     session)))
-                           (elmo-imap4-session-capability-internal session))
-                     (assq
-                      (elmo-network-session-auth-internal session)
-                      elmo-imap4-authenticator-alist)))
-       (if (or elmo-imap4-force-login
-              (y-or-n-p
-               (format
-                "There's no %s capability in server. continue?"
-                (elmo-network-session-auth-internal session))))
-          (elmo-network-session-set-auth-internal session nil)
-        (signal 'elmo-open-error
-                '(elmo-network-initialize-session))))
-     (let ((authenticator
-           (if (elmo-network-session-auth-internal session)
-               (nth 1 (assq
-                       (elmo-network-session-auth-internal session)
-                       elmo-imap4-authenticator-alist))
-             'elmo-imap4-login)))
-       (funcall authenticator session)))))
-
+                                                       elmo-imap4-session))
+  (with-current-buffer (process-buffer
+                       (elmo-network-session-process-internal session))
+    (let* ((auth (elmo-network-session-auth-internal session))
+          (auth (if (listp auth) auth (list auth))))
+      (unless (or (eq elmo-imap4-status 'auth)
+                 (null auth))
+       (if (eq 'plain (car auth))
+           (elmo-imap4-login session)
+         (let* ((elmo-imap4-debug-inhibit-logging t)
+                (sasl-mechanisms
+                 (delq nil
+                       (mapcar
+                        '(lambda (cap)
+                           (if (string-match "^auth=\\(.*\\)$"
+                                             (symbol-name cap))
+                               (match-string 1 (upcase (symbol-name cap)))))
+                        (elmo-imap4-session-capability-internal session))))
+                (mechanism
+                 (sasl-find-mechanism
+                  (delq nil
+                        (mapcar '(lambda (cap) (upcase (symbol-name cap)))
+                                (if (listp auth)
+                                    auth
+                                  (list auth)))))) ;)
+                client name step response tag
+                sasl-read-passphrase)
+           (unless mechanism
+             (if (or elmo-imap4-force-login
+                     (y-or-n-p
+                      (format
+                       "There's no %s capability in server. continue?"
+                       (elmo-list-to-string
+                        (elmo-network-session-auth-internal session)))))
+                 (setq mechanism (sasl-find-mechanism
+                                  sasl-mechanisms))
+               (signal 'elmo-authenticate-error
+                       '(elmo-imap4-auth-no-mechanisms))))
+           (setq client
+                 (sasl-make-client
+                  mechanism
+                  (elmo-network-session-user-internal session)
+                  "imap"
+                  (elmo-network-session-host-internal session)))
+;;;        (if elmo-imap4-auth-user-realm
+;;;            (sasl-client-set-property client 'realm elmo-imap4-auth-user-realm))
+           (setq name (sasl-mechanism-name mechanism)
+                 step (sasl-next-step client nil))
+           (elmo-network-session-set-auth-internal
+            session
+            (intern (downcase name)))
+           (setq sasl-read-passphrase
+                 (function
+                  (lambda (prompt)
+                    (elmo-get-passwd
+                     (elmo-network-session-password-key session)))))
+           (setq tag
+                 (elmo-imap4-send-command
+                  session
+                  (concat "AUTHENTICATE " name
+                          (and (sasl-step-data step)
+                               (concat 
+                                " "
+                                (elmo-base64-encode-string
+                                 (sasl-step-data step)
+                                 'no-lin-break)))))) ;)
+           (catch 'done
+             (while t
+               (setq response
+                     (elmo-imap4-read-untagged
+                      (elmo-network-session-process-internal session)))
+               (if (elmo-imap4-response-continue-req-p response)
+                   (unless (sasl-next-step client step)
+                     ;; response is '+' but there's no next step.
+                     (signal 'elmo-authenticate-error
+                             (list (intern
+                                    (concat "elmo-imap4-auth-"
+                                            (downcase name))))))
+                 ;; response is OK.
+                 (if (elmo-imap4-response-ok-p response)
+                     (throw 'done nil) ; finished.
+                   ;; response is NO or BAD.
+                   (signal 'elmo-authenticate-error
+                           (list (intern
+                                  (concat "elmo-imap4-auth-"
+                                          (downcase name)))))))
+               (sasl-step-set-data
+                step
+                (elmo-base64-decode-string
+                 (elmo-imap4-response-value response 'continue-req)))
+               (setq step (sasl-next-step client step))
+               (setq tag
+                     (elmo-imap4-send-string
+                      session
+                      (if (sasl-step-data step)
+                          (elmo-base64-encode-string (sasl-step-data step)
+                                                     'no-line-break)
+                        "")))))))))))
 (luna-define-method elmo-network-setup-session ((session
                                                 elmo-imap4-session))
   (with-current-buffer (elmo-network-session-buffer session)
index 5fa1ceb..80833b9 100644 (file)
@@ -828,6 +828,95 @@ Header region is supposed to be narrowed."
            (elmo-make-directory new-dir))
        (rename-file old new)))))
 
+(defun elmo-generic-folder-diff (spec folder &optional number-list)
+  (let ((cached-in-db-max (elmo-folder-get-info-max folder))
+       (in-folder (elmo-call-func folder "max-of-folder"))
+       (in-db t)
+       unsync messages
+       in-db-max)
+    (if (or number-list (not cached-in-db-max))
+       (let ((number-list (or number-list
+                              (mapcar 'car
+                                      (elmo-msgdb-number-load
+                                       (elmo-msgdb-expand-path folder))))))
+         ;; No info-cache.
+         (setq in-db (sort number-list '<))
+         (setq in-db-max (or (nth (max 0 (1- (length in-db))) in-db)
+                             0))
+         (if (not number-list)
+             (elmo-folder-set-info-hashtb folder in-db-max nil)))
+      (setq in-db-max cached-in-db-max))
+    (setq unsync (if (and in-db
+                         (car in-folder))
+                    (- (car in-folder) in-db-max)
+                  (if (and in-folder
+                           (null in-db))
+                      (cdr in-folder)
+                    (if (null (car in-folder))
+                        nil))))
+    (setq messages (cdr in-folder))
+    (if (and unsync messages (> unsync messages))
+       (setq unsync messages))
+    (cons (or unsync 0) (or messages 0))))
+
+(defun elmo-generic-list-folder-unread (spec number-alist mark-alist
+                                            unread-marks)
+  (delq nil
+       (mapcar
+        (function (lambda (x)
+                    (if (member (cadr (assq (car x) mark-alist)) unread-marks)
+                        (car x))))
+        mark-alist)))
+
+(defsubst elmo-folder-get-info (folder &optional hashtb)
+  (elmo-get-hash-val folder
+                    (or hashtb elmo-folder-info-hashtb)))
+
+(defun elmo-folder-set-info-hashtb (folder max numbers &optional new unread)
+  (let ((info (elmo-folder-get-info folder)))
+    (when info
+      (or new     (setq new     (nth 0 info)))
+      (or unread  (setq unread  (nth 1 info)))
+      (or numbers (setq numbers (nth 2 info)))
+      (or max     (setq max     (nth 3 info))))
+    (elmo-set-hash-val folder
+                      (list new unread numbers max)
+                      elmo-folder-info-hashtb)))
+
+(defun elmo-folder-set-info-max-by-numdb (folder msgdb-number)
+  (let ((num-db (sort (mapcar 'car msgdb-number) '<)))
+    (elmo-folder-set-info-hashtb
+     folder
+     (or (nth (max 0 (1- (length num-db))) num-db) 0)
+     nil ;;(length num-db)
+     )))
+
+(defun elmo-folder-get-info-max (folder)
+  "Get folder info from cache."
+  (nth 3 (elmo-folder-get-info folder)))
+
+(defun elmo-folder-get-info-length (folder)
+  (nth 2 (elmo-folder-get-info folder)))
+
+(defun elmo-folder-get-info-unread (folder)
+  (nth 1 (elmo-folder-get-info folder)))
+
+(defun elmo-folder-info-make-hashtb (info-alist hashtb)
+  (let* ((hashtb (or hashtb
+                    (elmo-make-hash (length info-alist)))))
+    (mapcar
+     '(lambda (x)
+       (let ((info (cadr x)))
+         (and (intern-soft (car x) hashtb)
+              (elmo-set-hash-val (car x)
+                                 (list (nth 2 info)   ;; new
+                                       (nth 3 info)   ;; unread
+                                       (nth 1 info)   ;; length
+                                       (nth 0 info))  ;; max
+                                 hashtb))))
+     info-alist)
+    (setq elmo-folder-info-hashtb hashtb)))
+
 (require 'product)
 (product-provide (provide 'elmo-msgdb) (require 'elmo-version))
 
index f283b2a..0380a85 100644 (file)
 (require 'elmo-util)
 (require 'elmo-vars)
 
+(eval-and-compile
+  (autoload 'starttls-negotiate "starttls")
+  (autoload 'sasl-find-mechanism "sasl")
+  (autoload 'sasl-make-client "sasl")
+  (autoload 'sasl-mechanism-name "sasl")
+  (autoload 'sasl-next-step "sasl")
+  (autoload 'sasl-step-data "sasl")
+  (autoload 'sasl-step-set-data "sasl"))
+
+(defvar sasl-mechanisms)
+
 ;;; Code:
 ;;
 (eval-and-compile
index 7ad5770..1fc88a0 100644 (file)
 
 (require 'elmo-msgdb)
 (eval-when-compile
-  (condition-case nil
-      (progn
-       (require 'starttls))
-    (error))
   (require 'elmo-cache)
-  (require 'elmo-util)
-  (defun-maybe starttls-negotiate (a)))
+  (require 'elmo-util))
 (require 'elmo-net)
 
 (eval-and-compile
index e09e44e..294f2ad 100644 (file)
 
 (require 'elmo-msgdb)
 (require 'elmo-net)
+
 (eval-when-compile
-  (require 'elmo-util)
-  (condition-case nil
-      (progn
-       (require 'starttls)
-       (require 'sasl))
-    (error))
-  (defun-maybe md5 (a))
-  (defun-maybe sasl-digest-md5-digest-response
-    (digest-challenge username passwd serv-type host &optional realm))
-  (defun-maybe sasl-scram-md5-client-msg-1
-    (authenticate-id &optional authorize-id))
-  (defun-maybe sasl-scram-md5-client-msg-2
-    (server-msg-1 client-msg-1 salted-pass))
-  (defun-maybe sasl-scram-md5-make-salted-pass
-    (server-msg-1 passphrase))
-  (defun-maybe sasl-cram-md5 (username passphrase challenge))
-  (defun-maybe sasl-scram-md5-authenticate-server
-    (server-msg-1 server-msg-2 client-msg-1 salted-pass))
-  (defun-maybe starttls-negotiate (a)))
-(condition-case nil
-    (progn
-      (require 'sasl))
-  (error))
+  (require 'elmo-util))
+
+(eval-and-compile
+  (autoload 'md5 "md5"))
 
 (defvar elmo-pop3-use-uidl t
   "*If non-nil, use UIDL.")
 
 (defvar elmo-pop3-exists-exactly t)
 
-(defvar elmo-pop3-authenticator-alist
-  '((user        elmo-pop3-auth-user)
-    (apop        elmo-pop3-auth-apop)
-    (cram-md5    elmo-pop3-auth-cram-md5)
-    (scram-md5   elmo-pop3-auth-scram-md5)
-    (digest-md5  elmo-pop3-auth-digest-md5))
-  "Definition of authenticators.")
-
-(eval-and-compile
-  (luna-define-class elmo-pop3-session (elmo-network-session) ()))
+(luna-define-class elmo-pop3-session (elmo-network-session) ())
 
 ;; buffer-local
 (defvar elmo-pop3-read-point nil)
                    (elmo-network-session-greeting-internal session))
       ;; good, APOP ready server
       (progn
-       (require 'md5)
        (elmo-pop3-send-command
         (elmo-network-session-process-internal session)
         (format "apop %s %s"
             t)
            (signal 'elmo-authenticate-error
                    '(elmo-pop3-auth-apop))))
-    (signal 'elmo-open-error '(elmo-pop-auth-user))))
+    (signal 'elmo-open-error '(elmo-pop3-auth-apop))))
     
-(defun elmo-pop3-auth-cram-md5 (session)
-  (let ((process (elmo-network-session-process-internal session))
-       response)
-    (elmo-pop3-send-command  process "auth cram-md5")
-    (or (setq response
-             (elmo-pop3-read-response process t))
-       (signal 'elmo-open-error '(elmo-pop-auth-cram-md5)))
-    (elmo-pop3-send-command
-     process
-     (elmo-base64-encode-string
-      (sasl-cram-md5 (elmo-network-session-user-internal session)
-                    (elmo-get-passwd
-                     (elmo-network-session-password-key session))
-                    (elmo-base64-decode-string
-                     (cadr (split-string response " "))))))
-    (or (elmo-pop3-read-response process t)
-       (signal 'elmo-authenticate-error
-               '(elmo-pop-auth-cram-md5)))))
-
-(defun elmo-pop3-auth-scram-md5 (session)
-  (let ((process (elmo-network-session-process-internal session))
-       server-msg-1 server-msg-2 client-msg-1 client-msg-2
-       salted-pass response)
-    (elmo-pop3-send-command
-     process
-     (format "auth scram-md5 %s"
-            (elmo-base64-encode-string
-             (setq client-msg-1
-                   (sasl-scram-md5-client-msg-1
-                    (elmo-network-session-user-internal session))))))
-    (or (elmo-pop3-read-response process t)
-       (signal 'elmo-open-error '(elmo-pop-auth-scram-md5)))
-    (setq server-msg-1
-         (elmo-base64-decode-string (cadr (split-string response " "))))
-    (elmo-pop3-send-command
-     process
-     (elmo-base64-encode-string
-      (sasl-scram-md5-client-msg-2
-       server-msg-1
-       client-msg-1
-       (setq salted-pass
-            (sasl-scram-md5-make-salted-pass
-             server-msg-1
-             (elmo-get-passwd
-              (elmo-network-session-password-key session)))))))
-    (or (setq response (elmo-pop3-read-response process t))
-       (signal 'elmo-authenticate-error
-               '(elmo-pop-auth-scram-md5)))
-    (setq server-msg-2 (elmo-base64-decode-string
-                       (cadr (split-string response " "))))
-    (or (sasl-scram-md5-authenticate-server server-msg-1
-                                           server-msg-2
-                                           client-msg-1
-                                           salted-pass)
-       (signal 'elmo-authenticate-error
-               '(elmo-pop-auth-scram-md5)))
-    (elmo-pop3-send-command process "")
-    (or (setq response (elmo-pop3-read-response process t))
-       (signal 'elmo-authenticate-error
-               '(elmo-pop-auth-scram-md5)))))
-
-(defun elmo-pop3-auth-digest-md5 (session)
-  (let ((process (elmo-network-session-process-internal session))
-       response)
-    (elmo-pop3-send-command process "auth digest-md5")
-    (or (setq response
-             (elmo-pop3-read-response process t))
-       (signal 'elmo-open-error
-               '(elmo-pop-auth-digest-md5)))
-    (elmo-pop3-send-command
-     process
-     (elmo-base64-encode-string
-      (sasl-digest-md5-digest-response
-       (elmo-base64-decode-string
-       (cadr (split-string response " ")))
-       (elmo-network-session-user-internal session)
-       (elmo-get-passwd
-       (elmo-network-session-password-key session))
-       "pop"
-       (elmo-network-session-host-internal session))
-      'no-line-break))
-    (or (elmo-pop3-read-response process t)
-       (signal 'elmo-authenticate-error
-               '(elmo-pop-auth-digest-md5)))
-    (elmo-pop3-send-command process "")
-    (or (elmo-pop3-read-response process t)
-       (signal 'elmo-open-error
-               '(elmo-pop-auth-digest-md5)))))
-
 (luna-define-method elmo-network-initialize-session-buffer :after
   ((session elmo-pop3-session) buffer)
   (with-current-buffer buffer
 
 (luna-define-method elmo-network-authenticate-session ((session
                                                        elmo-pop3-session))
-  (let (authenticator)
-    ;; defaults to 'user.
-    (unless (elmo-network-session-auth-internal session)
-      (elmo-network-session-set-auth-internal session 'user))
-    (setq authenticator
-         (nth 1 (assq (elmo-network-session-auth-internal session)
-                      elmo-pop3-authenticator-alist)))
-    (unless authenticator (error "There's no authenticator for %s"
-                                (elmo-network-session-auth-internal session)))
-    (funcall authenticator session)))
+  (with-current-buffer (process-buffer 
+                       (elmo-network-session-process-internal session))
+    (let* ((process (elmo-network-session-process-internal session))
+          (auth (elmo-network-session-auth-internal session))
+          (auth (mapcar '(lambda (mechanism) (upcase (symbol-name mechanism)))
+                        (if (listp auth) auth (list auth))))
+          client name step response mechanism
+          sasl-read-passphrase)
+      (or (and (string= "USER" (car auth))
+              (elmo-pop3-auth-user session))
+         (and (string= "APOP" (car auth))
+              (elmo-pop3-auth-apop session))
+         (progn
+           (setq mechanism (sasl-find-mechanism auth))
+           (unless mechanism
+             (signal 'elmo-authenticate-error '(elmo-pop3-auth-no-mechanisms)))
+           (setq client
+                 (sasl-make-client
+                  mechanism
+                  (elmo-network-session-user-internal session)
+                  "pop"
+                  (elmo-network-session-host-internal session)))
+;;;        (if elmo-pop3-auth-user-realm
+;;;            (sasl-client-set-property client 'realm elmo-pop3-auth-user-realm))
+           (setq name (sasl-mechanism-name mechanism))
+           (elmo-network-session-set-auth-internal session
+                                                   (intern (downcase name)))
+           (setq sasl-read-passphrase
+                 (function
+                  (lambda (prompt)
+                    (elmo-get-passwd
+                     (elmo-network-session-password-key session)))))
+           (setq step (sasl-next-step client nil))
+           (elmo-pop3-send-command
+            process
+            (concat "AUTH " name
+                    (and (sasl-step-data step)
+                         (concat 
+                          " "
+                          (elmo-base64-encode-string
+                           (sasl-step-data step) 'no-line-break))))) ;)
+           (catch 'done
+             (while t
+               (unless (setq response (elmo-pop3-read-response process t))
+                 (signal 'elmo-authenticate-error
+                         (list (intern
+                                (concat "elmo-pop3-auth-"
+                                        (downcase name))))))
+               (if (string-match "^\+OK" response)
+                   (if (sasl-next-step client step)
+                       (signal 'elmo-authenticate-error
+                               (list (intern
+                                      (concat "elmo-pop3-auth-"
+                                              (downcase name)))))
+                     (throw 'done nil)))
+               (sasl-step-set-data
+                step
+                (elmo-base64-decode-string 
+                 (cadr (split-string response " "))))
+               (setq step (sasl-next-step client step))
+               (elmo-pop3-send-command
+                process
+                (if (sasl-step-data step)
+                    (elmo-base64-encode-string (sasl-step-data step)
+                                               'no-line-break)
+                  "")))))))))
 
 (luna-define-method elmo-network-setup-session ((session
                                                 elmo-pop3-session))
index 164b79a..0f29e83 100644 (file)
@@ -899,6 +899,31 @@ Otherwise treat \\ in NEWTEXT string as special:
    (goto-char (point-min))
    (read (current-buffer))))
 
+(defun elmo-list-to-string (list)
+  (let ((tlist list)
+       str)
+    (if (listp tlist)
+       (progn
+         (setq str "(")
+         (while (car tlist)
+           (setq str
+                 (concat str
+                         (if (symbolp (car tlist))
+                             (symbol-name (car tlist))
+                           (car tlist))))
+           (if (cdr tlist)
+               (setq str
+                     (concat str " ")))
+           (setq tlist (cdr tlist)))
+         (setq str
+               (concat str ")")))
+      (setq str 
+           (if (symbolp tlist)
+               (symbol-name tlist)
+             tlist)))
+    str))
+
 (defun elmo-plug-on-by-servers (alist &optional servers)
   (let ((server-list (or servers elmo-plug-on-servers)))
     (catch 'plugged
index 33ee179..8208aaf 100644 (file)
@@ -598,15 +598,6 @@ without cacheing."
   "Just return number-alist."
   number-alist)
 
-(defun elmo-generic-list-folder-unread (spec number-alist mark-alist
-                                            unread-marks)
-  (delq nil
-       (mapcar
-        (function (lambda (x)
-                    (if (member (cadr (assq (car x) mark-alist)) unread-marks)
-                        (car x))))
-        mark-alist)))
-
 (defun elmo-generic-list-folder-important (spec number-alist)
   nil)
 
@@ -711,86 +702,6 @@ If optional argumnet NUMBER-LIST is set, it is used as a
 message list in msgdb. Otherwise, number-list is load from msgdb."
   (elmo-call-func folder "folder-diff" folder number-list))
 
-(defun elmo-generic-folder-diff (spec folder &optional number-list)
-  (let ((cached-in-db-max (elmo-folder-get-info-max folder))
-       (in-folder (elmo-max-of-folder folder))
-       (in-db t)
-       unsync messages
-       in-db-max)
-    (if (or number-list (not cached-in-db-max))
-       (let ((number-list (or number-list
-                              (mapcar 'car
-                                      (elmo-msgdb-number-load
-                                       (elmo-msgdb-expand-path folder))))))
-         ;; No info-cache.
-         (setq in-db (sort number-list '<))
-         (setq in-db-max (or (nth (max 0 (1- (length in-db))) in-db)
-                             0))
-         (if (not number-list)
-             (elmo-folder-set-info-hashtb folder in-db-max nil)))
-      (setq in-db-max cached-in-db-max))
-    (setq unsync (if (and in-db
-                         (car in-folder))
-                    (- (car in-folder) in-db-max)
-                  (if (and in-folder
-                           (null in-db))
-                      (cdr in-folder)
-                    (if (null (car in-folder))
-                        nil))))
-    (setq messages (cdr in-folder))
-    (if (and unsync messages (> unsync messages))
-       (setq unsync messages))
-    (cons (or unsync 0) (or messages 0))))
-
-(defsubst elmo-folder-get-info (folder &optional hashtb)
-  (elmo-get-hash-val folder
-                    (or hashtb elmo-folder-info-hashtb)))
-
-(defun elmo-folder-set-info-hashtb (folder max numbers &optional new unread)
-  (let ((info (elmo-folder-get-info folder)))
-    (when info
-      (or new     (setq new     (nth 0 info)))
-      (or unread  (setq unread  (nth 1 info)))
-      (or numbers (setq numbers (nth 2 info)))
-      (or max     (setq max     (nth 3 info))))
-    (elmo-set-hash-val folder
-                      (list new unread numbers max)
-                      elmo-folder-info-hashtb)))
-
-(defun elmo-folder-set-info-max-by-numdb (folder msgdb-number)
-  (let ((num-db (sort (mapcar 'car msgdb-number) '<)))
-    (elmo-folder-set-info-hashtb
-     folder
-     (or (nth (max 0 (1- (length num-db))) num-db) 0)
-     nil ;;(length num-db)
-     )))
-
-(defun elmo-folder-get-info-max (folder)
-  "Get folder info from cache."
-  (nth 3 (elmo-folder-get-info folder)))
-
-(defun elmo-folder-get-info-length (folder)
-  (nth 2 (elmo-folder-get-info folder)))
-
-(defun elmo-folder-get-info-unread (folder)
-  (nth 1 (elmo-folder-get-info folder)))
-
-(defun elmo-folder-info-make-hashtb (info-alist hashtb)
-  (let* ((hashtb (or hashtb
-                    (elmo-make-hash (length info-alist)))))
-    (mapcar
-     '(lambda (x)
-       (let ((info (cadr x)))
-         (and (intern-soft (car x) hashtb)
-              (elmo-set-hash-val (car x)
-                                 (list (nth 2 info)   ;; new
-                                       (nth 3 info)   ;; unread
-                                       (nth 1 info)   ;; length
-                                       (nth 0 info))  ;; max
-                                 hashtb))))
-     info-alist)
-    (setq elmo-folder-info-hashtb hashtb)))
-
 (defun elmo-crosspost-message-set (message-id folders &optional type)
   (if (assoc message-id elmo-crosspost-message-alist)
       (setcdr (assoc message-id elmo-crosspost-message-alist)