1 ;;; elmo-pipe.el -- PIPE Interface for ELMO.
3 ;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
5 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
6 ;; Keywords: mail, net news
8 ;; This file is part of ELMO (Elisp Library for Message Orchestration).
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)
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.
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.
36 (luna-define-class elmo-pipe-folder (elmo-folder)
38 (luna-define-internal-accessors 'elmo-pipe-folder))
40 (luna-define-method elmo-folder-initialize ((folder elmo-pipe-folder)
42 (when (string-match "^\\([^|]*\\)|\\(.*\\)$" name)
43 (elmo-pipe-folder-set-src-internal folder
45 (elmo-match-string 1 name)))
46 (elmo-pipe-folder-set-dst-internal folder
48 (elmo-match-string 2 name))))
51 (luna-define-method elmo-folder-get-primitive-list ((folder elmo-pipe-folder))
54 'elmo-folder-get-primitive-list
55 (list (elmo-pipe-folder-src-internal folder)
56 (elmo-pipe-folder-dst-internal folder)))))
58 (luna-define-method elmo-folder-contains-type ((folder elmo-pipe-folder)
60 (or (elmo-folder-contains-type (elmo-pipe-folder-src-internal folder) type)
61 (elmo-folder-contains-type (elmo-pipe-folder-dst-internal folder) type)))
63 (luna-define-method elmo-folder-msgdb-create ((folder elmo-pipe-folder)
64 numlist new-mark already-mark
65 seen-mark important-mark
67 (elmo-folder-msgdb-create (elmo-pipe-folder-dst-internal folder)
68 numlist new-mark already-mark
69 seen-mark important-mark seen-list))
71 (luna-define-method elmo-folder-append-messages ((folder elmo-pipe-folder)
74 &optional same-number)
75 (elmo-folder-append-messages (elmo-pipe-folder-dst-internal folder)
80 (luna-define-method elmo-folder-append-buffer ((folder elmo-pipe-folder)
81 unread &optional number)
82 (elmo-folder-append-buffer (elmo-pipe-folder-dst-internal folder)
85 (luna-define-method elmo-message-fetch ((folder elmo-pipe-folder)
87 &optional section outbuf unseen)
88 (elmo-message-fetch (elmo-pipe-folder-dst-internal folder)
89 number strategy section outbuf unseen))
91 (luna-define-method elmo-folder-delete-messages ((folder elmo-pipe-folder)
93 (elmo-folder-delete-messages (elmo-pipe-folder-dst-internal folder)
96 (defvar elmo-pipe-drained-hook nil "A hook called when the pipe is flushed.")
98 (defun elmo-pipe-drain (src dst)
99 "Move all messages of SRC to DST."
100 (let ((elmo-inhibit-number-mapping t) ; No need to use UIDL
102 (message "Checking %s..." (elmo-folder-name-internal src))
103 (elmo-folder-open-internal src)
104 (setq msgs (elmo-folder-list-messages src)
106 (when (> len elmo-display-progress-threshold)
107 (elmo-progress-set 'elmo-folder-move-messages
108 len "Moving messages..."))
109 (elmo-folder-move-messages src msgs dst)
110 (elmo-progress-clear 'elmo-folder-move-messages))
111 ;; Don't save msgdb here.
112 ;; Because summary view of original folder is not updated yet.
113 (elmo-folder-close-internal src)
114 (run-hooks 'elmo-pipe-drained-hook))
116 (luna-define-method elmo-folder-open-internal ((folder elmo-pipe-folder))
117 (elmo-folder-open-internal (elmo-pipe-folder-dst-internal folder))
118 (let ((src-folder (elmo-pipe-folder-src-internal folder))
119 (dst-folder (elmo-pipe-folder-dst-internal folder)))
120 (when (and (elmo-folder-plugged-p src-folder)
121 (elmo-folder-plugged-p dst-folder))
122 (elmo-pipe-drain src-folder dst-folder))))
124 (luna-define-method elmo-folder-close-internal ((folder elmo-pipe-folder))
125 (elmo-folder-close-internal(elmo-pipe-folder-dst-internal folder)))
127 (luna-define-method elmo-folder-list-messages-internal
128 ((folder elmo-pipe-folder) &optional nohide)
129 (elmo-folder-list-messages-internal (elmo-pipe-folder-dst-internal
132 (luna-define-method elmo-folder-list-unreads-internal
133 ((folder elmo-pipe-folder) unread-marks &optional mark-alist)
134 (elmo-folder-list-unreads-internal (elmo-pipe-folder-dst-internal folder)
135 unread-marks mark-alist))
137 (luna-define-method elmo-folder-list-importants-internal
138 ((folder elmo-pipe-folder) important-mark)
139 (elmo-folder-list-importants-internal (elmo-pipe-folder-dst-internal folder)
142 (luna-define-method elmo-folder-status ((folder elmo-pipe-folder))
143 (elmo-folder-open-internal (elmo-pipe-folder-src-internal folder))
144 (elmo-folder-open-internal (elmo-pipe-folder-dst-internal folder))
145 (let* ((elmo-inhibit-number-mapping t)
146 (src-length (length (elmo-folder-list-messages
147 (elmo-pipe-folder-src-internal folder))))
148 (dst-list (elmo-folder-list-messages
149 (elmo-pipe-folder-dst-internal folder))))
150 (prog1 (cons (+ src-length (elmo-max-of-list dst-list))
151 (+ src-length (length dst-list)))
153 (elmo-folder-close-internal (elmo-pipe-folder-src-internal folder))
154 (elmo-folder-close-internal (elmo-pipe-folder-dst-internal folder)))))
156 (luna-define-method elmo-folder-exists-p ((folder elmo-pipe-folder))
157 (and (elmo-folder-exists-p (elmo-pipe-folder-src-internal folder))
158 (elmo-folder-exists-p (elmo-pipe-folder-dst-internal folder))))
160 (luna-define-method elmo-folder-expand-msgdb-path ((folder
162 ;; Share with destination...OK?
163 (elmo-folder-expand-msgdb-path (elmo-pipe-folder-dst-internal folder)))
165 (luna-define-method elmo-folder-creatable-p ((folder elmo-pipe-folder))
166 (and (elmo-folder-creatable-p (elmo-pipe-folder-src-internal folder))
167 (elmo-folder-creatable-p (elmo-pipe-folder-dst-internal folder))))
169 (luna-define-method elmo-folder-writable-p ((folder elmo-pipe-folder))
170 (elmo-folder-writable-p (elmo-pipe-folder-dst-internal folder)))
172 (luna-define-method elmo-folder-create ((folder elmo-pipe-folder))
173 (if (and (not (elmo-folder-exists-p (elmo-pipe-folder-src-internal folder)))
174 (elmo-folder-creatable-p (elmo-pipe-folder-src-internal folder)))
175 (elmo-folder-create (elmo-pipe-folder-src-internal folder)))
176 (if (and (not (elmo-folder-exists-p (elmo-pipe-folder-dst-internal folder)))
177 (elmo-folder-creatable-p (elmo-pipe-folder-dst-internal folder)))
178 (elmo-folder-create (elmo-pipe-folder-dst-internal folder))))
180 (luna-define-method elmo-folder-search ((folder elmo-pipe-folder)
181 condition &optional numlist)
182 (elmo-folder-search (elmo-pipe-folder-dst-internal folder)
185 (luna-define-method elmo-message-use-cache-p ((folder elmo-pipe-folder) number)
186 (elmo-message-use-cache-p (elmo-pipe-folder-dst-internal folder) number))
188 (luna-define-method elmo-folder-check ((folder elmo-pipe-folder))
189 (elmo-folder-close-internal folder)
190 (elmo-folder-open-internal folder))
192 (luna-define-method elmo-folder-plugged-p ((folder elmo-pipe-folder))
193 (and (elmo-folder-plugged-p (elmo-pipe-folder-src-internal folder))
194 (elmo-folder-plugged-p (elmo-pipe-folder-dst-internal folder))))
196 (luna-define-method elmo-folder-message-file-p ((folder elmo-pipe-folder))
197 (elmo-folder-message-file-p (elmo-pipe-folder-dst-internal folder)))
199 (luna-define-method elmo-message-file-p ((folder elmo-pipe-folder) number)
200 (elmo-message-file-p (elmo-pipe-folder-dst-internal folder) number))
202 (luna-define-method elmo-message-file-name ((folder elmo-pipe-folder) number)
203 (elmo-message-file-name (elmo-pipe-folder-dst-internal folder) number))
205 (luna-define-method elmo-folder-message-file-number-p ((folder
207 (elmo-folder-message-file-number-p (elmo-pipe-folder-dst-internal folder)))
209 (luna-define-method elmo-folder-message-file-directory ((folder
211 (elmo-folder-message-file-directory
212 (elmo-pipe-folder-dst-internal folder)))
214 (luna-define-method elmo-folder-message-make-temp-file-p
215 ((folder elmo-pipe-folder))
216 (elmo-folder-message-make-temp-file-p
217 (elmo-pipe-folder-dst-internal folder)))
219 (luna-define-method elmo-folder-message-make-temp-files ((folder
224 (elmo-folder-message-make-temp-files
225 (elmo-pipe-folder-dst-internal folder) numbers start-number))
227 (luna-define-method elmo-folder-mark-as-read ((folder elmo-pipe-folder)
229 (elmo-folder-mark-as-read (elmo-pipe-folder-dst-internal folder)
232 (luna-define-method elmo-folder-unmark-read ((folder elmo-pipe-folder)
234 (elmo-folder-unmark-read (elmo-pipe-folder-dst-internal folder)
237 (luna-define-method elmo-folder-unmark-important ((folder elmo-pipe-folder)
239 (elmo-folder-unmark-important (elmo-pipe-folder-dst-internal folder)
242 (luna-define-method elmo-folder-mark-as-important ((folder elmo-pipe-folder)
244 (elmo-folder-mark-as-important (elmo-pipe-folder-dst-internal folder)
247 (luna-define-method elmo-folder-pack-numbers ((folder elmo-pipe-folder))
248 (elmo-folder-pack-numbers (elmo-pipe-folder-dst-internal folder)))
251 (product-provide (provide 'elmo-pipe) (require 'elmo-version))
253 ;;; elmo-pipe.el ends here