gnu.inet.imap
Class IMAPConnection

java.lang.Object
  extended by gnu.inet.imap.IMAPConnection
All Implemented Interfaces:
IMAPConstants

public class IMAPConnection
extends java.lang.Object
implements IMAPConstants

The protocol class implementing IMAP4rev1.

Author:
Chris Burdess

Field Summary
protected  java.util.List asyncResponses
          List of responses received asynchronously.
protected static int DEFAULT_PORT
          The default IMAP port.
protected static int DEFAULT_SSL_PORT
          The default IMAP-SSL port.
static java.util.logging.Level IMAP_TRACE
          The network trace level.
protected  IMAPResponseTokenizer in
          The tokenizer used to read IMAP responses from.
static java.util.logging.Logger logger
          The logger used for IMAP protocol traces.
protected  CRLFOutputStream out
          The output stream.
protected  java.net.Socket socket
          The socket used for communication with the server.
protected static java.lang.String TAG_PREFIX
          Prefix for tags.
protected static java.lang.String US_ASCII
          The encoding used to create strings for IMAP commands.
 
Fields inherited from interface gnu.inet.imap.IMAPConstants
ACL, ALERT, APPEND, APPENDUID, AUTHENTICATE, BAD, BODY, BODY_PEEK, BODYSTRUCTURE, BYE, CAPABILITY, CHECK, CLOSE, COPY, COPYUID, CRAM_MD5, CREATE, DELETE, DELETEACL, ENVELOPE, EXAMINE, EXISTS, EXPUNGE, FETCH, FETCH_FLAGS, FLAG_ANSWERED, FLAG_DELETED, FLAG_DRAFT, FLAG_FLAGGED, FLAG_RECENT, FLAG_SEEN, FLAGS, GETACL, GETQUOTA, GETQUOTAROOT, GSSAPI, HEADER, HEADER_FIELDS, HEADER_FIELDS_NOT, INTERNALDATE, KERBEROS_V4, LIST, LIST_MARKED, LIST_NOINFERIORS, LIST_NOSELECT, LIST_UNMARKED, LISTRIGHTS, LOGIN, LOGINDISABLED, LOGOUT, LSUB, MESSAGES, MYRIGHTS, NAMESPACE, NEWNAME, NIL, NO, NOOP, OK, PARSE, PERMANENTFLAGS, PREAUTH, QUOTA, QUOTAROOT, READ_ONLY, READ_WRITE, RECENT, RENAME, RFC822, RFC822_HEADER, RFC822_SIZE, RFC822_TEXT, RIGHTS_ADMIN, RIGHTS_CREATE, RIGHTS_DELETE, RIGHTS_INSERT, RIGHTS_LOOKUP, RIGHTS_POST, RIGHTS_READ, RIGHTS_SEEN, RIGHTS_WRITE, SEARCH, SEARCH_ALL, SEARCH_ANSWERED, SEARCH_BCC, SEARCH_BEFORE, SEARCH_BODY, SEARCH_CC, SEARCH_DELETED, SEARCH_DRAFT, SEARCH_FLAGGED, SEARCH_FROM, SEARCH_HEADER, SEARCH_KEYWORD, SEARCH_LARGER, SEARCH_NEW, SEARCH_NOT, SEARCH_OLD, SEARCH_ON, SEARCH_OR, SEARCH_RECENT, SEARCH_SEEN, SEARCH_SENTBEFORE, SEARCH_SENTON, SEARCH_SENTSINCE, SEARCH_SINCE, SEARCH_SMALLER, SEARCH_SUBJECT, SEARCH_TEXT, SEARCH_TO, SEARCH_UID, SEARCH_UNANSWERED, SEARCH_UNDELETED, SEARCH_UNDRAFT, SEARCH_UNFLAGGED, SEARCH_UNKEYWORD, SEARCH_UNSEEN, SELECT, SETACL, SETQUOTA, SKEY, STARTTLS, STATUS, STORAGE, STORE, SUBSCRIBE, TRYCREATE, UID, UID_EXPUNGE, UIDNEXT, UIDVALIDITY, UNSEEN, UNSUBSCRIBE
 
