2007-12-04 11:12:56 +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-12-04 11:12:56 +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 --> */
|
|
|
|
#include "MetalinkParserStateMachine.h"
|
2010-03-02 14:07:30 +00:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <iterator>
|
|
|
|
|
2009-10-03 12:52:16 +00:00
|
|
|
#include "MetalinkParserStateImpl.h"
|
2010-02-25 14:40:18 +00:00
|
|
|
#include "MetalinkParserStateV3Impl.h"
|
|
|
|
#include "MetalinkParserStateV4Impl.h"
|
2007-12-04 11:12:56 +00:00
|
|
|
#include "Metalinker.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "MetalinkEntry.h"
|
|
|
|
|
|
|
|
namespace aria2 {
|
2007-12-04 11:12:56 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::initialState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new InitialMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::skipTagState_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new SkipTagMetalinkParserState();
|
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::metalinkState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new MetalinkMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::filesState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new FilesMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::fileState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new FileMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::sizeState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new SizeMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::versionState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new VersionMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::languageState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new LanguageMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::osState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new OSMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::verificationState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new VerificationMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::hashState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new HashMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::piecesState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new PiecesMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::pieceHashState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new PieceHashMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::signatureState_ =
|
2008-07-12 13:35:35 +00:00
|
|
|
new SignatureMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::resourcesState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new ResourcesMetalinkParserState();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::urlState_ =
|
2009-10-03 12:52:16 +00:00
|
|
|
new URLMetalinkParserState();
|
2010-02-25 14:40:18 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::metalinkStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new MetalinkMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::fileStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new FileMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::sizeStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new SizeMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::versionStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new VersionMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::languageStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new LanguageMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::osStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new OSMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::hashStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new HashMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::piecesStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new PiecesMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::pieceHashStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new PieceHashMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::signatureStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new SignatureMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::urlStateV4_ =
|
2010-02-25 14:40:18 +00:00
|
|
|
new URLMetalinkParserStateV4();
|
2010-06-21 13:51:56 +00:00
|
|
|
MetalinkParserState* MetalinkParserStateMachine::metaurlStateV4_ =
|
2010-02-25 16:00:24 +00:00
|
|
|
new MetaurlMetalinkParserStateV4();
|
2007-12-04 11:12:56 +00:00
|
|
|
|
|
|
|
MetalinkParserStateMachine::MetalinkParserStateMachine():
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_(new MetalinkParserController())
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(initialState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2010-11-14 07:17:55 +00:00
|
|
|
MetalinkParserStateMachine::~MetalinkParserStateMachine() {}
|
|
|
|
|
2007-12-04 11:12:56 +00:00
|
|
|
void MetalinkParserStateMachine::setMetalinkState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(metalinkState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setFilesState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(filesState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setFileState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(fileState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setSizeState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(sizeState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setVersionState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(versionState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setLanguageState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(languageState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setOSState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(osState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setVerificationState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(verificationState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setHashState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(hashState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setPiecesState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(piecesState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setPieceHashState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(pieceHashState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-07-12 13:35:35 +00:00
|
|
|
void MetalinkParserStateMachine::setSignatureState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(signatureState_);
|
2008-07-12 13:35:35 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 11:12:56 +00:00
|
|
|
void MetalinkParserStateMachine::setResourcesState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(resourcesState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setURLState()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(urlState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:40:18 +00:00
|
|
|
void MetalinkParserStateMachine::setMetalinkStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(metalinkStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setFileStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(fileStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setSizeStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(sizeStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setVersionStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(versionStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setLanguageStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(languageStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setOSStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(osStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setHashStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(hashStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setPiecesStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(piecesStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setPieceHashStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(pieceHashStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setSignatureStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(signatureStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setURLStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(urlStateV4_);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 16:00:24 +00:00
|
|
|
void MetalinkParserStateMachine::setMetaurlStateV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(metaurlStateV4_);
|
2010-02-25 16:00:24 +00:00
|
|
|
}
|
|
|
|
|
2009-10-03 12:52:16 +00:00
|
|
|
void MetalinkParserStateMachine::setSkipTagState()
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.push(skipTagState_);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MetalinkParserStateMachine::finished() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return stateStack_.top() == initialState_;
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::newEntryTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->newEntryTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setFileNameOfEntry(const std::string& filename)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setFileNameOfEntry(filename);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void MetalinkParserStateMachine::setFileLengthOfEntry(uint64_t length)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setFileLengthOfEntry(length);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setVersionOfEntry(const std::string& version)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setVersionOfEntry(version);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setLanguageOfEntry(const std::string& language)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setLanguageOfEntry(language);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setOSOfEntry(const std::string& os)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setOSOfEntry(os);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void MetalinkParserStateMachine::setMaxConnectionsOfEntry(int maxConnections)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setMaxConnectionsOfEntry(maxConnections);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::commitEntryTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->commitEntryTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2010-03-02 15:14:39 +00:00
|
|
|
void MetalinkParserStateMachine::cancelEntryTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->cancelEntryTransaction();
|
2010-03-02 15:14:39 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 11:12:56 +00:00
|
|
|
void MetalinkParserStateMachine::newResourceTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->newResourceTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setURLOfResource(const std::string& url)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setURLOfResource(url);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setTypeOfResource(const std::string& type)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setTypeOfResource(type);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2009-10-03 12:52:16 +00:00
|
|
|
void MetalinkParserStateMachine::setLocationOfResource
|
|
|
|
(const std::string& location)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setLocationOfResource(location);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:40:18 +00:00
|
|
|
void MetalinkParserStateMachine::setPriorityOfResource(int priority)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setPriorityOfResource(priority);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void MetalinkParserStateMachine::setMaxConnectionsOfResource(int maxConnections)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setMaxConnectionsOfResource(maxConnections);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::commitResourceTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->commitResourceTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::cancelResourceTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->cancelResourceTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::newChecksumTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->newChecksumTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setTypeOfChecksum(const std::string& type)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setTypeOfChecksum(type);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setHashOfChecksum(const std::string& md)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setHashOfChecksum(md);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::commitChecksumTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->commitChecksumTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::cancelChecksumTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->cancelChecksumTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:40:18 +00:00
|
|
|
void MetalinkParserStateMachine::newChunkChecksumTransactionV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->newChunkChecksumTransactionV4();
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setLengthOfChunkChecksumV4(size_t length)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setLengthOfChunkChecksumV4(length);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setTypeOfChunkChecksumV4
|
|
|
|
(const std::string& type)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setTypeOfChunkChecksumV4(type);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::addHashOfChunkChecksumV4(const std::string& md)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->addHashOfChunkChecksumV4(md);
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::commitChunkChecksumTransactionV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->commitChunkChecksumTransactionV4();
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::cancelChunkChecksumTransactionV4()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->cancelChunkChecksumTransactionV4();
|
2010-02-25 14:40:18 +00:00
|
|
|
}
|
|
|
|
|
2007-12-04 11:12:56 +00:00
|
|
|
void MetalinkParserStateMachine::newChunkChecksumTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->newChunkChecksumTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void MetalinkParserStateMachine::setLengthOfChunkChecksum(size_t length)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setLengthOfChunkChecksum(length);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
void MetalinkParserStateMachine::setTypeOfChunkChecksum(const std::string& type)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setTypeOfChunkChecksum(type);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
void MetalinkParserStateMachine::createNewHashOfChunkChecksum(size_t order)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->createNewHashOfChunkChecksum(order);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2009-10-03 12:52:16 +00:00
|
|
|
void MetalinkParserStateMachine::setMessageDigestOfChunkChecksum
|
|
|
|
(const std::string& md)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setMessageDigestOfChunkChecksum(md);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::addHashOfChunkChecksum()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->addHashOfChunkChecksum();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::commitChunkChecksumTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->commitChunkChecksumTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::cancelChunkChecksumTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->cancelChunkChecksumTransaction();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-07-12 13:35:35 +00:00
|
|
|
void MetalinkParserStateMachine::newSignatureTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->newSignatureTransaction();
|
2008-07-12 13:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setTypeOfSignature(const std::string& type)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setTypeOfSignature(type);
|
2008-07-12 13:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setFileOfSignature(const std::string& file)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setFileOfSignature(file);
|
2008-07-12 13:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setBodyOfSignature(const std::string& body)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setBodyOfSignature(body);
|
2008-07-12 13:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::commitSignatureTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->commitSignatureTransaction();
|
2008-07-12 13:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::cancelSignatureTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->cancelSignatureTransaction();
|
2008-07-12 13:35:35 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 16:00:24 +00:00
|
|
|
void MetalinkParserStateMachine::newMetaurlTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->newMetaurlTransaction();
|
2010-02-25 16:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setURLOfMetaurl(const std::string& url)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setURLOfMetaurl(url);
|
2010-02-25 16:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setMediatypeOfMetaurl
|
|
|
|
(const std::string& mediatype)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setMediatypeOfMetaurl(mediatype);
|
2010-02-25 16:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::setPriorityOfMetaurl(int priority)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setPriorityOfMetaurl(priority);
|
2010-02-25 16:00:24 +00:00
|
|
|
}
|
|
|
|
|
2010-02-26 08:55:10 +00:00
|
|
|
void MetalinkParserStateMachine::setNameOfMetaurl(const std::string& name)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->setNameOfMetaurl(name);
|
2010-02-26 08:55:10 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 16:00:24 +00:00
|
|
|
void MetalinkParserStateMachine::commitMetaurlTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->commitMetaurlTransaction();
|
2010-02-25 16:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MetalinkParserStateMachine::cancelMetaurlTransaction()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
ctrl_->cancelMetaurlTransaction();
|
2010-02-25 16:00:24 +00:00
|
|
|
}
|
|
|
|
|
2009-10-03 12:52:16 +00:00
|
|
|
void MetalinkParserStateMachine::beginElement
|
2010-02-25 14:40:18 +00:00
|
|
|
(const std::string& localname,
|
|
|
|
const std::string& prefix,
|
|
|
|
const std::string& nsUri,
|
|
|
|
const std::vector<XmlAttr>& attrs)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.top()->beginElement(this, localname, prefix, nsUri, attrs);
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2009-10-03 12:52:16 +00:00
|
|
|
void MetalinkParserStateMachine::endElement
|
2010-02-25 14:40:18 +00:00
|
|
|
(const std::string& localname,
|
|
|
|
const std::string& prefix,
|
|
|
|
const std::string& nsUri,
|
|
|
|
const std::string& characters)
|
2007-12-04 11:12:56 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
stateStack_.top()->endElement(this, localname, prefix, nsUri, characters);
|
|
|
|
stateStack_.pop();
|
2007-12-04 11:12:56 +00:00
|
|
|
}
|
|
|
|
|
2008-04-26 07:43:01 +00:00
|
|
|
bool MetalinkParserStateMachine::needsCharactersBuffering() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return stateStack_.top()->needsCharactersBuffering();
|
2008-04-26 07:43:01 +00:00
|
|
|
}
|
|
|
|
|
2010-03-02 14:07:30 +00:00
|
|
|
void MetalinkParserStateMachine::logError(const std::string& log)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(errors_.size() < 10) {
|
|
|
|
errors_.push_back(log);
|
2010-03-02 14:07:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string MetalinkParserStateMachine::getErrorString() const
|
|
|
|
{
|
|
|
|
std::stringstream error;
|
|
|
|
error << "Specification violation: ";
|
2010-06-21 13:51:56 +00:00
|
|
|
std::copy(errors_.begin(), errors_.end(),
|
2010-03-02 14:07:30 +00:00
|
|
|
std::ostream_iterator<std::string>(error, ", "));
|
|
|
|
return error.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|