001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo
013: // Stich.
014: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
015: //
016: //All Rights Reserved.
017:
018: package org.columba.mail.folder;
019:
020: import java.io.File;
021: import java.io.IOException;
022: import java.io.InputStream;
023:
024: import org.columba.api.command.IStatusObservable;
025: import org.columba.core.filter.IFilterList;
026: import org.columba.core.filter.IFilter;
027: import org.columba.mail.message.IHeaderList;
028: import org.columba.ristretto.message.Attributes;
029: import org.columba.ristretto.message.Flags;
030: import org.columba.ristretto.message.Header;
031: import org.columba.ristretto.message.MailboxInfo;
032: import org.columba.ristretto.message.MimeTree;
033:
034: /**
035: * Every mailbox which actually containss message should implement this
036: * interface.
037: * <p>
038: * Note, that this also means to subclass {@link Folder}.
039: *
040: * @author fdietz
041: */
042: public interface IMailbox extends IMailFolder {
043:
044: /**
045: * Get the {@link MailboxInfo} of this mailbox
046: *
047: * @return
048: * @throws IOException
049: */
050: public IMailboxInfo getMessageFolderInfo();
051:
052: /**
053: * Removes all messages which are marked as expunged
054: *
055: * @throws Exception
056: */
057: public void expungeFolder() throws Exception;
058:
059: /**
060: * Checks if message with uid exists in this folder.
061: *
062: * @param uid
063: * UID of message
064: * @return boolean true, if message exists. False, otherwise.
065: * @throws Exception
066: */
067: public boolean exists(Object uid) throws Exception;
068:
069: /**
070: * Return list of headers.
071: *
072: * @return HeaderList list of headers
073: * @throws Exception
074: */
075: public IHeaderList getHeaderList() throws Exception;
076:
077: /**
078: * Mark messages as read/flagged/expunged/etc.
079: *
080: * See <code>MarkMessageCommand</code> for more information especially concerning
081: * the variant value.
082: *
083: * @param uid
084: * array of UIDs
085: * @param variant
086: * variant can be a value between 0 and 6
087: * @throws Exception
088: */
089: public abstract void markMessage(Object[] uids, int variant)
090: throws Exception;
091:
092: /**
093: * Return mimepart structure. See <class>MimePartTree </class> for more
094: * details.
095: *
096: * @param uid
097: * UID of message
098: * @return MimePartTree return mimepart structure
099: * @throws Exception
100: */
101: public MimeTree getMimePartTree(Object uid) throws Exception;
102:
103: /**
104: * Copy messages identified by UID to this folder.
105: * <p>
106: * This method is necessary for optimization reasons.
107: * <p>
108: * Think about using local and remote folders. If we would have only methods
109: * to add/remove messages this wouldn't be very efficient when moving
110: * messages between for example IMAP folders on the same server. We would
111: * have to download a complete message to remove it and then upload it again
112: * to add it to the destination folder.
113: * <p>
114: * Using the innercopy method the IMAP server can use its COPY command to
115: * move the message on the server-side.
116: *
117: * @param destFolder
118: * the destination folder of the copy operation
119: * @param uids
120: * an array of UID's identifying the messages
121: * @throws Exception
122: */
123: public void innerCopy(IMailbox destFolder, Object[] uids)
124: throws Exception;
125:
126: /**
127: * Adds a message to this Mailbox
128: *
129: * @param in
130: * The message InputStream
131: * @return The new uid of the added message or null if not defined
132: * @throws Exception
133: */
134: public Object addMessage(InputStream in) throws Exception;
135:
136: /**
137: * Adds a message to this Mailbox
138: *
139: * @param in
140: * The message InputStream
141: * @param attributes
142: * The attributes of the message
143: * @param flags
144: * the flags of the message
145: * @return The new uid of the added message or null if not defined
146: * @throws Exception
147: */
148: public Object addMessage(InputStream in, Attributes attributes,
149: Flags flags) throws Exception;
150:
151: /**
152: * Gets all specified headerfields. An example headerfield might be
153: * "Subject" or "From" (take care of lower/uppercaseletters).
154: * <p>
155: * Note, that you should use getAttributes() for fetching the internal
156: * headerfields (for example: columba.subject, columba.flags.seen, etc.).
157: * <p>
158: * This method first tries to find the requested header in the header cache
159: * (@see CachedFolder). If the headerfield is not cached, the message source
160: * is parsed.
161: *
162: * @param uid
163: * The uid of the desired message
164: * @param keys
165: * The keys like defined in e.g. RFC2822
166: * @return A {@link Header}containing the headerfields if they were present
167: * @throws Exception
168: */
169: public Header getHeaderFields(Object uid, String[] keys)
170: throws Exception;
171:
172: /**
173: * Gets the InputStream from the body of the mimepart. This excludes the
174: * header. If the stream was encoded with QuotedPrintable or Base64 decoding
175: * is already done.
176: *
177: * @param uid
178: * The UID of the message
179: * @param address
180: * The address of the mimepart
181: * @return
182: * @throws Exception
183: */
184: public InputStream getMimePartBodyStream(Object uid,
185: Integer[] address) throws Exception;
186:
187: /**
188: * Gets the InputStream from the complete mimepart. This includes the
189: * header.
190: *
191: * @param uid
192: * The UID of the message
193: * @param address
194: * address The address of the mimepart
195: * @return
196: * @throws Exception
197: */
198: public InputStream getMimePartSourceStream(Object uid,
199: Integer[] address) throws Exception;
200:
201: /**
202: * Gets the InputStream of the complete messagesource.
203: *
204: * @param uid
205: * The UID of the message
206: * @return
207: * @throws Exception
208: */
209: public InputStream getMessageSourceStream(Object uid)
210: throws Exception;
211:
212: /**
213: * Gets the Flags of the message.
214: *
215: * @param uid
216: * The UID of the message
217: * @return
218: * @throws Exception
219: */
220: public Flags getFlags(Object uid) throws Exception;
221:
222: /**
223: * Gets a attribute from the message
224: *
225: * @param uid
226: * The UID of the message
227: * @param key
228: * The name of the attribute (e.g. "columba.subject",
229: * "columba.size")
230: * @return
231: * @throws Exception
232: */
233: public Object getAttribute(Object uid, String key) throws Exception;
234:
235: /**
236: * Gets the attributes from the message
237: *
238: * @param uid
239: * The UID of the message
240: * @return
241: * @throws Exception
242: */
243: public Attributes getAttributes(Object uid) throws Exception;
244:
245: /**
246: * Set attribute for message with UID.
247: *
248: * @param uid
249: * UID of message
250: * @param key
251: * name of attribute (e.g."columba.subject");
252: * @param value
253: * value of attribute
254: * @throws Exception
255: */
256: public void setAttribute(Object uid, String key, Object value)
257: throws Exception;
258:
259: public void removeMessage(Object uid) throws Exception;
260:
261: /**
262: * Return array of uids this folder contains.
263: *
264: * @return Object[] array of all UIDs this folder contains
265: */
266: public Object[] getUids() throws Exception;
267:
268: /**
269: * Get all email headers.
270: *
271: * @param uid
272: * message uid
273: * @return complete email headers
274: * @throws Exception
275: */
276: public Header getAllHeaderFields(Object uid) throws Exception;
277:
278: public Object[] searchMessages(IFilter filter) throws Exception;
279:
280: public Object[] searchMessages(IFilter filter, Object[] uids)
281: throws Exception;
282:
283: /**
284: * Is this mailbox read-only?
285: *
286: * @return
287: *
288: */
289: public boolean isReadOnly();
290:
291: IStatusObservable getObservable();
292:
293: Object getLastSelection();
294:
295: void setLastSelection(Object lastSel);
296:
297: IFilterList getFilterList();
298:
299: public File getDirectoryFile();
300:
301: public boolean isInboxFolder();
302:
303: public boolean isTrashFolder();
304: }
|