net.kano.joscar.snaccmd.ssi
Class SsiDataCheck

java.lang.Object
  extended bySnacCommand
      extended bySsiCommand
          extended bySsiDataCheck

public class SsiDataCheck
extends SsiCommand

A SNAC command sent to request the user's server-stored data if and only if it was modified past a certain date. Normally responded-to with either a SsiDataCmd or a SsiUnchangedCmd. The purpose of this command in addition to SsiDataRequest is to avoid downloading the same buddy list at the start of every connection, which both wastes bandwidth and increases the net time it takes to sign on, especially for those with large buddy lists. This command should only be used if the client saves the SSI data to disk or some other non-temporary medium; otherwise one should use SsiDataRequest.

See Also:
SsiDataCmd, SsiUnchangedCmd
Source of this SNAC:
AIM client
SNAC command type:
Family 0x13, command 0x05

Field Summary
 
Fields inherited from class SsiCommand
CMD_ACTIVATE, CMD_CREATE_ITEMS, CMD_DATA_CHECK, CMD_DATA_REQ, CMD_DELETE_ITEMS, CMD_MOD_ACK, CMD_MODIFY_ITEMS, CMD_POST_MOD, CMD_PRE_MOD, CMD_RIGHTS, CMD_RIGHTS_REQ, CMD_SSI_DATA, CMD_UNCHANGED, FAMILY_INFO, FAMILY_SSI
 
Fields inherited from class SnacCommand
SNACFLAG_DEFAULT
 
Constructor Summary
  SsiDataCheck(long lastmod, int itemCount)
          Creates a new outgoing SSI data check command with the given last modification date of the client's version of the SSI data and the given number of SSI items currently present in the client's SSI data.
protected SsiDataCheck(SnacPacket packet)
          Generates a new SSI data check command from the given incoming SNAC packet.
 
Method Summary
 int getItemCount()
          Returns the number of SSI "items" contained in the client's version of the SSI data.
 long getLastModDate()
          Returns the last-modification date of the client's version of the SSI data, in seconds since the unix epoch.
 java.lang.String toString()
           
 void writeData(java.io.OutputStream out)
          Writes this command's SNAC data block to the given stream.
 
Methods inherited from class SnacCommand
getCommand, getFamily, getFlag1, getFlag2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SsiDataCheck

protected SsiDataCheck(SnacPacket packet)
Generates a new SSI data check command from the given incoming SNAC packet.

Parameters:
packet - an incoming SSI data check packet

SsiDataCheck

public SsiDataCheck(long lastmod,
                    int itemCount)
Creates a new outgoing SSI data check command with the given last modification date of the client's version of the SSI data and the given number of SSI items currently present in the client's SSI data.

For those unfamiliar with unixtime, a fine way to use this command, if the SSI data were stored locally (which is totally optional in itself) in a file called "ssi.dat" (which is a filename I personally wouldn't use outside of this example :):
// create a File object for the SSI data file
File ssiDataFile = new File("ssi.dat");

// lastModifed returns milliseconds since unix epoch, so we can just divide by
// 1000 to get seconds
long secondsSinceUnixEpoch = ssiDataFile.lastModified() / 1000;

// count the items. I assume you'll have your own system for determining this
// sort of thing.
int itemCount = someCommandYouMadeToCountTheItems(ssiDataFile);

// now send the command with some send command you made
send(new SsiDataCheck(secondsSinceUnixEpoch, itemCount));

Parameters:
lastmod - the last modification date of the client's version of the SSI data, in seconds since the unix epoch
itemCount - the number of SSI "items" in the local version of the SSI data
Method Detail

getLastModDate

public final long getLastModDate()
Returns the last-modification date of the client's version of the SSI data, in seconds since the unix epoch.

Returns:
the last-modification date of the client's version of the SSI data

getItemCount

public final int getItemCount()
Returns the number of SSI "items" contained in the client's version of the SSI data.

Returns:
the number of SSI "items" contained in the client's copy of the SSI data

writeData

public void writeData(java.io.OutputStream out)
               throws java.io.IOException
Description copied from class: SnacCommand
Writes this command's SNAC data block to the given stream. The SNAC data block is the data after the first ten bytes of a SNAC packet.

Specified by:
writeData in class SnacCommand
Parameters:
out - the stream to which to write the SNAC data
Throws:
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()