Constructor Summary
IMAPConnection(java.lang.String host)
          Creates a new connection to the default IMAP port.
IMAPConnection(java.lang.String host, int port)
          Creates a new connection.
IMAPConnection(java.lang.String host, int port, int connectionTimeout, int timeout)
          Creates a new connection.
IMAPConnection(java.lang.String host, int port, int connectionTimeout, int timeout, boolean secure, javax.net.ssl.TrustManager tm)
          Creates a new connection.
IMAPConnection(java.lang.String host, int port, javax.net.ssl.TrustManager tm)
          Creates a new secure connection using the specified trust manager.
 
Method Summary
 boolean alertsPending()
          Indicates if there are alerts pending for the user-agent.
 boolean append(java.lang.String mailbox, java.lang.String[] flags, byte[] content)
          Append a message to the specified mailbox.
 boolean append(java.lang.String mailbox, java.lang.String[] flags, byte[] content, UIDPlusHandler uidplus)
          Append a message to the specified mailbox.
 boolean authenticate(java.lang.String mechanism, java.lang.String username, java.lang.String password)
          Authenticates the connection using the specified SASL mechanism, username, and password.
 java.util.List capability()
          Returns a list of the capabilities of the IMAP server.
 void check()
          Request a checkpoint of the currently selected mailbox.
 boolean close()
          Permanently remove all messages that have the \Deleted flags set, and close the mailbox.
 boolean copy(int[] messages, java.lang.String mailbox)
          Copies the specified messages to the end of the destination mailbox.
 boolean copy(int[] messages, java.lang.String mailbox, UIDPlusHandler uidplus)
          Copies the specified messages to the end of the destination mailbox.
 boolean create(java.lang.String mailbox)
          Creates a mailbox with the specified name.
 boolean delete(java.lang.String mailbox)
          Deletes the mailbox with the specified name.
 boolean deleteacl(java.lang.String mailbox, java.lang.String principal)
          Removes any access rights for the given authentication principal on the specified mailbox.
 MailboxStatus examine(java.lang.String mailbox)
          Selects the specified mailbox.
 int[] expunge()
          Permanently removes all messages that have the \Delete flag set.
 MessageStatus[] fetch(int[] messages, java.lang.String[] fetchCommands)
          Retrieves data associated with messages in the mailbox.
 MessageStatus[] fetch(int start, int end, java.lang.String[] fetchCommands)
          Retrieves data associated with the specified range of messages in the mailbox.
 MessageStatus fetch(int message, java.lang.String[] fetchCommands)
          Retrieves data associated with the specified message in the mailbox.
 java.util.Map getacl(java.lang.String mailbox)
          Returns the access control list for the specified mailbox.
 java.lang.String[] getAlerts()
          Returns the pending alerts for the user-agent as an array.
 Quota getquota(java.lang.String quotaRoot)
          Returns the specified quota root's resource usage and limits.
 Quota[] getquotaroot(java.lang.String mailbox)
          Returns the quotas for the given mailbox.
protected  javax.net.ssl.SSLSocketFactory getSSLSocketFactory(javax.net.ssl.TrustManager tm)
          Returns a configured SSLSocketFactory to use in creating new SSL sockets.
 boolean invokeSimpleCommand(java.lang.String command)
          Sends the specified IMAP command.
 ListEntry[] list(java.lang.String reference, java.lang.String mailbox)
          Returns a subset of names from the compete set of names available to the client.
