libktorrent  2.1.1
datacheckerjob.h
1 /***************************************************************************
2  * Copyright (C) 2009 by *
3  * Joris Guisson <joris.guisson@gmail.com> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef BT_DATACHECKERJOB_H
21 #define BT_DATACHECKERJOB_H
22 
23 #include <torrent/job.h>
24 #include <util/resourcemanager.h>
25 
26 namespace bt
27 {
28  class DataCheckerThread;
29 
30 
32  class KTORRENT_EXPORT DataCheckerJob : public bt::Job, public Resource
33  {
34  Q_OBJECT
35  public:
36  DataCheckerJob(bool auto_import,TorrentControl* tc, bt::Uint32 from, bt::Uint32 to);
37  ~DataCheckerJob() override;
38 
39  void start() override;
40  void kill(bool quietly = true) override;
41  TorrentStatus torrentStatus() const override {return CHECKING_DATA;}
42 
44  bool isAutoImport() const {return auto_import;}
45 
47  bool isStopped() const {return killed;}
48 
50  bt::Uint32 firstChunk() const {return from;}
51 
53  bt::Uint32 lastChunk() const {return to;}
54 
55  private Q_SLOTS:
56  void threadFinished();
57  void progress(quint32 num, quint32 total);
58  void status(quint32 num_failed, quint32 num_found, quint32 num_downloaded, quint32 num_not_downloaded);
59 
60  private:
61  void acquired() override;
62 
63  private:
64  DataCheckerThread* dcheck_thread;
65  bool killed;
66  bool auto_import;
67  bool started;
68  bt::Uint32 from;
69  bt::Uint32 to;
70  };
71 
72 }
73 
74 #endif // BT_DATACHECKERJOB_H
bt::Job
Definition: job.h:38
bt::DataCheckerThread
Definition: datacheckerthread.h:56