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

Variable Index

 o seqno
current line tag number (eg A23)

Constructor Index

 o IMAP2Connection()

Method Index

 o closeBox()
Issue the 'EXPUNGE' command
 o connect(String)
Connect to a server on port 143 (IMAP).
 o deleteMessage(int)
Issue a 'STORE' command to set the \Deleted flag on
 o getHeaders(List, int, int)
Issue the 'FETCH' command to retrieve the message headers and parse the headers into a List
 o getMessage(int, boolean)
Issue the 'FETCH' command to retrieve a specific message.
 o getMessage(TextArea, int, boolean)
Issue the 'FETCH' command to retrieve a specific message, placing the contents into a java.awt.TextArea component
 o login(String, String)
Issue the 'login' command for a userid and password
 o logout()
Issue the 'logout' command
 o openBox(String)
Issue the 'SELECT' mailbox command and return response
 o parseFlags(Response)
Search a response for the 'FLAGS' line and parse out the flags values (eg.
 o parseHeader(List, Response, int)
Parse a server response for the mail headers and place them into a list component.
 o parseNumMessages(Response)
Search a response for the 'EXIST' line and return the value on that line.
 o parseNumRecent(Response)
Search a response for the 'RECENT' line and return the value on that line.
 o parsePermanentFlags(Response)
Search a response for the 'PERMANENTFLAGS' line and parse out the flags values (eg.
 o purgeMessages()
Issue an 'expunge' command to purge deleted messages.
 o undeleteMessage(int)
Issue a 'STORE' command to clear the \Deleted flag
 o wrstring(String)
Perform a 'write' command and 'read' response operation on the socket.
 o wrstring(TextArea, String)
Perform a 'write' command and 'read' response operation on the socket, storing the results into a java.awt.TextArea component

Variables

 o seqno
  protected int seqno
current line tag number (eg A23)

Constructors

 o IMAP2Connection
  public IMAP2Connection()

Methods

 o 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
 o 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
 o logout
  public void logout() throws ExceptionMailConnection
Issue the 'logout' command
Overrides:
logout in class MailConnection
 o 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
 o closeBox
  public Response closeBox() throws ExceptionMailConnection
Issue the 'EXPUNGE' command
Returns:
server response from the command
Overrides:
closeBox in class MailConnection
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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
 o 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