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