2007-05-31 15:56:20 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-05-31 15:56:20 +00:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
2007-11-12 11:28:16 +00:00
|
|
|
#include "PieceHashCheckIntegrityEntry.h"
|
|
|
|
#include "RequestGroup.h"
|
|
|
|
#include "IteratableChunkChecksumValidator.h"
|
|
|
|
#include "DownloadContext.h"
|
|
|
|
#include "PieceStorage.h"
|
2007-05-31 15:56:20 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2010-06-09 15:04:01 +00:00
|
|
|
PieceHashCheckIntegrityEntry::PieceHashCheckIntegrityEntry
|
|
|
|
(RequestGroup* requestGroup,
|
|
|
|
Command* nextCommand):
|
2007-11-12 11:28:16 +00:00
|
|
|
CheckIntegrityEntry(requestGroup, nextCommand) {}
|
2007-05-31 15:56:20 +00:00
|
|
|
|
2007-11-12 11:28:16 +00:00
|
|
|
PieceHashCheckIntegrityEntry::~PieceHashCheckIntegrityEntry() {}
|
2007-05-31 15:56:20 +00:00
|
|
|
|
2007-11-12 11:28:16 +00:00
|
|
|
bool PieceHashCheckIntegrityEntry::isValidationReady()
|
|
|
|
{
|
2009-06-28 10:37:15 +00:00
|
|
|
const SharedHandle<DownloadContext>& dctx =
|
2010-06-09 15:04:01 +00:00
|
|
|
getRequestGroup()->getDownloadContext();
|
2010-09-15 11:46:25 +00:00
|
|
|
return dctx->isPieceHashVerificationAvailable();
|
2007-11-12 11:28:16 +00:00
|
|
|
}
|
2007-05-31 15:56:20 +00:00
|
|
|
|
2007-11-12 11:28:16 +00:00
|
|
|
void PieceHashCheckIntegrityEntry::initValidator()
|
|
|
|
{
|
2007-11-14 10:10:38 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2008-04-20 00:50:22 +00:00
|
|
|
IteratableChunkChecksumValidatorHandle validator
|
2010-06-09 15:04:01 +00:00
|
|
|
(new IteratableChunkChecksumValidator
|
|
|
|
(getRequestGroup()->getDownloadContext(),
|
|
|
|
getRequestGroup()->getPieceStorage()));
|
2007-12-05 13:41:56 +00:00
|
|
|
validator->init();
|
2010-06-09 15:04:01 +00:00
|
|
|
setValidator(validator);
|
2007-11-14 10:10:38 +00:00
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
2007-11-12 11:28:16 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|