edu.columbia.coms6901.pingtel.pingim
Class Buddy

java.lang.Object
  |
  +--edu.columbia.coms6901.pingtel.pingim.Buddy

public class Buddy
extends java.lang.Object

Represents an IM buddy.

Version:
1.0
Author:
Micah Sherr

Field Summary
static int ADDRESSBOOK_BUDDY
          an addressbook/phonebook entry
private  java.util.Date dtExpires
          the date that our subscription to this buddy expires
private  int iBuddyState
          the state of this buddy (away, available, etc.)
private  int iBuddyType
          the type of this buddy (IM, X10, etc.)
private  int iNotifySeqNum
          the current sequence number of the notify messages
static int PINGTEL_BUDDY
          a PingTel IM Buddy
private  java.lang.String sCommonName
          buddy's common name, in string format
private  java.lang.String sDescription
          the description for this buddy
private  java.lang.String sDeviceName
          the devicename of this buddy.
private  java.lang.String sDistinguishedName
          Buddy's distinguished name in LDAP server
private  java.lang.String sipAddress
          buddy's sip address, in string format
private  java.lang.String sSurname
          buddy's surname (last name)
static int STATE_AWAY
          buddy's state is away
static int STATE_BUSY
          buddy's state is busy
static int STATE_BUSY_WORKING
          buddy's state is busy working
static int STATE_DO_NOT_DISTURB
          buddy's state is do not disturb
static int STATE_PRESENT
          buddy's state is present
static int STATE_UNAVAILABLE
          buddy's state is unavailable
static int STATE_UNKNOWN
          buddy's state is unknown
static int STATE_X10
          buddy is an X10 device
static int X10_BUDDY
          an X10-controlled device
 
Constructor Summary
Buddy(java.lang.String buddy, java.lang.String sip, java.lang.String cn, int type)
          Creates a new instance of a Buddy.
Buddy(java.lang.String buddy, java.lang.String sip, java.lang.String cn, int type, java.lang.String description)
          Creates a new instance of a Buddy.
 
Method Summary
 void activateX10()
          Activates X10 buddy
 void call(PingIM application)
          Places a call to this buddy
 void deactivateX10()
          Deactivates X10 buddy
 void displayBuddyInfo(PingIM application)
          Displays information about this particular buddy
 int getBuddyType()
          Returns the buddy type (e.g., PINGTEL_BUDDY or X10_BUDDY)
 java.lang.String getCN()
          Returns the common name for this buddy
 java.lang.String getDescription()
          Returns the description for this buddy
 java.lang.String getDeviceName()
          Returns the device name for this buddy.
 java.lang.String getDN()
          Returns the distinguished name for this buddy
 java.util.Date getExpirationTime()
          Gets buddy's expiration time
 java.lang.String getSIPAddress()
          Returns the SIP Object for this buddy
 int getState()
          Returns the current state of the buddy
 java.lang.String getStateString()
          Returns the current state of this buddy in plain English
static java.lang.String getStateString(int iState)
          Returns the current state of the buddy in plain English
protected  char getStateSymbol()
          Returns symbol representing the state of the buddy
 java.lang.String getSurname()
          Retrieves the surname of the budy
protected  void resetExpirationTime()
          Resets buddy's expiration time
private  void sendX10Command(int iAction)
          Sends ON or OFF message to X10 buddy
 void setDeviceName(java.lang.String sDevice)
          Sets the name of the device if this buddy is an X10-controlled device
protected  boolean setExpirationTime(int iSeconds)
          Sets buddy's expiration time
 void setState(int iState)
          Sets the state of the buddy
 void setSurname(java.lang.String sSurname)
          Sets the surname of the budy
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

PINGTEL_BUDDY

public static final int PINGTEL_BUDDY
a PingTel IM Buddy

X10_BUDDY

public static final int X10_BUDDY
an X10-controlled device

ADDRESSBOOK_BUDDY

public static final int ADDRESSBOOK_BUDDY
an addressbook/phonebook entry

STATE_UNKNOWN

public static final int STATE_UNKNOWN
buddy's state is unknown

STATE_PRESENT

public static final int STATE_PRESENT
buddy's state is present

STATE_AWAY

public static final int STATE_AWAY
buddy's state is away

STATE_BUSY

public static final int STATE_BUSY
buddy's state is busy

STATE_BUSY_WORKING

public static final int STATE_BUSY_WORKING
buddy's state is busy working

STATE_DO_NOT_DISTURB

