001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.folder.outbox;
019:
020: import java.io.InputStream;
021:
022: import org.columba.mail.composer.SendableMessage;
023: import org.columba.mail.config.FolderItem;
024: import org.columba.mail.folder.headercache.BerkeleyDBHeaderList;
025: import org.columba.mail.folder.mbox.CachedMboxFolder;
026: import org.columba.mail.folder.mh.CachedMHFolder;
027: import org.columba.mail.message.ColumbaMessage;
028: import org.columba.ristretto.message.Attributes;
029: import org.columba.ristretto.message.Flags;
030:
031: /**
032: * Additionally to {@CachedMHFolder}is capable of saving
033: * {@link SendableMessage}objects.
034: * <p>
035: * It is used to store messages to send them later all at once.
036: *
037: * @author fdietz
038: */
039: public class OutboxFolder extends CachedMboxFolder {
040:
041: private SendListManager[] sendListManager = new SendListManager[2];
042:
043: public OutboxFolder(FolderItem item, String path) {
044: super (item, path);
045:
046: try {
047: ((BerkeleyDBHeaderList) getHeaderList())
048: .setHeaderBinding(new OutboxHeaderBinding());
049: } catch (Exception e) {
050: }
051:
052: sendListManager[0] = new SendListManager();
053: sendListManager[1] = new SendListManager();
054: }
055:
056: public SendableMessage getSendableMessage(Object uid)
057: throws Exception {
058: ColumbaMessage message = getMessage(uid);
059:
060: SendableMessage sendableMessage = new SendableMessage(message);
061:
062: return sendableMessage;
063: }
064:
065: /**
066: *
067: * OutboxFolder doesn't allow adding messages, in comparison to other
068: * regular mailbox folders.
069: *
070: * @see org.columba.mail.folder.FolderTreeNode#supportsAddMessage()
071: */
072: public boolean supportsAddMessage() {
073: return false;
074: }
075:
076: /**
077: * The outbox folder doesnt allow adding folders to it.
078: *
079: * @param newFolderType
080: * folder to check..
081: * @return false always.
082: */
083: public boolean supportsAddFolder(String newFolderType) {
084: return false;
085: }
086:
087: /**
088: * Returns if this folder type can be moved.
089: *
090: * @return false always.
091: */
092: public boolean supportsMove() {
093: return false;
094: }
095:
096: /**
097: * @see org.columba.mail.folder.IMailbox#addMessage(java.io.InputStream,
098: * org.columba.ristretto.message.Attributes)
099: */
100: public Object addMessage(InputStream in, Attributes attributes,
101: Flags flags) throws Exception {
102: Object uid = super .addMessage(in, attributes, flags);
103: setAttribute(uid, "columba.recipients", attributes
104: .get("columba.recipients"));
105:
106: return uid;
107: }
108:
109: }
|