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.folder;
18:
19: import org.columba.core.io.DiskIO;
20: import org.columba.core.xml.XmlIO;
21: import org.columba.mail.config.AccountItem;
22: import org.columba.mail.folder.imap.IMAPFolder;
23: import org.columba.mail.folder.imap.IMAPRootFolder;
24:
25: public class IMAPTstFactory implements MailboxTstFactory {
26:
27: IMAPRootFolder cyrusRoot;
28: IMAPFolder inbox;
29: String namebase;
30:
31: public IMAPTstFactory() {
32: XmlIO accountXml = new XmlIO(
33: DiskIO
34: .getResourceURL("org/columba/mail/folder/cyrusaccount.xml"));
35: accountXml.load();
36:
37: AccountItem accountItem = new AccountItem(accountXml.getRoot()
38: .getElement("account"));
39:
40: cyrusRoot = new IMAPRootFolder(accountItem,
41: FolderTstHelper.homeDirectory + "/folders/");
42:
43: try {
44: inbox = new IMAPFolder("INBOX", "IMAPFolder",
45: FolderTstHelper.homeDirectory + "/folders/");
46: cyrusRoot.add(inbox);
47: } catch (Exception e) {
48: e.printStackTrace();
49: }
50:
51: // An individual 3 digit number
52: namebase = Integer
53: .toString((int) (System.currentTimeMillis() % 1000));
54: }
55:
56: /**
57: * @see org.columba.mail.folder.MailboxTstFactory#createFolder(int)
58: */
59: public AbstractMessageFolder createFolder(int folderId) {
60: try {
61: IMAPFolder folder = new IMAPFolder(namebase
62: + Integer.toString(folderId), "IMAPFolder",
63: FolderTstHelper.homeDirectory + "/folders/");
64: inbox.addSubfolder(folder);
65: /*
66: ((AbstractFolder)MailInterface.treeModel.getRoot()).add(cyrusRoot);
67: ((AbstractFolder) MailInterface.treeModel.getRoot())
68: .getConfiguration().getRoot().addElement(
69: cyrusRoot.getConfiguration().getRoot());
70: MailInterface.treeModel.nodeStructureChanged(cyrusRoot.getParent());
71: */
72: return folder;
73: } catch (Exception e) {
74: e.printStackTrace();
75: }
76: return null;
77: }
78: }
|