public static final int STATE_DO_NOT_DISTURB
buddy's state is do not disturb

STATE_UNAVAILABLE

public static final int STATE_UNAVAILABLE
buddy's state is unavailable

STATE_X10

public static final int STATE_X10
buddy is an X10 device

sDistinguishedName

private java.lang.String sDistinguishedName
Buddy's distinguished name in LDAP server

sipAddress

private java.lang.String sipAddress
buddy's sip address, in string format

sCommonName

private java.lang.String sCommonName
buddy's common name, in string format

sSurname

private java.lang.String sSurname
buddy's surname (last name)

iBuddyType

private int iBuddyType
the type of this buddy (IM, X10, etc.)

sDescription

private java.lang.String sDescription
the description for this buddy

iBuddyState

private int iBuddyState
the state of this buddy (away, available, etc.)

sDeviceName

private java.lang.String sDeviceName
the devicename of this buddy. used for X10 buddies

dtExpires

private java.util.Date dtExpires
the date that our subscription to this buddy expires

iNotifySeqNum

private int iNotifySeqNum
the current sequence number of the notify messages
Constructor Detail

Buddy

public Buddy(java.lang.String buddy,
             java.lang.String sip,
             java.lang.String cn,
             int type)
Creates a new instance of a Buddy.
Parameters:
buddy - Buddy's DN
sip - SIP address
cn - Common name (full name)
type - Either X10 or PINGIM

Buddy

public Buddy(java.lang.String buddy,
             java.lang.String sip,
             java.lang.String cn,
             int type,
             java.lang.String description)
Creates a new instance of a Buddy.
Parameters:
buddy - Buddy's DN
sip - SIP address
cn - Common name (full name)
type - Either X10 or PINGIM
description - Brief description of the buddy
Method Detail

setSurname

public void setSurname(java.lang.String sSurname)
Sets the surname of the budy
Parameters:
sSurname - surname of our budy

getSurname

public java.lang.String getSurname()
Retrieves the surname of the budy
Returns:
the surname of the buddy

setDeviceName

public void setDeviceName(java.lang.String sDevice)
Sets the name of the device if this buddy is an X10-controlled device
Parameters:
sDevice - name of the device

getBuddyType

public int getBuddyType()
Returns the buddy type (e.g., PINGTEL_BUDDY or X10_BUDDY)
Returns:
the buddy type

getSIPAddress

public java.lang.String getSIPAddress()
Returns the SIP Object for this buddy
Returns:
the SIP address (in string format) of this buddy

getDN

public java.lang.String getDN()
Returns the distinguished name for this buddy
Returns:
the buddy's DN

getCN

public java.lang.String getCN()
Returns the common name for this buddy
Returns:
the buddy's CN

getDescription

public java.lang.String getDescription()
Returns the description for this buddy
Returns:
the description

getDeviceName

public java.lang.String getDeviceName()
Returns the device name for this buddy. Used for X10 buddies
Returns:
the device name

setState

public void setState(int iState)
Sets the state of the buddy
Parameters:
iState - New state

getState

public int getState()
Returns the current state of the buddy
Returns:
the state of the buddy

getStateString

public static java.lang.String getStateString(int iState)
Returns the current state of the buddy in plain English
Parameters:
iState - State of the buddy
Returns:
the state of the buddy, in string format

getStateString

public java.lang.String getStateString()
Returns the current state of this buddy in plain English
Returns:
the state of this buddy, in string format

getStateSymbol

protected char getStateSymbol()
Returns symbol representing the state of the buddy
Returns:
the state of the buddy

setExpirationTime

protected boolean setExpirationTime(int iSeconds)
Sets buddy's expiration time
Parameters:
iSeconds - Expiration date in number of seconds from now
Returns:
true if expiration time was successfully written, else false

resetExpirationTime

protected void resetExpirationTime()
Resets buddy's expiration time

getExpirationTime

public java.util.Date getExpirationTime()
Gets buddy's expiration time
Returns:
this buddy's expiration time

displayBuddyInfo

public void displayBuddyInfo(PingIM application)
Displays information about this particular buddy

call

public void call(PingIM application)
Places a call to this buddy

sendX10Command

private void sendX10Command(int iAction)
Sends ON or OFF message to X10 buddy
Parameters:
iAction - ON or OFF

activateX10

public void activateX10()
Activates X10 buddy

deactivateX10

public void deactivateX10()
Deactivates X10 buddy