org.xnap.plugin.opennap.net
Class OpenNapUpload

java.lang.Object
  extended by org.xnap.transfer.AbstractTransfer
      extended by org.xnap.plugin.opennap.net.OpenNapUpload
All Implemented Interfaces:
ExceptionListener, MessageListener, SocketListener, Queueable, Transfer, Upload

public class OpenNapUpload
extends AbstractTransfer
implements ExceptionListener, MessageListener, Queueable, Upload, SocketListener


Field Summary
static int ACK_TIMEOUT
          If the upload is not received within this timeout after the ack message has been sent, the upload will be cancelled.
protected static org.apache.log4j.Logger logger
           
static int MAX_REREQUST_INTERVAL
          If the upload request is not renewed within this interval, the upload will be cancelled.
 
Fields inherited from class org.xnap.transfer.AbstractTransfer
MIN_RECALC_INTERVAL, RECALC_INTERVAL, SOCKET_TIMEOUT
 
Fields inherited from interface org.xnap.transfer.Transfer
TRANSFER_TIMEOUT
 
Constructor Summary
OpenNapUpload(OpenNapServer server, OpenNapUser user, java.io.File file, java.lang.String requestFilename)
           
 
Method Summary
 void exceptionThrown(java.lang.Exception e)
           
 javax.swing.Action[] getActions()
          Returns the actions that can performed by the transfer.
 long getBytesTransferred()
          Returns how many bytes have been transferred since the transfer was started.
 long getEnqueueTime()
          Returns the time when the queueable was enqueued in milli seconds.
 java.io.File getFile()
          Returns the file the transfer is using.
 long getFilesize()
          Returns the final filesize.
 java.lang.String getHash()
           
 javax.swing.Icon getIcon()
          Returns null.
 Peer getPeer()
          Returns the peer.
 Plugin getPlugin()
          Returns the plugin.
 int getPriority()
          Basically a boost factor.
 int getQueuePosition()
          Returns the position in the UploadManager queue.
 Segment[] getSegments()
          Returns the segments for segmented downloads.
 java.lang.String getStatus()
          Returns the current status that should be presented to the user.
 long getTotalBytesTransferred()
          Returns how many bytes have been transferred.
 boolean isDone()
          Returns true if the transfer is finished.
 boolean isRunning()
          Returns true if the transfer is running.
 void messageReceived(ServerMessage msg)
           
 void setHash(java.lang.String hash)
           
 void setQueuePosition(int position)
          Invoked by the queue to update the position.
 boolean socketReceived(IncomingSocket s)
          Invoked when an incoming connect is recognized.
 void start()
          Inovked by OpenNapTransferManager after the instanciation.
 boolean startTransfer()
          Starts the transfer.
 void stop()
           
 
Methods inherited from class org.xnap.transfer.AbstractTransfer
addStateListener, cleared, getAverageRate, getCurrentRate, getDescription, getElapsedTime, getFilename, getRemainingTime, removeStateListener, stateChanged, toString, transferStarted, transferStopped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xnap.transfer.Queueable
getFilename
 
Methods inherited from interface org.xnap.transfer.Transfer
addStateListener, cleared, getAverageRate, getCurrentRate, getDescription, getFilename, getRemainingTime, removeStateListener
 

Field Detail

ACK_TIMEOUT

public static final int ACK_TIMEOUT
If the upload is not received within this timeout after the ack message has been sent, the upload will be cancelled.

See Also:
Constant Field Values

MAX_REREQUST_INTERVAL

public static final int MAX_REREQUST_INTERVAL
If the upload request is not renewed within this interval, the upload will be cancelled.

See Also:
Constant Field Values

logger

protected static org.apache.log4j.Logger logger
Constructor Detail

OpenNapUpload

public OpenNapUpload(OpenNapServer server,
                     OpenNapUser user,
                     java.io.File file,
                     java.lang.String requestFilename)
Method Detail

exceptionThrown

public void exceptionThrown(java.lang.Exception e)
Specified by:
exceptionThrown in interface ExceptionListener

getFile

public java.io.File getFile()
Description copied from interface: Transfer
Returns the file the transfer is using.

Specified by:
getFile in interface Transfer
Returns:
null, if file is unknown; the file, otherwise

getFilesize

public long getFilesize()
Description copied from interface: Transfer
Returns the final filesize.

