net.kano.joscar.snaccmd
Class FullUserInfo

java.lang.Object
  extended byFullUserInfo
All Implemented Interfaces:
LiveWritable

public class FullUserInfo
extends java.lang.Object
implements LiveWritable

A very widely used structure that represents a single screen name and various flags and values associated with it. Such values include warning level, idle time, and away status.


Field Summary
static int MASK_AB
          A user mask indicating that a user is an ActiveBuddy robot.
static int MASK_ADMIN
          A user mask indicating that a user is an administrator.
static long MASK_ALL
          A user mask representing all users.
static int MASK_AOL
          A user mask indicating that a user is using AOL and not AIM.
static int MASK_AWAY
          A user mask indicating that a user is away.
static int MASK_FREE
          A user mask indicating that a user is using AIM for free (as opposed to using AOL, as with MASK_AOL).
static int MASK_UNCONFIRMED
          A user mask indicating that a user never replied to his confirmation email, and may in fact not actually own the email address to which the screenname is registered.
static int MASK_WIRELESS
          A user mask indicating that a user is using a mobile phone to chat.
 
Constructor Summary
FullUserInfo(java.lang.String sn, int warningLevel, int flags, java.util.Date accountCreated, java.util.Date memberSince, long sessAIM, long sessAOL, java.util.Date onSince, int idleMins, CapabilityBlock[] capabilityBlocks, java.lang.Boolean away, ExtraInfoBlock[] extraInfos, ByteBlock certHash, ShortCapabilityBlock[] shortCaps)
          Creates a new user info block with the given properties.
FullUserInfo(java.lang.String sn, int warningLevel, int flags, java.util.Date accountCreated, java.util.Date memberSince, long sessAIM, long sessAOL, java.util.Date onSince, int idleMins, CapabilityBlock[] capabilityBlocks, java.lang.Boolean away, ExtraInfoBlock[] extraInfos, ByteBlock certHash, ShortCapabilityBlock[] shortCaps, ImmutableTlvChain extraTlvs)
          Creates a new user info block with the given properties.
 
Method Summary
 java.util.Date getAccountCreated()
          Returns the date at which this user's account was created, or null if this field was not sent.
 java.lang.Boolean getAwayStatus()
          Returns whether this user is away, or null if this field was not sent.
 CapabilityBlock[] getCapabilityBlocks()
          Returns the list of "capability blocks" which this user is advertising, or null if this field was not sent.
 ByteBlock getCertInfoHash()
          Returns an MD5 hash of the user's security information block, or null if none is contained in this user info object.
 ExtraInfoBlock[] getExtraInfoBlocks()
          Returns the list of extra information objects this user is advertising, or null if this field was not sent.
 ImmutableTlvChain getExtraTlvs()
          Returns a TLV chain consisting of all TLV's not processed into fields accessible by get* methods of this object.
 int getFlags()
          Returns this user's "user mask" flags.
 int getIdleMins()
          Returns the number of minutes for which this user has been idle, or -1 if this field was not sent.
 java.util.Date getMemberSince()
          Returns the date since which this user has been a member of AIM, or null if this field was not sent.
 java.util.Date getOnSince()
          Returns the date at which this user began the current session (that is, the current AIM connection).
 java.lang.String getScreenname()
          Returns the screenname of the user whose info this object represents.
 long getSessionLengthAIM()
          Returns the number of seconds for which this user has been online, if this user is an AIM user and not an AOL user.
 long getSessionLengthAOL()
          Returns the number of seconds for which this user has been online, if this user is an AOL user.
 ShortCapabilityBlock[] getShortCapabilityBlocks()
          Returns the list of "short capability blocks" contained in this user info object.
 int getTotalSize()
          Returns the total number of bytes that were read to generate this user info block.
 int getWarningLevel()
          Returns the warning level of this user, as a "percentage," but multiplied by ten.
static FullUserInfo readUserInfo(ByteBlock block)
          Reads a user info block from the given data block, or returns null if no valid user info block is present in the given data block.
 java.lang.String toString()
           
 void write(java.io.OutputStream out)
          Writes a representation of this object to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MASK_UNCONFIRMED

public static final int MASK_UNCONFIRMED
A user mask indicating that a user never replied to his confirmation email, and may in fact not actually own the email address to which the screenname is registered.