protected  ListEntry[] listImpl(java.lang.String command, java.lang.String reference, java.lang.String mailbox)
           
 int listrights(java.lang.String mailbox, java.lang.String principal)
          Returns the rights for the given principal for the specified mailbox.
 boolean login(java.lang.String username, java.lang.String password)
          Login to the connection using the username and password method.
 void logout()
          Logout this connection.
 ListEntry[] lsub(java.lang.String reference, java.lang.String mailbox)
          Returns a subset of subscribed names.
 int myrights(java.lang.String mailbox)
          Returns the rights for the current principal for the specified mailbox.
 Namespaces namespace()
          Returns the namespaces available on the server.
protected  java.lang.String newTag()
          Returns a new tag for a command.
 MailboxStatus noop()
          Ping the server.
protected  IMAPResponse readResponse()
          Reads an IMAP response from the server.
 boolean rename(java.lang.String source, java.lang.String target)
          Renames the source mailbox to the specified name.
 int[] search(java.lang.String charset, java.lang.String[] criteria)
          Searches the currently selected mailbox for messages matching the specified criteria.
 MailboxStatus select(java.lang.String mailbox)
          Selects the specified mailbox.
protected  MailboxStatus selectImpl(java.lang.String mailbox, java.lang.String command)
           
protected  void sendCommand(java.lang.String tag, java.lang.String command)
          Sends the specified IMAP tagged command to the server.
 boolean setacl(java.lang.String mailbox, java.lang.String principal, int rights)
          Changes the access rights on the specified mailbox such that the authentication principal is granted the specified permissions.
 void setAnsiDebug(boolean flag)
          Sets whether debugging output should use ANSI colour escape sequences.
 Quota setquota(java.lang.String quotaRoot, Quota.Resource[] resources)
          Sets the quota for the specified quota root.
 boolean starttls()
          Attempts to start TLS on the specified connection.
 boolean starttls(javax.net.ssl.TrustManager tm)
          Attempts to start TLS on the specified connection.
 MailboxStatus status(java.lang.String mailbox, java.lang.String[] statusNames)
          Requests the status of the specified mailbox.
 MessageStatus[] store(int[] messages, java.lang.String flagCommand, java.lang.String[] flags)
          Alters data associated with messages in the mailbox.
 MessageStatus[] store(int start, int end, java.lang.String flagCommand, java.lang.String[] flags)
          Alters data associated with the specified range of messages in the mailbox.
 MessageStatus store(int message, java.lang.String flagCommand, java.lang.String[] flags)
          Alters data associated with the specified message in the mailbox.
 boolean subscribe(java.lang.String mailbox)
          Adds the specified mailbox to the set of subscribed mailboxes as returned by the LSUB command.
 int[] uidExpunge(long start, long end)
          Expunges the specified range of messages.
 MessageStatus[] uidFetch(long[] uids, java.lang.String[] fetchCommands)
          Retrieves data associated with messages in the mailbox.
 MessageStatus[] uidFetch(long start, long end, java.lang.String[] fetchCommands)
          Retrieves data associated with the specified range of messages in the mailbox.
 MessageStatus uidFetch(long uid, java.lang.String[] fetchCommands)
          Retrieves data associated with the specified message in the mailbox.
 MessageStatus[] uidStore(long[] uids, java.lang.String flagCommand, java.lang.String[] flags)
          Alters data associated with messages in the mailbox.
 MessageStatus[] uidStore(long start, long end, java.lang.String flagCommand, java.lang.String[] flags)
          Alters data associated with the specified range of messages in the mailbox.
 MessageStatus uidStore(long uid, java.lang.String flagCommand, java.lang.String[] flags)
          Alters data associated with the specified message in the mailbox.
 boolean unsubscribe(java.lang.String mailbox)
          Removes the specified mailbox from the set of subscribed mailboxes as returned by the LSUB command.
protected  boolean updateMailboxStatus(MailboxStatus ms, java.lang.String id, IMAPResponse response)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAP_TRACE

public static final java.util.logging.Level IMAP_TRACE
The network trace level.


TAG_PREFIX

protected static final java.lang.String TAG_PREFIX
Prefix for tags.

