2000-10-09 Yuuichi Teranishi <teranisi@gohome.org>
authorteranisi <teranisi>
Tue, 10 Oct 2000 00:56:26 +0000 (00:56 +0000)
committerteranisi <teranisi>
Tue, 10 Oct 2000 00:56:26 +0000 (00:56 +0000)
* elmo2.el (elmo-copy-msgs): Set `spec' as 1st argument for
`elmo-msgdb-expand-path'.
(elmo-msgdb-load): Ditto.
Abolished 2nd argument. If 1st argument is not string, treat as spec.
(elmo-generic-list-folder-unread): Rewrite.
(elmo-generic-list-folder-important): Changed argument.
(elmo-list-folder-unread): Ditto.
(elmo-list-folder-important): Ditto.
(elmo-folder-diff): Rewrite.
(elmo-generic-folder-diff): New function.
(elmo-multi-get-number-alist-list): Abolished
(Renamed to elmo-multi-split-number-alist and moved to elmo-multi.el)
(elmo-multi-folder-diff): Moved to elmo-multi.el
(toplevel): Removed autoload setting of `elmo-multi-folder-diff'.

* elmo-pop3.el (elmo-pop3-list-folder): Set `spec' as 1st argument for
`elmo-msgdb-expand-path'.
(elmo-pop3-msgdb-create-as-numlist): Ditto.
(elmo-pop3-read-msg): Ditto.
(elmo-pop3-delete-msgs): Ditto.
(elmo-pop3-folder-diff): New alias.

* elmo-pipe.el (elmo-pipe-list-folder): Set `spec' as 1st argument for
`elmo-msgdb-expand-path'.
(elmo-pipe-list-folder-unread): Changed arguments.
(elmo-pipe-list-folder-important): Ditto.
(elmo-pipe-folder-diff): New alias.

* elmo-nntp.el (elmo-nntp-list-folder): Set `spec' as 1st argument for
`elmo-msgdb-expand-path'.
(elmo-nntp-max-of-folder): Ditto.
(elmo-nntp-msgdb-create): Ditto.
(elmo-nntp-delete-msgs): Ditto.
(elmo-nntp-folder-diff): New alias.

* elmo-multi.el (elmo-multi-folder-diff): New function.
(elmo-multi-split-mark-alist): Ditto.
(elmo-multi-split-number-alist): Ditto.
(elmo-multi-mark-alist-list): Abolished (Renamed to
elmo-multi-split-mark-alist).
(elmo-multi-list-folder-unread): Rewrite.
(elmo-multi-list-folder-important): Ditto.
(elmo-multi-list-folder): Set `spec' as 1st argument for
`elmo-msgdb-expand-path'.
(elmo-multi-sync-number-alist): Use `elmo-multi-split-number-alist'
instead of `elmo-multi-get-number-alist-list'.

* elmo-msgdb.el (elmo-msgdb-expand-path): Abolished 2nd argument.
If 1st argument is not string, treat as spec.
(elmo-list-folder-by-location): Set `spec' as 1st argument for
`elmo-msgdb-expand-path'.
(elmo-msgdb-flist-load): Ditto.
(elmo-msgdb-flist-save): Ditto.
(elmo-msgdb-delete-path): Ditto.
(elmo-msgdb-rename-path): Ditto.

* elmo-maildir.el (elmo-maildir-set-mark-msgs):
Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
(elmo-maildir-delete-mark-msgs): Ditto.
(elmo-maildir-msgdb-create): Ditto.
(elmo-maildir-read-msg): Ditto.
(elmo-maildir-delete-msgs): Ditto.
(elmo-maildir-list-folder-subr): Ditto.
(elmo-maildir-search): Ditto.
(elmo-maildir-get-msg-filename): Ditto.
(elmo-maildir-pack-number): Ditto.
(elmo-maildir-folder-diff): New alias.

* elmo-localnews.el (elmo-localnews-folder-diff): New alias.

* elmo-localdir.el (elmo-localdir-list-folder-subr):
Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
(elmo-localdir-folder-diff): New alias.

* elmo-internal.el (elmo-internal-list-folder-subr):
Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
(elmo-internal-list-folder-by-location): Ditto.
(elmo-internal-msgdb-create): Ditto.
(elmo-internal-delete-msgs): Ditto.
(elmo-internal-read-msg): Ditto.
(elmo-internal-folder-diff): New alias.

* elmo-imap4.el (elmo-imap4-folder-diff): New function.
(elmo-imap4-list-folder): Set `spec' as 1st argument for
`elmo-msgdb-expand-path'.
(elmo-imap4-list-folder-unread): Changed arguments.
(elmo-imap4-list-folder-important): Ditto.

* elmo-filter.el (elmo-filter-list-folder-unread): Changed arguments.
(elmo-filter-list-folder-important): Ditto.
(elmo-filter-folder-diff): New function.

* elmo-dop.el (elmo-dop-folder-exists-p): Check elmo directory first.

* elmo-cache.el (elmo-cache-list-folder):
Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
(elmo-cache-copy-msgs): Ditto.
(elmo-cache-folder-diff): New alias.

* elmo-archive.el (elmo-archive-list-folder-subr):
Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
(elmo-archive-get-archive-name): Ditto.
(elmo-archive-create-file): Ditto.
(elmo-archive-append-msg): Ditto.
(elmo-archive-copy-msgs): Ditto.
(elmo-archive-copy-msgs-froms): Ditto.
(elmo-archive-get-msg-filename): Ditto.
(elmo-archive-folder-diff): New alias.

16 files changed:
elmo/ChangeLog
elmo/elmo-archive.el
elmo/elmo-cache.el
elmo/elmo-dop.el
elmo/elmo-filter.el
elmo/elmo-imap4.el
elmo/elmo-internal.el
elmo/elmo-localdir.el
elmo/elmo-localnews.el
elmo/elmo-maildir.el
elmo/elmo-msgdb.el
elmo/elmo-multi.el
elmo/elmo-nntp.el
elmo/elmo-pipe.el
elmo/elmo-pop3.el
elmo/elmo2.el

index c8cf70a..0d5f011 100644 (file)
@@ -1,3 +1,114 @@
+2000-10-09  Yuuichi Teranishi  <teranisi@gohome.org>
+
+       * elmo2.el (elmo-copy-msgs): Set `spec' as 1st argument for
+       `elmo-msgdb-expand-path'.
+       (elmo-msgdb-load): Ditto.
+       Abolished 2nd argument. If 1st argument is not string, treat as spec.
+       (elmo-generic-list-folder-unread): Rewrite.
+       (elmo-generic-list-folder-important): Changed argument.
+       (elmo-list-folder-unread): Ditto.
+       (elmo-list-folder-important): Ditto.
+       (elmo-folder-diff): Rewrite.
+       (elmo-generic-folder-diff): New function.
+       (elmo-multi-get-number-alist-list): Abolished
+       (Renamed to elmo-multi-split-number-alist and moved to elmo-multi.el)
+       (elmo-multi-folder-diff): Moved to elmo-multi.el
+       (toplevel): Removed autoload setting of `elmo-multi-folder-diff'.
+
+       * elmo-pop3.el (elmo-pop3-list-folder): Set `spec' as 1st argument for
+       `elmo-msgdb-expand-path'.
+       (elmo-pop3-msgdb-create-as-numlist): Ditto.
+       (elmo-pop3-read-msg): Ditto.
+       (elmo-pop3-delete-msgs): Ditto.
+       (elmo-pop3-folder-diff): New alias.
+
+       * elmo-pipe.el (elmo-pipe-list-folder): Set `spec' as 1st argument for
+       `elmo-msgdb-expand-path'.
+       (elmo-pipe-list-folder-unread): Changed arguments.
+       (elmo-pipe-list-folder-important): Ditto.
+       (elmo-pipe-folder-diff): New alias.
+
+       * elmo-nntp.el (elmo-nntp-list-folder): Set `spec' as 1st argument for
+       `elmo-msgdb-expand-path'.
+       (elmo-nntp-max-of-folder): Ditto.
+       (elmo-nntp-msgdb-create): Ditto.
+       (elmo-nntp-delete-msgs): Ditto.
+       (elmo-nntp-folder-diff): New alias.
+
+       * elmo-multi.el (elmo-multi-folder-diff): New function.
+       (elmo-multi-split-mark-alist): Ditto.
+       (elmo-multi-split-number-alist): Ditto.
+       (elmo-multi-mark-alist-list): Abolished (Renamed to
+       elmo-multi-split-mark-alist).
+       (elmo-multi-list-folder-unread): Rewrite.
+       (elmo-multi-list-folder-important): Ditto.
+       (elmo-multi-list-folder): Set `spec' as 1st argument for
+       `elmo-msgdb-expand-path'.
+       (elmo-multi-sync-number-alist): Use `elmo-multi-split-number-alist'
+       instead of `elmo-multi-get-number-alist-list'.
+
+       * elmo-msgdb.el (elmo-msgdb-expand-path): Abolished 2nd argument.
+       If 1st argument is not string, treat as spec.
+       (elmo-list-folder-by-location): Set `spec' as 1st argument for
+       `elmo-msgdb-expand-path'.
+       (elmo-msgdb-flist-load): Ditto.
+       (elmo-msgdb-flist-save): Ditto.
+       (elmo-msgdb-delete-path): Ditto.
+       (elmo-msgdb-rename-path): Ditto.
+
+       * elmo-maildir.el (elmo-maildir-set-mark-msgs):
+       Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
+       (elmo-maildir-delete-mark-msgs): Ditto.
+       (elmo-maildir-msgdb-create): Ditto.
+       (elmo-maildir-read-msg): Ditto.
+       (elmo-maildir-delete-msgs): Ditto.
+       (elmo-maildir-list-folder-subr): Ditto.
+       (elmo-maildir-search): Ditto.
+       (elmo-maildir-get-msg-filename): Ditto.
+       (elmo-maildir-pack-number): Ditto.
+       (elmo-maildir-folder-diff): New alias.
+
+       * elmo-localnews.el (elmo-localnews-folder-diff): New alias.
+
+       * elmo-localdir.el (elmo-localdir-list-folder-subr):
+       Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
+       (elmo-localdir-folder-diff): New alias.
+
+       * elmo-internal.el (elmo-internal-list-folder-subr):
+       Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
+       (elmo-internal-list-folder-by-location): Ditto.
+       (elmo-internal-msgdb-create): Ditto.
+       (elmo-internal-delete-msgs): Ditto.
+       (elmo-internal-read-msg): Ditto.
+       (elmo-internal-folder-diff): New alias.
+
+       * elmo-imap4.el (elmo-imap4-folder-diff): New function.
+       (elmo-imap4-list-folder): Set `spec' as 1st argument for
+       `elmo-msgdb-expand-path'.
+       (elmo-imap4-list-folder-unread): Changed arguments.
+       (elmo-imap4-list-folder-important): Ditto.
+
+       * elmo-filter.el (elmo-filter-list-folder-unread): Changed arguments.
+       (elmo-filter-list-folder-important): Ditto.
+       (elmo-filter-folder-diff): New function.
+
+       * elmo-dop.el (elmo-dop-folder-exists-p): Check elmo directory first.
+
+       * elmo-cache.el (elmo-cache-list-folder):
+       Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
+       (elmo-cache-copy-msgs): Ditto.
+       (elmo-cache-folder-diff): New alias.
+
+       * elmo-archive.el (elmo-archive-list-folder-subr):
+       Set `spec' as 1st argument for `elmo-msgdb-expand-path'.
+       (elmo-archive-get-archive-name): Ditto.
+       (elmo-archive-create-file): Ditto.
+       (elmo-archive-append-msg): Ditto.
+       (elmo-archive-copy-msgs): Ditto.
+       (elmo-archive-copy-msgs-froms): Ditto.
+       (elmo-archive-get-msg-filename): Ditto.
+       (elmo-archive-folder-diff): New alias.
+
 2000-10-06   Daiki Ueno  <ueno@unixuser.org>
 
        * elmo-vars.el (elmo-imap4-stream-type-alist): New variable.
