;;; elmo-msgdb.el -- Message Database for Elmo.
-;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
-;; Copyright 2000 Masahiro MURATA <muse@ba2.so-net.ne.jp>
+;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 2000 Masahiro MURATA <muse@ba2.so-net.ne.jp>
-;; Author: Yuuichi Teranishi <teranisi@gohome.org>,
-;; Masahiro MURATA <muse@ba2.so-net.ne.jp>
+;; Author: Yuuichi Teranishi <teranisi@gohome.org>
+;; Masahiro MURATA <muse@ba2.so-net.ne.jp>
;; Keywords: mail, net news
;; This file is part of ELMO (Elisp Library for Message Orchestration).
(setq killed (cdr killed)))
ret-val))
+(defun elmo-msgdb-max-of-killed (killed-list)
+ (let ((klist killed-list)
+ (max 0)
+ k)
+ (while (car klist)
+ (if (< max
+ (setq k
+ (if (consp (car klist))
+ (cdar klist)
+ (car klist))))
+ (setq max k))
+ (setq klist (cdr klist)))
+ max))
+
(defun elmo-living-messages (messages killed-list)
(if killed-list
(delq nil
(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-spec)))
- (new (directory-file-name (elmo-msgdb-expand-path new-spec)))
+ (let* ((old (directory-file-name (elmo-msgdb-expand-path old-folder)))
+ (new (directory-file-name (elmo-msgdb-expand-path new-folder)))
(new-dir (directory-file-name (file-name-directory new))))
(if (not (file-directory-p old))
()
(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))