See Also:
Constant Field Values

US_ASCII

protected static final java.lang.String US_ASCII
The encoding used to create strings for IMAP commands.

See Also:
Constant Field Values

DEFAULT_PORT

protected static final int DEFAULT_PORT
The default IMAP port.

See Also:
Constant Field Values

DEFAULT_SSL_PORT

protected static final int DEFAULT_SSL_PORT
The default IMAP-SSL port.

See Also:
Constant Field Values

logger

public static final java.util.logging.Logger logger
The logger used for IMAP protocol traces.


socket

protected java.net.Socket socket
The socket used for communication with the server.


in

protected IMAPResponseTokenizer in
The tokenizer used to read IMAP responses from.


out

protected CRLFOutputStream out
The output stream.


asyncResponses

protected java.util.List asyncResponses
List of responses received asynchronously.

Constructor Detail

IMAPConnection

public IMAPConnection(java.lang.String host)
               throws java.net.UnknownHostException,
                      java.io.IOException
Creates a new connection to the default IMAP port.

Parameters:
host - the name of the host to connect to
Throws:
java.net.UnknownHostException
java.io.IOException

IMAPConnection

public IMAPConnection(java.lang.String host,
                      int port)
               throws java.net.UnknownHostException,
                      java.io.IOException
Creates a new connection.

Parameters:
host - the name of the host to connect to
port - the port to connect to, or -1 for the default
Throws:
java.net.UnknownHostException
java.io.IOException

IMAPConnection

public IMAPConnection(java.lang.String host,
                      int port,
                      int connectionTimeout,
                      int timeout)
               throws java.net.UnknownHostException,
                      java.io.IOException
Creates a new connection.

Parameters:
host - the name of the host to connect to
port - the port to connect to, or -1 for the default
connectionTimeout - the socket connection timeout
timeout - the socket timeout
Throws:
java.net.UnknownHostException
java.io.IOException

IMAPConnection

public IMAPConnection(java.lang.String host,
                      int port,
                      javax.net.ssl.TrustManager tm)
               throws java.net.UnknownHostException,
                      java.io.IOException
Creates a new secure connection using the specified trust manager.

Parameters:
host - the name of the host to connect to
port - the port to connect to, or -1 for the default
tm - a trust manager used to check SSL certificates, or null to use the default
Throws:
java.net.UnknownHostException
java.io.IOException

IMAPConnection

public IMAPConnection(java.lang.String host,
                      int port,
                      int connectionTimeout,
                      int timeout,
                      boolean secure,
                      javax.net.ssl.TrustManager tm)
               throws java.net.UnknownHostException,
                      java.io.IOException
Creates a new connection.

Parameters:
host - the name of the host to connect to
port - the port to connect to, or -1 for the default
connectionTimeout - the socket connection timeout
timeout - the socket timeout
secure - if an IMAP-SSL connection should be made
tm - a trust manager used to check SSL certificates, or null to use the default
Throws:
java.net.UnknownHostException
java.io.IOException
Method Detail

setAnsiDebug

public void setAnsiDebug(boolean flag)
Sets whether debugging output should use ANSI colour escape sequences.


newTag

protected java.lang.String newTag()
Returns a new tag for a command.


sendCommand

protected void sendCommand(java.lang.String tag,
                           java.lang.String command)
                    throws java.io.IOException
Sends the specified IMAP tagged command to the server.

Throws:
java.io.IOException

invokeSimpleCommand

public boolean invokeSimpleCommand(java.lang.String command)
                            throws java.io.IOException
Sends the specified IMAP command.

Parameters:
command - the command
Returns:
true if OK was received, or false if NO was received
Throws:
java.io.IOException - if BAD was received or an I/O error occurred

readResponse

protected IMAPResponse readResponse()
                             throws java.io.IOException
Reads an IMAP response from the server. The response will consist of either:

alertsPending

