wtalk.protocols.pms
Class PMSProtocol

java.lang.Object
  |
  +--wtalk.protocols.pms.PMSProtocol
All Implemented Interfaces:
WTalkProtocol

public class PMSProtocol
extends java.lang.Object
implements WTalkProtocol


Field Summary
protected  java.io.DataInputStream mDis
           
protected  java.io.DataOutputStream mDos
           
protected  java.net.Socket mSock
           
static java.lang.String PMS_NAME
           
 
Constructor Summary
PMSProtocol()
          Constructor
 
Method Summary
 void addBuddy(java.lang.String buddy, java.lang.String group)
          Adds a buddy to "group" on a list maintained on the server.
 void changePassword(java.lang.String oldpwd, java.lang.String newpwd)
          Dummy function needed to implement WTalkProtocol.
 void chatList(java.lang.String room)
          Dummy function needed to implement WTalkProtocol.
 void chatMessage(java.lang.String room, java.lang.String data)
          Dummy function needed to implement WTalkProtocol.
 void connect()
          Connects to the server
 void connect(java.lang.String login)
          Connects to the server
 void connect(java.lang.String server, int port)
          Connects to the server
 void connect(java.lang.String server, int port, java.lang.String login)
          Connect to the server
 void createTestBuddyList()
          Function with which to test buddy list functionality.
 void disconnect(java.lang.String msg)
          Dummy function needed to implement WTalkProtocol.
 java.lang.String getConnectionName()
          Returns a connection name for use with user lists.
 java.lang.String getName()
          Returns the user's name (handle) understood by the current connection.
 java.lang.String getServer()
          Returns name of current server.
 int getServerPort()
          Gets the current server port
 boolean isConnected()
          Returns true if there is an active connection, false otherwise.
 void joinChat(java.lang.String room)
          Dummy function needed to implement WTalkProtocol.
 void partChat(java.lang.String room)
          Dummy function needed to implement WTalkProtocol.
 void removeBuddy(java.lang.String buddy, java.lang.String group)
          Removes a buddy from "group" on a list maintained on the server.
protected  void sendBuddyListCmd(java.io.DataOutputStream dos, java.lang.String grp, java.lang.String user, int version, int msgType)
          Send the server buddy list management commands.
 void sendMessage(java.io.DataOutputStream dos, java.lang.String to, java.lang.String data, int version, java.util.Vector recipients, java.lang.String chatID)
          Sends a message from one user to another.
 void sendMessage(java.lang.String to, java.lang.String data)
          Wrapper function for the sendMessage function called below.
 void sendRaw(java.lang.String msg)
          Dummy function needed to implement WTalkProtocol.
protected  void sendSignOn(java.io.DataOutputStream dos, java.lang.String name, java.lang.String password, int version)
          Send a message to the server with the user's name and password indicating they wish to logon to the system.
 void sendSimpleMessage(java.io.DataOutputStream dos, java.lang.String data, int version, int msgType)
          Write out any "simple" message to the socket.
 void sendStatusInfo(java.io.DataOutputStream dos, int version, int msgType, java.lang.String name, java.lang.String phoneNum, java.lang.String email, java.lang.String major, java.lang.String location, int idle, int away)
          Send updated status info to the server.
 void sendWall(java.lang.String msg)
          Dummy function needed to implement WTalkProtocol.
 void setAutoMessageHandler(wtalk.RMsgHandler r)
          Implements the function defined in WTalkProtocol
 void setAway(java.lang.String message)
          Sets or removes away message that the server will send to users who try and message us.
 void setBan(java.lang.String user, boolean banned)
          Implements WTalkProtocol function.
 void setChatMessageHandler(wtalk.RMsgHandler r)
          Implements the function defined in WTalkProtocol
 void setName(java.lang.String name)
          Sets the user's name for the active connection to name
 void setPassword(java.lang.String passwd)
          Sets the password the connection will use to authenticate.
 void setPrivateMessageHandler(wtalk.RMsgHandler r)
          Implements the function defined in WTalkProtocol
 void setReceivedMessageHandler(wtalk.RMsgHandler r)
          Implements the function defined in WTalkProtocol
 void setServer(java.lang.String server)
          Sets the server to use when connect() is called.
 void setServerPort(int port)
          Sets the current server port
 void setSystemMessageHandler(wtalk.RMsgHandler r)
          Implements the function defined in WTalkProtocol
 void setTopic(java.lang.String room, java.lang.String topic)
          Dummy function needed to implement WTalkProtocol.
 void setUserListHandler(wtalk.IUserList ul)
          Sets handler for manipulating the buddy list
 void setWallMessageHandler(wtalk.RMsgHandler r)
          Implements the function defined in WTalkProtocol
 void whois(java.lang.String user)
          Dummy function needed to implement WTalkProtocol.
 void writeMsgHeader(java.io.DataOutputStream dos, int version, int msgType, int dataSize, int time)
          Write out the individual components of the message header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PMS_NAME

