net.kano.joscar.snaccmd.icbm
Class InstantMessage

java.lang.Object
  extended byInstantMessage

public class InstantMessage
extends java.lang.Object

Represents a single instant message, either plain or encrypted.


Field Summary
static int ENCRYPTIONCODE_DEFAULT
          A default encryption code used by the offiical AIM clients.
 
Constructor Summary
InstantMessage(ByteBlock encryptedData)
          Creates a new encrypted instant message with the given encrypted data and an encryption code of ENCRYPTIONCODE_DEFAULT.
InstantMessage(int encryptionCode, ByteBlock encryptedData)
          Creates a new encrypted instant message with the given encryption code and the given encrypted message data block.
InstantMessage(java.lang.String message)
          Creates a new plaintext (unencrypted) instant message object with the given message text.
 
Method Summary
 ByteBlock getEncryptedData()
          Returns the encrypted message data stored in this message, if encrypted.
 int getEncryptionCode()
          Returns the encryption code stored in this message, if any.
 java.lang.String getMessage()
          Returns the text of the message, if unencrypted.
 boolean isEncrypted()
          Returns whether or not this message is encrypted.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENCRYPTIONCODE_DEFAULT

public static final int ENCRYPTIONCODE_DEFAULT
A default encryption code used by the offiical AIM clients.

See Also:
Constant Field Values
Constructor Detail

InstantMessage

public InstantMessage(java.lang.String message)
Creates a new plaintext (unencrypted) instant message object with the given message text.

Parameters:
message - the message body text

InstantMessage

public InstantMessage(ByteBlock encryptedData)
Creates a new encrypted instant message with the given encrypted data and an encryption code of ENCRYPTIONCODE_DEFAULT.

Parameters:
encryptedData - the encrypted message block

InstantMessage

public InstantMessage(int encryptionCode,
                      ByteBlock encryptedData)
Creates a new encrypted instant message with the given encryption code and the given encrypted message data block.

Parameters:
encryptionCode - an encryption code, normally ENCRYPTIONCODE_DEFAULT
encryptedData - the encrypted message block
Method Detail

isEncrypted

public final boolean isEncrypted()
Returns whether or not this message is encrypted. If the returned value is true, encrypted message data can be retrieved using getEncryptedData(). If the returned value is false, the message body text can be retrieved using getMessage().

Returns:
whether or not this message is encrypted

getMessage

public final java.lang.String getMessage()
Returns the text of the message, if unencrypted. This method will always return null if isEncrypted() is true; it will never return null otherwise.

Returns:
the text of this message, if unencrypted

getEncryptionCode

public final int getEncryptionCode()
Returns the encryption code stored in this message, if any. As of this writing, the significance of this value is unknown, but it appears that the official AIM clients always send ENCRYPTIONCODE_DEFAULT. Note that this method will always return -1 if isEncrypted() is false, and may still return -1 otherwise (if no encryption code was included in this message).

Returns:
the encryption code stored in this message, or -1 if none was sent or if this message is not encrypted

getEncryptedData

public final ByteBlock getEncryptedData()
Returns the encrypted message data stored in this message, if encrypted. Note that this method will always return null if isEncrypted() is false, and will never return null otherwise.

Returns:
the encrypted message data

toString

public java.lang.String toString()