See Also:
Constant Field Values

MASK_ADMIN

public static final int MASK_ADMIN
A user mask indicating that a user is an administrator.

See Also:
Constant Field Values

MASK_AOL

public static final int MASK_AOL
A user mask indicating that a user is using AOL and not AIM.

See Also:
Constant Field Values

MASK_FREE

public static final int MASK_FREE
A user mask indicating that a user is using AIM for free (as opposed to using AOL, as with MASK_AOL).

See Also:
Constant Field Values

MASK_WIRELESS

public static final int MASK_WIRELESS
A user mask indicating that a user is using a mobile phone to chat. Note that not every user on a mobile phone will have this flag, as it can be disabled.

See Also:
Constant Field Values

MASK_AB

public static final int MASK_AB
A user mask indicating that a user is an ActiveBuddy robot.

See Also:
Constant Field Values

MASK_AWAY

public static final int MASK_AWAY
A user mask indicating that a user is away.

See Also:
Constant Field Values

MASK_ALL

public static final long MASK_ALL
A user mask representing all users. Mainly for use in PrivacyItem.

See Also:
Constant Field Values
Constructor Detail

FullUserInfo

public FullUserInfo(java.lang.String sn,
                    int warningLevel,
                    int flags,
                    java.util.Date accountCreated,
                    java.util.Date memberSince,
                    long sessAIM,
                    long sessAOL,
                    java.util.Date onSince,
                    int idleMins,
                    CapabilityBlock[] capabilityBlocks,
                    java.lang.Boolean away,
                    ExtraInfoBlock[] extraInfos,
                    ByteBlock certHash,
                    ShortCapabilityBlock[] shortCaps)
Creates a new user info block with the given properties. Note that any of these values except for sn can be null or -1 (depending on argument type) to indicate that the given field should not be sent in this user info block.

Parameters:
sn - the user's screenname
warningLevel - the user's warning level
flags - the user's "user flags," like MASK_FREE
accountCreated - the date at which this user's account was created
memberSince - the date since which this user has been a member
sessAIM - the amount of time, in seconds this user has been online, if this user is not an AOL user
sessAOL - the amount of time, in seconds, this user has been online, if this user is on AOL
onSince - the date at which this user signed on
idleMins - the number of minutes this user has been idle
capabilityBlocks - a list of capability blocks that this user is advertising
away - whether this user is away
extraInfos - a list of extra information blocks that this user is advertising
certHash - an MD5 hash of the user's certificate information block
shortCaps - a list of "short capability blocks"

FullUserInfo

public FullUserInfo(java.lang.String sn,
                    int warningLevel,
                    int flags,
                    java.util.Date accountCreated,
                    java.util.Date memberSince,
                    long sessAIM,
                    long sessAOL,
                    java.util.Date onSince,
                    int idleMins,
                    CapabilityBlock[] capabilityBlocks,
                    java.lang.Boolean away,
                    ExtraInfoBlock[] extraInfos,
                    ByteBlock certHash,
                    ShortCapabilityBlock[] shortCaps,
                    ImmutableTlvChain extraTlvs)
Creates a new user info block with the given properties. Note that any of these values except for sn can be null or -1 (depending on argument type) to indicate that the given field should not be sent in this user info block. This constructor allows you to specify extra user info TLV's to be sent, in the case of a feature added to the protcool after the release of this library.

Parameters:
sn - the user's screenname
warningLevel - the user's warning level
flags - the user's "user flags," like MASK_FREE
accountCreated - the date at which this user's account was created
memberSince - the date since which this user has been a member
sessAIM - the amount of time, in seconds this user has been online, if this user is not an AOL user
sessAOL - the amount of time, in seconds, this user has been online, if this user is on AOL
onSince - the date at which this user signed on
idleMins - the number of minutes this user has been idle
capabilityBlocks - a list of capability blocks that this user is advertising
away - whether this user is away
extraInfos - a list of extra information blocks that this user is advertising
certHash - an MD5 hash of the user's certificate information block
shortCaps - a list of "short capability blocks"
extraTlvs - a set of extra TLV's to be appended to this user info block
Method Detail

readUserInfo

public static FullUserInfo readUserInfo(ByteBlock block)
Reads a user info block from the given data block, or returns null if no valid user info block is present in the given data block.

