talx x1.0.5

talx.model
Class TransportToolkit

java.lang.Object
  extended bytalx.model.TransportToolkit
All Implemented Interfaces:
ControllerConstants, java.util.EventListener, GUIStateConstants, MailConstants, ReceiverFilterListener

public class TransportToolkit
extends java.lang.Object
implements ReceiverFilterListener, ControllerConstants, GUIStateConstants, MailConstants

Provides the message store API. This class is the last consumer in the incoming message stack, and the producer for the outgoing message stack. This class is also the repository for the people in the model.


Field Summary
 
Fields inherited from interface talx.controller.ControllerConstants
EXIT_COMMAND, FILE_ATTACHMENTS_KEY, ILLEGAL_ACTION_COMMAND, LOGOUT_COMMAND, MAIL_COUNT_CHANGED_COMMAND, REMOTE_GAME_COMMAND, SAVE_COMMAND, STOP_COMMAND, TEST_COMMAND
 
Fields inherited from interface talx.model.GUIStateConstants
ACTIVE_COMMANDS, ARCHIVE_MESSAGE, CHOICE_DIALOG, COMPOSE_FOCUS, COMPOSE_WINDOW, COMPOSER_CAPTION, COMPOSER_DIRTY, CONFIRM_DIALOG, CURRENT_PEOPLE, CURRENT_PLAYER, DEFAULT_MESSAGE, DIALOG_FOCUS, DIALOG_TEXT, INBOX_FOCUS, INBOX_MAIL_COUNTS, INBOX_MAIL_COUNTS_ANSWERED, INBOX_MAIL_COUNTS_NEW, INBOX_PANEL, INBOX_PLAYER_CAPTIONS, NO_CHANGE, NO_MESSAGE, NO_PEOPLE, NO_PERSON, NO_PLAYER, READER_CAPTION, READER_FOCUS, READER_HEADERS, READER_WINDOW, STATE_ABBR, STATE_CONST, STATE_DESC
 
Fields inherited from interface talx.util.MailConstants
ARCHIVE_ID, BOUNCE_HEADER, COMPOSE_TIME, DEFAULT_ID, ERASE_COUNTS, EXPIRATION_TIME, NO_DELETE, NO_REPLY, REMINDER
 
Constructor Summary
TransportToolkit(Settings settings)
           
 
Method Summary
 void addSenderListener(SenderFilterListener obj)
           
 void addStoreListener(StoreListener obj)
           
 boolean canDelete(javax.mail.internet.MimeMessage m)
           
 boolean canReply(javax.mail.internet.MimeMessage m)
           
 void close()
          Closes the inbox, outbox and trash and the enclosing store.
 void filterActivated(TALMailEvent ev)
          Moves the message from the inbox to the trash.
 javax.mail.internet.MimeMessage findDraft(javax.mail.internet.MimeMessage original, Person[] to)
          Returns a saved draft of a reply to the given message.
 Person findPerson(javax.mail.internet.MimeMessage m)
          Returns the person in the model who sent the given message.
 Person findPerson(java.lang.String address)
          Returns the person in the model with the given address or null.
 void fireAutoMailEvent(java.lang.Object source, javax.mail.internet.MimeMessage original, java.lang.String newText)
          This method sends the given new text to the originator of the given original message.
 void fireDeleteMail(javax.mail.internet.MimeMessage message)
          Sends the event and deletes the message.
 void fireMailAbortEvent(javax.mail.internet.MimeMessage reply, long time, int del_words, int del_chars, GUIState state)
          Fires a mail abort event to all store listeners.
 void fireMailPostponedEvent(javax.mail.internet.MimeMessage reply, long time, int del_words, int del_chars, GUIState state)
          Fires a mail postponed event to all store listeners.
 void fireMessageCountChanged(Person p)
           
 void fireMessageDropped(javax.mail.internet.MimeMessage m, Person p)
           
 void fireReadMail(javax.mail.internet.MimeMessage m, Person p)
          Fires read mail event, sets message to seen and fires message count changed.
 void fireSendMailEvent(javax.mail.internet.MimeMessage reply, long time, int del_words, int del_chars, GUIState state)
          Fires a mail sent event to all listeners.
 void fireSendMailEvent(java.lang.String recipient, java.lang.String[][] headers, java.lang.Object body)
          Sends the object in an unlogged message to recipient.
 javax.mail.internet.MimeMessage getDefaultMessage(Person person)
          Constructs the default message from the given person.
 Outbox getDrafts()
          Returns the message box used for outgoing messages).
 Outbox getInbox()
          Returns the message box used for incoming messages (part of IMAP system).
 javax.mail.internet.MimeMessage getMessageHistory(Person person)
          Constructs the message history for the given person.
 Outbox getOutbox()
          Returns the message box used for outgoing messages).
 Person getPerson(java.lang.String name)
          Returns the person in the model with the given name or null.
 Trash getTrash()
          Returns the message box used for messages that are scheduled for deletion.
 void newMailArrived(TALMailEvent ev)
          Adds mail to person's inbox.
 void removeDrafts(GUIState state)
           
 void saveDraft(javax.mail.internet.MimeMessage reply, GUIState state)
           
 java.lang.String toString()
           
 Person[] translate(javax.mail.Address[] a)
          Translates InternetAddress objects to People in the model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransportToolkit

public TransportToolkit(Settings settings)
Method Detail

close

public void close()
Closes the inbox, outbox and trash and the enclosing store.


getInbox

