SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class AbstractFileTransfer

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractFileTransfer
All Implemented Interfaces:
FileTransfer
Direct Known Subclasses:
FileTransferImpl, FileTransferImpl, FileTransferImpl, FileTransferSSHImpl, IncomingFileTransferJabberImpl, MockFileTransferImpl, OutgoingFileTransferJabberImpl

public abstract class AbstractFileTransfer
extends Object
implements FileTransfer

An abstract implementation of the FileTransfer interface providing implementation of status and progress events related methods and leaving all protocol specific methods abstract. A protocol specific implementation could extend this class and implement only cancel() and getTransferredBytes().

Author:
Yana Stamcheva

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.FileTransfer
IN, OUT
 
Constructor Summary
AbstractFileTransfer()
           
 
Method Summary
 void addProgressListener(FileTransferProgressListener listener)
          Adds the given FileTransferProgressListener to listen for status changes on this file transfer.
 void addStatusListener(FileTransferStatusListener listener)
          Adds the given FileTransferStatusListener to listen for status changes on this file transfer.
abstract  void cancel()
          Cancels this file transfer.
 void fireProgressChangeEvent(long timestamp, long progress)
          Notifies all status listeners that a new FileTransferProgressEvent occured.
 void fireStatusChangeEvent(int newStatus)
          Notifies all status listeners that a new FileTransferStatusChangeEvent occured.
 void fireStatusChangeEvent(int newStatus, String reason)
          Notifies all status listeners that a new FileTransferStatusChangeEvent occured.
 int getStatus()
          Returns the current status of the transfer.
abstract  long getTransferedBytes()
          Returns the number of bytes already transfered through this file transfer.
 void removeProgressListener(FileTransferProgressListener listener)
          Removes the given FileTransferProgressListener.
 void removeStatusListener(FileTransferStatusListener listener)
          Removes the given FileTransferStatusListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.service.protocol.FileTransfer
getContact, getDirection, getID, getLocalFile
 

Constructor Detail

AbstractFileTransfer

public AbstractFileTransfer()
Method Detail

cancel

public abstract void cancel()
Cancels this file transfer. When this method is called transfer should be interrupted.

Specified by:
cancel in interface FileTransfer

getTransferedBytes

public abstract long getTransferedBytes()
Returns the number of bytes already transfered through this file transfer.

Specified by:
getTransferedBytes in interface FileTransfer
Returns:
the number of bytes already transfered through this file transfer

addProgressListener

public void addProgressListener(FileTransferProgressListener listener)
Adds the given FileTransferProgressListener to listen for status changes on this file transfer.

Specified by:
addProgressListener in interface FileTransfer
Parameters:
listener - the listener to add

addStatusListener

public void addStatusListener(FileTransferStatusListener listener)
Adds the given FileTransferStatusListener to listen for status changes on this file transfer.

Specified by:
addStatusListener in interface FileTransfer
Parameters:
listener - the listener to add

removeProgressListener

public void removeProgressListener(FileTransferProgressListener listener)
Removes the given FileTransferProgressListener.

Specified by:
removeProgressListener in interface FileTransfer
Parameters:
listener - the listener to remove

removeStatusListener

public void removeStatusListener(FileTransferStatusListener listener)
Removes the given FileTransferStatusListener.

Specified by:
removeStatusListener in interface FileTransfer
Parameters:
listener - the listener to remove

getStatus

public int getStatus()
Returns the current status of the transfer. This information could be used from the user interface to show a progress bar indicating the file transfer status.

Specified by:
getStatus in interface FileTransfer
Returns:
the current status of the transfer

fireStatusChangeEvent

public void fireStatusChangeEvent(int newStatus)
Notifies all status listeners that a new FileTransferStatusChangeEvent occured.

Parameters:
newStatus - the new status

fireStatusChangeEvent

public void fireStatusChangeEvent(int newStatus,
                                  String reason)
Notifies all status listeners that a new FileTransferStatusChangeEvent occured.

Parameters:
newStatus - the new status
reason - the reason of the status change

fireProgressChangeEvent

public void fireProgressChangeEvent(long timestamp,
                                    long progress)
Notifies all status listeners that a new FileTransferProgressEvent occured.

Parameters:
timestamp - the date on which the event occured
progress - the bytes representing the progress of the transfer

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.