org.lastbamboo.jni
Class JLibTorrent

java.lang.Object
  extended by org.lastbamboo.jni.JLibTorrent
All Implemented Interfaces:
org.lastbamboo.common.portmapping.NatPmpService, org.lastbamboo.common.portmapping.UpnpService

public class JLibTorrent
extends Object
implements org.lastbamboo.common.portmapping.NatPmpService, org.lastbamboo.common.portmapping.UpnpService

Java wrapper class for calls to native lib torrent.


Constructor Summary
JLibTorrent(boolean isPro)
           
JLibTorrent(Collection<File> libFiles, boolean isPro)
           
JLibTorrent(String libraryPath, boolean isPro)
           
 
Method Summary
 int addNatPmpMapping(org.lastbamboo.common.portmapping.PortMappingProtocol protocol, int internalPort, int externalPort, org.lastbamboo.common.portmapping.PortMapListener portMapListener)
           
 int addUpnpMapping(org.lastbamboo.common.portmapping.PortMappingProtocol protocol, int internalPort, int externalPort, org.lastbamboo.common.portmapping.PortMapListener portMapListener)
           
 void checkAlerts()
           
 void download(File incompleteDir, File torrentFile, boolean sequential, int torrentState)
           
 long getBytesRead(File torrentFile)
           
 int getDownloadRate()
           
 int getDownloadSpeed(File torrentFile)
           
 long getMaxByteForTorrent(File torrentFile)
           
 String getName(File torrentFile)
           
 int getNumFiles(File torrentFile)
           
 int getNumHosts(File torrentFile)
           
 int getNumPeers()
           
 int getPayloadDownloadRate()
           
 int getPayloadUploadRate()
           
 long getSizeForTorrent(File torrentFile)
           
 int getStateForTorrent(File torrentFile)
           
 long getTotalDownloadBytes()
           
 long getTotalPayloadDownloadBytes()
           
 long getTotalPayloadUploadBytes()
           
 long getTotalUploadBytes()
           
 int getUploadRate()
           
 void hardResumeTorrent(File torrentFile)
          Performs a "hard" resume of a torrent.
 void log(String msg)
           
 void logError(String msg)
           
 void moveToDownloadsDir(File torrentFile, File downloadsDir)
           
 void pauseTorrent(File torrentFile)
           
 void portMapAlert(int mappingId, int externalPort, int type)
           
 void portMapLogAlert(int type, String message)
           
 void removeNatPmpMapping(int mappingIndex)
           
 void removeTorrent(File torrentFile)
           
 void removeTorrentAndFiles(File torrentFile)
           
 void removeUpnpMapping(int mappingIndex)
           
 void rename(File torrentFile, String newName)
           
 void resumeTorrent(File torrentFile)
           
 void setDownloadRate(int downloadRate)
           
 void setMaxUploadSpeed(int bytesPerSecond)
           
 void setNumPeers(int numPeers)
           
 void setPayloadDownloadRate(int payloadDownloadRate)
           
 void setPayloadUploadRate(int payloadUploadRate)
           
 void setTotalDownloadBytes(long totalDownloadBytes)
           
 void setTotalPayloadDownloadBytes(long totalPayloadDownloadBytes)
           
 void setTotalPayloadUploadBytes(long totalPayloadUploadBytes)
           
 void setTotalUploadBytes(long totalUploadBytes)
           
 void setUploadRate(int uploadRate)
           
 void shutdown()
           
 void stopLibTorrent()
          Shuts down the libtorrent core.
 void updateSessionStatus()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JLibTorrent

public JLibTorrent(Collection<File> libFiles,
                   boolean isPro)

JLibTorrent

public JLibTorrent(boolean isPro)

JLibTorrent

public JLibTorrent(String libraryPath,
                   boolean isPro)
Method Detail

stopLibTorrent

public void stopLibTorrent()
Shuts down the libtorrent core.


updateSessionStatus

public void updateSessionStatus()

download

public void download(File incompleteDir,
                     File torrentFile,
                     boolean sequential,
                     int torrentState)
              throws IOException
Throws:
IOException

rename

public void rename(File torrentFile,
                   String newName)

moveToDownloadsDir

public void moveToDownloadsDir(File torrentFile,
                               File downloadsDir)

