01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //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.gui.composer.command;
19:
20: import java.io.InputStream;
21:
22: import org.columba.api.command.ICommandReference;
23: import org.columba.api.command.IWorkerStatusController;
24: import org.columba.mail.command.MailFolderCommandReference;
25: import org.columba.mail.folder.IMailbox;
26: import org.columba.mail.gui.composer.ComposerModel;
27: import org.columba.ristretto.message.InputStreamMimePart;
28: import org.columba.ristretto.message.MimeHeader;
29: import org.columba.ristretto.message.MimeType;
30:
31: /**
32: * Reply to message, while keeping the original message as attachment. In
33: * comparison to quoting the bodytext inline.
34: *
35: * @author fdietz
36: */
37: public class ReplyAsAttachmentCommand extends ReplyCommand {
38:
39: /**
40: * Constructor for ReplyCommand.
41: *
42: * @param frameMediator
43: * @param references
44: */
45: public ReplyAsAttachmentCommand(ICommandReference reference) {
46: super (reference);
47: }
48:
49: public void execute(IWorkerStatusController worker)
50: throws Exception {
51: // create composer model
52: model = new ComposerModel();
53:
54: // get selected folder
55: IMailbox folder = (IMailbox) ((MailFolderCommandReference) getReference())
56: .getSourceFolder();
57:
58: // get first selected message
59: Object[] uids = ((MailFolderCommandReference) getReference())
60: .getUids();
61:
62: // ->set source reference in composermodel
63: // when replying this is the original sender's message
64: // you selected and replied to
65: MailFolderCommandReference ref = new MailFolderCommandReference(
66: folder, uids);
67: model.setSourceReference(ref);
68:
69: // setup to, references and account
70: initHeader(folder, uids);
71:
72: // initialize MimeHeader as RFC822-compliant-message
73: MimeHeader mimeHeader = new MimeHeader();
74: mimeHeader.setMimeType(new MimeType("message", "rfc822"));
75: mimeHeader.setContentDescription((String) folder.getAttribute(
76: uids[0], "columba.subject"));
77:
78: // add mimepart to model
79:
80: InputStream messageSourceStream = folder
81: .getMessageSourceStream(uids[0]);
82: model.addMimePart(new InputStreamMimePart(mimeHeader,
83: messageSourceStream));
84: messageSourceStream.close();
85: }
86: }
|