|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFileTransferHeader
A data structure used to transfer information over a file transfer connection.
Field Summary | |
static java.lang.String |
CLIENTID_DEFAULT
A client ID string used by WinAIM 5.2 beta. |
static java.lang.String |
CLIENTID_OLD
A client ID string used by WinAIM 5.1 and earlier. |
static int |
COMPRESSION_NONE
An encryption code indicating that no compression is being used. |
static ByteBlock |
DUMMY_DEFAULT
The "dummy" block sent by WinAIM. |
static int |
ENCRYPTION_NONE
An encryption code indicating that no encryption is being used. |
static int |
FLAG_DEFAULT
A flag that is always sent by WinAIM. |
static int |
FLAG_DONE
A flag sent in a HEADERTYPE_RECEIVED header. |
static int |
FLAG_FILELIST
A flag sent in a HEADERTYPE_FILELIST_SENDLIST header. |
static java.lang.String |
FTVERSION_DEFAULT
The file transfer protocol version used by WinAIM. |
static int |
HEADERTYPE_ACK
A header typing indicating that a header is an "acknowledgement" header. |
static int |
HEADERTYPE_FILELIST_ACK
A header typed used in Get File to acknowledge that a file list is about to be sent. |
static int |
HEADERTYPE_FILELIST_RECEIVED
A header type used in Get File to indicate that a file list was received successfully. |
static int |
HEADERTYPE_FILELIST_REQDIR
A header type used in Get File to request a directory listing for a specific directory. |
static int |
HEADERTYPE_FILELIST_REQFILE
A header type used in Get File to request a file. |
static int |
HEADERTYPE_FILELIST_SENDLIST
A header type used in Get File indicating that a file list is about to be sent. |
static int |
HEADERTYPE_RECEIVED
A header type indicating that a header is a "transfer finished" header. |
static int |
HEADERTYPE_RESUME
A header type indicating that the header is requesting that a file be "resumed" from a point in the file up to which the receiver has already received data. |
static int |
HEADERTYPE_RESUME_ACK
A header type used to indicate that the sender can begin sending the resumed file. |
static int |
HEADERTYPE_RESUME_SENDHEADER
A header type indicating that the sender is about to send ("resume") the file being resumed. |
static int |
HEADERTYPE_SENDHEADER
A header type indicating that a header is a "sending file" header. |
static int |
LISTNAMEOFFSET_DEFAULT
The value always sent by WinAIM for the listNameOffset
field. |
static int |
LISTSIZEOFFSET_DEFAULT
The value always sent by WinAIM for the listSizeOffset
field. |
static ByteBlock |
MACFILEINFO_DEFAULT
The Mac file information block sent by WinAIM. |
Constructor Summary | |
FileTransferHeader()
Creates a new file transfer header with all values initialized to either null or -1 , depending on type. |
|
FileTransferHeader(FileTransferHeader other)
Creates a new file transfer header with the same properties as the given header. |
Method Summary | |
long |
getBytesReceived()
Returns the number of bytes received for the file being transferred. |
long |
getChecksum()
Returns a checksum of the file being transferred. |
java.lang.String |
getClientid()
Returns the file transfer client ID string sent in this header. |
int |
getCompression()
Returns a code describing the compression being used to transfer a file. |
long |
getCreated()
Returns the creation date of the file being transferred, in seconds since the unix epoch. |
ByteBlock |
getDummyBlock()
Returns the value of the (sigh) 69-byte "dummy block" sent in this command. |
int |
getEncryption()
Returns a code describing the encryption being used to transfer a file. |
int |
getFileCount()
Returns the total number of files being transferred, or in the case of transferring a file list, the total number of files in the following file list. |
SegmentedFilename |
getFilename()
Returns an object representing the filename sent in this header. |
long |
getFileSize()
Returns the size of the file currently being sent. |
int |
getFilesLeft()
Returns the number of files (of the total number) that remain to be sent. |
int |
getFlags()
Returns the set of bit flags sent in this header. |
java.lang.String |
getFtVersion()
Returns the file transfer protocol version string contained in this header. |
int |
getHeaderSize()
Returns the size, in bytes, of this header, or -1 if this
header was not read from an incoming block of binary data. |
int |
getHeaderType()
Returns a code describing which type of header this is. |
long |
getIcbmMessageId()
Returns an ICBM message ID associated with this file transfer header. |
long |
getLastmod()
Returns the last modification date of the file being sent, in seconds since the unix epoch. |
int |
getListNameOffset()
Returns the "list name offset" sent in this header. |
int |
getListSizeOffset()
Returns the "list size offset" sent in this header. |
ByteBlock |
getMacFileInfo()
Returns the Mac file information block sent in this command. |
int |
getPartCount()
Returns the total number of file "parts" being sent. |
int |
getPartsLeft()
Returns the number of "parts" (of the total number that remain to be sent. |
long |
getReceivedChecksum()
Returns a checksum of the data received for the current file. |
long |
getResForkChecksum()
Returns a checksum of the MacOS resource fork for the file being transferred. |
long |
getResForkReceivedChecksum()
Returns a checksum of the received MacOS resource fork data. |
long |
getResForkSize()
Returns the size of the MacOS resource fork of the file being transferred. |
long |
getTotalFileSize()
Returns the total file size of all files being sent. |
static FileTransferHeader |
readHeader(java.io.InputStream in)
Reads a file transfer header from the given stream. |
void |
setBytesReceived(long bytesReceived)
Sets the number of bytes received in the current transfer. |
void |
setChecksum(long checksum)
Sets the checksum of the file currently being transferred. |
void |
setClientid(java.lang.String clientid)
Sets the file transfer client ID string for this header. |
void |
setCompression(int compression)
Sets this header's encryption mode to the given value. |
void |
setCreated(long created)
Sets the creation date of the file being sent, or 0 for
none. |
void |
setDefaults()
Sets all fields in this header (except filename and
headerType ) to a set of default values. |
void |
setDummyBlock(ByteBlock dummyBlock)
Sets this header's "dummy block" value. |
void |
setEncryption(int encryption)
Sets this header's encryption mode to the given value. |
void |
setFileCount(int fileCount)
Sets the total file count for this header. |
void |
setFilename(SegmentedFilename filename)
Sets this header's filename value. |
void |
setFileSize(long fileSize)
Sets this header's value for the size of the file currently being transferred. |
void |
setFilesLeft(int filesLeft)
Sets this header's "number of files remaining to be sent" value. |
void |
setFlags(int flags)
Sets this header's bit flags. |
void |
setFtVersion(java.lang.String ftVersion)
Sets the file transfer protocol version string for this header. |
void |
setHeaderType(int headerType)
Sets this header's header type. |
void |
setIcbmMessageId(long icbmMessageId)
Sets this header's ICBM message ID. |
void |
setLastmod(long lastmod)
Sets the last modification date of the file being transferred, in seconds since the unix epoch, or 0 for none. |
void |
setListNameOffset(int listNameOffset)
Sets the value of the "list name offset" in this header. |
void |
setListSizeOffset(int listSizeOffset)
Sets the value of the "list size offset" in this header. |
void |
setMacFileInfo(ByteBlock macFileInfo)
Sets this header's Mac file information block. |
void |
setPartCount(int partCount)
Sets the total file part count for this header. |
void |
setPartsLeft(int partsLeft)
Sets this header's "number of parts remaining to be sent" value. |
void |
setReceivedChecksum(long receivedChecksum)
Sets the value of the checksum of the data received. |
void |
setResForkChecksum(long resForkChecksum)
Sets the value of the checksum of the MacOS "resource fork" being transferred. |
void |
setResForkReceivedChecksum(long resForkReceivedChecksum)
Sets the value of the checksum of the received portion of the MacOS "resource fork" being sent. |
void |
setResForkSize(long resForkSize)
Sets the size of the MacOS "resource fork" being sent. |
void |
setTotalFileSize(long totalFileSize)
Sets the total cumulative size of all files being transferred. |
java.lang.String |
toString()
|
void |
write(java.io.OutputStream out)
Writes this header to the given stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String FTVERSION_DEFAULT
public static final int HEADERTYPE_SENDHEADER
public static final int HEADERTYPE_ACK
public static final int HEADERTYPE_RECEIVED
public static final int HEADERTYPE_RESUME
public static final int HEADERTYPE_RESUME_SENDHEADER
public static final int HEADERTYPE_RESUME_ACK
public static final int HEADERTYPE_FILELIST_SENDLIST
public static final int HEADERTYPE_FILELIST_ACK
public static final int HEADERTYPE_FILELIST_RECEIVED
public static final int HEADERTYPE_FILELIST_REQFILE
public static final int HEADERTYPE_FILELIST_REQDIR
public static final int ENCRYPTION_NONE
public static final int COMPRESSION_NONE
public static final java.lang.String CLIENTID_OLD
public static final java.lang.String CLIENTID_DEFAULT
public static final int LISTNAMEOFFSET_DEFAULT
listNameOffset
field.
setListNameOffset(int)
,
Constant Field Valuespublic static final int LISTSIZEOFFSET_DEFAULT
listSizeOffset
field.
setListSizeOffset(int)
,
Constant Field Valuespublic static final int FLAG_DEFAULT
public static final int FLAG_DONE
HEADERTYPE_RECEIVED
header.
public static final int FLAG_FILELIST
HEADERTYPE_FILELIST_SENDLIST
header.
public static final ByteBlock DUMMY_DEFAULT
public static final ByteBlock MACFILEINFO_DEFAULT
Constructor Detail |
public FileTransferHeader()
null
or -1
, depending on type.
setDefaults()
public FileTransferHeader(FileTransferHeader other)
other
- a header to copyMethod Detail |
public static FileTransferHeader readHeader(java.io.InputStream in) throws java.io.IOException
null
if no valid header can be read or
if the end of the stream is reached before a valid header can be read.
Also note that this method will block until a complete header is read
or until one of the situations mentioned above occurs.
in
- the stream from which to read the header
null
if none could be read
java.io.IOException
- if an I/O error occurspublic java.lang.String getFtVersion()
FTVERSION_DEFAULT
.
public int getHeaderType()
HEADERTYPE_*
constants defined in this class.
public long getIcbmMessageId()
FileSendAcceptRvCmd
sent to accept the
transfer. Otherwise, this value will normally be 0
.
public int getEncryption()
ENCRYPTION_NONE
(to indicate that no
encryption is taking place).
public int getCompression()
COMPRESSION_NONE
(to indicate that the
transfer is not compressed).
public int getFileCount()
public int getFilesLeft()
public int getPartCount()
1
for most files and 2
for files on MacOS
that have resource forks.
public int getPartsLeft()
public long getTotalFileSize()
public long getFileSize()
public long getLastmod()
public long getChecksum()
FileTransferChecksum
public long getResForkReceivedChecksum()
0
.
FileTransferChecksum
public long getResForkSize()
0
.
public long getCreated()
0
for this
value.
public long getResForkChecksum()
public long getBytesReceived()
public long getReceivedChecksum()
public java.lang.String getClientid()
CLIENTID_DEFAULT
or CLIENTID_OLD
.
public int getFlags()
FLAG_*
constants defined in this class.
public int getListNameOffset()
0
or LISTNAMEOFFSET_DEFAULT
.
public int getListSizeOffset()
0
or LISTSIZEOFFSET_DEFAULT
.
public ByteBlock getDummyBlock()
0x00
).
public ByteBlock getMacFileInfo()
MACFILEINFO_DEFAULT
(a block of sixteen null bytes).
When coming from a Macintosh user, however, this block is a copy of the
file's FInfo
block. For more information on reading and
writing Macintosh file attributes in Java, see JConfig, an "extension of the core Java API's" for various
platforms.
public SegmentedFilename getFilename()
public int getHeaderSize()
-1
if this
header was not read from an incoming block of binary data.
-1
if this
header was not reapublic void setFtVersion(java.lang.String ftVersion)
FTVERSION_DEFAULT
.
ftVersion
- a new file transfer protocol version stringpublic void setHeaderType(int headerType)
HEADERTYPE_*
constants defined in this class.
headerType
- a new header type codepublic void setIcbmMessageId(long icbmMessageId)
getIcbmMessageId()
for
details on what this value means.
icbmMessageId
- a new ICBM message IDpublic void setEncryption(int encryption)
ENCRYPTION_NONE
.
encryption
- a new encryption method codepublic void setCompression(int compression)
COMPRESSION_NONE
.
compression
- a new compression method codepublic void setFileCount(int fileCount)
getFileCount()
for details on what this value means.
fileCount
- a new total file count value for this headerpublic void setFilesLeft(int filesLeft)
filesLeft
- the number of files (of the total) remaining to be sentpublic void setPartCount(int partCount)
getPartCount()
for details on what this value means.
partCount
- a new total "file part" count for this headerpublic void setPartsLeft(int partsLeft)
partsLeft
- the number of parts (of the total) remaining to be sentpublic void setTotalFileSize(long totalFileSize)
totalFileSize
- a new total file size value for this headerpublic void setFileSize(long fileSize)
fileSize
- the size of the file currently being transferredpublic void setLastmod(long lastmod)
0
for none.
lastmod
- the last modification date of the file being transferredpublic void setChecksum(long checksum)
checksum
- the checksum of the file currently being transferredpublic void setResForkReceivedChecksum(long resForkReceivedChecksum)
resForkReceivedChecksum
- the checksum of the received portion of
the MacOS resource fork being sentpublic void setResForkSize(long resForkSize)
resForkSize
- the size, in bytes, of the MacOS resource fork being
sentpublic void setCreated(long created)
0
for
none. Note that WinAIM does not send the creation date of files being
transferred.
created
- the creation date of the file being sent, in seconds since
the unix epochpublic void setResForkChecksum(long resForkChecksum)
resForkChecksum
- the value of the checksum of the MacOS resource
fork being transferredpublic void setBytesReceived(long bytesReceived)
bytesReceived
- the number of bytes received in the current transferpublic void setReceivedChecksum(long receivedChecksum)
receivedChecksum
- the checksum of the data received in the current
transferpublic void setClientid(java.lang.String clientid)
CLIENTID_DEFAULT
and CLIENTID_OLD
.) Note
that the given string will be truncated to 32 characters as per the
protocol spec.
clientid
- the file transfer client ID string for this headerpublic void setFlags(int flags)
FLAG_*
constants defined in this class.
flags
- a set of bit flags for this headerpublic void setListNameOffset(int listNameOffset)
LISTNAMEOFFSET_DEFAULT
for this value.
listNameOffset
- a new "list name offset" valuepublic void setListSizeOffset(int listSizeOffset)
LISTSIZEOFFSET_DEFAULT
for this value.
listSizeOffset
- a new "list size offset" valuepublic void setDummyBlock(ByteBlock dummyBlock)
DUMMY_DEFAULT
(69 null bytes).
dummyBlock
- a new "dummy block" valuepublic void setMacFileInfo(ByteBlock macFileInfo)
getMacFileInfo()
for details on what this value means.
macFileInfo
- a new Mac file information block valuepublic void setFilename(SegmentedFilename filename)
filename
- the name of the file being transferredpublic final void setDefaults()
filename
and
headerType
) to a set of default values. Calling this method
is equivalent to executing the following code:
header.setClientid(FileTransferHeader.CLIENTID_DEFAULT); header.setCompression(FileTransferHeader.COMPRESSION_NONE); header.setEncryption(FileTransferHeader.ENCRYPTION_NONE); header.setIcbmMessageId(0); header.setDummyBlock(FileTransferHeader.DUMMY_DEFAULT); header.setFlags(FileTransferHeader.FLAG_DEFAULT); header.setFtVersion(FileTransferHeader.FTVERSION_DEFAULT); header.setResForkChecksum(0); header.setResForkReceivedChecksum(0); header.setResForkSize(0); header.setCreated(0); header.setLastmod(0); header.setChecksum(0); header.setListNameOffset(0); header.setListSizeOffset(0); header.setMacFileInfo(FileTransferHeader.MACFILEINFO_DEFAULT); header.setBytesReceived(0); header.setFileCount(0); header.setFileSize(0); header.setFilesLeft(0); header.setPartCount(0); header.setPartsLeft(0); header.setReceivedChecksum(0); header.setTotalFileSize(0);
public void write(java.io.OutputStream out) throws java.io.IOException, java.lang.IllegalArgumentException
IllegalArgumentException
will be thrown. A valid field
has either a nonnegative (that is, 0
or greater) or
non-null
value. Only the filename
field may be
null
; such a value indicates that no filename should be
sent.
write
in interface LiveWritable
out
- the stream to which to write
java.io.IOException
- if an I/O error occurs
java.lang.IllegalArgumentException
- if any field in this header has an
invalid valuepublic java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |