File indexing completed on 2025-01-05 04:37:09
0001 /* 0002 SPDX-FileCopyrightText: 2009 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef BT_DATACHECKERJOB_H 0007 #define BT_DATACHECKERJOB_H 0008 0009 #include <torrent/job.h> 0010 #include <util/resourcemanager.h> 0011 0012 namespace bt 0013 { 0014 class DataCheckerThread; 0015 0016 /// Job which runs a DataChecker 0017 class KTORRENT_EXPORT DataCheckerJob : public bt::Job, public Resource 0018 { 0019 public: 0020 DataCheckerJob(bool auto_import, TorrentControl *tc, bt::Uint32 from, bt::Uint32 to); 0021 ~DataCheckerJob() override; 0022 0023 void start() override; 0024 void kill(bool quietly = true) override; 0025 TorrentStatus torrentStatus() const override 0026 { 0027 return CHECKING_DATA; 0028 } 0029 0030 /// Is this an automatic import 0031 bool isAutoImport() const 0032 { 0033 return auto_import; 0034 } 0035 0036 /// Was the job stopped 0037 bool isStopped() const 0038 { 0039 return killed; 0040 } 0041 0042 /// Get the first chunk the datacheck was started from 0043 bt::Uint32 firstChunk() const 0044 { 0045 return from; 0046 } 0047 0048 /// Get the last chunk of the datacheck 0049 bt::Uint32 lastChunk() const 0050 { 0051 return to; 0052 } 0053 0054 private: 0055 void threadFinished(); 0056 void progress(quint32 num, quint32 total); 0057 void status(quint32 num_failed, quint32 num_found, quint32 num_downloaded, quint32 num_not_downloaded); 0058 0059 void acquired() override; 0060 0061 DataCheckerThread *dcheck_thread; 0062 bool killed; 0063 bool auto_import; 0064 bool started; 0065 bt::Uint32 from; 0066 bt::Uint32 to; 0067 }; 0068 0069 } 0070 0071 #endif // BT_DATACHECKERJOB_H