Merge from beta branch.
[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
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 (defsubst elmo-pipe-spec-src (spec)
35   (nth 1 spec))
36
37 (defsubst elmo-pipe-spec-dst (spec)
38   (nth 2 spec))
39
40 (defalias 'elmo-pipe-msgdb-create 'elmo-pipe-msgdb-create-as-numlist)
41
42 (defun elmo-pipe-msgdb-create-as-numlist (spec numlist new-mark already-mark
43                                                seen-mark important-mark 
44                                                seen-list)
45   (elmo-msgdb-create-as-numlist (elmo-pipe-spec-dst spec)
46                                 numlist new-mark already-mark
47                                 seen-mark important-mark seen-list))
48
49 (defun elmo-pipe-list-folders (spec &optional hierarchy)
50   nil)
51
52 (defun elmo-pipe-append-msg (spec string &optional msg no-see)
53   (elmo-append-msg (elmo-pipe-spec-dst spec) string))
54
55 (defun elmo-pipe-read-msg (spec number outbuf)
56   (elmo-call-func (elmo-pipe-spec-dst spec)
57                   "read-msg" 
58                   number outbuf))
59
60 (defun elmo-pipe-delete-msgs (spec msgs)
61   (elmo-delete-msgs (elmo-pipe-spec-dst spec) msgs))
62
63 (defvar elmo-pipe-drained-hook nil "A hook called when the pipe is flushed.")
64
65 (defun elmo-pipe-drain (src dst)
66   (let ((msgdb (elmo-msgdb-load src))
67         elmo-nntp-use-cache 
68         elmo-imap4-use-cache
69         elmo-pop3-use-cache) ; Inhibit caching while moving messages.
70     (message "Checking %s..." src)
71     (elmo-move-msgs src (elmo-list-folder src) dst msgdb)
72     (elmo-msgdb-save src msgdb)
73     (run-hooks 'elmo-pipe-drained-hook)))
74
75 (defun elmo-pipe-list-folder (spec)
76   (elmo-pipe-drain (elmo-pipe-spec-src spec)
77                    (elmo-pipe-spec-dst spec))
78   (elmo-list-folder (elmo-pipe-spec-dst spec)))
79
80 (defun elmo-pipe-list-folder-unread (spec mark-alist unread-marks)
81   (elmo-list-folder-unread (elmo-pipe-spec-dst spec) mark-alist unread-marks))
82   
83 (defun elmo-pipe-list-folder-important (spec overview)
84   (elmo-list-folder-important (elmo-pipe-spec-dst spec) overview))
85
86 (defun elmo-pipe-max-of-folder (spec)
87   (let ((src-length (length (elmo-list-folder (elmo-pipe-spec-src spec))))
88         (dst-list (elmo-list-folder (elmo-pipe-spec-dst spec))))
89     (cons (+ src-length (elmo-max-of-list dst-list))
90           (+ src-length (length dst-list)))))
91
92 (defun elmo-pipe-folder-exists-p (spec)
93   (and (elmo-folder-exists-p (elmo-pipe-spec-src spec))
94        (elmo-folder-exists-p (elmo-pipe-spec-dst spec))))
95
96 (defun elmo-pipe-folder-creatable-p (spec)
97   (or (elmo-folder-creatable-p (elmo-pipe-spec-src spec))
98       (elmo-folder-creatable-p (elmo-pipe-spec-dst spec))))
99
100 (defun elmo-pipe-create-folder (spec)
101   (if (and (not (elmo-folder-exists-p (elmo-pipe-spec-src spec)))
102            (elmo-folder-creatable-p (elmo-pipe-spec-src spec)))
103       (elmo-create-folder (elmo-pipe-spec-src spec)))
104   (if (and (not (elmo-folder-exists-p (elmo-pipe-spec-dst spec)))
105            (elmo-folder-creatable-p (elmo-pipe-spec-dst spec)))
106       (elmo-create-folder (elmo-pipe-spec-dst spec))))
107
108 (defun elmo-pipe-search (spec condition &optional numlist)
109   (elmo-search (elmo-pipe-spec-dst spec) condition numlist))
110
111 (defun elmo-pipe-use-cache-p (spec number)
112   (elmo-use-cache-p (elmo-pipe-spec-dst spec) number))
113
114 (defun elmo-pipe-commit (spec)
115   (elmo-commit (elmo-pipe-spec-src spec))
116   (elmo-commit (elmo-pipe-spec-dst spec)))
117
118 (defun elmo-pipe-plugged-p (spec)
119   (and (elmo-folder-plugged-p (elmo-pipe-spec-src spec))
120        (elmo-folder-plugged-p (elmo-pipe-spec-dst spec))))
121
122 (defun elmo-pipe-set-plugged (spec plugged add)
123   (elmo-folder-set-plugged (elmo-pipe-spec-src spec) plugged add)
124   (elmo-folder-set-plugged (elmo-pipe-spec-dst spec) plugged add))
125
126 (defun elmo-pipe-local-file-p (spec number)
127   (elmo-local-file-p (elmo-pipe-spec-dst spec) number))
128
129 (defun elmo-pipe-get-msg-filename (spec number &optional loc-alist)
130   (elmo-get-msg-filename (elmo-pipe-spec-dst spec) number loc-alist))
131
132 (defun elmo-pipe-sync-number-alist (spec number-alist)
133   (elmo-call-func (elmo-pipe-spec-src spec) 
134                   "sync-number-alist" number-alist)) ; ??
135
136 (defun elmo-pipe-server-diff (spec)
137   nil)
138
139 (provide 'elmo-pipe)
140
141 ;;; elmo-pipe.el ends here