21 #ifndef BTTORRENTCONTROL_H
22 #define BTTORRENTCONTROL_H
24 #include <qdatetime.h>
28 #include <util/timer.h>
29 #include <interfaces/torrentinterface.h>
30 #include <interfaces/trackerslist.h>
31 #include <ktorrent_export.h>
44 class PeerSourceManager;
51 class QueueManagerInterface;
54 class MonitorInterface;
55 class ChunkSelectorFactoryInterface;
88 const QByteArray & data,
89 const QString & tmpdir,
90 const QString & datadir);
242 void beforeDataCheck();
243 void preallocFinished(
const QString & error,
bool completed);
248 void onNewPeer(
Peer* p);
249 void onPeerRemoved(
Peer* p);
251 void onIOError(
const QString & msg);
254 void corrupted(Uint32 chunk);
255 void moveDataFilesFinished(KJob* j);
256 void moveDataFilesWithMapFinished(KJob* j);
257 void downloaded(Uint32 chunk);
258 void moveToCompletedDir();
262 void updateTracker(
const QString & ev,
bool last_succes =
true);
263 void updateStatus()
override;
266 void loadOutputDir();
268 void getSeederInfo(Uint32 & total,Uint32 & connected_to)
const;
269 void getLeecherInfo(Uint32 & total,Uint32 & connected_to)
const;
270 void continueStart();
271 void handleError(
const QString & err)
override;
274 void setupDirs(
const QString & tmpdir,
const QString & ddir);
277 void setUploadProps(Uint32 limit,Uint32 rate);
278 void setDownloadProps(Uint32 limit,Uint32 rate);
279 void downloadPriorityChanged(
TorrentFile* tf, Priority newpriority, Priority oldpriority)
override;
280 void updateRunningTimes();
283 void dataCheckFinished();
297 QString move_data_files_destination_path;
298 Timer choker_update_timer;
299 Timer stats_save_timer;
301 Timer wanted_update_timer;
306 QString completed_dir;
308 TimeStamp last_diskspace_check;
313 QDateTime time_started_dl;
314 QDateTime time_started_ul;
315 Uint32 running_time_dl;
316 Uint32 running_time_ul;
317 Uint64 prev_bytes_dl;
318 Uint64 prev_bytes_ul;
319 Uint64 session_bytes_uploaded;
321 bool custom_output_name;
325 bool diskspace_warning_emitted;
331 Uint32 download_limit;
333 Uint32 assured_download_speed;
334 Uint32 assured_upload_speed;
336 InternalStats istats;
339 TorrentFileStream::WPtr stream;
341 static bool completed_datacheck;
342 static Uint32 min_diskspace;
QString getMoveWhenCompletedDir() const override
Simple implementation of a BitSet.
void setSuperSeeding(bool on) override
Uint32 getNumWebSeeds() const override
Get the number of webseeds.
const BitSet & downloadedChunksBitSet() const override
const Torrent & getTorrent() const
Get the Torrent.
Interface for a file in a multifile torrent.
void scrapeTracker() override
bool overMaxRatio() override
Checks if a seeding torrent has reached its maximum share ratio.
const bt::PeerID & getOwnPeerID() const override
Get our PeerID.
Uint32 getNumDHTNodes() const override
Get the number of initial DHT nodes.
void stop(WaitJob *wjob=0) override
void setMaxSeedTime(float hours) override
Set the max seed time in hours (0 is no limit)
void updateTracker() override
void setChunkSelectorFactory(ChunkSelectorFactoryInterface *csfi)
bool addWebSeed(const QUrl &url) override
Add a webseed (return false, if there is already a webseed with the same url)
bool isFeatureEnabled(TorrentFeature tf) override
Is a feature enabled.
void createFiles()
Create all the necessary files.
TrackersList * getTrackersList() override
Get a pointer to TrackersList object.
const DHTNode & getDHTNode(Uint32 i) const override
Get a DHT node.
void init(QueueManagerInterface *qman, const QByteArray &data, const QString &tmpdir, const QString &datadir)
void setChunkSelector(ChunkSelectorInterface *csel) override
Set the ChunkSelector to use (0 resets to the default ChunkSelector)
Manages the connection with a peer.
bool checkDiskSpace(bool emit_sig=true) override
Check if there is enough diskspace available for this torrent.
void setMonitor(MonitorInterface *tmo) override
Set the monitor.
static void setMinimumDiskSpace(Uint32 m)
Uint32 getNumFiles() const override
Get the number of files in a multifile torrent (0 if we do not have a multifile torrent)
void deleteDataFiles() override
const PeerManager * getPeerMgr() const
Get the PeerManager.
void setAssuredSpeeds(Uint32 up, Uint32 down) override
Set the assured speeds.
void markExistingFilesAsDownloaded() override
Mark all existing files as downloaded (.
int getPriority() const override
Get the torrent queue number. Zero if not in queue.
void setMaxShareRatio(float ratio) override
Set the max share ratio.
float getMaxShareRatio() const override
Get the max share ratio.
void setAllowedToStart(bool on) override
Set whether the QM can start a torrent.
void setCacheFactory(CacheFactory *cf)
Set a custom Cache factory.
void setQueued(bool queued) override
Interface for classes who want to monitor a TorrentInterface.
Uint32 getRunningTimeDL() const override
bool isStorageMounted(QStringList &missing) override
const SHA1Hash & getInfoHash() const override
Get the info_hash.
void setPreallocateDiskSpace(bool pa)
Tell the TorrentControl obj to preallocate diskspace in the next update.
float getMaxSeedTime() const override
Get the max seed time.
TorrentFileStream::Ptr createTorrentFileStream(bt::Uint32 index, bool streaming_mode, QObject *parent) override
Job which runs a DataChecker.
void setFeatureEnabled(TorrentFeature tf, bool on) override
Disable or enable a feature.
const TrackersList * getTrackersList() const override
Get a pointer to TrackersList object.
void getTrafficLimits(Uint32 &up, Uint32 &down) override
Get the traffic limits.
void networkUp() override
After some network down time, the network is back up.
bool moveTorrentFiles(const QMap< TorrentFileInterface *, QString > &files) override
void setTrafficLimits(Uint32 up, Uint32 down) override
Set the traffic limits for this torrent.
bool removeWebSeed(const QUrl &url) override
Remove a webseed (only user created ones can be removed)
QString getDataDir() const override
Get the data directory of this torrent.
Uint32 getRunningTimeUL() const override
QString getTorDir() const override
void recreateMissingFiles() override
WebSeedInterface * getWebSeed(Uint32 i) override
Get a webseed (returns 0 if index is invalid)
bool changeOutputDir(const QString &new_dir, int flags) override
void addPeerSource(PeerSource *ps) override
void setPriority(int p) override
Set the torrent queue number.
void setMoveWhenCompletedDir(const QString &dir) override
void removePeerSource(PeerSource *ps) override
const TorrentFileInterface & getTorrentFile(Uint32 index) const override
const QTextCodec * getTextCodec() const override
Get the text codec used in the torrent.
const BitSet & availableChunksBitSet() const override
Controls just about everything.
Job * startDataCheck(bool auto_import, bt::Uint32 from, bt::Uint32 to) override
QString getComments() const override
Get the comments.
void getAssuredSpeeds(Uint32 &up, Uint32 &down) override
Get the assured speeds.
TorrentFileInterface & getTorrentFile(Uint32 index) override
static void setDataCheckWhenCompleted(bool on)
bool hasExistingFiles() const
Test if the torrent has existing files, only works the first time a torrent is loaded.
bool announceAllowed() override
Is manual announce allowed?
void dndMissingFiles() override
void setUserModifiedFileName(const QString &n) override
Set the user modified file or toplevel directory name.
bool hasMissingFiles(QStringList &sl) override
bool changeTorDir(const QString &new_dir) override
This class is used for loading/storing torrent stats in a file.
bool overMaxSeedTime() override
Checks if a seeding torrent has reached it's max seed timery / will be ret.
const BitSet & onlySeedChunksBitSet() const override
const WebSeedInterface * getWebSeed(Uint32 i) const override
Get a webseed (returns 0 if index is invalid)
void changeTextCodec(QTextCodec *tc) override
Set the text codec.
bool readyForPreview() const override
const BitSet & excludedChunksBitSet() const override
bool isMultimedia() const override
See if this is a single file torrent and a multimedia files.
void setDisplayName(const QString &n) override
Set the displayed name.
Interface for an object which controls one torrent.
const JobQueue * getJobQueue() const override
Get the JobQueue of the torrent.
void afterDataCheck(DataCheckerJob *job, const BitSet &result)
Called when a data check is finished by DataCheckerJob.