public static final java.lang.String PMS_NAME
See Also:
Constant Field Values

mSock

protected java.net.Socket mSock

mDos

protected java.io.DataOutputStream mDos

mDis

protected java.io.DataInputStream mDis
Constructor Detail

PMSProtocol

public PMSProtocol()
Constructor

Method Detail

writeMsgHeader

public void writeMsgHeader(java.io.DataOutputStream dos,
                           int version,
                           int msgType,
                           int dataSize,
                           int time)
                    throws java.io.IOException,
                           java.lang.NumberFormatException
Write out the individual components of the message header.

Parameters:
dos - A DataOutputStream mapped to the socket to which the message header is to be written
version - The version of the PMS protocol being used
msgType - A code identifying the type of message that is being written out
dataSize - The size of the data contained in the message, including an extra byte for each string to account for the null terminator
time - The time to use to stamp the message (in ms from the epoch)
Throws:
An - IOException is thrown when there is a problem writing to the DataOutputStream.
java.io.IOException
java.lang.NumberFormatException

getConnectionName

public java.lang.String getConnectionName()
Returns a connection name for use with user lists.

Returns:
Returns PMS-<User_Name>

setReceivedMessageHandler

public void setReceivedMessageHandler(wtalk.RMsgHandler r)
Implements the function defined in WTalkProtocol

Specified by:
setReceivedMessageHandler in interface WTalkProtocol
See Also:
WTalkProtocol

setChatMessageHandler

public void setChatMessageHandler(wtalk.RMsgHandler r)
Implements the function defined in WTalkProtocol

Specified by:
setChatMessageHandler in interface WTalkProtocol
See Also:
WTalkProtocol

setPrivateMessageHandler

public void setPrivateMessageHandler(wtalk.RMsgHandler r)
Implements the function defined in WTalkProtocol

Specified by:
setPrivateMessageHandler in interface WTalkProtocol
See Also:
WTalkProtocol

setWallMessageHandler

public void setWallMessageHandler(wtalk.RMsgHandler r)
Implements the function defined in WTalkProtocol

Specified by:
setWallMessageHandler in interface WTalkProtocol
See Also:
WTalkProtocol

setSystemMessageHandler

public void setSystemMessageHandler(wtalk.RMsgHandler r)
Implements the function defined in WTalkProtocol

Specified by:
setSystemMessageHandler in interface WTalkProtocol
See Also:
WTalkProtocol

setAutoMessageHandler

public void setAutoMessageHandler(wtalk.RMsgHandler r)
Implements the function defined in WTalkProtocol

Specified by:
setAutoMessageHandler in interface WTalkProtocol
See Also:
WTalkProtocol

setUserListHandler

public void setUserListHandler(wtalk.IUserList ul)
Sets handler for manipulating the buddy list

Specified by:
setUserListHandler in interface WTalkProtocol
Parameters:
ul - is a class that implements wtalk.IUserList
See Also:
IUserList

sendRaw

public void sendRaw(java.lang.String msg)
Dummy function needed to implement WTalkProtocol.

Specified by:
sendRaw in interface WTalkProtocol
See Also:
WTalkProtocol

connect

public void connect()
             throws java.io.IOException
Connects to the server

Specified by:
connect in interface WTalkProtocol
Throws:
java.io.IOException - if there is an I/O error

connect

public void connect(java.lang.String login)
             throws java.io.IOException
Connects to the server

Specified by:
connect in interface WTalkProtocol
Parameters:
login - String representing login (user name)
Throws:
java.io.IOException - if there's an I/O error

connect

public void connect(java.lang.String server,
                    int port)
             throws java.io.IOException
Connects to the server

Specified by:
connect in interface WTalkProtocol
Parameters:
server - String representing host to connect to
port - int representing port to connect to
Throws:
java.io.IOException - if there's an I/O error

connect

public void connect(java.lang.String server,
                    int port,
                    java.lang.String login)
             throws java.io.IOException
Connect to the server

Specified by:
connect in interface WTalkProtocol
Parameters:
server - String representing host to connect to
port - int representing port to connect to
login - String representing login (user name)
Throws:
java.io.IOException - if there's an I/O error

disconnect

public void disconnect(java.lang.String msg)
Dummy function needed to implement WTalkProtocol.

Specified by:
disconnect in interface WTalkProtocol
See Also:
WTalkProtocol

isConnected

public boolean isConnected()
Returns true if there is an active connection, false otherwise.

