edu.columbia.coms6901.pingtel.pingim
Class MESSAGEListener

java.lang.Object
  |
  +--com.pingtel.sip.SipAgent
        |
        +--edu.columbia.coms6901.pingtel.pingim.MESSAGEListener

public class MESSAGEListener
extends com.pingtel.sip.SipAgent

Listens for incoming SIP MESSAGE messages and interprets them. Displays the message to the user, and asks for an action.

Author:
Micah Sherr

Inner classes inherited from class com.pingtel.sip.SipAgent
com.pingtel.sip.SipAgent.icSipMessageListener
 
Field Summary
private  PingIM application
          the current PingIM Xpression
 
Fields inherited from class com.pingtel.sip.SipAgent
m_htContainFilter, m_htMatchFilter, m_listener, m_strMethod
 
Constructor Summary
MESSAGEListener(PingIM application)
          Creates a new instance of MESSAGEListener
 
Method Summary
 void handleMessage(com.pingtel.sip.SipMessage message)
          Handles incoming messages
private  boolean isOkToPlaySound()
          Determines whether a sound should be played when an incoming message arrives.
private  void printMessage(byte[] arrBody, Buddy buddy)
          Prints incoming message and gives user option of replying
private  void printMessage(byte[] arrBody, java.lang.String sFrom)
          Prints incoming message
private  void promptForAction(com.pingtel.sip.SipMessage message)
          Prompts user for one of three actions when a message comes in from a user who is not in the buddy list: ignore message, display message, or display message and add user to buddy-list
protected  void setApplication(PingIM app)
          Sets local Application variable to point to current PingTel Expression
 
Methods inherited from class com.pingtel.sip.SipAgent
addContainsHeaderFilter, addMatchHeaderFilter, SendOKResponse, sendResponse, start, stop
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

application

private PingIM application
the current PingIM Xpression
Constructor Detail

MESSAGEListener

public MESSAGEListener(PingIM application)
Creates a new instance of MESSAGEListener
Parameters:
application - The current instance of the PingIM application
Method Detail

setApplication

protected void setApplication(PingIM app)
Sets local Application variable to point to current PingTel Expression
Parameters:
app - Current PingTel Expression application

handleMessage

public void handleMessage(com.pingtel.sip.SipMessage message)
Handles incoming messages
Overrides:
handleMessage in class com.pingtel.sip.SipAgent
Parameters:
message - Incoming SIP message

promptForAction

private void promptForAction(com.pingtel.sip.SipMessage message)
Prompts user for one of three actions when a message comes in from a user who is not in the buddy list: ignore message, display message, or display message and add user to buddy-list
Parameters:
message - The incoming SIP MESSAGE message

printMessage

private void printMessage(byte[] arrBody,
                          java.lang.String sFrom)
Prints incoming message
Parameters:
arrBody - Bytes of the incoming message
sFrom - The sender of the message

printMessage

private void printMessage(byte[] arrBody,
                          Buddy buddy)
Prints incoming message and gives user option of replying
Parameters:
arrBody - Bytes of the incoming message
buddy - The buddy who sent the message

isOkToPlaySound

private boolean isOkToPlaySound()
Determines whether a sound should be played when an incoming message arrives. For users in Do not disturb mode/busy mode, don't play sound.
Returns:
true if sound should be played, otherwise false