2
* This file is part of nzbget
4
* Copyright (C) 2007-2014 Andrey Prygunkov <hugbug@users.sourceforge.net>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
* $Date: 2014-10-09 23:11:42 +0200 (Thu, 09 Oct 2014) $
29
#ifndef DISABLE_PARCHECK
38
class ParChecker : public Thread
74
Segment(bool bSuccess, long long iOffset, int iSize, unsigned long lCrc);
75
bool GetSuccess() { return m_bSuccess; }
76
long long GetOffset() { return m_iOffset; }
77
int GetSize() { return m_iSize; }
78
unsigned long GetCrc() { return m_lCrc; }
81
typedef std::deque<Segment*> SegmentListBase;
83
class SegmentList : public SegmentListBase
89
typedef std::deque<char*> FileList;
90
typedef std::deque<void*> SourceList;
91
typedef std::vector<bool> ValidBlocks;
93
friend class Repairer;
99
const char* m_szParFilename;
102
// declared as void* to prevent the including of libpar2-headers into this header-file
105
FileList m_QueuedParFiles;
106
Mutex m_mutexQueuedParFiles;
107
bool m_bQueuedParFilesChanged;
108
FileList m_ProcessedFiles;
109
int m_iProcessedFiles;
110
int m_iFilesToRepair;
112
bool m_bVerifyingExtraFiles;
113
char* m_szProgressLabel;
115
int m_iStageProgress;
117
SourceList m_sourceFiles;
118
std::string m_lastFilename;
119
bool m_bHasDamagedFiles;
124
EStatus RunParCheckAll();
125
EStatus RunParCheck(const char* szParFilename);
127
bool LoadMainParBak();
128
int ProcessMorePars();
130
bool AddSplittedFragments();
131
bool AddMissingFiles();
132
bool IsProcessedFile(const char* szFilename);
133
void WriteBrokenLog(EStatus eStatus);
134
void SaveSourceList();
135
void DeleteLeftovers();
136
void signal_filename(std::string str);
137
void signal_progress(double progress);
138
void signal_done(std::string str, int available, int total);
139
// declared as void* to prevent the including of libpar2-headers into this header-file
140
// DiskFile* pDiskfile, Par2RepairerSourceFile* pSourcefile
141
EFileStatus VerifyDataFile(void* pDiskfile, void* pSourcefile, int* pAvailableBlocks);
142
bool VerifySuccessDataFile(void* pDiskfile, void* pSourcefile, unsigned long lDownloadCrc);
143
bool VerifyPartialDataFile(void* pDiskfile, void* pSourcefile, SegmentList* pSegments, ValidBlocks* pValidBlocks);
144
bool SmartCalcFileRangeCrc(FILE* pFile, long long lStart, long long lEnd, SegmentList* pSegments,
145
unsigned long* pDownloadCrc);
146
bool DumbCalcFileRangeCrc(FILE* pFile, long long lStart, long long lEnd, unsigned long* pDownloadCrc);
151
* returns true, if the files with required number of blocks were unpaused,
152
* or false if there are no more files in queue for this collection or not enough blocks
154
virtual bool RequestMorePars(int iBlockNeeded, int* pBlockFound) = 0;
155
virtual void UpdateProgress() {}
156
virtual void Completed() {}
157
virtual void PrintMessage(Message::EKind eKind, const char* szFormat, ...) {}
158
virtual void RegisterParredFile(const char* szFilename) {}
159
virtual bool IsParredFile(const char* szFilename) { return false; }
160
virtual EFileStatus FindFileCrc(const char* szFilename, unsigned long* lCrc, SegmentList* pSegments) { return fsUnknown; }
161
EStage GetStage() { return m_eStage; }
162
const char* GetProgressLabel() { return m_szProgressLabel; }
163
int GetFileProgress() { return m_iFileProgress; }
164
int GetStageProgress() { return m_iStageProgress; }
168
virtual ~ParChecker();
170
void SetDestDir(const char* szDestDir);
171
const char* GetParFilename() { return m_szParFilename; }
172
const char* GetInfoName() { return m_szInfoName; }
173
void SetInfoName(const char* szInfoName);
174
void SetNZBName(const char* szNZBName);
175
void SetParQuick(bool bParQuick) { m_bParQuick = bParQuick; }
176
bool GetParQuick() { return m_bParQuick; }
177
void SetForceRepair(bool bForceRepair) { m_bForceRepair = bForceRepair; }
178
bool GetForceRepair() { return m_bForceRepair; }
179
EStatus GetStatus() { return m_eStatus; }
180
void AddParFile(const char* szParFilename);
183
bool GetCancelled() { return m_bCancelled; }