com.zion.jbuddy.filetransfer
Interface IFileSession


public interface IFileSession

Represents a file transfer session between two clients.

Since:
2.3, 6.3 LCS (also OCS)

Method Summary
 void accept()
          Accepts an incoming file and initiates the transfer.
 void addFileSessionListener(IFileSessionListener listener)
          Registers a file session listener to receive events from this file session.
 void cancel(String reason)
          Cancels an outgoing file invitation.
 void decline(String reason)
          Declines an incoming file.
 void disconnect()
          Disconnects this file session.
 IClient getClient()
          Returns the client this session is associated with.
 File getCurrentFile()
          Returns the current file being transfered.
 long getCurrentFileProgress()
          Returns the number of bytes transfered so far in the current file.
 long getCurrentFileSize()
          Returns the size of the current file being transfered.
 String getDescription()
          Returns a description of the file being transfered.
 String getFileName()
          Returns the name of the file being transfered.
 long getFileSize()
          Returns the total size of all files being transfered.
 int getNumberOfFiles()
          Returns the number of files being transfered.
 String getRecipient()
          Returns the name of the user receiving this file.
 File getSaveToDirectory()
          Returns the directory where incoming files will be saved.
 String getSender()
          Returns the name of the user sending this file.
 void invite()
          Invites the recipient to this file session.
 boolean isConnected()
          Returns true if this session is connected.
 boolean isIncoming()
          Returns true if this session is incoming, ie: the client is receiving the file.
 boolean isOutgoing()
          Returns true if this session is outgoing, ie: the client is sending the file.
 boolean isProgressThreadEnabled()
          Returns true if the progress thread is enabled.
 void removeFileSessionListener(IFileSessionListener listener)
          Stops a file session listener from receiving events from this file session.
 void setDescription(String s)
          Sets a description of the file being transfered.
 void setPortRange(int min, int max)
          Sets a range of ports which can be used to serve this session.
 void setProgressThreadEnabled(boolean b)
          Sets whether the progress thread is enabled.
 void setSaveToDirectory(File file)
          Sets the directory where incoming files will be saved.
 

Method Detail

accept

void accept()
            throws IOException
Accepts an incoming file and initiates the transfer.

Throws:
IOException - if isIncoming() == false, or there was a problem communicating to the server

addFileSessionListener

void addFileSessionListener(IFileSessionListener listener)
Registers a file session listener to receive events from this file session.


cancel

void cancel(String reason)
            throws IOException
Cancels an outgoing file invitation.

Throws:
IOException - if isOutgoing() == false, or there was a problem communicating to the server

decline

void decline(String reason)
             throws IOException
Declines an incoming file.

Throws:
IOException - if isIncoming() == false, or there was a problem communicating to the server

disconnect

void disconnect()
Disconnects this file session. This is not the same as cancel() or decline(), in that it stops the transfer once it has already begun.


getClient

IClient getClient()
Returns the client this session is associated with.


getCurrentFile

File getCurrentFile()
Returns the current file being transfered.


getCurrentFileProgress

long getCurrentFileProgress()
Returns the number of bytes transfered so far in the current file.


getCurrentFileSize

long getCurrentFileSize()
Returns the size of the current file being transfered.


getDescription

String getDescription()
Returns a description of the file being transfered.


getFileName

String getFileName()
Returns the name of the file being transfered.


getFileSize

long getFileSize()
Returns the total size of all files being transfered.


getNumberOfFiles

int getNumberOfFiles()
Returns the number of files being transfered.


getRecipient

String getRecipient()
Returns the name of the user receiving this file. If isIncoming() == true, this will be the same as the associated client.


getSaveToDirectory

File getSaveToDirectory()
Returns the directory where incoming files will be saved.

Returns:
the directory, or null if isIncoming() == false

getSender

String getSender()
Returns the name of the user sending this file. If isOutgoing() == true, this will be the same as the associated client.


invite

void invite()
            throws IOException
Invites the recipient to this file session.

Throws:
IOException - if isOutgoing() == false, or there was a problem communicating to the server

isConnected

boolean isConnected()
Returns true if this session is connected.


isIncoming

boolean isIncoming()
Returns true if this session is incoming, ie: the client is receiving the file.


isOutgoing

boolean isOutgoing()
Returns true if this session is outgoing, ie: the client is sending the file.


isProgressThreadEnabled

boolean isProgressThreadEnabled()
Returns true if the progress thread is enabled.


removeFileSessionListener

void removeFileSessionListener(IFileSessionListener listener)
Stops a file session listener from receiving events from this file session.


setDescription

void setDescription(String s)
Sets a description of the file being transfered.


setPortRange

void setPortRange(int min,
                  int max)
Sets a range of ports which can be used to serve this session. A port number will be chosen (not necessarily in order) until a listening socket can be created.


setProgressThreadEnabled

void setProgressThreadEnabled(boolean b)
Sets whether the progress thread is enabled. When enabled, the progress thread fires IFileSessionListener.updateProgress events at selected intervals.


setSaveToDirectory

void setSaveToDirectory(File file)
                        throws IOException
Sets the directory where incoming files will be saved.

Throws:
IOException - if isIncoming() == false, or file is not a directory


JBuddy is a trademark of Zion Software, LLC in the US and other countries.
Copyright 2000-2012 Zion Software, LLC All Rights Reserved.