Class com.tdac.mail.IMAP2Connection
All Packages Class Hierarchy This Package Previous Next Index
Class com.tdac.mail.IMAP2Connection
java.lang.Object
|
+----com.tdac.mail.SocketConnection
|
+----com.tdac.mail.MailConnection
|
+----com.tdac.mail.IMAP2Connection
- public class IMAP2Connection
- extends MailConnection
This class is used to connect to an IMAP2 mail server. The class
implements a 'tagged' or sequenced conversation protocol.
- Version:
- 1.0, 11/11/96
- Author:
- Timothy D. A. Cox
-
seqno
- current line tag number (eg A23)
-
IMAP2Connection()
-
-
closeBox()
- Issue the 'EXPUNGE' command
-
connect(String)
- Connect to a server on port 143 (IMAP).
-
deleteMessage(int)
- Issue a 'STORE' command to set the \Deleted flag on
-
getHeaders(List, int, int)
- Issue the 'FETCH' command to retrieve the message headers and
parse the headers into a List
-
getMessage(int, boolean)
- Issue the 'FETCH' command to retrieve a specific message.
-
getMessage(TextArea, int, boolean)
- Issue the 'FETCH' command to retrieve a specific message, placing
the contents into a java.awt.TextArea component
-
login(String, String)
- Issue the 'login' command for a userid and password
-
logout()
- Issue the 'logout' command
-
openBox(String)
- Issue the 'SELECT' mailbox command and return response
-
parseFlags(Response)
- Search a response for the 'FLAGS' line and parse out
the flags values (eg.
-
parseHeader(List, Response, int)
- Parse a server response for the mail headers and place
them into a list component.
-
parseNumMessages(Response)
- Search a response for the 'EXIST' line and return the
value on that line.
-
parseNumRecent(Response)
- Search a response for the 'RECENT' line and return the
value on that line.
-
parsePermanentFlags(Response)
- Search a response for the 'PERMANENTFLAGS' line and parse out
the flags values (eg.
-
purgeMessages()
- Issue an 'expunge' command to purge deleted messages.
-
undeleteMessage(int)
- Issue a 'STORE' command to clear the \Deleted flag
-
wrstring(String)
- Perform a 'write' command and 'read' response operation on
the socket.
-
wrstring(TextArea, String)
- Perform a 'write' command and 'read' response operation on
the socket, storing the results into a java.awt.TextArea component
seqno
protected int seqno
- current line tag number (eg A23)
IMAP2Connection
public IMAP2Connection()
connect
public synchronized String connect(String server) throws ExceptionMailConnection
- Connect to a server on port 143 (IMAP). Will setup the private
stream objects and read the mail server greeting.
- Parameters:
- server - the mail server name (eg. mail.domain.com)
- Returns:
- the mail server greeting string
- Overrides:
- connect in class MailConnection
login
public void login(String userid,
String password) throws ExceptionMailConnection
- Issue the 'login' command for a userid and password
- Parameters:
- userid - the mailbox name to login to
- password - the mailbox password
- Overrides:
- login in class MailConnection
logout
public void logout() throws ExceptionMailConnection
- Issue the 'logout' command
- Overrides:
- logout in class MailConnection
openBox
public Response openBox(String name) throws ExceptionMailConnection
- Issue the 'SELECT' mailbox command and return response
- Parameters:
- name - the mailbox folder to open
- Returns:
- server response from the command
- Overrides:
- openBox in class MailConnection
closeBox
public Response closeBox() throws ExceptionMailConnection
- Issue the 'EXPUNGE' command
- Returns:
- server response from the command
- Overrides:
- closeBox in class MailConnection
getHeaders
public MailHeader[] getHeaders(List list,
int start,
int num) throws ExceptionMailConnection
- Issue the 'FETCH' command to retrieve the message headers and
parse the headers into a List
- Parameters:
- list - the java.awt.List component to receive the headers
- start - the first message to read
- num - the number of messages to read
- Returns:
- an array of MailHeader objects
- Overrides:
- getHeaders in class MailConnection
getMessage
public Response getMessage(int msgnum,
boolean fullheader) throws ExceptionMailConnection
- Issue the 'FETCH' command to retrieve a specific message.
- Parameters:
- msgnum - message number to retrieve
- fullheader - true if the full RFC822 header is required
- Returns:
- server response from the command
- Overrides:
- getMessage in class MailConnection
getMessage
public Response getMessage(TextArea ta,
int msgnum,
boolean fullheader) throws ExceptionMailConnection
- Issue the 'FETCH' command to retrieve a specific message, placing
the contents into a java.awt.TextArea component
- Parameters:
- msgnum - message number to retrieve
- fullheader - true if the full RFC822 header is required
- Returns:
- server response from the command
- Overrides:
- getMessage in class MailConnection
deleteMessage
public Response deleteMessage(int msgnum) throws ExceptionMailConnection
- Issue a 'STORE' command to set the \Deleted flag on
- Parameters:
- msgnum - message to be deleted
- Returns:
- server response from the command
- Overrides:
- deleteMessage in class MailConnection
undeleteMessage
public Response undeleteMessage(int msgnum) throws ExceptionMailConnection
- Issue a 'STORE' command to clear the \Deleted flag
- Parameters:
- msgnum - message to be un-deleted
- Returns:
- server response from the command
- Overrides:
- undeleteMessage in class MailConnection
purgeMessages
public Response purgeMessages() throws ExceptionMailConnection
- Issue an 'expunge' command to purge deleted messages.
- Returns:
- server response from the command
- Overrides:
- purgeMessages in class MailConnection
wrstring
protected Response wrstring(String io) throws ExceptionMailConnection
- Perform a 'write' command and 'read' response operation on
the socket.
- Parameters:
- io - the command to be written
- Returns:
- server response from the command
wrstring
protected Response wrstring(TextArea ta,
String io) throws ExceptionMailConnection
- Perform a 'write' command and 'read' response operation on
the socket, storing the results into a java.awt.TextArea component
- Parameters:
- ta - the TextArea that will recieve the response lines
- io - the command to be written
- Returns:
- server response from the command
parseNumMessages
public int parseNumMessages(Response rsp)
- Search a response for the 'EXIST' line and return the
value on that line. This is the number of messages in the
currently selected mailbox folder.
- Parameters:
- rsp - the server response to parse
- Returns:
- number of messages in the folder
- Overrides:
- parseNumMessages in class MailConnection
parseNumRecent
public int parseNumRecent(Response rsp)
- Search a response for the 'RECENT' line and return the
value on that line. This is the number of messages in the
currently selected mailbox folder that have not yet been seen.
- Parameters:
- rsp - the server response to parse
- Returns:
- number of un-seen messages in the folder
- Overrides:
- parseNumRecent in class MailConnection
parseFlags
public Vector parseFlags(Response rsp)
- Search a response for the 'FLAGS' line and parse out
the flags values (eg. Seen, Deleted etc)
- Parameters:
- rsp - the server response to parse
- Returns:
- vector containing the Flag names
- Overrides:
- parseFlags in class MailConnection
parsePermanentFlags
public Vector parsePermanentFlags(Response rsp)
- Search a response for the 'PERMANENTFLAGS' line and parse out
the flags values (eg. Seen, Deleted etc)
- Parameters:
- rsp - the server response to parse
- Returns:
- vector containing the Flag names
- Overrides:
- parsePermanentFlags in class MailConnection
parseHeader
public MailHeader[] parseHeader(List list,
Response rsp,
int num) throws ExceptionMailConnection
- Parse a server response for the mail headers and place
them into a list component.
- Parameters:
- list - the java.awt.List that will recieve the headers
- rsp - the server response to parse
- num - the number of headers to parse
- Returns:
- an array of MailHeader objects
- Overrides:
- parseHeader in class MailConnection
All Packages Class Hierarchy This Package Previous Next Index