public boolean alertsPending()
Indicates if there are alerts pending for the user-agent.


getAlerts

public java.lang.String[] getAlerts()
Returns the pending alerts for the user-agent as an array.


capability

public java.util.List capability()
                          throws java.io.IOException
Returns a list of the capabilities of the IMAP server.

Throws:
java.io.IOException

noop

public MailboxStatus noop()
                   throws java.io.IOException
Ping the server. If a change in mailbox state is detected, a new mailbox status is returned, otherwise this method returns null.

Throws:
java.io.IOException

getSSLSocketFactory

protected javax.net.ssl.SSLSocketFactory getSSLSocketFactory(javax.net.ssl.TrustManager tm)
                                                      throws java.security.GeneralSecurityException
Returns a configured SSLSocketFactory to use in creating new SSL sockets.

Parameters:
tm - an optional trust manager to use
Throws:
java.security.GeneralSecurityException

starttls

public boolean starttls()
                 throws java.io.IOException
Attempts to start TLS on the specified connection. See RFC 2595 for details.

Returns:
true if successful, false otherwise
Throws:
java.io.IOException

starttls

public boolean starttls(javax.net.ssl.TrustManager tm)
                 throws java.io.IOException
Attempts to start TLS on the specified connection. See RFC 2595 for details.

Parameters:
tm - the custom trust manager to use
Returns:
true if successful, false otherwise
Throws:
java.io.IOException

login

public boolean login(java.lang.String username,
                     java.lang.String password)
              throws java.io.IOException
Login to the connection using the username and password method.

Parameters:
username - the authentication principal
password - the authentication credentials
Returns:
true if authentication was successful, false otherwise
Throws:
java.io.IOException

authenticate

public boolean authenticate(java.lang.String mechanism,
                            java.lang.String username,
                            java.lang.String password)
                     throws java.io.IOException
Authenticates the connection using the specified SASL mechanism, username, and password.

Parameters:
mechanism - a SASL authentication mechanism, e.g. LOGIN, PLAIN, CRAM-MD5, GSSAPI
username - the authentication principal
password - the authentication credentials
Returns:
true if authentication was successful, false otherwise
Throws:
java.io.IOException

logout

public void logout()
            throws java.io.IOException
Logout this connection. Underlying network resources will be freed.

Throws:
java.io.IOException

select

public MailboxStatus select(java.lang.String mailbox)
                     throws java.io.IOException
Selects the specified mailbox. The mailbox is identified as read-write if writes are permitted.

Parameters:
mailbox - the mailbox name
Returns:
a MailboxStatus containing the state of the selected mailbox
Throws:
java.io.IOException

examine

public MailboxStatus examine(java.lang.String mailbox)
                      throws java.io.IOException
Selects the specified mailbox. The mailbox is identified as read-only.

Parameters:
mailbox - the mailbox name
Returns:
a MailboxStatus containing the state of the selected mailbox
Throws:
java.io.IOException

selectImpl

protected MailboxStatus selectImpl(java.lang.String mailbox,
                                   java.lang.String command)
                            throws java.io.IOException
Throws:
java.io.IOException

updateMailboxStatus

protected boolean updateMailboxStatus(MailboxStatus ms,
                                      java.lang.String id,
                                      IMAPResponse response)
                               throws java.io.IOException
Throws:
java.io.IOException

create

public boolean create(java.lang.String mailbox)
               throws java.io.IOException
Creates a mailbox with the specified name.

Parameters:
mailbox - the mailbox name
Returns:
true if the mailbox was successfully created, false otherwise
Throws:
java.io.IOException

delete

public boolean delete(java.lang.String mailbox)
               throws java.io.IOException
Deletes the mailbox with the specified name.

Parameters:
mailbox - the mailbox name
Returns:
true if the mailbox was successfully deleted, false otherwise
Throws:
java.io.IOException

rename

public boolean rename(java.lang.String source,
                      java.lang.String target)
               throws java.io.IOException
