public class IMAPProtocol extends Protocol
notifyResponseHandlers(r)
.Modifier and Type | Field and Description |
---|---|
protected String[] |
searchCharsets |
Constructor and Description |
---|
IMAPProtocol(String name,
String host,
int port,
boolean debug,
PrintStream out,
Properties props,
boolean isSSL)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
append(String mbox,
Flags f,
Date d,
Literal data)
APPEND Command.
|
AppendUID |
appenduid(String mbox,
Flags f,
Date d,
Literal data)
APPEND Command, return uid from APPENDUID response code.
|
AppendUID |
appenduid(String mbox,
Flags f,
Date d,
Literal data,
boolean uid) |
void |
authlogin(String u,
String p)
The AUTHENTICATE command with AUTH=LOGIN authenticate scheme
|
void |
authntlm(String authzid,
String u,
String p)
The AUTHENTICATE command with AUTH=NTLM authentication scheme.
|
void |
authplain(String authzid,
String u,
String p)
The AUTHENTICATE command with AUTH=PLAIN authentication scheme.
|
void |
capability()
CAPABILITY command.
|
void |
check()
CHECK Command.
|
void |
close()
CLOSE Command.
|
void |
copy(int start,
int end,
String mbox) |
void |
copy(MessageSet[] msgsets,
String mbox)
COPY command.
|
void |
create(String mbox)
CREATE Command.
|
void |
delete(String mbox)
DELETE Command.
|
void |
deleteACL(String mbox,
String user)
DELETEACL Command.
|
void |
disconnect()
Close socket connection.
|
MailboxInfo |
examine(String mbox)
EXAMINE Command.
|
void |
expunge()
EXPUNGE Command.
|
Response[] |
fetch(int start,
int end,
String what) |
Response[] |
fetch(int msg,
String what) |
Response[] |
fetch(MessageSet[] msgsets,
String what) |
BODY |
fetchBody(int msgno,
String section)
Fetch given BODY section.
|
protected BODY |
fetchBody(int msgno,
String section,
boolean peek) |
BODY |
fetchBody(int msgno,
String section,
int start,
int size)
Partial FETCH of given BODY section.
|
protected BODY |
fetchBody(int msgno,
String section,
int start,
int size,
boolean peek,
ByteArray ba) |
BODY |
fetchBody(int msgno,
String section,
int start,
int size,
ByteArray ba)
Partial FETCH of given BODY section.
|
BODYSTRUCTURE |
fetchBodyStructure(int msgno)
Fetch the BODYSTRUCTURE of the specified message.
|
Flags |
fetchFlags(int msgno)
Fetch the FLAGS for the given message.
|
RFC822DATA |
fetchRFC822(int msgno,
String what)
Fetch the specified RFC822 Data item.
|
UID |
fetchSequenceNumber(long uid)
Get the sequence number for the given UID.
|
UID[] |
fetchSequenceNumbers(long[] uids)
Get the sequence numbers for UIDs ranging from start till end.
|
UID[] |
fetchSequenceNumbers(long start,
long end)
Get the sequence numbers for UIDs ranging from start till end.
|
UID |
fetchUID(int msgno)
Fetch the IMAP UID for the given message.
|
ACL[] |
getACL(String mbox)
GETACL Command.
|
Map |
getCapabilities()
Return the map of capabilities returned by the server.
|
Quota[] |
getQuota(String root)
GETQUOTA Command.
|
Quota[] |
getQuotaRoot(String mbox)
GETQUOTAROOT Command.
|
protected ByteArray |
getResponseBuffer()
Return a buffer to read a response into.
|
boolean |
hasCapability(String c)
Check whether the given capability is supported by
this server.
|
void |
id(String guid)
ID Command, for Yahoo! Mail IMAP server.
|
void |
idleAbort()
Abort an IDLE command.
|
void |
idleStart()
IDLE Command.
|
boolean |
isAuthenticated()
Returns
true if the connection has been authenticated,
either due to a successful login, or due to a PREAUTH greeting response. |
boolean |
isREV1()
Returns
true if this is a IMAP4rev1 server |
ListInfo[] |
list(String ref,
String pattern)
LIST Command.
|
Rights[] |
listRights(String mbox,
String user)
LISTRIGHTS Command.
|
void |
login(String u,
String p)
LOGIN Command.
|
void |
logout()
LOGOUT Command.
|
ListInfo[] |
lsub(String ref,
String pattern)
LSUB Command.
|
Rights |
myRights(String mbox)
MYRIGHTS Command.
|
Namespaces |
namespace()
NAMESPACE Command.
|
void |
noop()
The NOOP command.
|
protected void |
parseCapabilities(Response r)
Parse the capabilities from a CAPABILITY response or from
a CAPABILITY response code attached to (e.g.) an OK response.
|
BODY |
peekBody(int msgno,
String section)
Fetch given BODY section, without marking the message
as SEEN.
|
BODY |
peekBody(int msgno,
String section,
int start,
int size)
Partial FETCH of given BODY section, without setting SEEN flag.
|
BODY |
peekBody(int msgno,
String section,
int start,
int size,
ByteArray ba)
Partial FETCH of given BODY section, without setting SEEN flag.
|
protected void |
processGreeting(Response r)
Check the greeting when first connecting; look for PREAUTH response.
|
boolean |
processIdleResponse(Response r)
Process a response returned by readIdleResponse().
|
void |
proxyauth(String u)
PROXYAUTH Command.
|
Response |
readIdleResponse()
While an IDLE command is in progress, read a response
sent from the server.
|
Response |
readResponse()
Read a response from the server.
|
void |
rename(String o,
String n)
RENAME Command.
|
void |
sasllogin(String[] allowed,
String realm,
String authzid,
String u,
String p)
SASL-based login.
|
int[] |
search(MessageSet[] msgsets,
SearchTerm term)
Issue the given search criterion on the specified message sets.
|
int[] |
search(SearchTerm term)
Issue the given search criterion on all messages in this folder.
|
MailboxInfo |
select(String mbox)
SELECT Command.
|
void |
setACL(String mbox,
char modifier,
ACL acl)
SETACL Command.
|
protected void |
setCapabilities(Response r)
If the response contains a CAPABILITY response code, extract
it and save the capabilities.
|
void |
setQuota(Quota quota)
SETQUOTA Command.
|
int[] |
sort(SortTerm[] term,
SearchTerm sterm)
Sort messages in the folder according to the specified sort criteria.
|
void |
startTLS()
STARTTLS Command.
|
Status |
status(String mbox,
String[] items)
STATUS Command.
|
void |
storeFlags(int msg,
Flags flags,
boolean set)
Set the specified flags on this message.
|
void |
storeFlags(int start,
int end,
Flags flags,
boolean set) |
void |
storeFlags(MessageSet[] msgsets,
Flags flags,
boolean set) |
void |
subscribe(String mbox)
SUBSCRIBE Command.
|
protected boolean |
supportsNonSyncLiterals()
Returns whether this Protocol supports non-synchronizing literals.
|
void |
uidexpunge(UIDSet[] set)
UID EXPUNGE Command.
|
void |
unselect()
UNSELECT Command.
|
void |
unsubscribe(String mbox)
UNSUBSCRIBE Command.
|
addResponseHandler, command, finalize, getInputStream, getLocalHost, getOutputStream, getTimestamp, handleResult, notifyResponseHandlers, removeResponseHandler, simpleCommand, startTLS, writeCommand
protected String[] searchCharsets
public IMAPProtocol(String name, String host, int port, boolean debug, PrintStream out, Properties props, boolean isSSL) throws IOException, ProtocolException
host
- host to connect toport
- portnumber to connect todebug
- debug modeprops
- Properties object used by this protocolIOException
ProtocolException
public void capability() throws ProtocolException
ProtocolException
protected void setCapabilities(Response r)
protected void parseCapabilities(Response r)
protected void processGreeting(Response r) throws ProtocolException
processGreeting
in class Protocol
ProtocolException
public boolean isAuthenticated()
true
if the connection has been authenticated,
either due to a successful login, or due to a PREAUTH greeting response.public boolean isREV1()
true
if this is a IMAP4rev1 serverprotected boolean supportsNonSyncLiterals()
supportsNonSyncLiterals
in class Protocol
public Response readResponse() throws IOException, ProtocolException
readResponse
in class Protocol
IOException
ProtocolException
public boolean hasCapability(String c)
true
if so, otherwise
returns false.public Map getCapabilities()
public void disconnect()
disconnect
in class Protocol
public void noop() throws ProtocolException
ProtocolException
public void logout() throws ProtocolException
ProtocolException
public void login(String u, String p) throws ProtocolException
ProtocolException
public void authlogin(String u, String p) throws ProtocolException
ProtocolException
public void authplain(String authzid, String u, String p) throws ProtocolException
authlogin(java.lang.String, java.lang.String)
method.authzid
- the authorization idu
- the usernamep
- the passwordProtocolException
- as thrown by Protocol.handleResult(com.sun.mail.iap.Response)
.public void authntlm(String authzid, String u, String p) throws ProtocolException
authlogin(java.lang.String, java.lang.String)
method.authzid
- the authorization idu
- the usernamep
- the passwordProtocolException
- as thrown by Protocol.handleResult(com.sun.mail.iap.Response)
.public void sasllogin(String[] allowed, String realm, String authzid, String u, String p) throws ProtocolException
ProtocolException
public void proxyauth(String u) throws ProtocolException
ProtocolException
public void id(String guid) throws ProtocolException
ProtocolException
http://en.wikipedia.org/wiki/Yahoo%21_Mail#Free_IMAP_and_SMTPs_access
public void startTLS() throws ProtocolException
ProtocolException
public MailboxInfo select(String mbox) throws ProtocolException
ProtocolException
public MailboxInfo examine(String mbox) throws ProtocolException
ProtocolException
public void unselect() throws ProtocolException
ProtocolException
public Status status(String mbox, String[] items) throws ProtocolException
ProtocolException
public void create(String mbox) throws ProtocolException
ProtocolException
public void delete(String mbox) throws ProtocolException
ProtocolException
public void rename(String o, String n) throws ProtocolException
ProtocolException
public void subscribe(String mbox) throws ProtocolException
ProtocolException
public void unsubscribe(String mbox) throws ProtocolException
ProtocolException
public ListInfo[] list(String ref, String pattern) throws ProtocolException
ProtocolException
public ListInfo[] lsub(String ref, String pattern) throws ProtocolException
ProtocolException
public void append(String mbox, Flags f, Date d, Literal data) throws ProtocolException
ProtocolException
public AppendUID appenduid(String mbox, Flags f, Date d, Literal data) throws ProtocolException
ProtocolException
public AppendUID appenduid(String mbox, Flags f, Date d, Literal data, boolean uid) throws ProtocolException
ProtocolException
public void check() throws ProtocolException
ProtocolException
public void close() throws ProtocolException
ProtocolException
public void expunge() throws ProtocolException
ProtocolException
public void uidexpunge(UIDSet[] set) throws ProtocolException
ProtocolException
public BODYSTRUCTURE fetchBodyStructure(int msgno) throws ProtocolException
ProtocolException
public BODY peekBody(int msgno, String section) throws ProtocolException
ProtocolException
public BODY fetchBody(int msgno, String section) throws ProtocolException
ProtocolException
protected BODY fetchBody(int msgno, String section, boolean peek) throws ProtocolException
ProtocolException
public BODY peekBody(int msgno, String section, int start, int size) throws ProtocolException
ProtocolException
public BODY fetchBody(int msgno, String section, int start, int size) throws ProtocolException
ProtocolException
public BODY peekBody(int msgno, String section, int start, int size, ByteArray ba) throws ProtocolException
ProtocolException
public BODY fetchBody(int msgno, String section, int start, int size, ByteArray ba) throws ProtocolException
ProtocolException
protected BODY fetchBody(int msgno, String section, int start, int size, boolean peek, ByteArray ba) throws ProtocolException
ProtocolException
protected ByteArray getResponseBuffer()
getResponseBuffer
in class Protocol
public RFC822DATA fetchRFC822(int msgno, String what) throws ProtocolException
null
to fetch the whole message.ProtocolException
public Flags fetchFlags(int msgno) throws ProtocolException
ProtocolException
public UID fetchUID(int msgno) throws ProtocolException
ProtocolException
public UID fetchSequenceNumber(long uid) throws ProtocolException
null
is returned.ProtocolException
public UID[] fetchSequenceNumbers(long start, long end) throws ProtocolException
ProtocolException
public UID[] fetchSequenceNumbers(long[] uids) throws ProtocolException
ProtocolException
public Response[] fetch(MessageSet[] msgsets, String what) throws ProtocolException
ProtocolException
public Response[] fetch(int start, int end, String what) throws ProtocolException
ProtocolException
public Response[] fetch(int msg, String what) throws ProtocolException
ProtocolException
public void copy(MessageSet[] msgsets, String mbox) throws ProtocolException
ProtocolException
public void copy(int start, int end, String mbox) throws ProtocolException
ProtocolException
public void storeFlags(MessageSet[] msgsets, Flags flags, boolean set) throws ProtocolException
ProtocolException
public void storeFlags(int start, int end, Flags flags, boolean set) throws ProtocolException
ProtocolException
public void storeFlags(int msg, Flags flags, boolean set) throws ProtocolException
ProtocolException
public int[] search(MessageSet[] msgsets, SearchTerm term) throws ProtocolException, SearchException
msgsets
- array of MessageSetsterm
- SearchTermProtocolException
SearchException
public int[] search(SearchTerm term) throws ProtocolException, SearchException
term
- SearchTermProtocolException
SearchException
public int[] sort(SortTerm[] term, SearchTerm sterm) throws ProtocolException, SearchException
term
- sort criteriasterm
- SearchTermProtocolException
SearchException
public Namespaces namespace() throws ProtocolException
ProtocolException
public Quota[] getQuotaRoot(String mbox) throws ProtocolException
ProtocolException
public Quota[] getQuota(String root) throws ProtocolException
ProtocolException
public void setQuota(Quota quota) throws ProtocolException
ProtocolException
public void setACL(String mbox, char modifier, ACL acl) throws ProtocolException
ProtocolException
public void deleteACL(String mbox, String user) throws ProtocolException
ProtocolException
public ACL[] getACL(String mbox) throws ProtocolException
ProtocolException
public Rights[] listRights(String mbox, String user) throws ProtocolException
ProtocolException
public Rights myRights(String mbox) throws ProtocolException
ProtocolException
public void idleStart() throws ProtocolException
If the server supports the IDLE command extension, the IDLE command is issued and this method blocks until a response has been received. Once the first response has been received, the IDLE command is terminated and all responses are collected and handled and this method returns.
Note that while this method is blocked waiting for a response, no other threads may issue any commands to the server that would use this same connection.
ProtocolException
public Response readIdleResponse()
public boolean processIdleResponse(Response r) throws ProtocolException
ProtocolException
public void idleAbort() throws ProtocolException
ProtocolException
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.