Specified by:
isConnected in interface WTalkProtocol
Returns:
Returns true if the WTalkProtocol has an active connection.
See Also:
WTalkProtocol

setName

public void setName(java.lang.String name)
Sets the user's name for the active connection to name

Specified by:
setName in interface WTalkProtocol
Parameters:
name - User name to request. Depending on the protocol it is not guaranteed that this request will be granted, or if it will even make since once connected.
See Also:
WTalkProtocol

getName

public java.lang.String getName()
Returns the user's name (handle) understood by the current connection.

Specified by:
getName in interface WTalkProtocol
Returns:
The user's current handle on this connection.
See Also:
WTalkProtocol

setPassword

public void setPassword(java.lang.String passwd)
Sets the password the connection will use to authenticate.

Note that this does not change the password to authenticate, and no such method is provided under the PMS protocol.

Specified by:
setPassword in interface WTalkProtocol
Parameters:
passwd - Password to use to authenticate.
See Also:
WTalkProtocol

changePassword

public void changePassword(java.lang.String oldpwd,
                           java.lang.String newpwd)
Dummy function needed to implement WTalkProtocol.

Specified by:
changePassword in interface WTalkProtocol
Parameters:
oldpwd - The old password, such as the one used to authenticate with when loggin on.
newpwd - A new password, to be used in future authentication attempts.
See Also:
WTalkProtocol

setServer

public void setServer(java.lang.String server)
Sets the server to use when connect() is called.

This function does not attempt to connect.

Specified by:
setServer in interface WTalkProtocol
Parameters:
server - Host that connect() will connect to.
See Also:
WTalkProtocol

getServer

public java.lang.String getServer()
Returns name of current server.

Specified by:
getServer in interface WTalkProtocol
Returns:
Name of current server WTalkProtocol has stored.

setServerPort

public void setServerPort(int port)
Sets the current server port

Specified by:
setServerPort in interface WTalkProtocol
Parameters:
port - The port the server should run on

getServerPort

public int getServerPort()
Gets the current server port

Specified by:
getServerPort in interface WTalkProtocol
Returns:
The current Port stored by the WTalkProtocol.

sendMessage

public void sendMessage(java.io.DataOutputStream dos,
                        java.lang.String to,
                        java.lang.String data,
                        int version,
                        java.util.Vector recipients,
                        java.lang.String chatID)
                 throws java.io.IOException
Sends a message from one user to another.

Parameters:
dos - A DataOutputStream mapped to the socket to which the message header is to be written
to - The name of the user to which the message should be sent
data - The content of the message to be sent
version - The version of the PMS protocol being used
recipients - A vector of Strings containing the users to whom the message should be sent
chatID - The name associated with the chat to which this message should be sent
Throws:
An - IOException is thrown when a problems occurs trying to write to the DataOutputStream
java.io.IOException

sendSimpleMessage

public void sendSimpleMessage(java.io.DataOutputStream dos,
                              java.lang.String data,
                              int version,
                              int msgType)
                       throws java.io.IOException
Write out any "simple" message to the socket. This can be used to send the following message types: - Query Status Info - Get Away Message (here, set data to null) - Post Away Message - Ban user - Unban User

Parameters:
dos - A DataOutputStream mapped to the socket to which the message header is to be written
data - The data with which this command is dealing (varies depending on msgType)
version - The version of the PMS protocol being used
msgType - A code identifying the type of message that is being written out
Throws:
An - IOException is thrown when a problems occurs trying to write to the DataOutputStream
java.io.IOException

sendStatusInfo

public void sendStatusInfo(java.io.DataOutputStream dos,
                           int version,
                           int msgType,
                           java.lang.String name,
                           java.lang.String phoneNum,
                           java.lang.String email,
                           java.lang.String major,
                           java.lang.String location,
                           int idle,
                           int away)
                    throws java.io.IOException
Send updated status info to the server. Arguments which are not being updated should be null.

Parameters:
dos - A DataOutputStream mapped to the socket to which the message header is to be written
version - The version of the PMS protocol being used
msgType - A code identifying the type of message that is being written out
name - The name of the user associated with this info
phoneNum - A String representing the phone number of the user
email - A String representing the e-mail address of the user
major - A String reprsenting the name of the user's major
location - A String indentifying the user's location
idle - The user's idle time (in ms from the epoch)
away - The user's away time (in ms from the epoch)
Throws:
An - IOException is thrown when a problems occurs trying to write to the DataOutputStream
java.io.IOException

sendSignOn

protected void sendSignOn(java.io.DataOutputStream dos,
                          java.lang.String name,
                          java.lang.String password,
                          int version)
                   throws java.io.IOException
Send a message to the server with the user's name and password indicating they wish to logon to the system.

