KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > imap > IImapServer


1 package org.columba.mail.imap;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5 import java.util.List JavaDoc;
6 import java.util.Observable JavaDoc;
7
8 import org.columba.api.command.IStatusObservable;
9 import org.columba.core.command.CommandCancelledException;
10 import org.columba.core.filter.FilterRule;
11 import org.columba.core.filter.IFilterRule;
12 import org.columba.mail.config.ImapItem;
13 import org.columba.mail.folder.command.MarkMessageCommand;
14 import org.columba.mail.folder.imap.IMAPFolder;
15 import org.columba.mail.message.IHeaderList;
16 import org.columba.ristretto.imap.IMAPException;
17 import org.columba.ristretto.imap.IMAPFlags;
18 import org.columba.ristretto.imap.ListInfo;
19 import org.columba.ristretto.imap.MailboxStatus;
20 import org.columba.ristretto.imap.NamespaceCollection;
21 import org.columba.ristretto.imap.SearchKey;
22 import org.columba.ristretto.imap.SequenceSet;
23 import org.columba.ristretto.message.Header;
24 import org.columba.ristretto.message.MailboxInfo;
25 import org.columba.ristretto.message.MimePart;
26 import org.columba.ristretto.message.MimeTree;
27
28 public interface IImapServer {
29
30     /**
31      * Get mailbox path delimiter
32      * <p>
33      * example: "/" (uw-imap), or "." (cyrus)
34      *
35      * @return delimiter
36      */

37     public String JavaDoc getDelimiter() throws IOException JavaDoc, IMAPException,
38             CommandCancelledException;
39
40     /**
41      * Logout cleanly.
42      *
43      * @throws Exception
44      */

45     public void logout() throws Exception JavaDoc;
46
47     public List JavaDoc checkSupportedAuthenticationMethods() throws IOException JavaDoc;
48
49     /**
50      * @param command
51      * @return
52      */

53     public boolean isSupported(String JavaDoc command) throws IOException JavaDoc;
54
55     public void setFirstLoginAction(IFirstLoginAction action);
56
57     /**
58      * Check if mailbox is already selected.
59      * <p>
60      * If its not selected -> select it.
61      *
62      * @param path
63      * mailbox path
64      * @throws Exception
65      */

66     public void ensureSelectedState(IMAPFolder folder) throws IOException JavaDoc,
67             IMAPException, CommandCancelledException;
68
69     public MailboxStatus getStatus(IMAPFolder folder) throws IOException JavaDoc,
70             IMAPException, CommandCancelledException;
71
72     /**
73      * List available Mailboxes.
74      *
75      * @param reference
76      * @param pattern
77      * @return
78      * @throws Exception
79      */

80     public ListInfo[] list(String JavaDoc reference, String JavaDoc pattern) throws Exception JavaDoc;
81
82     /**
83      * Append message to mailbox.
84      *
85      * @param messageSource
86      * message source
87      * @param folder
88      * name of mailbox
89      *
90      * @throws Exception
91      */

92     public Integer JavaDoc append(InputStream JavaDoc messageSource, IMAPFlags flags,
93             IMAPFolder folder) throws Exception JavaDoc;
94
95     /**
96      * Append message to mailbox.
97      *
98      * @param messageSource
99      * message source
100      * @param folder
101      * name of mailbox
102      *
103      * @throws Exception
104      */

105     public Integer JavaDoc append(InputStream JavaDoc messageSource, IMAPFolder folder)
106             throws Exception JavaDoc;
107
108     /**
109      * Create new mailbox.
110      *
111      * @param mailboxName
112      * name of new mailbox
113      *
114      * @return
115      * @throws Exception
116      */

117     public void createMailbox(String JavaDoc mailboxName, IMAPFolder folder)
118             throws IOException JavaDoc, IMAPException, CommandCancelledException;
119
120     /**
121      * Delete mailbox.
122      *
123      * @param mailboxName
124      * name of mailbox
125      * @return
126      * @throws Exception
127      */

128     public void deleteFolder(String JavaDoc path) throws Exception JavaDoc;
129
130     /**
131      * Rename mailbox.
132      *
133      * @param oldMailboxName
134      * old mailbox name
135      * @param newMailboxName
136      * new mailbox name
137      * @return
138      * @throws Exception
139      */

140     public void renameFolder(String JavaDoc oldMailboxName, String JavaDoc newMailboxName)
141             throws IOException JavaDoc, IMAPException, CommandCancelledException;
142
143     /**
144      * Subscribe to mailbox.
145      *
146      * @param mailboxName
147      * name of mailbox
148      * @return
149      * @throws Exception
150      */

151     public void subscribeFolder(String JavaDoc mailboxName) throws IOException JavaDoc,
152             IMAPException, CommandCancelledException;
153
154     /**
155      * Unsubscribe to mailbox.
156      *
157      * @param mailboxNamename
158      * of mailbox
159      * @return
160      * @throws Exception
161      */

162     public void unsubscribeFolder(String JavaDoc mailboxName) throws IOException JavaDoc,
163             IMAPException, CommandCancelledException;
164
165     /**
166      * Expunge folder.
167      * <p>
168      * Delete every message mark as expunged.
169      *
170      * @param folder
171      * name of mailbox
172      * @return
173      * @throws Exception
174      */

175     public void expunge(IMAPFolder folder) throws IOException JavaDoc, IMAPException,
176             CommandCancelledException;
177
178     /**
179      * Copy a set of messages to another mailbox on the same IMAP server.
180      * <p>
181      * <p>
182      * We copy messages in pieces of 100 headers. This means we tokenize the
183      * <code>list</code> in sublists of the size of 100. Then we execute the
184      * command and process those 100 results.
185      *
186      * @param destFolder
187      * destination mailbox
188      * @param uids
189      * UIDs of messages -> this array will get sorted!
190      * @param path
191      * source mailbox
192      * @throws Exception
193      */

194     public Integer JavaDoc[] copy(IMAPFolder destFolder, Object JavaDoc[] uids,
195             IMAPFolder folder) throws Exception JavaDoc;
196
197     /**
198      * Fetch the uid for the index.
199      *
200      * @param index of the message
201      * @param folder the IMAP mailbox
202      * @return uid of the message
203      * @throws IOException
204      * @throws IMAPException
205      * @throws CommandCancelledException
206      */

207     public int fetchUid(SequenceSet set, IMAPFolder folder) throws IOException JavaDoc,
208             IMAPException, CommandCancelledException;
209
210     /**
211      * Fetch list of UIDs.
212      *
213      * @param folder
214      * mailbox name
215      *
216      * @return list of flags
217      * @throws Exception
218      */

219     public Integer JavaDoc[] fetchUids(SequenceSet set, IMAPFolder folder)
220             throws IOException JavaDoc, IMAPException, CommandCancelledException;
221
222     /**
223      * Fetch list of flags and parse it.
224      *
225      * @param folder
226      * mailbox name
227      *
228      * @return list of flags
229      * @throws Exception
230      */

231     public IMAPFlags[] fetchFlagsListStartFrom(int startIdx, IMAPFolder folder)
232             throws IOException JavaDoc, IMAPException, CommandCancelledException;
233
234     /**
235      * Fetch list of flags and parse it.
236      *
237      * @param folder
238      * mailbox name
239      *
240      * @return list of flags
241      * @throws Exception
242      */

243     public IMAPFlags[] fetchFlagsListStartFrom2(int startIdx, IMAPFolder folder)
244             throws IOException JavaDoc, IMAPException, CommandCancelledException;
245
246     public NamespaceCollection fetchNamespaces() throws IOException JavaDoc,
247             IMAPException, CommandCancelledException;
248
249     /**
250      * Fetch list of headers and parse them.
251      * <p>
252      * We fetch headers in pieces of 100 headers. This means we tokenize the
253      * <code>list</code> in sublists of the size of 100. Then we execute the
254      * command and process those 100 results.
255      *
256      * @param headerList
257      * headerlist to add new headers
258      * @param list
259      * list of UIDs to download
260      * @param path
261      * mailbox name
262      * @throws Exception
263      */

264     public void fetchHeaderList(IHeaderList headerList, List JavaDoc list,
265             IMAPFolder folder) throws Exception JavaDoc;
266
267     /**
268      * Get {@link MimeTree}.
269      *
270      * @param uid
271      * message UID
272      * @param folder
273      * mailbox name
274      * @return mimetree
275      * @throws Exception
276      */

277     public MimeTree getMimeTree(Object JavaDoc uid, IMAPFolder folder)
278             throws IOException JavaDoc, IMAPException, CommandCancelledException;
279
280     /**
281      * Get {@link MimePart}.
282      *
283      * @param uid
284      * message UID
285      * @param address
286      * address of MimePart in MimeTree
287      * @param folder
288      * mailbox name
289      * @return mimepart
290      * @throws CommandCancelledException
291      * @throws IMAPException
292      * @throws IOException
293      * @throws Exception
294      */

295     public InputStream JavaDoc getMimePartBodyStream(Object JavaDoc uid, Integer JavaDoc[] address,
296             IMAPFolder folder) throws IOException JavaDoc, IMAPException,
297             CommandCancelledException;
298
299     /**
300      * Get {@link MimePart}.
301      *
302      * @param uid
303      * message UID
304      * @param address
305      * address of MimePart in MimeTree
306      * @param folder
307      * mailbox name
308      * @return mimepart
309      * @throws CommandCancelledException
310      * @throws IMAPException
311      * @throws IOException
312      * @throws Exception
313      */

314     public Header getHeaders(Object JavaDoc uid, String JavaDoc[] keys, IMAPFolder folder)
315             throws IOException JavaDoc, IMAPException, CommandCancelledException;
316
317     /**
318      * Get complete headers.
319      *
320      * @param uid
321      * message uid
322      * @param folder
323      * mailbox path
324      * @return
325      * @throws Exception
326      * @throws CommandCancelledException
327      * @throws IMAPException
328      * @throws IOException
329      */

330     public Header getAllHeaders(Object JavaDoc uid, IMAPFolder folder)
331             throws IOException JavaDoc, IMAPException, CommandCancelledException;
332
333     /**
334      * Get {@link MimePart}.
335      *
336      * @param uid
337      * message UID
338      * @param address
339      * address of MimePart in MimeTree
340      * @param folder
341      * mailbox name
342      * @return mimepart
343      * @throws CommandCancelledException
344      * @throws IMAPException
345      * @throws IOException
346      * @throws Exception
347      */

348     public InputStream JavaDoc getMimePartSourceStream(Object JavaDoc uid, Integer JavaDoc[] address,
349             IMAPFolder folder) throws IOException JavaDoc, IMAPException,
350             CommandCancelledException;
351
352     /**
353      * Get complete message source.
354      *
355      * @param uid
356      * message UID
357      * @param path
358      * mailbox name
359      * @return message source
360      * @throws CommandCancelledException
361      * @throws IMAPException
362      * @throws IOException
363      * @throws Exception
364      */

365     public InputStream JavaDoc getMessageSourceStream(Object JavaDoc uid, IMAPFolder folder)
366             throws IOException JavaDoc, IMAPException, CommandCancelledException;
367
368     /**
369      * Mark message as specified by variant.
370      * <p>
371      * See {@link MarkMessageCommand}for a list of variants.
372      * <p>
373      * We mark messages in pieces of 100 headers. This means we tokenize the
374      * <code>list</code> in sublists of the size of 100. Then we execute the
375      * command and process those 100 results.
376      *
377      * @param uids
378      * message UID
379      * @param variant
380      * variant (read/flagged/expunged/etc.)
381      * @param folder
382      * mailbox name
383      * @throws Exception
384      */

385     public void markMessage(Object JavaDoc[] uids, int variant, IMAPFolder folder)
386             throws IOException JavaDoc, IMAPException, CommandCancelledException;
387
388     public void setFlags(Object JavaDoc[] uids, IMAPFlags flags, IMAPFolder folder)
389             throws IOException JavaDoc, IMAPException, CommandCancelledException;
390
391     /**
392      * Search messages.
393      *
394      * @param uids
395      * message UIDs
396      * @param filterRule
397      * filter rules
398      * @param folder
399      * mailbox name
400      * @return list of UIDs which match filter rules
401      * @throws Exception
402      */

403     public List JavaDoc search(Object JavaDoc[] uids, IFilterRule filterRule, IMAPFolder folder)
404             throws Exception JavaDoc;
405
406     public int getIndex(Integer JavaDoc uid, IMAPFolder folder) throws IOException JavaDoc,
407             IMAPException, CommandCancelledException;
408
409     public Integer JavaDoc[] search(SearchKey key, IMAPFolder folder)
410             throws IOException JavaDoc, IMAPException, CommandCancelledException;
411
412     /**
413      *
414      * @param filterRule
415      * @param folder
416      * @return
417      * @throws Exception
418      * @throws CommandCancelledException
419      * @throws IMAPException
420      * @throws IOException
421      */

422     public List JavaDoc search(IFilterRule filterRule, IMAPFolder folder)
423             throws IOException JavaDoc, IMAPException, CommandCancelledException;
424
425     /**
426      * @param folder
427      *
428      * @return
429      * @throws CommandCancelledException
430      * @throws IMAPException
431      * @throws IOException
432      */

433     public MailboxInfo getMessageFolderInfo(IMAPFolder folder)
434             throws IOException JavaDoc, IMAPException, CommandCancelledException;
435
436     /**
437      * @return
438      */

439     public ListInfo[] fetchSubscribedFolders() throws IOException JavaDoc,
440             IMAPException, CommandCancelledException;
441
442     /**
443      * @param imapPath
444      * @return
445      * @throws IOException
446      * @throws CommandCancelledException
447      * @throws IMAPException
448      */

449     public boolean isSelected(IMAPFolder folder) throws IOException JavaDoc,
450             IMAPException, CommandCancelledException;
451
452     /**
453      * @see org.columba.ristretto.imap.IMAPListener#alertMessage(java.lang.String)
454      */

455     public void alertMessage(String JavaDoc arg0);
456
457     /**
458      * @see org.columba.ristretto.imap.IMAPListener#connectionClosed(java.lang.String,
459      * java.lang.String)
460      */

461     public void connectionClosed(String JavaDoc arg0, String JavaDoc arg1);
462
463     /**
464      * @see org.columba.ristretto.imap.IMAPListener#existsChanged(java.lang.String,
465      * int)
466      */

467     public void existsChanged(String JavaDoc arg0, int arg1);
468
469     /**
470      * @see org.columba.ristretto.imap.IMAPListener#flagsChanged(java.lang.String,
471      * org.columba.ristretto.imap.IMAPFlags)
472      */

473     public void flagsChanged(String JavaDoc arg0, IMAPFlags arg1);
474
475     /**
476      * @see org.columba.ristretto.imap.IMAPListener#parseError(java.lang.String)
477      */

478     public void parseError(String JavaDoc arg0);
479
480     /**
481      * @see org.columba.ristretto.imap.IMAPListener#recentChanged(java.lang.String,
482      * int)
483      */

484     public void recentChanged(String JavaDoc arg0, int arg1);
485
486     /**
487      * @see org.columba.ristretto.imap.IMAPListener#warningMessage(java.lang.String)
488      */

489     public void warningMessage(String JavaDoc arg0);
490
491     /**
492      * @return Returns the item.
493      */

494     public ImapItem getItem();
495
496     public void update(Observable JavaDoc o, Object JavaDoc arg);
497
498     /**
499      * @param existsChangedAction The existsChangedAction to set.
500      */

501     public void setExistsChangedAction(IExistsChangedAction existsChangedAction);
502
503     /**
504      * @param updateFlagAction The updateFlagAction to set.
505      */

506     public void setUpdateFlagAction(IUpdateFlagAction updateFlagAction);
507
508     /**
509      * @param observable The observable to set.
510      */

511     public void setObservable(IStatusObservable observable);
512
513     
514     public int getLargestRemoteUid(IMAPFolder folder) throws IOException JavaDoc, IMAPException, CommandCancelledException;
515     
516 }
Popular Tags