public Outbox getInbox()
Returns the message box used for incoming messages (part of IMAP system).


getDrafts

public Outbox getDrafts()
Returns the message box used for outgoing messages).


getOutbox

public Outbox getOutbox()
Returns the message box used for outgoing messages).


getTrash

public Trash getTrash()
Returns the message box used for messages that are scheduled for deletion.


addStoreListener

public void addStoreListener(StoreListener obj)

addSenderListener

public void addSenderListener(SenderFilterListener obj)

newMailArrived

public void newMailArrived(TALMailEvent ev)
Adds mail to person's inbox. fires message count changed and the new mail.

Specified by:
newMailArrived in interface ReceiverFilterListener

filterActivated

public void filterActivated(TALMailEvent ev)
Moves the message from the inbox to the trash.

Specified by:
filterActivated in interface ReceiverFilterListener

fireMessageDropped

public void fireMessageDropped(javax.mail.internet.MimeMessage m,
                               Person p)

fireMessageCountChanged

public void fireMessageCountChanged(Person p)

fireReadMail

public void fireReadMail(javax.mail.internet.MimeMessage m,
                         Person p)
Fires read mail event, sets message to seen and fires message count changed.


fireDeleteMail

public void fireDeleteMail(javax.mail.internet.MimeMessage message)
Sends the event and deletes the message.

Throws:
javax.mail.MessagingException - if message.getFrom() throws a MessagingException.

fireMailAbortEvent

public void fireMailAbortEvent(javax.mail.internet.MimeMessage reply,
                               long time,
                               int del_words,
                               int del_chars,
                               GUIState state)
Fires a mail abort event to all store listeners. This method also clears any saved drafts of the reply.

Parameters:
reply - the user's message that has been aborted.
time - the time spent in composition
del_words - the number of words deleted during the composition
del_chars - the number of charancters deleted during the composition
state - the system state holding the original message

fireMailPostponedEvent

public void fireMailPostponedEvent(javax.mail.internet.MimeMessage reply,
                                   long time,
                                   int del_words,
                                   int del_chars,
                                   GUIState state)
Fires a mail postponed event to all store listeners. This method also saves a draft of the reply.

Parameters:
reply - the user's message that has been aborted.
time - the time spent in composition
del_words - the number of words deleted during the composition
del_chars - the number of charancters deleted during the composition
state - the system state holding the original message

fireSendMailEvent

public void fireSendMailEvent(javax.mail.internet.MimeMessage reply,
                              long time,
                              int del_words,
                              int del_chars,
                              GUIState state)
Fires a mail sent event to all listeners. Since this event goes to filter listeners as well as store listeners, it has the effect of sending the message (if it makes it througth the filter stack). The reply is added to the outbox, and the original has its answered flag set. This method also clears any saved drafts of the reply.

Parameters:
reply - the user's message that has been aborted.
time - the time spent in composition
del_words - the number of words deleted during the composition
del_chars - the number of charancters deleted during the composition
state - the system state holding the original message

removeDrafts

public void removeDrafts(GUIState state)

saveDraft

public void saveDraft(javax.mail.internet.MimeMessage reply,
                      GUIState state)

findDraft

public javax.mail.internet.MimeMessage findDraft(javax.mail.internet.MimeMessage original,
                                                 Person[] to)
Returns a saved draft of a reply to the given message. This method checks for any messages that are in response to this message ID and going to all of the given people (The check on people is to account for "responses" to the default message). If that turns up negative, then we look for responses to the default message that were also going to the given list of people. That is, initiated outgoing mail is considered a response to everything. This is so that initiated message content doesn't get buried under an active thread. When this happens, the draft that was a "reply" to the default message, gets marked as a reply to the given message.

Returns:
a draft of the original or null if no draft exists.

fireSendMailEvent

public void fireSendMailEvent(java.lang.String recipient,
                              java.lang.String[][] headers,
                              java.lang.Object body)
Sends the object in an unlogged message to recipient. The message goes through the outgoing filters, but does not generate any StoreListener events. The message is put in the trash.


fireAutoMailEvent

public void fireAutoMailEvent(java.lang.Object source,
                              javax.mail.internet.MimeMessage original,
                              java.lang.String newText)
This method sends the given new text to the originator of the given original message. This method can be used by incoming filters to alert the originator of problems with an incoming message.


getPerson

public Person getPerson(java.lang.String name)
Returns the person in the model with the given name or null.


toString

public java.lang.String toString()

findPerson

public Person findPerson(java.lang.String address)
Returns the person in the model with the given address or null.


findPerson

public Person findPerson(javax.mail.internet.MimeMessage m)
Returns the person in the model who sent the given message. If the message contains more than one from address, the addresses are searched in order until a matching address is found. If no address is found, null is returned.


translate

public Person[] translate(javax.mail.Address[] a)
Translates InternetAddress objects to People in the model. Addresses that do not match people in the model are returned as null entries.


getDefaultMessage

public javax.mail.internet.MimeMessage getDefaultMessage(Person person)
                                                  throws javax.mail.MessagingException
Constructs the default message from the given person.

Throws:
javax.mail.MessagingException

getMessageHistory

public javax.mail.internet.MimeMessage getMessageHistory(Person person)
                                                  throws javax.mail.MessagingException
Constructs the message history for the given person.

Throws:
javax.mail.MessagingException

canReply

public boolean canReply(javax.mail.internet.MimeMessage m)

canDelete

public boolean canDelete(javax.mail.internet.MimeMessage m)

talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.