Renames the source mailbox to the specified name.

Parameters:
source - the source mailbox name
target - the target mailbox name
Returns:
true if the mailbox was successfully renamed, false otherwise
Throws:
java.io.IOException

subscribe

public boolean subscribe(java.lang.String mailbox)
                  throws java.io.IOException
Adds the specified mailbox to the set of subscribed mailboxes as returned by the LSUB command.

Parameters:
mailbox - the mailbox name
Returns:
true if the mailbox was successfully subscribed, false otherwise
Throws:
java.io.IOException

unsubscribe

public boolean unsubscribe(java.lang.String mailbox)
                    throws java.io.IOException
Removes the specified mailbox from the set of subscribed mailboxes as returned by the LSUB command.

Parameters:
mailbox - the mailbox name
Returns:
true if the mailbox was successfully unsubscribed, false otherwise
Throws:
java.io.IOException

list

public ListEntry[] list(java.lang.String reference,
                        java.lang.String mailbox)
                 throws java.io.IOException
Returns a subset of names from the compete set of names available to the client.

Parameters:
reference - the context relative to which mailbox names are defined
mailbox - a mailbox name, possibly including IMAP wildcards
Throws:
java.io.IOException

lsub

public ListEntry[] lsub(java.lang.String reference,
                        java.lang.String mailbox)
                 throws java.io.IOException
Returns a subset of subscribed names.

Throws:
java.io.IOException
See Also:
list(java.lang.String, java.lang.String)

listImpl

protected ListEntry[] listImpl(java.lang.String command,
                               java.lang.String reference,
                               java.lang.String mailbox)
                        throws java.io.IOException
Throws:
java.io.IOException

status

public MailboxStatus status(java.lang.String mailbox,
                            java.lang.String[] statusNames)
                     throws java.io.IOException
Requests the status of the specified mailbox.

Throws:
java.io.IOException

append

public boolean append(java.lang.String mailbox,
                      java.lang.String[] flags,
                      byte[] content)
               throws java.io.IOException
Append a message to the specified mailbox. This method returns an OutputStream to which the message should be written and then closed.

Parameters:
mailbox - the mailbox name
flags - optional list of flags to specify for the message
content - the message body(including headers)
Returns:
true if successful, false if error in flags/text
Throws:
java.io.IOException

append

public boolean append(java.lang.String mailbox,
                      java.lang.String[] flags,
                      byte[] content,
                      UIDPlusHandler uidplus)
               throws java.io.IOException
Append a message to the specified mailbox. This method returns an OutputStream to which the message should be written and then closed.

Parameters:
mailbox - the mailbox name
flags - optional list of flags to specify for the message
content - the message body(including headers)
uidplus - handler for any APPENDUID information in the response
Returns:
true if successful, false if error in flags/text
Throws:
java.io.IOException

check

public void check()
           throws java.io.IOException
Request a checkpoint of the currently selected mailbox.

Throws:
java.io.IOException

close

public boolean close()
              throws java.io.IOException
Permanently remove all messages that have the \Deleted flags set, and close the mailbox.

Returns:
true if successful, false if no mailbox was selected
Throws:
java.io.IOException

expunge

public int[] expunge()
              throws java.io.IOException
Permanently removes all messages that have the \Delete flag set.

Returns:
the numbers of the messages expunged
Throws:
java.io.IOException

search

public int[] search(java.lang.String charset,
                    java.lang.String[] criteria)
             throws java.io.IOException
Searches the currently selected mailbox for messages matching the specified criteria.

Throws:
java.io.IOException

fetch

public MessageStatus fetch(int message,
                           java.lang.String[] fetchCommands)
                    throws java.io.IOException
Retrieves data associated with the specified message in the mailbox.

Parameters:
message - the message number
fetchCommands - the fetch commands, e.g. FLAGS
Throws:
java.io.IOException

fetch

