Fix typo.
[elisp/wanderlust.git] / elmo / elmo-pipe.el
1 ;;; elmo-pipe.el -- PIPE 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
32 (require 'elmo-msgdb)
33
34 (defalias 'elmo-pipe-msgdb-create 'elmo-pipe-msgdb-create-as-numlist)
35
36 (defun elmo-pipe-msgdb-create-as-numlist (spec numlist new-mark already-mark
37                                                seen-mark important-mark
38                                                seen-list)
39   (elmo-msgdb-create-as-numlist (elmo-pipe-spec-dst spec)
40                                 numlist new-mark already-mark
41                                 seen-mark important-mark seen-list))
42
43 (defun elmo-pipe-list-folders (spec &optional hierarchy)
44   nil)
45
46 (defun elmo-pipe-append-msg (spec string &optional msg no-see)
47   (elmo-append-msg (elmo-pipe-spec-dst spec) string))
48
49 (defun elmo-pipe-read-msg (spec number outbuf &optional msgdb unread)
50   (elmo-call-func (elmo-pipe-spec-dst spec)
51                   "read-msg"
52                   number outbuf msgdb unread))
53
54 (defun elmo-pipe-delete-msgs (spec msgs)
55   (elmo-delete-msgs (elmo-pipe-spec-dst spec) msgs))
56
57 (defvar elmo-pipe-drained-hook nil "A hook called when the pipe is flushed.")
58
59 (defun elmo-pipe-drain (src dst)
60   "Move all messages of SRC to DST."
61   (let ((elmo-inhibit-read-cache t); Inhibit caching while moving messages.
62         elmo-pop3-use-uidl) ; No need to use UIDL
63     (message "Checking %s..." src)
64     (let ((srclist (elmo-list-folder src))
65           (msgdb (elmo-msgdb-load src)))
66       (elmo-move-msgs src srclist dst msgdb)
67       ;; Don't save msgdb here.
68       ;; Because summary view of original folder is not updated yet.
69       ;; (elmo-msgdb-save src msgdb)
70       (elmo-commit src))
71     (run-hooks 'elmo-pipe-drained-hook)))
72
73 (defun elmo-pipe-list-folder (spec &optional nohide)
74   (elmo-pipe-drain (elmo-pipe-spec-src spec)
75                    (elmo-pipe-spec-dst spec))
76   (let ((killed (and elmo-use-killed-list
77                      (elmo-msgdb-killed-list-load
78                       (elmo-msgdb-expand-path spec))))
79         numbers)
80     (setq numbers (elmo-list-folder (elmo-pipe-spec-dst spec)))
81     (elmo-living-messages numbers killed)))
82
83 (defun elmo-pipe-list-folder-unread (spec number-alist mark-alist unread-marks)
84   (elmo-list-folder-unread (elmo-pipe-spec-dst spec)
85                            number-alist mark-alist unread-marks))
86   
87 (defun elmo-pipe-list-folder-important (spec number-alist)
88   (elmo-list-folder-important (elmo-pipe-spec-dst spec) number-alist))
89
90 (defun elmo-pipe-max-of-folder (spec)
91   (let* (elmo-pop3-use-uidl
92          (src-length (length (elmo-list-folder (elmo-pipe-spec-src spec))))
93          (dst-list (elmo-list-folder (elmo-pipe-spec-dst spec))))
94     (cons (+ src-length (elmo-max-of-list dst-list))
95           (+ src-length (length dst-list)))))
96
97 (defun elmo-pipe-folder-exists-p (spec)
98   (and (elmo-folder-exists-p (elmo-pipe-spec-src spec))
99        (elmo-folder-exists-p (elmo-pipe-spec-dst spec))))
100
101 (defun elmo-pipe-folder-creatable-p (spec)
102   (or (elmo-folder-creatable-p (elmo-pipe-spec-src spec))
103       (elmo-folder-creatable-p (elmo-pipe-spec-dst spec))))
104
105 (defun elmo-pipe-create-folder (spec)
106   (if (and (not (elmo-folder-exists-p (elmo-pipe-spec-src spec)))
107            (elmo-folder-creatable-p (elmo-pipe-spec-src spec)))
108       (elmo-create-folder (elmo-pipe-spec-src spec)))
109   (if (and (not (elmo-folder-exists-p (elmo-pipe-spec-dst spec)))
110            (elmo-folder-creatable-p (elmo-pipe-spec-dst spec)))
111       (elmo-create-folder (elmo-pipe-spec-dst spec))))
112
113 (defun elmo-pipe-search (spec condition &optional numlist)
114   (elmo-search (elmo-pipe-spec-dst spec) condition numlist))
115
116 (defun elmo-pipe-use-cache-p (spec number)
117   (elmo-use-cache-p (elmo-pipe-spec-dst spec) number))
118
119 (defun elmo-pipe-commit (spec)
120   (elmo-commit (elmo-pipe-spec-src spec))
121   (elmo-commit (elmo-pipe-spec-dst spec)))
122
123 (defun elmo-pipe-plugged-p (spec)
124   (and (elmo-folder-plugged-p (elmo-pipe-spec-src spec))
125        (elmo-folder-plugged-p (elmo-pipe-spec-dst spec))))
126
127 (defun elmo-pipe-set-plugged (spec plugged add)
128   (elmo-folder-set-plugged (elmo-pipe-spec-src spec) plugged add)
129   (elmo-folder-set-plugged (elmo-pipe-spec-dst spec) plugged add))
130
131 (defun elmo-pipe-local-file-p (spec number)
132   (elmo-local-file-p (elmo-pipe-spec-dst spec) number))
133
134 (defun elmo-pipe-get-msg-filename (spec number &optional loc-alist)
135   (elmo-get-msg-filename (elmo-pipe-spec-dst spec) number loc-alist))
136
137 (defun elmo-pipe-sync-number-alist (spec number-alist)
138   (elmo-call-func (elmo-pipe-spec-src spec)
139                   "sync-number-alist" number-alist)) ; ??
140
141 (defun elmo-pipe-server-diff (spec)
142   nil)
143
144 (defalias 'elmo-pipe-folder-diff 'elmo-generic-folder-diff)
145
146 (require 'product)
147 (product-provide (provide 'elmo-pipe) (require 'elmo-version))
148
149 ;;; elmo-pipe.el ends here