index 0fb7ed0..510fc78 100644 (file)
@@ -243,7 +243,7 @@ TYPE specifies the archiver's symbol."
                              (elmo-concat-path (regexp-quote prefix) "")))
         (killed (and elmo-use-killed-list
                      (elmo-msgdb-killed-list-load
-                      (elmo-msgdb-expand-path nil spec))))
+                      (elmo-msgdb-expand-path spec))))
         numbers buf file-list header-end)
     (when (file-exists-p file)
       (save-excursion
@@ -316,7 +316,7 @@ TYPE specifies the archiver's symbol."
            (progn
              (setq filename (expand-file-name
                              (concat elmo-archive-basename suffix)
-                             (setq dbdir (elmo-msgdb-expand-path nil spec))))
+                             (setq dbdir (elmo-msgdb-expand-path spec))))
              (if (file-directory-p dbdir)
                  (); ok.
                (if (file-exists-p dbdir)
@@ -363,7 +363,7 @@ TYPE specifies the archiver's symbol."
 (defun elmo-archive-create-file (archive type spec)
   (save-excursion
     (let* ((tmp-dir (directory-file-name
-                    (elmo-msgdb-expand-path nil spec)))
+                    (elmo-msgdb-expand-path spec)))
            (dummy elmo-archive-dummy-file)
            (method (or (elmo-archive-get-method type 'create)
                       (elmo-archive-get-method type 'mv)))
@@ -480,7 +480,7 @@ TYPE specifies the archiver's symbol."
         (next-num (or msg
                       (1+ (if (file-exists-p arc)
                               (car (elmo-archive-max-of-folder spec)) 0))))
-        (tmp-dir (elmo-msgdb-expand-path nil spec))
+        (tmp-dir (elmo-msgdb-expand-path spec))
         newfile)
     (when (null method)
       (ding)
@@ -519,7 +519,7 @@ TYPE specifies the archiver's symbol."
                (1+ (car (elmo-archive-max-of-folder dst-spec)))))
         (src-dir (elmo-localdir-get-folder-directory src-spec))
         (tmp-dir
-         (file-name-as-directory (elmo-msgdb-expand-path nil dst-spec)))
+         (file-name-as-directory (elmo-msgdb-expand-path dst-spec)))
         (do-link t)
         src tmp newfile tmp-msgs)
     (when (not (elmo-archive-folder-exists-p dst-spec))
@@ -583,7 +583,7 @@ TYPE specifies the archiver's symbol."
         (p-method (elmo-archive-get-method src-type 'ext-pipe))
         (n-method (elmo-archive-get-method src-type 'ext))
         (tmp-dir
-         (file-name-as-directory (elmo-msgdb-expand-path nil src-spec)))
+         (file-name-as-directory (elmo-msgdb-expand-path src-spec)))
         (tmp-msgs (mapcar '(lambda (x) (elmo-concat-path
                                         prefix
                                         (int-to-string x)))
@@ -1049,7 +1049,7 @@ TYPE specifies the archiver's symbol."
   nil)
 
 (defun elmo-archive-get-msg-filename (spec number &optional loc-alist)
-  (let ((tmp-dir (file-name-as-directory (elmo-msgdb-expand-path nil spec)))
+  (let ((tmp-dir (file-name-as-directory (elmo-msgdb-expand-path spec)))
        (prefix (nth 3 spec)))
     (expand-file-name
      (elmo-concat-path prefix (int-to-string number))
@@ -1062,6 +1062,7 @@ TYPE specifies the archiver's symbol."
 (defalias 'elmo-archive-list-folder-important
   'elmo-generic-list-folder-important)
 (defalias 'elmo-archive-commit 'elmo-generic-commit)
+(defalias 'elmo-archive-folder-diff 'elmo-generic-folder-diff)
 
 ;;; End
 (run-hooks 'elmo-archive-load-hook)
index 24ab6c6..93c96e5 100644 (file)
@@ -662,7 +662,7 @@ Returning its cache buffer."
 (defun elmo-cache-list-folder (spec); called by elmo-cache-search()
   (let ((killed (and elmo-use-killed-list
                     (elmo-msgdb-killed-list-load
-                     (elmo-msgdb-expand-path nil spec))))
+                     (elmo-msgdb-expand-path spec))))
        numbers)
     (setq numbers (elmo-cache-list-folder-subr spec))
     (elmo-living-messages numbers killed)))
@@ -716,7 +716,7 @@ Returning its cache buffer."
        (next-num (1+ (car (elmo-cache-list-folder-subr dst-spec t))))
        (number-alist
         (elmo-msgdb-number-load
-         (elmo-msgdb-expand-path nil src-spec))))
+         (elmo-msgdb-expand-path src-spec))))
     (if same-number (error "Not implemented"))
     (while msgs
       (elmo-copy-file
@@ -750,6 +750,7 @@ Returning its cache buffer."
 (defalias 'elmo-cache-list-folder-important
   'elmo-generic-list-folder-important)
 (defalias 'elmo-cache-commit 'elmo-generic-commit)
+(defalias 'elmo-cache-folder-diff 'elmo-generic-folder-diff)
 
 (provide 'elmo-cache)
 
index 2b32066..9d25d41 100644 (file)
@@ -419,10 +419,11 @@ even an operation concerns the unplugged folder."
   (message "Appending queued messages...done."))
 
 (defun elmo-dop-folder-exists-p (folder)
-  (if (and elmo-enable-disconnected-operation
-          (eq (elmo-folder-get-type folder) 'imap4))
-      (file-exists-p (elmo-msgdb-expand-path folder))
-    (elmo-call-func folder "folder-exists-p")))
+  (or (file-exists-p (elmo-msgdb-expand-path folder))
+      (if (and elmo-enable-disconnected-operation
+              (eq (elmo-folder-get-type folder) 'imap4))
+         (file-exists-p (elmo-msgdb-expand-path folder))
+       (elmo-call-func folder "folder-exists-p"))))
 
 (defun elmo-dop-create-folder (folder)
   (if (eq (elmo-folder-get-type folder) 'imap4)
index 2490bc6..413096f 100644 (file)
 (defun elmo-filter-list-folder (spec)
   (elmo-search (nth 2 spec) (nth 1 spec)))
 
-(defun elmo-filter-list-folder-unread (spec msgdb unread-marks)
+(defun elmo-filter-list-folder-unread (spec number-alist mark-alist
+                                           unread-marks)
   (elmo-list-filter
-   (mapcar 'car (elmo-msgdb-get-number-alist msgdb))
+   (mapcar 'car number-alist)
    (elmo-list-folder-unread
-    (nth 2 spec) msgdb unread-marks)))
+    (nth 2 spec) number-alist mark-alist unread-marks)))
 
-(defun elmo-filter-list-folder-important (spec msgdb)
+(defun elmo-filter-list-folder-important (spec number-alist)
   (elmo-list-filter
-   (mapcar 'car (elmo-msgdb-get-number-alist msgdb))
-   (elmo-list-folder-important
-    (nth 2 spec)
-    msgdb)))
+   (mapcar 'car number-alist)
+   (elmo-list-folder-important (nth 2 spec) number-alist)))
+
+(defun elmo-filter-folder-diff (spec folder &optional number-list)
+  (if (or (elmo-multi-p folder)
+         (not (and (vectorp (nth 1 spec))
+                   (string-match "^first$\\|^last$"
+                                 (elmo-filter-key (nth 1 spec))))))
+      (cons nil (cdr (elmo-folder-diff (nth 2 spec))))
+    (elmo-generic-folder-diff spec folder number-list)))
 
 (defun elmo-filter-max-of-folder (spec)
   (elmo-max-of-folder (nth 2 spec)))
index 2c6e555..d1957a2 100644 (file)
@@ -57,7 +57,8 @@
   (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 msgdb unread-marks))
+  (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))
 
 (defvar elmo-imap4-use-lock t
@@ -633,12 +634,11 @@ BUFFER must be a single-byte buffer."
      (- (elmo-imap4-response-value status 'uidnext) 1)
      (elmo-imap4-response-value status 'messages))))
 
-;      (when (and response (string-match
-;                         "\\* STATUS [^(]* \\(([^)]*)\\)" response))
-;      (setq response (read (downcase (elmo-match-string 1 response))))
-;      (cons (- (cadr (memq 'uidnext response)) 1)
-;            (cadr (memq 'messages response)))))))
-
+(defun elmo-imap4-folder-diff (spec folder &optional number-list)
+  (if elmo-use-server-diff
+      (elmo-imap4-server-diff spec)
+    (elmo-generic-folder-diff spec folder number-list)))
+    
 (defun elmo-imap4-get-session (spec &optional if-exists)
   (elmo-network-get-session
    'elmo-imap4-session
@@ -718,17 +718,19 @@ BUFFER must be a single-byte buffer."
 (defun elmo-imap4-list-folder (spec)
   (let ((killed (and elmo-use-killed-list
                     (elmo-msgdb-killed-list-load
-                     (elmo-msgdb-expand-path nil spec))))
+                     (elmo-msgdb-expand-path spec))))
        numbers)
     (setq numbers (elmo-imap4-list spec "all"))
     (elmo-living-messages numbers killed)))
 
-(defun elmo-imap4-list-folder-unread (spec msgdb unread-marks)
+(defun elmo-imap4-list-folder-unread (spec number-alist mark-alist
+                                          unread-marks)
   (if (elmo-imap4-use-flag-p spec)
       (elmo-imap4-list spec "unseen")
-    (elmo-generic-list-folder-unread spec msgdb unread-marks)))
+    (elmo-generic-list-folder-unread spec number-alist mark-alist
+                                    unread-marks)))
 
-(defun elmo-imap4-list-folder-important (spec msgdb)
+(defun elmo-imap4-list-folder-important (spec number-alist)
   (and (elmo-imap4-use-flag-p spec)
        (elmo-imap4-list spec "flagged")))
 
index 4288b66..6c33211 100644 (file)
@@ -38,7 +38,7 @@
                 (elmo-internal-list-location directive arg)))
         (killed (and elmo-use-killed-list
                      (elmo-msgdb-killed-list-load
-                      (elmo-msgdb-expand-path nil spec))))
+                      (elmo-msgdb-expand-path spec))))
         numbers)
     (if nonsort
        (cons (or (elmo-max-of-list flist) 0)
@@ -52,7 +52,7 @@
   (elmo-internal-list-folder-subr spec))
 
 (defun elmo-internal-list-folder-by-location (spec location &optional msgdb)
-  (let* ((path (elmo-msgdb-expand-path nil spec))
+  (let* ((path (elmo-msgdb-expand-path spec))
         (location-alist
          (if msgdb
              (elmo-msgdb-get-location msgdb)
           (arg       (nth 2 spec))
           (loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                        (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                                  nil spec))))
+                                                  spec))))
           (loc-list (elmo-internal-list-location directive arg))
           overview number-alist mark-alist entity
           i percent num location pair)
 (defun elmo-internal-delete-msgs (spec msgs &optional msgdb)
   (let ((loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                     (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                               nil spec)))))
+                                               spec)))))
     (mapcar '(lambda (msg) (elmo-internal-delete-msg spec msg
                                                     loc-alist))
            msgs)))
   (save-excursion
     (let* ((loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                        (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                                  nil spec))))
+                                                  spec))))
           (file (elmo-cache-get-path (cdr (assq number loc-alist)))))
       (set-buffer outbuf)
       (erase-buffer)
                                      elmo-msgdb-dir)))))
         (loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                      (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                                nil spec))))
+                                                spec))))
         (number-list (mapcar 'car loc-alist))
         cache-file
         ret-val
 (defalias 'elmo-internal-list-folder-important
   'elmo-generic-list-folder-important)
 (defalias 'elmo-internal-commit 'elmo-generic-commit)
+(defalias 'elmo-internal-folder-diff 'elmo-generic-folder-diff)
 
 (provide 'elmo-internal)
 
index 55be0ef..6ef6eff 100644 (file)
                        (directory-files dir nil "^[0-9]+$" t)))
         (killed (and elmo-use-killed-list
                      (elmo-msgdb-killed-list-load
-                      (elmo-msgdb-expand-path nil spec))))
+                      (elmo-msgdb-expand-path spec))))
         numbers)
     (if nonsort
        (cons (or (elmo-max-of-list flist) 0)
 (defalias 'elmo-localdir-list-folder-important
   'elmo-generic-list-folder-important)
 (defalias 'elmo-localdir-commit 'elmo-generic-commit)
+(defalias 'elmo-localdir-folder-diff 'elmo-generic-folder-diff)
 
 (provide 'elmo-localdir)
 
index 24af2fa..2cf3337 100644 (file)
 (defalias 'elmo-localnews-list-folder-important
   'elmo-generic-list-folder-important)
 (defalias 'elmo-localnews-commit 'elmo-generic-commit)
+(defalias 'elmo-localnews-folder-diff 'elmo-generic-folder-diff)
 
 (provide 'elmo-localnews)
 
index 9b2e6ec..12da26c 100644 (file)
@@ -148,7 +148,7 @@ This variable should not be used in elsewhere.")
   (let ((dir (elmo-maildir-get-folder-directory spec))
        (locs (if msgdb
                  (elmo-msgdb-get-location msgdb)
-               (elmo-msgdb-location-load (elmo-msgdb-expand-path nil spec))))
+               (elmo-msgdb-location-load (elmo-msgdb-expand-path spec))))
        file)
     (while msgs
       (if (setq file (elmo-maildir-number-to-filename dir (car msgs) locs))
@@ -159,7 +159,7 @@ This variable should not be used in elsewhere.")
   (let ((dir (elmo-maildir-get-folder-directory spec))
        (locs (if msgdb
                  (elmo-msgdb-get-location msgdb)
-               (elmo-msgdb-location-load (elmo-msgdb-expand-path nil spec))))
+               (elmo-msgdb-location-load (elmo-msgdb-expand-path spec))))
        file)
     (while msgs
       (if (setq file (elmo-maildir-number-to-filename dir (car msgs) locs))
@@ -187,7 +187,7 @@ This variable should not be used in elsewhere.")
     (let* ((dir (elmo-maildir-get-folder-directory spec))
           (loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                        (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                                  nil spec))))
+                                                  spec))))
           (loc-seen (elmo-maildir-list-location dir))
           (loc-list  (car loc-seen))
           (seen-list (cdr loc-seen))
@@ -329,7 +329,7 @@ file name for maildir directories."
   (save-excursion
     (let* ((loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                        (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                                  nil spec))))
+                                                  spec))))
           (dir (elmo-maildir-get-folder-directory spec))
           (file (elmo-maildir-number-to-filename dir number loc-alist)))
       (set-buffer outbuf)