public MessageStatus[] fetch(int start,
                             int end,
                             java.lang.String[] fetchCommands)
                      throws java.io.IOException
Retrieves data associated with the specified range of messages in the mailbox.

Parameters:
start - the message number of the first message
end - the message number of the last message
fetchCommands - the fetch commands, e.g. FLAGS
Throws:
java.io.IOException

fetch

public MessageStatus[] fetch(int[] messages,
                             java.lang.String[] fetchCommands)
                      throws java.io.IOException
Retrieves data associated with messages in the mailbox.

Parameters:
messages - the message numbers
fetchCommands - the fetch commands, e.g. FLAGS
Throws:
java.io.IOException

uidFetch

public MessageStatus uidFetch(long uid,
                              java.lang.String[] fetchCommands)
                       throws java.io.IOException
Retrieves data associated with the specified message in the mailbox.

Parameters:
uid - the message UID
fetchCommands - the fetch commands, e.g. FLAGS
Throws:
java.io.IOException

uidFetch

public MessageStatus[] uidFetch(long start,
                                long end,
                                java.lang.String[] fetchCommands)
                         throws java.io.IOException
Retrieves data associated with the specified range of messages in the mailbox.

Parameters:
start - the message number of the first message
end - the message number of the last message
fetchCommands - the fetch commands, e.g. FLAGS
Throws:
java.io.IOException

uidFetch

public MessageStatus[] uidFetch(long[] uids,
                                java.lang.String[] fetchCommands)
                         throws java.io.IOException
Retrieves data associated with messages in the mailbox.

Parameters:
uids - the message UIDs
fetchCommands - the fetch commands, e.g. FLAGS
Throws:
java.io.IOException

store

public MessageStatus store(int message,
                           java.lang.String flagCommand,
                           java.lang.String[] flags)
                    throws java.io.IOException
Alters data associated with the specified message in the mailbox.

Parameters:
message - the message number
flagCommand - FLAGS, +FLAGS, -FLAGS(or .SILENT versions)
flags - message flags to set
Returns:
the message status
Throws:
java.io.IOException

store

public MessageStatus[] store(int start,
                             int end,
                             java.lang.String flagCommand,
                             java.lang.String[] flags)
                      throws java.io.IOException
Alters data associated with the specified range of messages in the mailbox.

Parameters:
start - the message number of the first message
end - the message number of the last message
flagCommand - FLAGS, +FLAGS, -FLAGS(or .SILENT versions)
flags - message flags to set
Returns:
a list of message-number to current flags
Throws:
java.io.IOException

store

public MessageStatus[] store(int[] messages,
                             java.lang.String flagCommand,
                             java.lang.String[] flags)
                      throws java.io.IOException
Alters data associated with messages in the mailbox.

Parameters:
messages - the message numbers
flagCommand - FLAGS, +FLAGS, -FLAGS(or .SILENT versions)
flags - message flags to set
Returns:
a list of message-number to current flags
Throws:
java.io.IOException

uidStore

public MessageStatus uidStore(long uid,
                              java.lang.String flagCommand,
                              java.lang.String[] flags)
                       throws java.io.IOException
Alters data associated with the specified message in the mailbox.

Parameters:
uid - the message UID
flagCommand - FLAGS, +FLAGS, -FLAGS(or .SILENT versions)
flags - message flags to set
Returns:
the message status
Throws:
java.io.IOException

uidStore

public MessageStatus[] uidStore(long start,
                                long end,
                                java.lang.String flagCommand,
                                java.lang.String[] flags)
                         throws java.io.IOException
Alters data associated with the specified range of messages in the mailbox.

Parameters:
start - the UID of the first message
end - the UID of the last message
flagCommand - FLAGS, +FLAGS, -FLAGS(or .SILENT versions)
flags - message flags to set
Returns:
a list of message-number to current flags
Throws:
java.io.IOException

uidStore