Parameters:
dos - A DataOutputStream mapped to the socket to which the message header is to be written
name - The name of the user trying to connect to the system
password - The password of the user trying to connect to the system
version - The version of the PMS protocol being used
Throws:
An - IOException is thrown when a problems occurs trying to write to the DataOutputStream
java.io.IOException

sendBuddyListCmd

protected void sendBuddyListCmd(java.io.DataOutputStream dos,
                                java.lang.String grp,
                                java.lang.String user,
                                int version,
                                int msgType)
                         throws java.io.IOException
Send the server buddy list management commands. This can be used to send the following message types: - Add Buddy (ADD_BUDDY) - Remove Buddy (REMOVE_BUDDY)

Parameters:
dos - A DataOutputStream mapped to the socket to which the message header is to be written
grp - The group with which the user is (to be) associated
user - The name of the user on which to act
version - The version of the PMS protocol being used
msgType - A code identifying the type of message that is being written out
Throws:
An - IOException is thrown when a problems occurs trying to write to the DataOutputStream
java.io.IOException

createTestBuddyList

public void createTestBuddyList()
Function with which to test buddy list functionality. Adds the specified buddies (and groups implicitly, if they don't already exist). (Testing function only)


sendMessage

public void sendMessage(java.lang.String to,
                        java.lang.String data)
Wrapper function for the sendMessage function called below. This is called from the GUI to send a message to someone.

Specified by:
sendMessage in interface WTalkProtocol
Parameters:
to - A String designating to whom the message should be sent
data - A String containing the data (the message) to be sent

whois

public void whois(java.lang.String user)
Dummy function needed to implement WTalkProtocol.

Specified by:
whois in interface WTalkProtocol
Parameters:
user - Name of user to requst information on.
See Also:
WTalkProtocol

addBuddy

public void addBuddy(java.lang.String buddy,
                     java.lang.String group)
Adds a buddy to "group" on a list maintained on the server. This list will be retrieved at logon.

Specified by:
addBuddy in interface WTalkProtocol
Parameters:
buddy - Name of buddy to add.
group - Name of group buddy is to be added to.

removeBuddy

public void removeBuddy(java.lang.String buddy,
                        java.lang.String group)
Removes a buddy from "group" on a list maintained on the server. This list will be retrieved at logon.

Specified by:
removeBuddy in interface WTalkProtocol
Parameters:
buddy - Name of buddy to remove.
group - Name of group buddy is to be removed from.

setAway

public void setAway(java.lang.String message)
Sets or removes away message that the server will send to users who try and message us.

Specified by:
setAway in interface WTalkProtocol
Parameters:
message - The message to send when users contact us, or null to not send any message (removes away status).

joinChat

public void joinChat(java.lang.String room)
Dummy function needed to implement WTalkProtocol.

Specified by:
joinChat in interface WTalkProtocol
Parameters:
room - Name of chat to join.
See Also:
WTalkProtocol

partChat

public void partChat(java.lang.String room)
Dummy function needed to implement WTalkProtocol.

Specified by:
partChat in interface WTalkProtocol
Parameters:
room - Name of chat to part.
See Also:
WTalkProtocol

chatMessage

public void chatMessage(java.lang.String room,
                        java.lang.String data)
Dummy function needed to implement WTalkProtocol.

Specified by:
chatMessage in interface WTalkProtocol
Parameters:
room - The room to which a message is sent.
data - The contents of the message.
See Also:
WTalkProtocol

setTopic

public void setTopic(java.lang.String room,
                     java.lang.String topic)
Dummy function needed to implement WTalkProtocol.

Specified by:
setTopic in interface WTalkProtocol
Parameters:
room - Room whose topic we are concerned.
topic - If not null, the topic which will be set in room. If null, a request to receive the current topic is sent.
See Also:
WTalkProtocol

chatList

public void chatList(java.lang.String room)
Dummy function needed to implement WTalkProtocol.

Specified by:
chatList in interface WTalkProtocol
Parameters:
room - The chat which we would like information. A null value indicates a request for all active chats if this is permitted by the protocol (it may not be).
See Also:
WTalkProtocol

sendWall

public void sendWall(java.lang.String msg)
Dummy function needed to implement WTalkProtocol.

Specified by:
sendWall in interface WTalkProtocol
Parameters:
msg - The message to brodcast.
See Also:
WTalkProtocol

setBan

public void setBan(java.lang.String user,
                   boolean banned)
Implements WTalkProtocol function. Sets banned status of user to the boolean value of banned.

Specified by:
setBan in interface WTalkProtocol
Parameters:
user - User whose banned state we are concerned.
banned - If true, user is banned, otherwise banned status is removed.
See Also:
WTalkProtocol