aria2/test/MockBtContext.h
Tatsuhiro Tsujikawa cd91e2ea4f 2007-01-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Xml2MetalinkProcessor.h
	(xpathExists): New function.
	* src/Xml2MetalinkProcessor.cc
	(xpathExists): New function.

	Not to send HEAD request if filename and size are available in 
Metalink
	file:
	* src/UrlRequestInfo.h
	(filename): New variable.
	(totalLength): New variable.
	(setTotalLength): New function.
	(setFilename): New function.
	* src/MetalinkRequestInfo.cc
	(execute): Set filename and size to UrlRequestInfo.
	* src/MetalinkEntry.cc
	(MetalinkEntry): Initialize size with 0.
	* src/UrlRequestInfo.cc
	(execute): Set filename and size to SegmentMan.
	
	Not to download rest of the files after selected files are 
downloaded
	in BitTorrent:
	* src/PieceStorage.h
	(allDownloadFinished): New function.
	* src/DefaultBtAnnounce.cc
	(isCompleteAnnounceReady): Use allDownloadFinished instead of
	downloadFinished.
	(getAnnounceUrl): Use allDownloadFinished instead of 
downloadFinished.
	* src/DefaultPieceStorage.cc
	(completePiece): Use allDownloadFinished instead of 
downloadFinished.
	Commented out the call to finishSelectiveDownloadingMode().
	(downloadFinished): Call isFilteredAllBitSet() instead of
	isAllBitSet().
	(allDownloadFinished): New function.
	* src/DefaultBtInteractive.cc
	(addBitfieldMessageToQueue): Call allDownloadFinished() instead 
of
	downloadFinished().
	(checkHave): Call allDownloadFinished() instead of 
downloadFinished().
	* src/TorrentDownloadEngine.cc
	(onEndOfRun): Call allDownloadFinished() instead of 
downloadFinished().
	* src/BitfieldMan.h
	(isFilteredAllBitSet): New function.
	* src/ShareRatioSeedCriteria.h
	(PieceStorage.h): New include.
	(pieceStorage): New variable.
	(evaluate):
	btContext->getTotalLength() -> 
pieceStorage->getCompletedLength()
	* src/BitfieldMan.cc
	(isFilteredAllBitSet): New function.
	(isAllBitSet): Filter is not took into account.
	
	Rename --force-truncate as --allow-overwrite:
	* src/TorrentRequestInfo.cc
	(execute): PREF_FORCE_TRUNCATE -> PREF_ALLOW_OVERWRITE
	* src/main.cc
	(showUsage): --force-truncate -> --allow-overwrite
	* src/message.h
	(EX_FILE_ALREADY_EXISTS): --force-truncate -> --allow-overwrite
	* src/prefs.h
	(PREF_FORCE_TRUNCATE): Removed.
	(PREF_ALLOW_OVERWRITE): New definition.
	* src/SegmentMan.cc
	(shouldCancelDownloadForSafety): --force-truncate -> 
--allow-overwrite
	
	* src/MetalinkRequestInfo.cc
	(execute): Queueing message are now logged in info level.

	* src/common.h
	(LONG_LONG_MAX): Removed.
	(LONG_LONG_MIN): Removed.
	* src/HttpResponseCommand.cc
	(handleDefaultEncoding): LONG_LONG_MAX -> INT64_MAX
	* src/FtpNegotiateCommand.cc
	(recvSize): LONG_LONG_MAX -> INT64_MAX
	
	* src/main.cc
	(showUsage): Added --check-integiry and 
--realtime-chunk-checksum
	command-line option.
	(main): Added --check-integiry and --realtime-chunk-checksum
	command-line option.
	--force-truncate -> --allow-overwrite
	Set initial value of --check-integrity option to false.
	Don't show usage when error occurs while persing command-line 
options.
	Removed deprecated --upload-limit option.
2007-01-28 14:18:35 +00:00

125 lines
2.5 KiB
C++

#ifndef _D_MOCK_BT_CONTEXT_H_
#define _D_MOCK_BT_CONTEXT_H_
#include "BtContext.h"
#include "Util.h"
class MockBtContext : public BtContext {
private:
unsigned char infoHash[20];
Strings pieceHashes;
int64_t totalLength;
FILE_MODE fileMode;
string name;
int32_t pieceLength;
int32_t numPieces;
unsigned char peerId[20];
FileEntries fileEntries;
AnnounceTiers announceTiers;
public:
MockBtContext():totalLength(0),
pieceLength(0),
numPieces(0) {}
virtual ~MockBtContext() {}
virtual const unsigned char* getInfoHash() const {
return infoHash;
}
void setInfoHash(const unsigned char* infoHash) {
memcpy(this->infoHash, infoHash, sizeof(this->infoHash));
}
virtual int32_t getInfoHashLength() const {
return sizeof(infoHash);
}
virtual string getInfoHashAsString() const {
return Util::toHex(infoHash, sizeof(infoHash));
}
virtual string getPieceHash(int32_t index) const {
return pieceHashes.at(index);
}
virtual const Strings& getPieceHashes() const {
return pieceHashes;
}
void addPieceHash(const string pieceHash) {
pieceHashes.push_back(pieceHash);
}
virtual int64_t getTotalLength() const {
return totalLength;
}
void setTotalLength(int64_t length) {
this->totalLength = length;
}
virtual FILE_MODE getFileMode() const {
return fileMode;
}
void setFileMode(FILE_MODE fileMode) {
this->fileMode = fileMode;
}
virtual FileEntries getFileEntries() const {
return fileEntries;
}
void addFileEntry(const FileEntryHandle& fileEntry) {
fileEntries.push_back(fileEntry);
}
virtual AnnounceTiers getAnnounceTiers() const {
return announceTiers;
}
void addAnnounceTier(const AnnounceTierHandle& announceTier) {
announceTiers.push_back(announceTier);
}
virtual void load(const string& torrentFile) {}
virtual string getName() const {
return name;
}
void setName(const string& name) {
this->name = name;
}
virtual int32_t getPieceLength() const {
return pieceLength;
}
void setPieceLength(int32_t pieceLength) {
this->pieceLength = pieceLength;
}
virtual int32_t getNumPieces() const {
return numPieces;
}
void setNumPieces(int32_t numPieces) {
this->numPieces = numPieces;
}
virtual const unsigned char* getPeerId() {
return peerId;
}
void setPeerId(const unsigned char* peerId) {
memcpy(this->peerId, peerId, sizeof(this->peerId));
}
};
typedef SharedHandle<MockBtContext> MockBtContextHandle;
#endif // _D_MOCK_BT_CONTEXT_H_