Specified by:
getFilesize in interface Queueable
Specified by:
getFilesize in interface Transfer
Overrides:
getFilesize in class AbstractTransfer
See Also:
Transfer.getFilesize()

getPlugin

public Plugin getPlugin()
Description copied from interface: Transfer
Returns the plugin.

Specified by:
getPlugin in interface Transfer

getActions

public javax.swing.Action[] getActions()
Description copied from interface: Transfer
Returns the actions that can performed by the transfer.

Specified by:
getActions in interface Transfer
See Also:
xnap.transfer.Transfer#getActions()

getBytesTransferred

public long getBytesTransferred()
Description copied from class: AbstractTransfer
Returns how many bytes have been transferred since the transfer was started.

Specified by:
getBytesTransferred in class AbstractTransfer
Returns:
number of transferred bytes
See Also:
AbstractTransfer.getCurrentRate()

getEnqueueTime

public long getEnqueueTime()
Description copied from interface: Queueable
Returns the time when the queueable was enqueued in milli seconds.

Specified by:
getEnqueueTime in interface Queueable

getHash

public java.lang.String getHash()

getIcon

public javax.swing.Icon getIcon()
Description copied from class: AbstractTransfer
Returns null.

Specified by:
getIcon in interface Transfer
Overrides:
getIcon in class AbstractTransfer

getPriority

public int getPriority()
Description copied from interface: Queueable
Basically a boost factor. Higher values will yield better queue positions.

Specified by:
getPriority in interface Queueable

getQueuePosition

public int getQueuePosition()
Returns the position in the UploadManager queue.

Specified by:
getQueuePosition in interface Queueable
Specified by:
getQueuePosition in interface Transfer
Overrides:
getQueuePosition in class AbstractTransfer
Returns:
-1, if the transfer is not queued, the position otherwise.

getPeer

public Peer getPeer()
Description copied from interface: Transfer
Returns the peer.

Specified by:
getPeer in interface Queueable
Specified by:
getPeer in interface Transfer
See Also:
xnap.transfer.Transfer#getPeer()

getSegments

public Segment[] getSegments()
Description copied from interface: Transfer
Returns the segments for segmented downloads.

Specified by:
getSegments in interface Transfer
Overrides:
getSegments in class AbstractTransfer
Returns:
null, if segments are not supported (which means that there is only one segment that represents the whole file)

getStatus

public java.lang.String getStatus()
Description copied from interface: Transfer
Returns the current status that should be presented to the user.

Specified by:
getStatus in interface Transfer
See Also:
xnap.transfer.Transfer#getStatus()

getTotalBytesTransferred

public long getTotalBytesTransferred()
Description copied from interface: Transfer
Returns how many bytes have been transferred.

Specified by:
getTotalBytesTransferred in interface Transfer
Returns:
number of transferred bytes
See Also:
xnap.transfer.Transfer#getTotalBytesTransferred()

isDone

public boolean isDone()
Description copied from interface: Transfer
Returns true if the transfer is finished.

Specified by:
isDone in interface Transfer
Returns:
true, if thread has ended and the transfer can be cleared; false if, not yet started or still running

isRunning

public boolean isRunning()
Description copied from interface: Transfer
Returns true if the transfer is running.

Specified by:
isRunning in interface Transfer
Returns:
true, if data is transferred or a connect is in progress; false, if queued, not yet started or done

messageReceived

public void messageReceived(ServerMessage msg)
Specified by:
messageReceived in interface MessageListener

setHash

public void setHash(java.lang.String hash)

setQueuePosition

public void setQueuePosition(int position)
Description copied from interface: Queueable
Invoked by the queue to update the position.

Specified by:
setQueuePosition in interface Queueable
Parameters:
position - if 0, the item has been dequeued from the queue and startQueued() has been called.

socketReceived

public boolean socketReceived(IncomingSocket s)
Description copied from interface: SocketListener
Invoked when an incoming connect is recognized.

Specified by:
socketReceived in interface SocketListener
Returns:
true, if the socket was accepted

start

public void start()
Inovked by OpenNapTransferManager after the instanciation.


startTransfer

public boolean startTransfer()
Starts the transfer. Invoked by TransferQueue.

Specified by:
startTransfer in interface Queueable
Returns:
true, if item has accepted the running state and should be dequeued; false, if item wants to remain queued

stop

public void stop()


Copyright © 2001-2005 XNap Team. All Rights Reserved.