public MessageStatus[] uidStore(long[] uids,
                                java.lang.String flagCommand,
                                java.lang.String[] flags)
                         throws java.io.IOException
Alters data associated with messages in the mailbox.

Parameters:
uids - the message UIDs
flagCommand - FLAGS, +FLAGS, -FLAGS(or .SILENT versions)
flags - message flags to set
Returns:
a list of message-number to current flags
Throws:
java.io.IOException

copy

public boolean copy(int[] messages,
                    java.lang.String mailbox)
             throws java.io.IOException
Copies the specified messages to the end of the destination mailbox.

Parameters:
messages - the message numbers
mailbox - the destination mailbox
Throws:
java.io.IOException

copy

public boolean copy(int[] messages,
                    java.lang.String mailbox,
                    UIDPlusHandler uidplus)
             throws java.io.IOException
Copies the specified messages to the end of the destination mailbox.

Parameters:
messages - the message numbers
mailbox - the destination mailbox
uidplus - UIDPLUS callback for COPYUID information
Throws:
java.io.IOException

namespace

public Namespaces namespace()
                     throws java.io.IOException
Returns the namespaces available on the server. See RFC 2342 for details.

Throws:
java.io.IOException

setacl

public boolean setacl(java.lang.String mailbox,
                      java.lang.String principal,
                      int rights)
               throws java.io.IOException
Changes the access rights on the specified mailbox such that the authentication principal is granted the specified permissions.

Parameters:
mailbox - the mailbox name
principal - the authentication identifier
rights - the rights to assign
Throws:
java.io.IOException

deleteacl

public boolean deleteacl(java.lang.String mailbox,
                         java.lang.String principal)
                  throws java.io.IOException
Removes any access rights for the given authentication principal on the specified mailbox.

Parameters:
mailbox - the mailbox name
principal - the authentication identifier
Throws:
java.io.IOException

getacl

public java.util.Map getacl(java.lang.String mailbox)
                     throws java.io.IOException
Returns the access control list for the specified mailbox. The returned rights are a logical OR of RIGHTS_* bits.

Parameters:
mailbox - the mailbox name
Returns:
a map of principal names to Integer rights
Throws:
java.io.IOException

listrights

public int listrights(java.lang.String mailbox,
                      java.lang.String principal)
               throws java.io.IOException
Returns the rights for the given principal for the specified mailbox. The returned rights are a logical OR of RIGHTS_* bits.

Parameters:
mailbox - the mailbox name
principal - the authentication identity
Throws:
java.io.IOException

myrights

public int myrights(java.lang.String mailbox)
             throws java.io.IOException
Returns the rights for the current principal for the specified mailbox. The returned rights are a logical OR of RIGHTS_* bits.

Parameters:
mailbox - the mailbox name
Throws:
java.io.IOException

setquota

public Quota setquota(java.lang.String quotaRoot,
                      Quota.Resource[] resources)
               throws java.io.IOException
Sets the quota for the specified quota root.

Parameters:
quotaRoot - the quota root
resources - the list of resources and associated limits to set
Returns:
the new quota, or null if the operation failed
Throws:
java.io.IOException

getquota

public Quota getquota(java.lang.String quotaRoot)
               throws java.io.IOException
Returns the specified quota root's resource usage and limits.

Parameters:
quotaRoot - the quota root
Throws:
java.io.IOException

getquotaroot

public Quota[] getquotaroot(java.lang.String mailbox)
                     throws java.io.IOException
Returns the quotas for the given mailbox.

Parameters:
mailbox - the mailbox name
Throws:
java.io.IOException

uidExpunge

public int[] uidExpunge(long start,
                        long end)
                 throws java.io.IOException
Expunges the specified range of messages. See RFC 2359 for details.

Parameters:
start - the UID of the first message to expunge
end - the UID of the last message to expunge
Throws:
java.io.IOException


© Copyright 2003 The Free Software Foundation, all rights reserved