20 #ifndef BTDOWNLOADER_H
21 #define BTDOWNLOADER_H
24 #include <util/ptrmap.h>
25 #include <util/constants.h>
26 #include <ktorrent_export.h>
27 #include "download/webseed.h"
28 #include "download/chunkdownload.h"
29 #include "peer/peermanager.h"
42 class ChunkSelectorInterface;
43 class PieceDownloader;
44 class MonitorInterface;
45 class WebSeedChunkDownload;
47 typedef PtrMap<Uint32,ChunkDownload>::iterator CurChunkItr;
48 typedef PtrMap<Uint32,ChunkDownload>::const_iterator CurChunkCItr;
50 #define CURRENT_CHUNK_MAGIC 0xABCDEF00
92 const WebSeed*
getWebSeed(Uint32 i)
const {
return i < (Uint32)webseeds.count() ? webseeds[i] : 0;}
134 CurChunkCItr beginDownloads()
const {
return current_chunks.begin();}
135 CurChunkCItr endDownloads()
const {
return current_chunks.end();}
244 void pieceReceived(
const bt::Piece & p)
override;
252 void onExcluded(Uint32 from,Uint32 to);
259 void onIncluded(Uint32 from,Uint32 to);
265 void onChunkReady(
Chunk* c);
285 void downloadFrom(
WebSeed* ws);
295 Uint64 bytes_downloaded;
296 Uint64 curr_chunks_downloaded;
297 Uint64 unnecessary_data;
299 QList<PieceDownloader*> piece_downloaders;
302 QList<WebSeed*> webseeds;
304 Uint32 active_webseed_downloads;
306 Uint32 webseed_range_size;
307 bool webseed_endgame_mode;
309 static bool use_webseeds;
Simple implementation of a BitSet.
void setChunkSelector(ChunkSelectorInterface *csel)
Set the ChunkSelector, 0 means KT will reset to the default selector.
bool removeWebSeed(const QUrl &url)
Remove a webseed.
const ChunkDownload * download(Uint32 chunk) const
Uint32 getDownloadedBytesOfCurrentChunksFile(const QString &file)
Uint32 numDownloadersForChunk(Uint32 chunk) const
void removePieceDownloader(PieceDownloader *peer)
bool isFinished() const
See if the download is finished.
Uint32 downloadRate() const
Get the current dowload rate.
Keep track of a piece of the file.
void saveDownloads(const QString &file)
bool canDownloadFromWebSeed(Uint32 chunk) const
WebSeed * addWebSeed(const QUrl &url)
Add a webseed.
void dataChecked(const BitSet &ok_chunks, bt::Uint32 from, bt::Uint32 to)
const WebSeed * getWebSeed(Uint32 i) const
Get a webseed.
void addPieceDownloader(PieceDownloader *peer)
bool downloading(Uint32 chunk) const
void removeAllWebSeeds()
Remove all webseeds.
void setGroupIDs(Uint32 up, Uint32 down)
Interface for classes who want to monitor a TorrentInterface.
void saveWebSeeds(const QString &file)
Save the user created webseeds.
WebSeed * getWebSeed(Uint32 i)
Get a webseed.
void loadDownloads(const QString &file)
void chunkDownloaded(Uint32 chunk)
Uint32 numActiveDownloads() const
Get the number of chunks we are dowloading.
Base class for handling pieces.
void loadWebSeeds(const QString &file)
Add the user created webseeds.
Uint64 bytesDownloaded() const
Get the number of bytes we have downloaded.
static void setUseWebSeeds(bool on)
Enable or disable the use of webseeds.
Downloader(Torrent &tor, PeerManager &pman, ChunkManager &cman)
void corrupted(Uint32 chunk)
bool endgameMode() const
Are we in endgame mode.
void ioError(const QString &msg)
Handles the download off one Chunk off a Peer.
void setMonitor(MonitorInterface *tmo)
ChunkDownload * download(Uint32 chunk)
Uint32 getNumWebSeeds() const
Get the number of webseeds.