26 #include <ktorrent_export.h>
27 #include <util/constants.h>
28 #include <interfaces/webseedinterface.h>
29 #include <interfaces/chunkdownloadinterface.h>
30 #include <diskio/piecedata.h>
31 #include <peer/connectionlimit.h>
41 class WebSeedChunkDownload;
47 class KTORRENT_EXPORT WebSeed :
public QObject,
public WebSeedInterface
51 WebSeed(
const QUrl &url,
bool user,
const Torrent & tor,ChunkManager & cman);
58 bool inCurrentRange(Uint32 chunk)
const {
return chunk >= first_chunk && chunk <= last_chunk;}
65 void download(Uint32 first,Uint32 last);
73 void onExcluded(Uint32 from,Uint32 to);
85 void chunkDownloaded(Uint32 chunk);
93 Uint32 getDownloadRate()
const override;
101 void setGroupIDs(Uint32 up,Uint32 down);
109 static void setProxy(
const QString & host,bt::Uint16 port);
116 static void setProxyEnabled(
bool on);
121 void setEnabled(
bool on)
override;
124 void disable(
const QString & reason);
127 Uint32 failedAttempts()
const {
return num_failures;}
162 void redirected(
const QUrl &to_url);
172 class AutoDisabled {};
174 void fillRangeList(Uint32 chunk);
175 void handleData(
const QByteArray & data);
176 void chunkStarted(Uint32 chunk);
178 void connectToServer();
179 void continueCurChunk();
187 QList<QByteArray> chunks;
191 Uint32 bytes_of_cur_chunk;
195 Uint32 up_gid,down_gid;
196 QList<Range> range_queue;
198 PieceData::Ptr cur_piece;
200 ConnectionLimit::Token::Ptr token;
202 static QString proxy_host;
203 static Uint16 proxy_port;
204 static bool proxy_enabled;
213 void getStats(Stats & s)
override;
219 Uint32 pieces_downloaded;