* elmo2.el (elmo-prefetch-msg): Set `unread' argument of `elmo-read-msg' as
[elisp/wanderlust.git] / elmo / elmo-filter.el
1 ;;; elmo-filter.el -- Filtered Folder Interface for ELMO.
2
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
4
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
7
8 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
9
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14 ;;
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19 ;;
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24 ;;
25
26 ;;; Commentary:
27 ;; 
28
29 ;;; Code:
30 ;; 
31 (require 'elmo-msgdb)
32
33 (defun elmo-filter-msgdb-create (spec numlist new-mark already-mark
34                                       seen-mark important-mark seen-list)
35   (if (eq (nth 2 spec) 'partial)
36       (elmo-msgdb-create (nth 2 spec)
37                          numlist
38                          new-mark
39                          already-mark
40                          seen-mark important-mark seen-list)
41     (elmo-msgdb-create-as-numlist (nth 2 spec)
42                                   numlist
43                                   new-mark
44                                   already-mark
45                                   seen-mark important-mark seen-list)))
46
47 (defun elmo-filter-msgdb-create-as-numlist (spec numlist new-mark already-mark
48                                                  seen-mark important-mark
49                                                  seen-list)
50   (elmo-msgdb-create-as-numlist (nth 2 spec)
51                                 numlist
52                                 new-mark
53                                 already-mark
54                                 seen-mark important-mark seen-list))
55   
56 (defun elmo-filter-list-folders (spec &optional hierarchy)
57   nil)
58
59 (defun elmo-filter-append-msg (spec string &optional msg no-see)
60   (elmo-call-func (nth 2 spec) "append" string))
61
62 (defun elmo-filter-read-msg (spec number outbuf &optional msgdb unread)
63   (elmo-call-func (nth 2 spec) "read-msg" number outbuf msgdb unread))
64
65 (defun elmo-filter-delete-msgs (spec msgs)
66   (elmo-call-func (nth 2 spec) "delete-msgs" msgs))
67
68 (defun elmo-filter-list-folder (spec)
69   (elmo-search (nth 2 spec) (nth 1 spec)))
70
71 (defun elmo-filter-list-folder-unread (spec number-alist mark-alist
72                                             unread-marks)
73   (elmo-list-filter
74    (mapcar 'car number-alist)
75    (elmo-list-folder-unread
76     (nth 2 spec) number-alist mark-alist unread-marks)))
77
78 (defun elmo-filter-list-folder-important (spec number-alist)
79   (elmo-list-filter
80    (mapcar 'car number-alist)
81    (elmo-list-folder-important (nth 2 spec) number-alist)))
82
83 (defun elmo-filter-folder-diff (spec folder &optional number-list)
84   (if (or (elmo-multi-p folder)
85           (not (and (vectorp (nth 1 spec))
86                     (string-match "^last$"
87                                   (elmo-filter-key (nth 1 spec))))))
88       (cons nil (cdr (elmo-folder-diff (nth 2 spec))))
89     (elmo-generic-folder-diff spec folder number-list)))
90
91 (defun elmo-filter-max-of-folder (spec)
92   (elmo-max-of-folder (nth 2 spec)))
93
94 (defun elmo-filter-folder-exists-p (spec)
95   (elmo-folder-exists-p (nth 2 spec)))
96
97 (defun elmo-filter-folder-creatable-p (spec)
98   (elmo-call-func (nth 2 spec) "folder-creatable-p"))
99
100 (defun elmo-filter-create-folder (spec)
101   (elmo-create-folder (nth 2 spec)))
102
103 (defun elmo-filter-search (spec condition &optional from-msgs)
104   ;; search from messages in this folder
105   (elmo-list-filter
106    from-msgs
107    (elmo-search (nth 2 spec) condition
108                 (elmo-filter-list-folder spec))))
109
110 (defun elmo-filter-use-cache-p (spec number)
111   (elmo-call-func (nth 2 spec) "use-cache-p" number))
112
113 (defun elmo-filter-local-file-p (spec number)
114   (elmo-call-func (nth 2 spec) "local-file-p" number))
115
116 (defun elmo-filter-commit (spec)
117   (elmo-commit (nth 2 spec)))
118
119 (defun elmo-filter-plugged-p (spec)
120   (elmo-folder-plugged-p (nth 2 spec)))
121
122 (defun elmo-filter-set-plugged (spec plugged add)
123   (elmo-folder-set-plugged (nth 2 spec) plugged add))
124
125 (defun elmo-filter-get-msg-filename (spec number &optional loc-alist)
126   ;; This function may be called when elmo-filter-local-file-p()
127   ;; returns t.
128   (elmo-call-func (nth 2 spec) "get-msg-filename" number loc-alist))
129
130 (defun elmo-filter-sync-number-alist (spec number-alist)
131   (elmo-call-func (nth 2 spec) "sync-number-alist" number-alist))
132
133 (defun elmo-filter-server-diff (spec)
134   (elmo-call-func (nth 2 spec) "server-diff"))
135
136 (require 'product)
137 (product-provide (provide 'elmo-filter) (require 'elmo-version))
138
139 ;;; elmo-filter.el ends here