|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jthomas.mailfaces.FaceMailbox
FaceMailbox is an abstract class to handle the interface to the Mail Server.
Class to handle a General purpose FaceMailbox This is an abstract class that is intended to be extended by classes that implement methods unique to the type of mail server (POP3, IMAP4 etc)
The overall purpose of this class is to periodically scan a user's mailbox and when it finds a new email message then it will construct a MailMsg object and place it on the queue for the FaceResolver class. FaceResolver will determine which icon should be shown for this email.
Methods: Constructor: None * * Public Methods void init() void run() Mailmsg getMailmsg(String key) int count() void addMailmsg(key,Mailmsg) void resetMailmsgs() void setModified() boolean getNModified() The following are abstract methods imlemented by subclass that implements the code for handling some type of mailserver such as POP3 or IMAP4 void open() void read() void close() void terminate(); * --------------------------------------------------------------------- --------------------------------------------------------------------- Simple Usage Example to do something with each message - FaceMailbox mailbox = server.createMailbox(); - mailbox.getOptions(); - mailbox.open(); - mailbox.read(); - mailbox.close(); - for (i=0; i
- Author:
- John Thomas jthomas@cruzio.com
- See Also:
FaceResolver
,MailMsg
Field Summary protected FaceCache
_Cache
Cache of Iconsprotected int
_Count
count of mailmsgs on server.protected java.lang.String
_Host
Mail server hostprotected boolean
_Modified
Set true if one or more new messages were processedprotected boolean
_OpenFailure
Keep track that the previous pass failed to open the serverprotected FaceOptions
_Options
Reference to the FaceOptions object so we can access the options that the user wants to use.protected java.lang.String
_Password
password for users mail accountprotected FaceServer
_Server
FaceServer object that is controlling this Mailboxprotected java.lang.String
_Type
Protocol type POP3, APOP, IMAPprotected java.lang.String
_User
User name for mail accountprotected boolean
_ValidInfo
Set to true if all login info is specified.protected static java.util.Hashtable
_ValidTypes
List of valid supported types.static java.lang.String
COPY_HEADER
Constructor Summary protected
FaceMailbox()
Method Summary protected void
addMailmsg(java.lang.String key, Mailmsg mailmsg)
addMailmsg will add a new Mailmsg and begin the icon resolution.abstract void
close()
Abstract Method: close().boolean
copymsg(Mailmsg msg, java.lang.String addr)
Method to copy mail to a new server.int
count()
Method: count()boolean
delete(Mailmsg[] mailmsgs)
Method to delete any mail marked for deletion.protected Mailmsg
getMailmsg(java.lang.String key)
Method: getMailmsg(String key)protected Mailmsg[]
getMailmsgs()
Get an array of existing Mailmsg objects.boolean
getModified()
Method: getModified query whether the mailbox contains one or more new messages.void
init()
Method: init() This method is called by MailFaces to do setup It will initialize a number of references to various MailFaces objects.boolean
isCopySupported()
Method: isCopySupported queiries ability to copy Mailmsgs.boolean
isDeleteSupported()
Method: isDeleteSupported queries ability to delete Mailmsgs.abstract boolean
open()
Abstract Method: open().abstract void
read()
Abstract Method: read().void
refreshOptions()
Method: refreshOptions()protected void
removeMailmsg(Mailmsg mailmsg)
removeMailmsg will remove a Mailmsg and tell the GUI to remove the ICONprotected void
resetMailmsgs()
Method: resetMailmsgs Mark all the current mailmsgs with an "Unknown" status.void
run()
Method: run() This method is invoked when the Thread is started.void
setModified(boolean modified)
Method: setModified(boolean) Set flag to indicate if the mailbox contains one or more new messagesvoid
setServer(FaceServer server)
setServer(FaceServer server) will set a reference to the Server object for this Mailbox.abstract void
terminate()
Abstract Method: terminate().java.lang.String
toString()
toString is called to identify the Mailbox Object.protected boolean
verifyLoginInfo()
Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail COPY_HEADER
public static final java.lang.String COPY_HEADER
- See Also:
- Constant Field Values
_Count
protected int _Count
- count of mailmsgs on server. This is the value that the server returns at open time
_Options
protected final FaceOptions _Options
- Reference to the FaceOptions object so we can access the options that the user wants to use.
_Server
protected FaceServer _Server
- FaceServer object that is controlling this Mailbox
_Cache
protected FaceCache _Cache
- Cache of Icons
_Type
protected java.lang.String _Type
- Protocol type POP3, APOP, IMAP
_ValidTypes
protected static java.util.Hashtable _ValidTypes
- List of valid supported types. Filled in by subclasses in static constructor.
_Host
protected java.lang.String _Host
- Mail server host
_User
protected java.lang.String _User
- User name for mail account
_Password
protected java.lang.String _Password
- password for users mail account
_ValidInfo
protected boolean _ValidInfo
- Set to true if all login info is specified.
_OpenFailure
protected boolean _OpenFailure
- Keep track that the previous pass failed to open the server
_Modified
protected boolean _Modified
- Set true if one or more new messages were processed
Constructor Detail FaceMailbox
protected FaceMailbox()
Method Detail setServer
public void setServer(FaceServer server)
- setServer(FaceServer server) will set a reference to the Server object for this Mailbox. This method is called by MailFaces after creating the Mailbox object It used to specify it in the constructor
- Parameters:
server
- FaceServer Object that describes the server- Returns:
- void
init
public void init()
- Method: init() This method is called by MailFaces to do setup It will initialize a number of references to various MailFaces objects.
- Returns:
- void
run
public void run()
- Method: run() This method is invoked when the Thread is started.
It will sit in a loop doing the following:
-Check Flags set by action of the UI component and perform the action. These flags are: - Quit - Reset Server - Refresh Options - Check for new mail - expire - etc - Call checkmail rtn to see if there are new mail msgs - Sleep for number of seconds specified. - Repeat the loop
- Specified by:
run
in interfacejava.lang.Runnable
- Returns:
- void
resetMailmsgs
protected void resetMailmsgs()
- Method: resetMailmsgs Mark all the current mailmsgs with an "Unknown" status. This is done at the start of a pass that compares the messages at the server with the Mailmsg objects. As each msg is matched, the status is changed to "StatusOld". At the end of the pass, any Mailmsgs that still have a StatusUnknown are then deletable.
refreshOptions
public void refreshOptions()
- Method: refreshOptions()
- Returns:
- void This method is invoked when the MailFaces options are modified
verifyLoginInfo
protected boolean verifyLoginInfo()
addMailmsg
protected void addMailmsg(java.lang.String key, Mailmsg mailmsg)
- addMailmsg will add a new Mailmsg and begin the icon resolution.
Add mailmsg to the collection of mailmsgs Add mailmsg to FaceReslver Queue
- Returns:
- void
removeMailmsg
protected void removeMailmsg(Mailmsg mailmsg)
- removeMailmsg will remove a Mailmsg and tell the GUI to remove the ICON
- Returns:
- void
getMailmsg
protected Mailmsg getMailmsg(java.lang.String key)
- Method: getMailmsg(String key)
- Returns:
- Mailmsg Get the Mailmsg with the specified key. It returns "null" if no Mailmsg with that key
getMailmsgs
protected Mailmsg[] getMailmsgs()
- Get an array of existing Mailmsg objects.
count
public int count()
- Method: count()
- Returns:
- int Count of number of messages in the mailbox This method will return the number of messages in the mailbox
setModified
public void setModified(boolean modified)
- Method: setModified(boolean) Set flag to indicate if the mailbox contains one or more new messages
- Returns:
- void
getModified
public boolean getModified()
- Method: getModified query whether the mailbox contains one or more new messages.
- Returns:
- boolean
isDeleteSupported
public boolean isDeleteSupported()
- Method: isDeleteSupported queries ability to delete Mailmsgs. query whether the mailbox supports Deleting of Mailmsgs This will return false. The Mailbox subclass can override this to return true.
- Returns:
- boolean
isCopySupported
public boolean isCopySupported()
- Method: isCopySupported queiries ability to copy Mailmsgs. query whether the mailbox supports Copying of Mailmsgs This will return false. The Mailbox subclass can override this to return true.
- Returns:
- boolean
open
public abstract boolean open()
- Abstract Method: open(). Sets up the connection to the MailServer and logs in to the server. It also sets the _Count variable to the number of messages waiting
- Returns:
- booolean Returns true if Open suceeds.
read
public abstract void read()
- Abstract Method: read(). This is where the majority of the work is done. The end result is that the array "_Mailmsgs" contains the instances of Mailmsgs that are or were in this mailbox with the _Action value set to indicate if it is "new", "old" or "gone" This method creates a Mailmsg object for each waiting Mail msg This Mailmsg object contains the Mail Headers and the size of the msg
- Returns:
- void
- See Also:
Mailmsg
delete
public boolean delete(Mailmsg[] mailmsgs) throws FaceMailboxException
- Method to delete any mail marked for deletion.
This method is passed an array of mailmsgs where one or more may have been marked for deletion. The implementation of this should use the mailmsg.getDeleteFlag() to determine what msgs should be deleted and ensure that the mailmsg is marked for deletion and actually deleted.
- Returns:
- boolean true if one or more messages are deleted.
- Throws:
FaceMailboxException
- See Also:
Mailmsg
copymsg
public boolean copymsg(Mailmsg msg, java.lang.String addr) throws FaceMailboxException
- Method to copy mail to a new server.
This method is passed a mailmsg. The implementation of this should make a copy of the mailmsg and send it to the specified server.
- Parameters:
msg
- Mailmsg to be copied.- Returns:
- boolean true if the message is successfully copied.
- Throws:
FaceMailboxException
- See Also:
Mailmsg
close
public abstract void close()
- Abstract Method: close(). This close method will be called on each pass, Depending on the type of Server, we may or may not close the connection to the Mail server
- Returns:
- void
terminate
public abstract void terminate()
- Abstract Method: terminate(). This terminate method will be called when the server is asked to shutdown
- Returns:
- void
toString
public java.lang.String toString()
- toString is called to identify the Mailbox Object.
- Overrides:
toString
in classjava.lang.Object
- Returns:
- String that identifies the FaceMailBox object
Overview Package Class Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD