19
19
***************************************************************************/
21
21
#include "datacheckerjob.h"
22
#include "datacheckerlistener.h"
23
22
#include "datacheckerthread.h"
24
23
#include "multidatachecker.h"
25
24
#include "singledatachecker.h"
26
25
#include <torrent/torrentcontrol.h>
27
26
#include <util/functions.h>
31
static ResourceManager data_checker_slot(1);
32
DataCheckerJob::DataCheckerJob(bt::DataCheckerListener* lst, bt::TorrentControl* tc): Job(true,tc),listener(lst)
33
DataCheckerJob::DataCheckerJob(bool auto_import,bt::TorrentControl* tc)
35
Resource(&data_checker_slot,tc->getInfoHash().toString()),
38
auto_import(auto_import),
50
56
dc = new SingleDataChecker();
52
dc->setListener(listener);
58
connect(dc,SIGNAL(progress(quint32,quint32)),
59
this,SLOT(progress(quint32,quint32)),Qt::QueuedConnection);
60
connect(dc,SIGNAL(status(quint32,quint32,quint32,quint32)),
61
this,SLOT(status(quint32,quint32,quint32,quint32)),Qt::QueuedConnection);
53
63
TorrentControl* tor = torrent();
54
64
dcheck_thread = new DataCheckerThread(
55
65
dc,tor->downloadedChunksBitSet(),
56
66
stats.output_path,tor->getTorrent(),
57
67
tor->getTorDir() + "dnd" + bt::DirSeparator());
59
connect(dcheck_thread,SIGNAL(finished()),this,SLOT(finished()),Qt::QueuedConnection);
69
connect(dcheck_thread,SIGNAL(finished()),this,SLOT(threadFinished()),Qt::QueuedConnection);
61
71
torrent()->beforeDataCheck();
63
// dc->check(stats.output_path,*tor,tordir + "dnd" + bt::DirSeparator());
73
setTotalAmount(Bytes,stats.total_chunks);
74
data_checker_slot.add(this);
76
infoMessage(this,i18n("Waiting for other data checks to finish"));
79
void DataCheckerJob::acquired()
82
description(this,i18n("Checking data"));
64
83
dcheck_thread->start(QThread::IdlePriority);
81
void DataCheckerJob::finished()
100
void DataCheckerJob::threadFinished()
85
104
DataChecker* dc = dcheck_thread->getDataChecker();
86
torrent()->afterDataCheck(listener,dc->getResult(),dcheck_thread->getError());
105
torrent()->afterDataCheck(this,dc->getResult());
106
if (!dcheck_thread->getError().isEmpty())
108
setErrorText(dcheck_thread->getError());
109
setError(KIO::ERR_UNKNOWN);
88
117
dcheck_thread->deleteLater();
89
118
dcheck_thread = 0;
119
if (!killed) // Job::kill already emitted the result
125
void DataCheckerJob::progress(quint32 num, quint32 total)
128
setProcessedAmount(Bytes,num);
131
void DataCheckerJob::status(quint32 num_failed, quint32 num_found, quint32 num_downloaded, quint32 num_not_downloaded)
133
QPair<QString,QString> field1 = qMakePair(QString::number(num_failed),QString::number(num_found));
134
QPair<QString,QString> field2 = qMakePair(QString::number(num_downloaded),QString::number(num_not_downloaded));
135
description(this,i18n("Checking Data"),field1,field2);
b'\\ No newline at end of file'