001: package org.columba.mail.imap;
002:
003: import java.io.IOException;
004: import java.io.InputStream;
005: import java.util.List;
006: import java.util.Observable;
007:
008: import org.columba.api.command.IStatusObservable;
009: import org.columba.core.command.CommandCancelledException;
010: import org.columba.core.filter.FilterRule;
011: import org.columba.core.filter.IFilterRule;
012: import org.columba.mail.config.ImapItem;
013: import org.columba.mail.folder.command.MarkMessageCommand;
014: import org.columba.mail.folder.imap.IMAPFolder;
015: import org.columba.mail.message.IHeaderList;
016: import org.columba.ristretto.imap.IMAPException;
017: import org.columba.ristretto.imap.IMAPFlags;
018: import org.columba.ristretto.imap.ListInfo;
019: import org.columba.ristretto.imap.MailboxStatus;
020: import org.columba.ristretto.imap.NamespaceCollection;
021: import org.columba.ristretto.imap.SearchKey;
022: import org.columba.ristretto.imap.SequenceSet;
023: import org.columba.ristretto.message.Header;
024: import org.columba.ristretto.message.MailboxInfo;
025: import org.columba.ristretto.message.MimePart;
026: import org.columba.ristretto.message.MimeTree;
027:
028: public interface IImapServer {
029:
030: /**
031: * Get mailbox path delimiter
032: * <p>
033: * example: "/" (uw-imap), or "." (cyrus)
034: *
035: * @return delimiter
036: */
037: public String getDelimiter() throws IOException, IMAPException,
038: CommandCancelledException;
039:
040: /**
041: * Logout cleanly.
042: *
043: * @throws Exception
044: */
045: public void logout() throws Exception;
046:
047: public List checkSupportedAuthenticationMethods()
048: throws IOException;
049:
050: /**
051: * @param command
052: * @return
053: */
054: public boolean isSupported(String command) throws IOException;
055:
056: public void setFirstLoginAction(IFirstLoginAction action);
057:
058: /**
059: * Check if mailbox is already selected.
060: * <p>
061: * If its not selected -> select it.
062: *
063: * @param path
064: * mailbox path
065: * @throws Exception
066: */
067: public void ensureSelectedState(IMAPFolder folder)
068: throws IOException, IMAPException,
069: CommandCancelledException;
070:
071: public MailboxStatus getStatus(IMAPFolder folder)
072: throws IOException, IMAPException,
073: CommandCancelledException;
074:
075: /**
076: * List available Mailboxes.
077: *
078: * @param reference
079: * @param pattern
080: * @return
081: * @throws Exception
082: */
083: public ListInfo[] list(String reference, String pattern)
084: throws Exception;
085:
086: /**
087: * Append message to mailbox.
088: *
089: * @param messageSource
090: * message source
091: * @param folder
092: * name of mailbox
093: *
094: * @throws Exception
095: */
096: public Integer append(InputStream messageSource, IMAPFlags flags,
097: IMAPFolder folder) throws Exception;
098:
099: /**
100: * Append message to mailbox.
101: *
102: * @param messageSource
103: * message source
104: * @param folder
105: * name of mailbox
106: *
107: * @throws Exception
108: */
109: public Integer append(InputStream messageSource, IMAPFolder folder)
110: throws Exception;
111:
112: /**
113: * Create new mailbox.
114: *
115: * @param mailboxName
116: * name of new mailbox
117: *
118: * @return
119: * @throws Exception
120: */
121: public void createMailbox(String mailboxName, IMAPFolder folder)
122: throws IOException, IMAPException,
123: CommandCancelledException;
124:
125: /**
126: * Delete mailbox.
127: *
128: * @param mailboxName
129: * name of mailbox
130: * @return
131: * @throws Exception
132: */
133: public void deleteFolder(String path) throws Exception;
134:
135: /**
136: * Rename mailbox.
137: *
138: * @param oldMailboxName
139: * old mailbox name
140: * @param newMailboxName
141: * new mailbox name
142: * @return
143: * @throws Exception
144: */
145: public void renameFolder(String oldMailboxName,
146: String newMailboxName) throws IOException, IMAPException,
147: CommandCancelledException;
148:
149: /**
150: * Subscribe to mailbox.
151: *
152: * @param mailboxName
153: * name of mailbox
154: * @return
155: * @throws Exception
156: */
157: public void subscribeFolder(String mailboxName) throws IOException,
158: IMAPException, CommandCancelledException;
159:
160: /**
161: * Unsubscribe to mailbox.
162: *
163: * @param mailboxNamename
164: * of mailbox
165: * @return
166: * @throws Exception
167: */
168: public void unsubscribeFolder(String mailboxName)
169: throws IOException, IMAPException,
170: CommandCancelledException;
171:
172: /**
173: * Expunge folder.
174: * <p>
175: * Delete every message mark as expunged.
176: *
177: * @param folder
178: * name of mailbox
179: * @return
180: * @throws Exception
181: */
182: public void expunge(IMAPFolder folder) throws IOException,
183: IMAPException, CommandCancelledException;
184:
185: /**
186: * Copy a set of messages to another mailbox on the same IMAP server.
187: * <p>
188: * <p>
189: * We copy messages in pieces of 100 headers. This means we tokenize the
190: * <code>list</code> in sublists of the size of 100. Then we execute the
191: * command and process those 100 results.
192: *
193: * @param destFolder
194: * destination mailbox
195: * @param uids
196: * UIDs of messages -> this array will get sorted!
197: * @param path
198: * source mailbox
199: * @throws Exception
200: */
201: public Integer[] copy(IMAPFolder destFolder, Object[] uids,
202: IMAPFolder folder) throws Exception;
203:
204: /**
205: * Fetch the uid for the index.
206: *
207: * @param index of the message
208: * @param folder the IMAP mailbox
209: * @return uid of the message
210: * @throws IOException
211: * @throws IMAPException
212: * @throws CommandCancelledException
213: */
214: public int fetchUid(SequenceSet set, IMAPFolder folder)
215: throws IOException, IMAPException,
216: CommandCancelledException;
217:
218: /**
219: * Fetch list of UIDs.
220: *
221: * @param folder
222: * mailbox name
223: *
224: * @return list of flags
225: * @throws Exception
226: */
227: public Integer[] fetchUids(SequenceSet set, IMAPFolder folder)
228: throws IOException, IMAPException,
229: CommandCancelledException;
230:
231: /**
232: * Fetch list of flags and parse it.
233: *
234: * @param folder
235: * mailbox name
236: *
237: * @return list of flags
238: * @throws Exception
239: */
240: public IMAPFlags[] fetchFlagsListStartFrom(int startIdx,
241: IMAPFolder folder) throws IOException, IMAPException,
242: CommandCancelledException;
243:
244: /**
245: * Fetch list of flags and parse it.
246: *
247: * @param folder
248: * mailbox name
249: *
250: * @return list of flags
251: * @throws Exception
252: */
253: public IMAPFlags[] fetchFlagsListStartFrom2(int startIdx,
254: IMAPFolder folder) throws IOException, IMAPException,
255: CommandCancelledException;
256:
257: public NamespaceCollection fetchNamespaces() throws IOException,
258: IMAPException, CommandCancelledException;
259:
260: /**
261: * Fetch list of headers and parse them.
262: * <p>
263: * We fetch headers in pieces of 100 headers. This means we tokenize the
264: * <code>list</code> in sublists of the size of 100. Then we execute the
265: * command and process those 100 results.
266: *
267: * @param headerList
268: * headerlist to add new headers
269: * @param list
270: * list of UIDs to download
271: * @param path
272: * mailbox name
273: * @throws Exception
274: */
275: public void fetchHeaderList(IHeaderList headerList, List list,
276: IMAPFolder folder) throws Exception;
277:
278: /**
279: * Get {@link MimeTree}.
280: *
281: * @param uid
282: * message UID
283: * @param folder
284: * mailbox name
285: * @return mimetree
286: * @throws Exception
287: */
288: public MimeTree getMimeTree(Object uid, IMAPFolder folder)
289: throws IOException, IMAPException,
290: CommandCancelledException;
291:
292: /**
293: * Get {@link MimePart}.
294: *
295: * @param uid
296: * message UID
297: * @param address
298: * address of MimePart in MimeTree
299: * @param folder
300: * mailbox name
301: * @return mimepart
302: * @throws CommandCancelledException
303: * @throws IMAPException
304: * @throws IOException
305: * @throws Exception
306: */
307: public InputStream getMimePartBodyStream(Object uid,
308: Integer[] address, IMAPFolder folder) throws IOException,
309: IMAPException, CommandCancelledException;
310:
311: /**
312: * Get {@link MimePart}.
313: *
314: * @param uid
315: * message UID
316: * @param address
317: * address of MimePart in MimeTree
318: * @param folder
319: * mailbox name
320: * @return mimepart
321: * @throws CommandCancelledException
322: * @throws IMAPException
323: * @throws IOException
324: * @throws Exception
325: */
326: public Header getHeaders(Object uid, String[] keys,
327: IMAPFolder folder) throws IOException, IMAPException,
328: CommandCancelledException;
329:
330: /**
331: * Get complete headers.
332: *
333: * @param uid
334: * message uid
335: * @param folder
336: * mailbox path
337: * @return
338: * @throws Exception
339: * @throws CommandCancelledException
340: * @throws IMAPException
341: * @throws IOException
342: */
343: public Header getAllHeaders(Object uid, IMAPFolder folder)
344: throws IOException, IMAPException,
345: CommandCancelledException;
346:
347: /**
348: * Get {@link MimePart}.
349: *
350: * @param uid
351: * message UID
352: * @param address
353: * address of MimePart in MimeTree
354: * @param folder
355: * mailbox name
356: * @return mimepart
357: * @throws CommandCancelledException
358: * @throws IMAPException
359: * @throws IOException
360: * @throws Exception
361: */
362: public InputStream getMimePartSourceStream(Object uid,
363: Integer[] address, IMAPFolder folder) throws IOException,
364: IMAPException, CommandCancelledException;
365:
366: /**
367: * Get complete message source.
368: *
369: * @param uid
370: * message UID
371: * @param path
372: * mailbox name
373: * @return message source
374: * @throws CommandCancelledException
375: * @throws IMAPException
376: * @throws IOException
377: * @throws Exception
378: */
379: public InputStream getMessageSourceStream(Object uid,
380: IMAPFolder folder) throws IOException, IMAPException,
381: CommandCancelledException;
382:
383: /**
384: * Mark message as specified by variant.
385: * <p>
386: * See {@link MarkMessageCommand}for a list of variants.
387: * <p>
388: * We mark messages in pieces of 100 headers. This means we tokenize the
389: * <code>list</code> in sublists of the size of 100. Then we execute the
390: * command and process those 100 results.
391: *
392: * @param uids
393: * message UID
394: * @param variant
395: * variant (read/flagged/expunged/etc.)
396: * @param folder
397: * mailbox name
398: * @throws Exception
399: */
400: public void markMessage(Object[] uids, int variant,
401: IMAPFolder folder) throws IOException, IMAPException,
402: CommandCancelledException;
403:
404: public void setFlags(Object[] uids, IMAPFlags flags,
405: IMAPFolder folder) throws IOException, IMAPException,
406: CommandCancelledException;
407:
408: /**
409: * Search messages.
410: *
411: * @param uids
412: * message UIDs
413: * @param filterRule
414: * filter rules
415: * @param folder
416: * mailbox name
417: * @return list of UIDs which match filter rules
418: * @throws Exception
419: */
420: public List search(Object[] uids, IFilterRule filterRule,
421: IMAPFolder folder) throws Exception;
422:
423: public int getIndex(Integer uid, IMAPFolder folder)
424: throws IOException, IMAPException,
425: CommandCancelledException;
426:
427: public Integer[] search(SearchKey key, IMAPFolder folder)
428: throws IOException, IMAPException,
429: CommandCancelledException;
430:
431: /**
432: *
433: * @param filterRule
434: * @param folder
435: * @return
436: * @throws Exception
437: * @throws CommandCancelledException
438: * @throws IMAPException
439: * @throws IOException
440: */
441: public List search(IFilterRule filterRule, IMAPFolder folder)
442: throws IOException, IMAPException,
443: CommandCancelledException;
444:
445: /**
446: * @param folder
447: *
448: * @return
449: * @throws CommandCancelledException
450: * @throws IMAPException
451: * @throws IOException
452: */
453: public MailboxInfo getMessageFolderInfo(IMAPFolder folder)
454: throws IOException, IMAPException,
455: CommandCancelledException;
456:
457: /**
458: * @return
459: */
460: public ListInfo[] fetchSubscribedFolders() throws IOException,
461: IMAPException, CommandCancelledException;
462:
463: /**
464: * @param imapPath
465: * @return
466: * @throws IOException
467: * @throws CommandCancelledException
468: * @throws IMAPException
469: */
470: public boolean isSelected(IMAPFolder folder) throws IOException,
471: IMAPException, CommandCancelledException;
472:
473: /**
474: * @see org.columba.ristretto.imap.IMAPListener#alertMessage(java.lang.String)
475: */
476: public void alertMessage(String arg0);
477:
478: /**
479: * @see org.columba.ristretto.imap.IMAPListener#connectionClosed(java.lang.String,
480: * java.lang.String)
481: */
482: public void connectionClosed(String arg0, String arg1);
483:
484: /**
485: * @see org.columba.ristretto.imap.IMAPListener#existsChanged(java.lang.String,
486: * int)
487: */
488: public void existsChanged(String arg0, int arg1);
489:
490: /**
491: * @see org.columba.ristretto.imap.IMAPListener#flagsChanged(java.lang.String,
492: * org.columba.ristretto.imap.IMAPFlags)
493: */
494: public void flagsChanged(String arg0, IMAPFlags arg1);
495:
496: /**
497: * @see org.columba.ristretto.imap.IMAPListener#parseError(java.lang.String)
498: */
499: public void parseError(String arg0);
500:
501: /**
502: * @see org.columba.ristretto.imap.IMAPListener#recentChanged(java.lang.String,
503: * int)
504: */
505: public void recentChanged(String arg0, int arg1);
506:
507: /**
508: * @see org.columba.ristretto.imap.IMAPListener#warningMessage(java.lang.String)
509: */
510: public void warningMessage(String arg0);
511:
512: /**
513: * @return Returns the item.
514: */
515: public ImapItem getItem();
516:
517: public void update(Observable o, Object arg);
518:
519: /**
520: * @param existsChangedAction The existsChangedAction to set.
521: */
522: public void setExistsChangedAction(
523: IExistsChangedAction existsChangedAction);
524:
525: /**
526: * @param updateFlagAction The updateFlagAction to set.
527: */
528: public void setUpdateFlagAction(IUpdateFlagAction updateFlagAction);
529:
530: /**
531: * @param observable The observable to set.
532: */
533: public void setObservable(IStatusObservable observable);
534:
535: public int getLargestRemoteUid(IMAPFolder folder)
536: throws IOException, IMAPException,
537: CommandCancelledException;
538:
539: }
|