Parameters:
block - the block from which to read user info
Returns:
a user info object read from the given data block

getScreenname

public final java.lang.String getScreenname()
Returns the screenname of the user whose info this object represents.

Returns:
this user info object's associated screenname

getWarningLevel

public final int getWarningLevel()
Returns the warning level of this user, as a "percentage," but multiplied by ten. This value normally ranges inclusively from 0 to 999 (which represents the percentage range 0% to 99.9%), but will be -1 if no warning level was sent.

Returns:
the warning level of this user

getFlags

public final int getFlags()
Returns this user's "user mask" flags. This is normally a bitwise combination of MASK_UNCONFIRMED, MASK_FREE, MASK_AWAY, MASK_AOL, MASK_WIRELESS, MASK_ADMIN, and MASK_AB. To test for a given flag, use something resembling the following code:
if ((userInfo.getFlags() & FullUserInfo.MASK_WIRELESS) != 0) {
    System.out.println("User " + userInfo.getScreenname() + " is using a "
            + "wireless device!");
}
 
Note that this will return -1 if this field was not sent.

Returns:
this user's "user mask"

getAccountCreated

public final java.util.Date getAccountCreated()
Returns the date at which this user's account was created, or null if this field was not sent. This field does not appear to be sent anymore by normal AIM servers.

Returns:
the date at which this user's account was created

getMemberSince

public final java.util.Date getMemberSince()
Returns the date since which this user has been a member of AIM, or null if this field was not sent. This field does not appear to be sent anymore by normal AIM servers.

Returns:
the date since which this user has been a member of AIM

getSessionLengthAIM

public final long getSessionLengthAIM()
Returns the number of seconds for which this user has been online, if this user is an AIM user and not an AOL user. This will be null if this field was not sent.

Returns:
this user's "session length," if this user is on AIM and not AOL

getSessionLengthAOL

public final long getSessionLengthAOL()
Returns the number of seconds for which this user has been online, if this user is an AOL user. This will be null if this field was not sent.

Returns:
this user's "session length," if this user is on AOL

getOnSince

public final java.util.Date getOnSince()
Returns the date at which this user began the current session (that is, the current AIM connection). This will be null if this field was not sent.

Returns:
the date at which this user logged in

getIdleMins

public final int getIdleMins()
Returns the number of minutes for which this user has been idle, or -1 if this field was not sent.

Returns:
the number of minutes this user has spent idle

getCapabilityBlocks

public final CapabilityBlock[] getCapabilityBlocks()
Returns the list of "capability blocks" which this user is advertising, or null if this field was not sent. Note that this will return an array of size zero instead of null if this field was sent but contained no capability blocks.

Returns:
this user's advertised "capability blocks"

getAwayStatus

public final java.lang.Boolean getAwayStatus()
Returns whether this user is away, or null if this field was not sent.

Returns:
whether this user is currently away

getExtraInfoBlocks

public final ExtraInfoBlock[] getExtraInfoBlocks()
Returns the list of extra information objects this user is advertising, or null if this field was not sent. Note that this will return a zero-length array if the field was sent but empty.

Returns:
a list of advertised extra information blocks

getCertInfoHash

public final ByteBlock getCertInfoHash()
Returns an MD5 hash of the user's security information block, or null if none is contained in this user info object.

Returns:
an MD5 hash of the user's certificate information block

getShortCapabilityBlocks

public ShortCapabilityBlock[] getShortCapabilityBlocks()
Returns the list of "short capability blocks" contained in this user info object.

Returns:
the list of short capability blocks for the associated user

getExtraTlvs

public final ImmutableTlvChain getExtraTlvs()
Returns a TLV chain consisting of all TLV's not processed into fields accessible by get* methods of this object. This is useful to aid in processing additional fields AOL may add to the standard user info block after the release of this library.

Returns:
a list of TLV's present in the received user info block that were not processed into fields of this object

getTotalSize

public final int getTotalSize()
Returns the total number of bytes that were read to generate this user info block. Will be -1 if this object was not read from a block of data but instead instantiated manually.

Returns:
the total size, in bytes, of this object, as read from a block of binary data

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Description copied from interface: LiveWritable
Writes a representation of this object to the given stream.

Specified by:
write in interface LiveWritable
Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()