@@ -341,7 +341,7 @@ file name for maildir directories."
 (defun elmo-maildir-delete-msgs (spec msgs &optional msgdb)
   (let ((loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                     (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                               nil spec)))))
+                                               spec)))))
     (mapcar '(lambda (msg) (elmo-maildir-delete-msg spec msg
                                                    loc-alist))
            msgs)))
@@ -353,7 +353,7 @@ file name for maildir directories."
                 (car (elmo-maildir-list-location dir))))
         (killed (and elmo-use-killed-list
                      (elmo-msgdb-killed-list-load
-                      (elmo-msgdb-expand-path nil spec))))
+                      (elmo-msgdb-expand-path spec))))
         (news (car (elmo-maildir-list-location dir "new")))
         numbers)
     (if nonsort
@@ -423,7 +423,7 @@ file name for maildir directories."
     (let* ((msgs (or from-msgs (elmo-maildir-list-folder spec)))
           (loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                        (elmo-msgdb-location-load (elmo-msgdb-expand-path
-                                                  nil spec))))
+                                                  spec))))
           (dir (elmo-maildir-get-folder-directory spec))
           (i 0)
           case-fold-search ret-val
@@ -474,7 +474,7 @@ file name for maildir directories."
    (elmo-maildir-get-folder-directory spec)
    number (or loc-alist (elmo-msgdb-location-load
                         (elmo-msgdb-expand-path
-                         nil spec)))))
+                         spec)))))
 
 (defun elmo-maildir-pack-number (spec msgdb arg)
   (let ((old-number-alist (elmo-msgdb-get-number-alist msgdb))
@@ -501,7 +501,7 @@ file name for maildir directories."
       (setq number (1+ number))
       (setq old-overview (cdr old-overview)))
     ;; XXX Should consider when folder is not persistent.
-    (elmo-msgdb-location-save (elmo-msgdb-expand-path nil spec) location)
+    (elmo-msgdb-location-save (elmo-msgdb-expand-path spec) location)
     (list overview
          (nreverse number-alist)
          (nreverse mark-alist)
@@ -515,6 +515,7 @@ file name for maildir directories."
 (defalias 'elmo-maildir-list-folder-important
   'elmo-generic-list-folder-important)
 (defalias 'elmo-maildir-commit 'elmo-generic-commit)
+(defalias 'elmo-maildir-folder-diff 'elmo-generic-folder-diff)
 
 (provide 'elmo-maildir)
 
index 300fe8e..8e5f119 100644 (file)
 (require 'std11)
 (require 'elmo-cache)
 
-(defun elmo-msgdb-expand-path (folder &optional spec)
+(defun elmo-msgdb-expand-path (folder)
+  "Expand msgdb path for FOLDER.
+FOLDER should be a sring of folder name or folder spec."
   (convert-standard-filename
-   (let* ((spec (or spec (elmo-folder-get-spec folder)))
+   (let* ((spec (if (stringp folder)
+                   (elmo-folder-get-spec folder)
+                 folder))
          (type (car spec))
          fld)
      (cond
     dir) alist))
 
 (defun elmo-list-folder-by-location (spec locations &optional msgdb)
-  (let* ((path (elmo-msgdb-expand-path nil spec))
+  (let* ((path (elmo-msgdb-expand-path spec))
         (location-alist (if msgdb
                             (elmo-msgdb-get-location msgdb)
                           (elmo-msgdb-location-load path)))
@@ -667,13 +671,13 @@ content of MSGDB is changed."
 (defun elmo-msgdb-flist-load (folder)
   (let ((flist-file (expand-file-name
                     elmo-msgdb-flist-filename
-                    (elmo-msgdb-expand-path folder (list 'folder folder)))))
+                    (elmo-msgdb-expand-path (list 'folder folder)))))
     (elmo-object-load flist-file nil t)))
 
 (defun elmo-msgdb-flist-save (folder flist)
   (let ((flist-file (expand-file-name
                     elmo-msgdb-flist-filename
-                    (elmo-msgdb-expand-path folder (list 'folder folder)))))
+                    (elmo-msgdb-expand-path (list 'folder folder)))))
     (elmo-object-save flist-file flist)))
 
 (defun elmo-crosspost-alist-load ()
@@ -791,13 +795,13 @@ Header region is supposed to be narrowed."
     (list nil nil nil nil (elmo-msgdb-make-overview-hashtb nil))))
 
 (defun elmo-msgdb-delete-path (folder &optional spec)
-  (let ((path (elmo-msgdb-expand-path folder spec)))
+  (let ((path (elmo-msgdb-expand-path (or spec folder))))
     (if (file-directory-p path)
        (elmo-delete-directory path t))))
 
 (defun elmo-msgdb-rename-path (old-folder new-folder &optional old-spec new-spec)
-  (let* ((old (directory-file-name (elmo-msgdb-expand-path old-folder old-spec)))
-        (new (directory-file-name (elmo-msgdb-expand-path new-folder new-spec)))
+  (let* ((old (directory-file-name (elmo-msgdb-expand-path old-spec)))
+        (new (directory-file-name (elmo-msgdb-expand-path new-spec)))
         (new-dir (directory-file-name (file-name-directory new))))
     (if (not (file-directory-p old))
        ()
index 4d1a4c0..f196354 100644 (file)
       (setq cur-number (+ 1 cur-number)))
     t))
 
-(defun elmo-multi-mark-alist-list (mark-alist)
+(defun elmo-multi-folder-diff (spec folder &optional number-list)
+  (let ((flds (cdr spec))
+       (num-alist-list
+        (elmo-multi-split-number-alist
+         (elmo-msgdb-number-load (elmo-msgdb-expand-path spec))))
+       (count 0)
+       (unsync 0)
+       (messages 0)
+       diffs)
+    (while flds
+      (setq diffs (nconc diffs (list (elmo-folder-diff
+                                     (car flds)
+                                     (mapcar 'car
+                                             (nth count num-alist-list))))))
+      (setq count (+ 1 count))
+      (setq flds (cdr flds)))
+    (while diffs
+      (and (car (car diffs))
+          (setq unsync (+ unsync (car (car diffs)))))
+      (setq messages  (+ messages (cdr (car diffs))))
+      (setq diffs (cdr diffs)))
+    (elmo-folder-set-info-hashtb folder
+                                nil messages)
+    (cons unsync messages)))
+
+(defun elmo-multi-split-mark-alist (mark-alist)
   (let ((cur-number 0)
        one-alist result)
     (while mark-alist
       (setq result (nconc result (list one-alist))))
     result))
 
-(defun elmo-multi-list-folder-unread (spec msgdb unread-marks)
-  (let* ((flds (cdr spec))
-        (cur-number 0)
-        (mark-alist (elmo-msgdb-get-mark-alist msgdb))
-        mark-alist-list
-        ret-val)
-    (setq mark-alist-list (elmo-multi-mark-alist-list mark-alist))
-    (while flds
+(defun elmo-multi-split-number-alist (number-alist)
+  (let ((alist number-alist)
+       (cur-number 0)
+       one-alist split num)
+    (while alist
       (setq cur-number (+ cur-number 1))
-      (setq ret-val (append
-                    ret-val
-                    (mapcar
-                     (function
-                      (lambda (x)
-                        (+
-                         (* elmo-multi-divide-number cur-number) x)))
-                     (elmo-list-folder-unread (car flds)
-                                              (car mark-alist-list)
-                                              unread-marks))))
-      (setq mark-alist-list (cdr mark-alist-list))
-      (setq flds (cdr flds)))
-    ret-val))
-
-(defun elmo-multi-list-folder-important (spec msgdb)
-  (let* ((flds (cdr spec))
-        (cur-number 0)
-        ret-val)
-    (while flds
-      (setq cur-number (+ cur-number 1))
-      (setq ret-val (append
-                    ret-val
+      (setq one-alist nil)
+      (while (and alist
+                 (eq 0
+                     (/ (- (setq num (car (car alist)))
+                           (* elmo-multi-divide-number cur-number))
+                        elmo-multi-divide-number)))
+       (setq one-alist (nconc
+                        one-alist
+                        (list
+                         (cons
+                          (% num (* elmo-multi-divide-number cur-number))
+                          (cdr (car alist))))))
+       (setq alist (cdr alist)))
+      (setq split (nconc split (list one-alist))))
+    split))
+
+(defun elmo-multi-list-folder-unread (spec number-alist mark-alist
+                                          unread-marks)
+  (let ((folders (cdr spec))
+       (cur-number 0)
+       (split-mark-alist (elmo-multi-split-mark-alist mark-alist))
+       (split-number-alist (elmo-multi-split-number-alist number-alist))
+       unreads)
+    (while folders
+      (setq cur-number (+ cur-number 1)
+           unreads (append
+                    unreads
                     (mapcar
                      (function
                       (lambda (x)
                         (+
                          (* elmo-multi-divide-number cur-number) x)))
-                     (elmo-list-folder-important (car flds)
-                                                 msgdb))))
-      (setq flds (cdr flds)))
-    ret-val))
+                     (elmo-list-folder-unread (car folders)
+                                              (car split-number-alist)
+                                              (car split-mark-alist)
+                                              unread-marks)))
+           split-number-alist (cdr split-number-alist)
+           split-mark-alist (cdr split-number-alist)
+           folders (cdr folders)))
+    unreads))
+
+(defun elmo-multi-list-folder-important (spec number-alist)
+  (let ((folders (cdr spec))
+       (cur-number 0)
+       (split-number-alist (elmo-multi-split-number-alist number-alist))
+       importants)
+    (while folders
+      (setq cur-number (+ cur-number 1)
+           importants (nconc
+                       importants
+                       (mapcar
+                        (function
+                         (lambda (x)
+                           (+ (* elmo-multi-divide-number cur-number) x)))
+                        (elmo-list-folder-important 
+                         (car folders)
+                         (car split-number-alist))))
+           folders (cdr folders)))
+    importants))
 
 (defun elmo-multi-list-folder (spec)
   (let* ((flds (cdr spec))
         (cur-number 0)
         (killed (and elmo-use-killed-list
                      (elmo-msgdb-killed-list-load
-                      (elmo-msgdb-expand-path nil spec))))
+                      (elmo-msgdb-expand-path spec))))
         numbers)
     (while flds
       (setq cur-number (+ cur-number 1))
 (defun elmo-multi-sync-number-alist (spec number-alist)
   (let ((folder-list (cdr spec))
        (number-alist-list
-        (elmo-multi-get-number-alist-list number-alist))
+        (elmo-multi-split-number-alist number-alist))
        (multi-base 0)
        append-alist result-alist)
     (while folder-list
index e51d97a..d8cd5c6 100644 (file)
@@ -484,7 +484,7 @@ Don't cache if nil.")
     (let* ((server (format "%s" server)) ;; delete text property
           (killed (and elmo-use-killed-list
                        (elmo-msgdb-killed-list-load
-                        (elmo-msgdb-expand-path nil spec))))
+                        (elmo-msgdb-expand-path spec))))
           response numbers use-listgroup)
       (save-excursion
        (when (setq use-listgroup (elmo-nntp-listgroup-p server port))
@@ -522,7 +522,7 @@ Don't cache if nil.")
         (server (elmo-nntp-spec-hostname spec))
         (type  (elmo-nntp-spec-stream-type spec))
         (folder (elmo-nntp-spec-group spec))
-        (dir (elmo-msgdb-expand-path nil spec))
+        (dir (elmo-msgdb-expand-path spec))
         (killed-list (and elmo-use-killed-list
                           (elmo-msgdb-killed-list-load dir)))
         number-alist end-num)
@@ -742,7 +742,7 @@ Don't cache if nil.")
                        seen-list
                        filter))))))
        (when elmo-use-killed-list
-         (setq dir (elmo-msgdb-expand-path nil spec))
+         (setq dir (elmo-msgdb-expand-path spec))
          (elmo-msgdb-killed-list-save
           dir
           (nconc
@@ -1101,7 +1101,7 @@ Return nil if connection failed."
 (defun elmo-nntp-delete-msgs (spec msgs)
   "MSGS on FOLDER at SERVER pretended as Deleted. Returns nil if failed."
   (if elmo-use-killed-list
-      (let* ((dir (elmo-msgdb-expand-path nil spec))
+      (let* ((dir (elmo-msgdb-expand-path spec))
             (killed-list (elmo-msgdb-killed-list-load dir)))
        (mapcar '(lambda (msg)
                   (setq killed-list
@@ -1534,6 +1534,7 @@ Returns a list of cons cells like (NUMBER . VALUE)"
 (defalias 'elmo-nntp-list-folder-important
   'elmo-generic-list-folder-important)
 (defalias 'elmo-nntp-commit 'elmo-generic-commit)
+(defalias 'elmo-nntp-folder-diff 'elmo-generic-folder-diff)
 
 (provide 'elmo-nntp)
 
index a442fe9..cbfa534 100644 (file)
                   (elmo-pipe-spec-dst spec))
   (let ((killed (and elmo-use-killed-list
                     (elmo-msgdb-killed-list-load
-                     (elmo-msgdb-expand-path nil spec))))
+                     (elmo-msgdb-expand-path spec))))
        numbers)
     (setq numbers (elmo-list-folder (elmo-pipe-spec-dst spec)))
     (elmo-living-messages numbers killed)))
 
-(defun elmo-pipe-list-folder-unread (spec msgdb unread-marks)
+(defun elmo-pipe-list-folder-unread (spec number-alist mark-alist unread-marks)
   (elmo-list-folder-unread (elmo-pipe-spec-dst spec)
-                          msgdb unread-marks))
+                          number-alist mark-alist unread-marks))
   
-(defun elmo-pipe-list-folder-important (spec msgdb)
-  (elmo-list-folder-important (elmo-pipe-spec-dst spec) msgdb))
+(defun elmo-pipe-list-folder-important (spec number-alist)
+  (elmo-list-folder-important (elmo-pipe-spec-dst spec) number-alist))
 
 (defun elmo-pipe-max-of-folder (spec)
   (let* (elmo-pop3-use-uidl
 (defun elmo-pipe-server-diff (spec)
   nil)
 
+(defalias 'elmo-pipe-folder-diff 'elmo-generic-folder-diff)
+
 (provide 'elmo-pipe)
 
 ;;; elmo-pipe.el ends here
index 5378d6a..78a8c5f 100644 (file)
 (defun elmo-pop3-list-folder (spec)
   (let ((killed (and elmo-use-killed-list
                     (elmo-msgdb-killed-list-load
-                     (elmo-msgdb-expand-path nil spec))))
+                     (elmo-msgdb-expand-path spec))))
        numbers)
     (elmo-pop3-commit spec)
     (setq numbers (if elmo-pop3-use-uidl
       (if elmo-pop3-use-uidl
          (setq loc-alist (if msgdb (elmo-msgdb-get-location msgdb)
                            (elmo-msgdb-location-load
-                            (elmo-msgdb-expand-path nil spec)))))
+                            (elmo-msgdb-expand-path spec)))))
       (elmo-pop3-msgdb-create-by-header process numlist
                                        new-mark already-mark
                                        seen-mark seen-list
                        (if msgdb
                            (elmo-msgdb-get-location msgdb)
                          (elmo-msgdb-location-load
-                          (elmo-msgdb-expand-path nil spec)))))
+                          (elmo-msgdb-expand-path spec)))))
         (process (elmo-network-session-process-internal
                   (elmo-pop3-get-session spec)))
         response errmsg msg)
                       (if msgdb
                           (elmo-msgdb-get-location msgdb)
                         (elmo-msgdb-location-load
-                         (elmo-msgdb-expand-path nil spec)))))
+                         (elmo-msgdb-expand-path spec)))))
        (process (elmo-network-session-process-internal
                  (elmo-pop3-get-session spec))))
     (mapcar '(lambda (msg) (elmo-pop3-delete-msg
   'elmo-generic-list-folder-unread)
 (defalias 'elmo-pop3-list-folder-important
   'elmo-generic-list-folder-important)
+(defalias 'elmo-pop3-folder-diff 'elmo-generic-folder-diff)
 
 (defun elmo-pop3-commit (spec)
   (if (elmo-pop3-plugged-p spec)
index 8359d23..efd2ff3 100644 (file)
@@ -251,7 +251,7 @@ without cacheing."
         (loc-alist (if msgdb
                        (elmo-msgdb-get-location msgdb)
                      (elmo-msgdb-location-load
-                      (elmo-msgdb-expand-path nil src-spec)))))
+                      (elmo-msgdb-expand-path src-spec)))))
     (if (eq (car src-spec) 'archive)
        (elmo-archive-copy-msgs-froms
         (elmo-folder-get-spec dst-folder)
@@ -481,9 +481,9 @@ without cacheing."
      seen-mark important-mark seen-list)))
 
 ;;   msgdb elmo-msgdb-load        (folder)
-(defun elmo-msgdb-load (folder &optional spec)
+(defun elmo-msgdb-load (folder)
   (message "Loading msgdb for %s..." folder)
-  (let* ((path (elmo-msgdb-expand-path folder spec))
+  (let* ((path (elmo-msgdb-expand-path folder))
         (overview (elmo-msgdb-overview-load path))
         (ret-val
          (list overview
@@ -598,17 +598,16 @@ without cacheing."
   "Just return number-alist."
   number-alist)
 
-(defun elmo-generic-list-folder-unread (spec msgdb unread-marks)
-  (let ((mark-alist (elmo-msgdb-get-mark-alist msgdb)))
-    (elmo-delete-if
-     'null
-     (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 msgdb)
+(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)
 
 (defun elmo-update-number (folder msgdb)
@@ -653,29 +652,26 @@ without cacheing."
                0)))
          (length in-folder))))
 
-(defun elmo-list-folder-unread (folder msgdb unread-marks)
-  (elmo-call-func folder "list-folder-unread" msgdb unread-marks))
+(defun elmo-list-folder-unread (folder number-alist mark-alist unread-marks)
+  (elmo-call-func folder "list-folder-unread"
+                 number-alist mark-alist unread-marks))
 
-(defun elmo-list-folder-important (folder msgdb)
-  (let (importants 
-       (overview (elmo-msgdb-get-overview msgdb)))
-    ;; server side importants...(append only.)
+(defun elmo-list-folder-important (folder number-alist)
+  (let (importants)
+    ;; Server side importants...(append only.)
     (if (elmo-folder-plugged-p folder)
        (setq importants (elmo-call-func folder "list-folder-important"
-                                        msgdb)))
+                                        number-alist)))
     (or elmo-msgdb-global-mark-alist
        (setq elmo-msgdb-global-mark-alist
              (elmo-object-load (expand-file-name
                                 elmo-msgdb-global-mark-filename
                                 elmo-msgdb-dir))))
-    (while overview
-      (if (assoc (elmo-msgdb-overview-entity-get-id (car overview))
+    (while number-alist
+      (if (assoc (cdr (car number-alist))
                 elmo-msgdb-global-mark-alist)
-         (setq importants (cons
-                           (elmo-msgdb-overview-entity-get-number
-                            (car overview))
-                           importants)))
-      (setq overview (cdr overview)))
+         (setq importants (cons (car (car number-alist)) importants)))
+      (setq number-alist (cdr number-alist)))
     importants))
 
 (defun elmo-generic-commit (folder)
@@ -708,64 +704,44 @@ Currently works on IMAP4 folder only."
                  folder
                  (elmo-folder-diff folder)))))
 
-;; returns cons cell of (unsync . number-of-messages-in-folder)
-(defun elmo-folder-diff (fld &optional number-alist)
-  (interactive)
-  (let ((type (elmo-folder-get-type fld)))
-    (cond ((eq type 'multi)
-          (elmo-multi-folder-diff fld))
-         ((and (eq type 'filter)
-               (or (elmo-multi-p fld)
-                   (not (and (vectorp (nth 1 (elmo-folder-get-spec fld)))
-                             (string-match
-                              "^first$\\|^last$"
-                              (elmo-filter-key
-                               (nth 1 (elmo-folder-get-spec fld)))))))
-               ;; not partial...unsync number is unknown.
-               (cons nil
-                     (cdr (elmo-folder-diff
-                           (nth 2 (elmo-folder-get-spec fld)))))))
-         ((and (eq type 'imap4)
-               elmo-use-server-diff)
-          (elmo-call-func fld "server-diff")) ;; imap4 server side diff.
-         (t
-          (let ((cached-in-db-max (elmo-folder-get-info-max fld))
-                (in-folder (elmo-max-of-folder fld))
-                (in-db t)
-                unsync nomif
-                in-db-max)
-            (if (or number-alist
-                    (not cached-in-db-max))
-                (let* ((dir (elmo-msgdb-expand-path fld))
-                       (nalist (or number-alist
-                                   (elmo-msgdb-number-load dir))))
-                  ;; No info-cache.
-                  (setq in-db (sort (mapcar 'car nalist) '<))
-                  (setq in-db-max (or (nth (max 0 (1- (length in-db))) in-db)
-                                      0))
-                  (if (not number-alist)
-                      ;; Number-alist is not used.
-                      (elmo-folder-set-info-hashtb fld in-db-max
-                                                   nil))
-;;                                                (or
-;;                                                 (and in-db (length in-db))
-;;                                                 0)))
-                  )
-              ;; info-cache exists.
-              (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 nomif (cdr in-folder))
-            (if (and unsync nomif (> unsync nomif))
-                (setq unsync nomif))
-            (cons (or unsync 0) (or nomif 0)))))))
-    
+(defun elmo-folder-diff (folder &optional number-list)
+  "Get diff of FOLDER.
+Return value is a cons cell of NEW and MESSAGES.
+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 spec))))))
+         ;; 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)))
@@ -781,51 +757,6 @@ Currently works on IMAP4 folder only."
                       (list new unread numbers max)
                       elmo-folder-info-hashtb)))
 
-(defun elmo-multi-get-number-alist-list (number-alist)
-  (let ((alist (sort number-alist (function (lambda (x y) (< (car x)
-                                                            (car y))))))
-       (cur-number 0)
-       one-alist ret-val num)
-    (while alist
-      (setq cur-number (+ cur-number 1))
-      (setq one-alist nil)
-      (while (and alist
-                 (eq 0
-                     (/ (- (setq num (car (car alist)))
-                           (* elmo-multi-divide-number cur-number))
-                        elmo-multi-divide-number)))
-       (setq one-alist (nconc
-                        one-alist
-                        (list
-                         (cons
-                          (% num (* elmo-multi-divide-number cur-number))
-                          (cdr (car alist))))))
-       (setq alist (cdr alist)))
-      (setq ret-val (nconc ret-val (list one-alist))))
-    ret-val))
-
-(defun elmo-multi-folder-diff (fld)
-  (let ((flds (cdr (elmo-folder-get-spec fld)))
-       (num-alist-list
-        (elmo-multi-get-number-alist-list
-         (elmo-msgdb-number-load (elmo-msgdb-expand-path fld))))
-       (count 0)
-       diffs (unsync 0) (nomif 0))
-    (while flds
-      (setq diffs (nconc diffs (list (elmo-folder-diff (car flds)
-                                                      (nth count
-                                                           num-alist-list)
-                                                      ))))
-      (setq count (+ 1 count))
-      (setq flds (cdr flds)))
-    (while diffs
-      (and (car (car diffs))
-          (setq unsync (+ unsync (car (car diffs)))))
-      (setq nomif  (+ nomif (cdr (car diffs))))
-      (setq diffs (cdr diffs)))
-    (elmo-folder-set-info-hashtb fld nil nomif)
-    (cons unsync nomif)))
-
 (defun elmo-folder-set-info-max-by-numdb (folder msgdb-number)
   (let ((num-db (sort (mapcar 'car msgdb-number) '<)))
     (elmo-folder-set-info-hashtb
@@ -1077,7 +1008,6 @@ Currently works on IMAP4 folder only."
 (autoload 'elmo-nntp-post "elmo-nntp")
 (autoload 'elmo-localdir-max-of-folder "elmo-localdir")
 (autoload 'elmo-localdir-msgdb-create-overview-entity-from-file "elmo-localdir")
-(autoload 'elmo-multi-folder-diff "elmo-multi")
 (autoload 'elmo-archive-copy-msgs-froms "elmo-archive")
 
 ;;; elmo2.el ends here