KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > folder > outbox > OutboxFolder


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.mail.folder.outbox;
19
20 import java.io.InputStream JavaDoc;
21
22 import org.columba.mail.composer.SendableMessage;
23 import org.columba.mail.config.FolderItem;
24 import org.columba.mail.folder.headercache.BerkeleyDBHeaderList;
25 import org.columba.mail.folder.mbox.CachedMboxFolder;
26 import org.columba.mail.folder.mh.CachedMHFolder;
27 import org.columba.mail.message.ColumbaMessage;
28 import org.columba.ristretto.message.Attributes;
29 import org.columba.ristretto.message.Flags;
30
31 /**
32  * Additionally to {@CachedMHFolder}is capable of saving
33  * {@link SendableMessage}objects.
34  * <p>
35  * It is used to store messages to send them later all at once.
36  *
37  * @author fdietz
38  */

39 public class OutboxFolder extends CachedMboxFolder {
40
41     private SendListManager[] sendListManager = new SendListManager[2];
42
43
44     public OutboxFolder(FolderItem item, String JavaDoc path) {
45         super(item, path);
46         
47         try {
48             ((BerkeleyDBHeaderList)getHeaderList()).setHeaderBinding(new OutboxHeaderBinding());
49         } catch (Exception JavaDoc e) {
50         }
51         
52         sendListManager[0] = new SendListManager();
53         sendListManager[1] = new SendListManager();
54     }
55
56     public SendableMessage getSendableMessage(Object JavaDoc uid) throws Exception JavaDoc {
57         ColumbaMessage message = getMessage(uid);
58
59         SendableMessage sendableMessage = new SendableMessage(message);
60
61         return sendableMessage;
62     }
63
64     /**
65      *
66      * OutboxFolder doesn't allow adding messages, in comparison to other
67      * regular mailbox folders.
68      *
69      * @see org.columba.mail.folder.FolderTreeNode#supportsAddMessage()
70      */

71     public boolean supportsAddMessage() {
72         return false;
73     }
74
75     /**
76      * The outbox folder doesnt allow adding folders to it.
77      *
78      * @param newFolderType
79      * folder to check..
80      * @return false always.
81      */

82     public boolean supportsAddFolder(String JavaDoc newFolderType) {
83         return false;
84     }
85
86     /**
87      * Returns if this folder type can be moved.
88      *
89      * @return false always.
90      */

91     public boolean supportsMove() {
92         return false;
93     }
94
95     /**
96      * @see org.columba.mail.folder.IMailbox#addMessage(java.io.InputStream,
97      * org.columba.ristretto.message.Attributes)
98      */

99     public Object JavaDoc addMessage(InputStream JavaDoc in, Attributes attributes, Flags flags)
100             throws Exception JavaDoc {
101         Object JavaDoc uid = super.addMessage(in, attributes, flags);
102         setAttribute(uid, "columba.recipients", attributes
103                 .get("columba.recipients"));
104
105         return uid;
106     }
107
108 }
Popular Tags