01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16:
17: package org.columba.mail.gui.message.filter;
18:
19: import org.columba.api.gui.frame.IFrameMediator;
20: import org.columba.mail.command.IMailFolderCommandReference;
21: import org.columba.mail.command.MailFolderCommandReference;
22: import org.columba.mail.folder.IMailbox;
23: import org.columba.mail.folder.temp.TempFolder;
24: import org.columba.mail.gui.frame.MailFrameMediator;
25: import org.columba.mail.gui.message.IMessageController;
26: import org.columba.mail.gui.table.selection.TableSelectionHandler;
27: import org.columba.mail.gui.tree.FolderTreeModel;
28: import org.columba.mail.message.IColumbaMessage;
29:
30: /**
31: * Should be used by every filter, which alters the message contents. This
32: * is done the following way:
33: * <p>
34: * A new message is created and added to a temporary folder. All references of
35: * the sources folder are re-mapped to the message in the temporary folder.
36: * <p>
37: *
38: * @author fdietz
39: */
40: public abstract class AbstractFilter implements Filter {
41:
42: private MailFrameMediator mediator;
43:
44: public AbstractFilter(MailFrameMediator mediator,
45: IMessageController messageViewer) {
46: this .mediator = mediator;
47: }
48:
49: /**
50: * @return
51: * @see org.columba.mail.gui.message.filter.Filter#filter(IMailbox, java.lang.Object)
52: */
53: public IMailFolderCommandReference filter(IMailbox folder,
54: Object uid, IColumbaMessage message) throws Exception {
55: // map selection to this temporary message
56: TempFolder tempFolder = FolderTreeModel.getInstance()
57: .getTempFolder();
58:
59: // add message to temporary folder
60: uid = tempFolder.addMessage(message);
61:
62: // create reference to this message
63: MailFolderCommandReference local = new MailFolderCommandReference(
64: tempFolder, new Object[] { uid });
65:
66: // if we don't use this here - actions like reply would only work
67: // on the
68: // the encrypted message
69: TableSelectionHandler h1 = ((TableSelectionHandler) mediator
70: .getSelectionManager().getHandler(
71: TableSelectionHandler.HANDLER_ID));
72:
73: h1.setLocalReference(local);
74:
75: // this is needed to be able to open attachments of the decrypted
76: // message
77:
78: // TODO check if we have to manually set the folder/uid in
79: // message controller to make this work
80:
81: //messageController.setAttachmentSelectionReference(local);
82:
83: return local;
84: }
85:
86: /**
87: * @return Returns the mediator.
88: */
89: public IFrameMediator getMediator() {
90: return mediator;
91: }
92: }
|