getMaxByteForTorrent

public long getMaxByteForTorrent(File torrentFile)

pauseTorrent

public void pauseTorrent(File torrentFile)

resumeTorrent

public void resumeTorrent(File torrentFile)

hardResumeTorrent

public void hardResumeTorrent(File torrentFile)
Performs a "hard" resume of a torrent. This is necessary when starting torrents from previous sessions that were paused in the previous session. The usual resume scenario doesn't appear to work in this case because simply setting a torrent to auto_managed that was never started out of the pause state in the first place appears to have no effect.

Parameters:
torrentFile - The torrent file.

getSizeForTorrent

public long getSizeForTorrent(File torrentFile)

removeTorrent

public void removeTorrent(File torrentFile)

removeTorrentAndFiles

public void removeTorrentAndFiles(File torrentFile)

getStateForTorrent

public int getStateForTorrent(File torrentFile)

getName

public String getName(File torrentFile)

getNumFiles

public int getNumFiles(File torrentFile)

getDownloadSpeed

public int getDownloadSpeed(File torrentFile)

getNumHosts

public int getNumHosts(File torrentFile)

getBytesRead

public long getBytesRead(File torrentFile)

setMaxUploadSpeed

public void setMaxUploadSpeed(int bytesPerSecond)

addUpnpMapping

public int addUpnpMapping(org.lastbamboo.common.portmapping.PortMappingProtocol protocol,
                          int internalPort,
                          int externalPort,
                          org.lastbamboo.common.portmapping.PortMapListener portMapListener)
Specified by:
addUpnpMapping in interface org.lastbamboo.common.portmapping.UpnpService

addNatPmpMapping

public int addNatPmpMapping(org.lastbamboo.common.portmapping.PortMappingProtocol protocol,
                            int internalPort,
                            int externalPort,
                            org.lastbamboo.common.portmapping.PortMapListener portMapListener)
Specified by:
addNatPmpMapping in interface org.lastbamboo.common.portmapping.NatPmpService

removeUpnpMapping

public void removeUpnpMapping(int mappingIndex)
Specified by:
removeUpnpMapping in interface org.lastbamboo.common.portmapping.UpnpService

removeNatPmpMapping

public void removeNatPmpMapping(int mappingIndex)
Specified by:
removeNatPmpMapping in interface org.lastbamboo.common.portmapping.NatPmpService

checkAlerts

public void checkAlerts()

setTotalUploadBytes

public void setTotalUploadBytes(long totalUploadBytes)

getTotalUploadBytes

public long getTotalUploadBytes()

setTotalDownloadBytes

public void setTotalDownloadBytes(long totalDownloadBytes)

getTotalDownloadBytes

public long getTotalDownloadBytes()

setDownloadRate

public void setDownloadRate(int downloadRate)

getDownloadRate

public int getDownloadRate()

setUploadRate

public void setUploadRate(int uploadRate)

getUploadRate

public int getUploadRate()

setNumPeers

public void setNumPeers(int numPeers)

getNumPeers

public int getNumPeers()

setPayloadUploadRate

public void setPayloadUploadRate(int payloadUploadRate)

getPayloadUploadRate

public int getPayloadUploadRate()

setPayloadDownloadRate

public void setPayloadDownloadRate(int payloadDownloadRate)

getPayloadDownloadRate

public int getPayloadDownloadRate()

setTotalPayloadUploadBytes

public void setTotalPayloadUploadBytes(long totalPayloadUploadBytes)

getTotalPayloadUploadBytes

public long getTotalPayloadUploadBytes()

setTotalPayloadDownloadBytes

public void setTotalPayloadDownloadBytes(long totalPayloadDownloadBytes)

getTotalPayloadDownloadBytes

public long getTotalPayloadDownloadBytes()

portMapAlert

public void portMapAlert(int mappingId,
                         int externalPort,
                         int type)

portMapLogAlert

public void portMapLogAlert(int type,
                            String message)

log

public void log(String msg)

logError

public void logError(String msg)

shutdown

public void shutdown()
Specified by:
shutdown in interface org.lastbamboo.common.portmapping.NatPmpService
Specified by:
shutdown in interface org.lastbamboo.common.portmapping.UpnpService


Copyright © 2013 LittleShoot. All Rights Reserved.