Commit Graph

22 Commits (20b7c8cd0e058ba74bc311c855db6111726276ef)

Author SHA1 Message Date
Tatsuhiro Tsujikawa ca4940622c 2010-06-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Changed naming standards for class member variable: now it looks
	like var_ instead of _var.
2010-06-21 13:51:56 +00:00
Tatsuhiro Tsujikawa c342bde962 2010-02-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use vector instead of deque for containers which is used for
	mostly read-only purpose.
2010-02-28 12:30:11 +00:00
Tatsuhiro Tsujikawa 4db349c1f3 2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Untabify. Fixed one line in copyright which is longer than 80
	columns.
	* src
	* test
2010-01-05 16:01:46 +00:00
Tatsuhiro Tsujikawa 7b63e121c7 2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use dynamic_pointer_cast
	* test/BtPieceMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/DefaultBtRequestFactoryTest.cc
2009-11-15 13:25:44 +00:00
Tatsuhiro Tsujikawa 5699b67526 2009-06-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten DownloadContext and removed SingleFileDownloadContext
	and BtContext and its derived classes. BitTorrent specific
	attributes are now set by DownloadContext::setAttribute() with key
	bittorrent::BITTORRENT.
	* src/AbstractBtMessage.cc
	* src/AbstractBtMessage.h
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/AbstractProxyRequestCommand.cc
	* src/AbstractProxyResponseCommand.cc
	* src/ActivePeerConnectionCommand.cc
	* src/ActivePeerConnectionCommand.h
	* src/AnnounceList.cc
	* src/BtCheckIntegrityEntry.cc
	* src/BtConstants.h
	* src/BtContext.h: Removed
	* src/BtDependency.cc
	* src/BtExtendedMessage.cc
	* src/BtPieceMessage.cc
	* src/BtPieceMessage.h
	* src/BtPostDownloadHandler.cc
	* src/BtRegistry.cc
	* src/BtRegistry.h
	* src/BtSetup.cc
	* src/CheckIntegrityCommand.cc
	* src/CheckIntegrityEntry.cc
	* src/ChecksumCheckIntegrityEntry.cc
	* src/ConsoleStatCalc.cc
	* src/ContentTypeRequestGroupCriteria.cc
	* src/DHTGetPeersCommand.cc
	* src/DHTGetPeersCommand.h
	* src/DHTPeerLookupTask.cc
	* src/DHTPeerLookupTask.h
	* src/DHTTaskFactory.h
	* src/DHTTaskFactoryImpl.cc
	* src/DHTTaskFactoryImpl.h
	* src/DefaultBtAnnounce.cc
	* src/DefaultBtAnnounce.h
	* src/DefaultBtContext.cc: Removed
	* src/DefaultBtContext.h: Removed
	* src/DefaultBtInteractive.cc
	* src/DefaultBtInteractive.h
	* src/DefaultBtMessageDispatcher.cc
	* src/DefaultBtMessageDispatcher.h
	* src/DefaultBtMessageFactory.cc
	* src/DefaultBtMessageFactory.h
	* src/DefaultBtMessageReceiver.cc
	* src/DefaultBtMessageReceiver.h
	* src/DefaultBtProgressInfoFile.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/DefaultExtensionMessageFactory.cc
	* src/DefaultExtensionMessageFactory.h
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/DefaultPieceStorage.cc
	* src/DefaultSegmentManFactory.cc
	* src/DiskAdaptor.cc
	* src/DiskAdaptor.h
	* src/DownloadContext.cc
	* src/DownloadContext.h
	* src/DownloadEngine.cc
	* src/DownloadEngineFactory.cc
	* src/DownloadHandler.cc
	* src/DownloadResult.h
	* src/FileAllocationCommand.cc
	* src/FileAllocationDispatcherCommand.cc
	* src/FileAllocationEntry.cc
	* src/FileEntry.h
	* src/FillRequestGroupCommand.cc
	* src/FtpDownloadCommand.cc
	* src/FtpFinishDownloadCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/FtpTunnelRequestCommand.cc
	* src/FtpTunnelResponseCommand.cc
	* src/HandshakeExtensionMessage.cc
	* src/HandshakeExtensionMessage.h
	* src/HaveEraseCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpProxyRequestCommand.cc
	* src/HttpProxyResponseCommand.cc
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpRequestCommand.cc
	* src/HttpResponseCommand.cc
	* src/HttpServerBodyCommand.cc
	* src/HttpServerCommand.cc
	* src/HttpSkipResponseCommand.cc
	* src/InitiateConnectionCommandFactory.cc
	* src/InitiatorMSEHandshakeCommand.cc
	* src/InitiatorMSEHandshakeCommand.h
	* src/IteratableChecksumValidator.cc
	* src/IteratableChecksumValidator.h
	* src/IteratableChunkChecksumValidator.cc
	* src/MSEHandshake.cc
	* src/MSEHandshake.h
	* src/Makefile.am
	* src/Makefile.in
	* src/Metalink2RequestGroup.cc
	* src/MetalinkPostDownloadHandler.cc
	* src/MultiDiskAdaptor.cc
	* src/MultiDiskAdaptor.h
	* src/MultiFileAllocationIterator.cc
	* src/MultiUrlRequestInfo.cc
	* src/PeerChokeCommand.cc
	* src/PeerChokeCommand.h
	* src/PeerInitiateConnectionCommand.cc
	* src/PeerInitiateConnectionCommand.h
	* src/PeerInteractionCommand.cc
	* src/PeerInteractionCommand.h
	* src/PeerReceiveHandshakeCommand.cc
	* src/PieceHashCheckIntegrityEntry.cc
	* src/RealtimeCommand.cc
	* src/ReceiverMSEHandshakeCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupEntry.cc
	* src/RequestGroupMan.cc
	* src/SeedCheckCommand.cc
	* src/SeedCheckCommand.h
	* src/SegmentMan.cc
	* src/ShareRatioSeedCriteria.h
	* src/SingleFileDownloadContext.cc: Removed
	* src/SingleFileDownloadContext.h: Removed
	* src/SleepCommand.cc
	* src/StreamCheckIntegrityEntry.cc
	* src/TrackerWatcherCommand.cc
	* src/TrackerWatcherCommand.h
	* src/UnknownLengthPieceStorage.cc
	* src/Util.cc
	* src/Util.h
	* src/XmlRpcMethodImpl.cc
	* src/bittorrent_helper.cc
	* src/bittorrent_helper.h
	* src/download_helper.cc
	* src/main.cc
	* src/option_processing.cc
	* test/BitfieldManTest.cc
	* test/BittorrentHelperTest.cc
	* test/BtCancelMessageTest.cc
	* test/BtChokeMessageTest.cc
	* test/BtDependencyTest.cc
	* test/BtPieceMessageTest.cc
	* test/BtPostDownloadHandlerTest.cc
	* test/BtRegistryTest.cc
	* test/BtRejectMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/DHTPeerAnnounceStorageTest.cc
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtContextTest.cc: Removed
	* test/DefaultBtMessageDispatcherTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/DirectDiskAdaptorTest.cc
	* test/DownloadContextTest.cc
	* test/DownloadHandlerFactoryTest.cc
	* test/DownloadHelperTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/HttpRequestTest.cc
	* test/HttpResponseTest.cc
	* test/IteratableChecksumValidatorTest.cc
	* test/IteratableChunkChecksumValidatorTest.cc
	* test/MSEHandshakeTest.cc
	* test/Makefile.am
	* test/Makefile.in
	* test/Metalink2RequestGroupTest.cc
	* test/MetalinkPostDownloadHandlerTest.cc
	* test/MockBtContext.h: Removed
	* test/MockDHTTaskFactory.h
	* test/MockDownloadContext.h: Removed
	* test/MockPieceStorage.h
	* test/MultiDiskAdaptorTest.cc
	* test/MultiFileAllocationIteratorTest.cc
	* test/RequestGroupManTest.cc
	* test/RequestGroupTest.cc
	* test/SegmentManTest.cc
	* test/ShareRatioSeedCriteriaTest.cc
	* test/SingleFileDownloadContextTest.cc: Removed
	* test/UtilTest.cc
	* test/XmlRpcMethodTest.cc
2009-06-28 10:37:15 +00:00
Tatsuhiro Tsujikawa 7cf589e784 2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Made BtRegistry non-static object. Now DownloadEngine has a
	reference to its object.
	* src/AbstractBtMessage.cc
	* src/ActivePeerConnectionCommand.cc
	* src/ActivePeerConnectionCommand.h
	* src/BtContextAwareCommand.cc
	* src/BtContextAwareCommand.h
	* src/BtExtendedMessage.cc
	* src/BtExtendedMessage.h
	* src/BtInterestedMessage.cc
	* src/BtInterestedMessage.h
	* src/BtNotInterestedMessage.cc
	* src/BtNotInterestedMessage.h
	* src/BtRegistry.cc
	* src/BtRegistry.h
	* src/BtSeederStateChoke.cc
	* src/BtSetup.cc
	* src/DHTGetPeersCommand.cc
	* src/DHTGetPeersCommand.h
	* src/DHTPeerAnnounceEntry.cc
	* src/DHTPeerAnnounceEntry.h
	* src/DHTPeerAnnounceStorage.cc
	* src/DHTPeerAnnounceStorage.h
	* src/DHTPeerLookupTask.cc
	* src/DHTPeerLookupTask.h
	* src/DHTSetup.cc
	* src/DHTSetup.h
	* src/DHTTaskFactory.h
	* src/DHTTaskFactoryImpl.cc
	* src/DHTTaskFactoryImpl.h
	* src/DefaultBtAnnounce.cc
	* src/DefaultBtInteractive.cc
	* src/DefaultBtInteractive.h
	* src/DefaultBtMessageDispatcher.cc
	* src/DefaultBtMessageDispatcher.h
	* src/DefaultBtMessageFactory.cc
	* src/DefaultBtMessageFactory.h
	* src/DefaultBtMessageReceiver.cc
	* src/DefaultBtProgressInfoFile.cc
	* src/DefaultBtProgressInfoFile.h
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/DefaultExtensionMessageFactory.cc
	* src/DefaultExtensionMessageFactory.h
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/DownloadEngine.cc
	* src/DownloadEngine.h
	* src/InitiatorMSEHandshakeCommand.cc
	* src/InitiatorMSEHandshakeCommand.h
	* src/MSEHandshake.cc
	* src/MSEHandshake.h
	* src/Makefile.am
	* src/Makefile.in
	* src/PeerChokeCommand.cc
	* src/PeerChokeCommand.h
	* src/PeerInitiateConnectionCommand.cc
	* src/PeerInitiateConnectionCommand.h
	* src/PeerInteractionCommand.cc
	* src/PeerInteractionCommand.h
	* src/PeerObject.h
	* src/PeerReceiveHandshakeCommand.cc
	* src/PeerReceiveHandshakeCommand.h
	* src/ReceiverMSEHandshakeCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupMan.cc
	* src/RequestGroupMan.h
	* src/SeedCheckCommand.cc
	* src/SeedCheckCommand.h
	* src/ShareRatioSeedCriteria.h
	* src/SimpleBtMessage.cc
	* src/TrackerWatcherCommand.cc
	* src/TrackerWatcherCommand.h
	* src/UTPexExtensionMessage.cc
	* src/UTPexExtensionMessage.h
	* test/BtCancelMessageTest.cc
	* test/BtChokeMessageTest.cc
	* test/BtExtendedMessageTest.cc
	* test/BtInterestedMessageTest.cc
	* test/BtNotInterestedMessageTest.cc
	* test/BtPieceMessageTest.cc
	* test/BtPortMessageTest.cc
	* test/BtRegistryTest.cc
	* test/BtRejectMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/DHTPeerAnnounceEntryTest.cc
	* test/DHTPeerAnnounceStorageTest.cc
	* test/DefaultBtMessageDispatcherTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/MSEHandshakeTest.cc
	* test/MockDHTTaskFactory.h
	* test/ShareRatioSeedCriteriaTest.cc
	* test/UTPexExtensionMessageTest.cc
2008-11-03 06:49:02 +00:00
Tatsuhiro Tsujikawa 67767e2f61 2008-09-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that a block in a piece is requested when same 
block is
	already requested to the same peer in end game mode.
	* src/BtRequestFactory.h
	* src/DefaultBtInteractive.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/DefaultPieceStorage.cc
	* src/DefaultPieceStorage.h
	* src/PieceStorage.h
	* src/UnknownLengthPieceStorage.cc
	* src/UnknownLengthPieceStorage.h
	* test/DefaultBtRequestFactoryTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/MockBtRequestFactory.h
	* test/MockPieceStorage.h
2008-09-19 14:11:41 +00:00
Tatsuhiro Tsujikawa dfe2f99345 2008-06-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Filled up pieces based on the number of missing blocks, rather 
than
	simplay the number of piece * block length.
	* src/BtRequestFactory.h
	* src/DefaultBtInteractive.cc
	* src/DefaultBtInteractive.h
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/Piece.cc
	* src/Piece.h
	* test/BitfieldManTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/MockBtRequestFactory.h
2008-06-17 11:43:29 +00:00
Tatsuhiro Tsujikawa ddd1206b42 2008-05-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed method signature:
	BtRequestFactory::createRequestMessages,
	BtRequestFactory::createRequestMessagesOnEndGame
	* src/BtRequestFactory.h
	* src/DefaultBtInteractive.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* test/DefaultBtRequestFactoryTest.cc
	* test/MockBtRequestFactory.h
2008-05-12 10:54:36 +00:00
Tatsuhiro Tsujikawa 3505201f33 2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten SharedHandle. Now copy constructor taking raw pointer 
has
	keyword explicit and SharedHandle's default constructor 
initializes
	its internal obj to null, old implementation initializes it 
using
	obj's default constructor.
	To assign null, write SharedHandle<T> x(...); x.reset();
	TODO: test/SharedHandleTest.cc needs more tests.
	* src/SharedHandle.h
2008-04-20 00:50:22 +00:00
Tatsuhiro Tsujikawa 032c7c2808 2008-03-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
type cleanup for allmost all remaining files.
2008-03-09 12:24:01 +00:00
Tatsuhiro Tsujikawa 518a200d57 2008-03-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Type clarification: size_t for length or size, uint64_t for file
	length, off_t for file offset.

	* src/PiecedSegment.cc
	* src/GrowSegment.h
	* src/DefaultBtRequestFactory.h
	* src/DefaultBtProgressInfoFile.cc
	* src/UnknownLengthPieceStorage.h
	* src/DefaultPieceStorage.cc
	* src/UnknownLengthPieceStorage.cc
	* src/DefaultBtInteractive.cc
	* src/GrowSegment.cc
	* src/BitfieldMan.h
	* src/DownloadCommand.cc
	* src/BtRequestFactory.h
	* src/PiecedSegment.h
	* src/DefaultPieceStorage.h
	* src/Piece.cc
	* src/DefaultBtRequestFactory.cc
	* src/PieceStorage.h
	* src/Segment.h
	* src/Piece.h
	* src/BitfieldMan.cc
	* src/Util.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/MockPieceStorage.h
	* test/BtRequestMessageTest.cc
	* test/DefaultBtMessageDispatcherTest.cc
	* test/BitfieldManTest.cc
	* test/GrowSegmentTest.cc
	* test/PieceTest.cc
	* test/SegmentTest.cc
	* test/SegmentManTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/MockBtRequestFactory.h
2008-03-08 08:04:28 +00:00
Tatsuhiro Tsujikawa c064a2cd9e 2008-02-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Extract the Peer class's member variables, which are only needed 
after
	PeerInteractionCommand, into PeerSessionResource class.
	This class is instantiated in PeerInteractionCommand class's 
ctor and
	released in its dtor.
	This will make Peer class lightweight and uses less memory for 
peers
	which are not connected and wait in the queue.
	* src/PeerChokeCommand.cc
	* src/PeerSessionResource.{h, cc}
	* src/PeerInteractionCommand.cc
	* src/PeerAbstractCommand.cc: Note: 0 is given to onAbort() 
function.
	* src/DefaultBtInteractive.cc
	* src/BtPieceMessage.cc
	* src/BtInterestedMessage.cc
	* src/BtUnchokeMessage.cc
	* src/DefaultPeerStorage.{h, cc}
	* src/PeerInitiateConnectionCommand.cc
	* src/ActivePeerConnectionCommand.cc
	* src/BtNotInterestedMessage.cc
	* src/DefaultBtMessageDispatcher.cc
	* src/BtChokeMessage.cc
	* src/BtRequestMessage.cc
	* src/Peer.{h, cc}
	* src/BtRegistry.h
	* src/TrackerWatcherCommand.cc
	* src/PeerReceiveHandshakeCommand.cc
	* test/BtExtendedMessageTest.cc
	* test/BtAllowedFastMessageTest.cc
	* test/BtCancelMessageTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/BtBitfieldMessageTest.cc
	* test/BtHaveMessageTest.cc
	* test/BtNotInterestedMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/PeerSessionResourceTest.cc
	* test/DefaultBtMessageDispatcherTest.cc
	* test/PeerTest.cc
	* test/BtInterestedMessageTest.cc
	* test/BtRejectMessageTest.cc
	* test/BtChokeMessageTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/BtHaveNoneMessageTest.cc
	* test/BtHaveAllMessageTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/BtUnchokeMessageTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/UTPexExtensionMessageTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/BtPieceMessageTest.cc
	
	Removed typedef PeerStats.
	* src/PeerStat.h
	* src/SegmentMan.cc
2008-02-09 17:14:40 +00:00
Tatsuhiro Tsujikawa 1b7c198289 2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: 
prefix to c++
	standard classes.
	Included string.h where mem* function are used.
2008-02-08 15:53:45 +00:00
Tatsuhiro Tsujikawa e39f7a7e9c 2007-12-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Allocate bitfield in Peer when it is really used. More 
specifically,
	bitfield in Peer is allocated after the connection is 
established and
	deallocated when the connection is dropped.
	Since 2 parameters(piece length and total length) was removed 
from the
	constructor of Peer class, many test classes were modified 
accordingly.
	See svn log for more detailed information.
	* src/PeerInteractionCommand.cc
	* src/CompactPeerListProcessor.cc
	* src/Peer.cc
	* src/DefaultPeerListProcessor.cc
	* src/PeerListenCommand.cc
	* src/PeerReceiveHandshakeCommand.cc

	Fixed memory leak
	* src/Piece.cc
2007-12-26 14:26:55 +00:00
Tatsuhiro Tsujikawa 048a2cf597 2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented BitTorrent/http/ftp integrated download.
	I've rewritten lots of files and now some headers have forward
	class declarations to reduce compile time.
	The implementation is extremely alpha stage, I recommend to use this
	for testing purpose only.
2007-10-11 16:58:24 +00:00
Tatsuhiro Tsujikawa 3cc1ed5e09 2007-08-10 Ross Smith II <aria2spam at smithii dot com>
gcc 3.4.4 support:
	* src/DefaultBtContext.cc: int32_t -> int
	* src/main.cc: int -> int32_t, int32_t -> int
	* src/messageDigest.h: uint32_t -> unsigned int
	* src/NameResolver.h: int32_t -> int
	* src/PeerConnection.cc: int -> int32_t
	* src/SpeedCalc.cc: int32_t -> int
	* src/TrackerUpdateCommand.h: int -> int32_t
	* src/Util.cc: int32_t -> int
	* src/Util.h: int32_t -> int
	* src/Xml2MetalinkProcessor.cc: int -> uint32_t, int64_t -> 
uint64_t
	* test/AnnounceListTest.cc: int -> int32_t
	* test/ChunkedEncodingTest.cc: int -> int32_t
	* test/DataTest.cc: int -> int32_t
	* test/DefaultBtRequestFactoryTest.cc: int -> int32_t
	* test/DefaultPeerListProcessorTest.cc: int -> int32_t
	* test/DefaultPieceStorageTest.cc: int -> int32_t
	* test/FeatureConfigTest.cc: int -> int32_t
	* test/MetalinkEntryTest.cc: int -> int32_t
	* test/MockBtRequestFactory.h: int -> int32_t
	* test/MockPieceStorage.h: int -> int32_t
	* test/OptionTest.cc: int -> int32_t
	* test/RequestTest.cc: int -> int32_t
	* test/SegmentManTest.cc: int -> int32_t
	* test/Xml2MetalinkProcessorTest.cc: int -> int32_t
2007-08-15 15:11:01 +00:00
Tatsuhiro Tsujikawa e85f9ccfd6 2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
	of message digest. Removed repeated code.
	The message digest algorithm is now specified by string, like 
"sha1",
	"md5".
	* src/messageDigest.{h, cc}
	* src/MessageDigestHelper.{h, cc}: New class.
	* src/DefaultPieceStorage.cc
	* src/DefaultBtContext.{h, cc}
	(computeFastSet): New function.
	(setInfoHash): Added for unit testing.
	(setNumPieces): Added for unit testing.
	* src/DefaultBtInteractive.cc
	* src/BtPieceMessage.cc
	* src/Peer.cc
	* src/Checksum.h
	* src/message.h
	* src/IteratableChecksumValidator.h
	* src/ChunkChecksumValidator.{h, cc}: Use 
IteratableChecksumValidator
	inside it.
	* src/SegmentMan.{h, cc}
	(checkIntegrity): Removed.
	* src/IteratableChunkChecksumValidator.{h, cc}
	* src/Util.h
	(sha1Sum): Removed.
	(simpleMessageDigest): Removed.
	(fileChecksum): Removed.
	(computeFastSet): Removed.
	* src/ShaVisitor.cc
	* src/ChunkChecksum.h
	* src/DownloadCommand.cc

	Removed messageDigest virtual functions.
	* src/MultiDiskAdaptor.{h, cc}
	* src/DiskAdaptor.h
	* src/ByteArrayDiskWriter.h
	* src/DiskWriter.h
	* src/DiskAdaptorWriter.h
	* src/AbstractSingleDiskAdaptor.{h, cc}
	* src/AbstractDiskWriter.{h, cc}
	
	Fixed comilation error when message digest is disabled.
	* src/MetalinkEntry.{h, cc}
	* src/MetalinkRequestInfo.cc
	
	Removed srandom and random.
	* src/SimpleRandomizer.h

	Added size() virtual function to DiskAdaptor
	* src/MultiDiskAdaptor.h

	Fixed the bug that causes that files are not opened correctly in
	multi-file torrent.
	* src/TorrentRequestInfo.cc
	* src/MultiDiskAdaptor.cc
	
	Added SHA256 support
	* src/messageDigest.cc
	* src/Xml2MetalinkProcessor.cc

	Show supported message digest algorithms
	* src/main.cc

	Updated contact info.
	* src/main.cc
2007-08-08 14:40:11 +00:00
Tatsuhiro Tsujikawa a98caece59 Fixed unittest error 2007-07-23 14:53:39 +00:00
Tatsuhiro Tsujikawa a1df7a762e 2007-01-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To decrease CPU usage in bittorrent download, calculation 
results in
	BitfieldMan were cached and realtime fetching PeerObject was 
removed
	with WeakHandle introduced. Option values are set to the objects
	by setter before download begins.

	* src/DefaultBtRequestFactory.cc: Use messageFactory member.
	* src/DefaultBtRequestFactory.h
	(dispatcher): BtMessageDispatcherHandle ->
	BtMessageDispatcherWeakHandle.
	(messageFactory): New variable.
	(setBtMessageDispatcher): BtMessageDispatcherHandle ->
	BtMessageDispatcherWeakHandle.
	(setBtMessageFactory): New function.
	* src/DefaultBtMessageDispatcher.cc:
	(sendMessages): Use maxUploadSpeedLimit instead of fetching the 
value
	from Option.
	(checkRequestSlotAndDoNecessaryThing): Use requestTimeout 
instead of
	feating the value from Option.
	Use messageFactory member.
	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Added maxDownloadSpeedLimit.
	Add reverse dependencies to factory object.
	Set maxUploadSpeedLimit and requestTimeout and messageFactory to
	dispatcher.
	Set messageFactory to receiver.
	Set keepAliveInterval and maxDownloadSpeedLimit and 
messageFactory to
	btInteractive.
	Set receiver to peerObject.
	Set maxDownloadSpeedLimit to this.
	(executeInternal): Use maxDownloadSpeedLimit member.
	* src/BtChokeMessage.cc
	(doReceivedAction): Use dispatcher, requestFactory member.
	(onSendComplete): Use dispatcher member.
	* src/PeerInteractionCommand.h
	(maxDownloadSpeedLimit): New variable.
	* src/DefaultBtMessageReceiver.h
	(peerConnection): PeerConnectionHandle -> 
PeerConnectionWeakHandle
	(dispatcher):
	BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
	(messageFactory): New variable.
	(setPeerConnection): PeerConnectionHandle -> 
PeerConnectionWeakHandle
	(getPeerConnection): PeerConnectionHandle -> 
PeerConnectionWeakHandle
	(setDispatcher):
	BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
	(setBtMessageFactory): New function.
	* src/DefaultBtInteractive.cc
	(initiateHandshake): Use messageFactory member.
	(addBitfieldMessageToQueue): Use messageFactory member.
	(addAllowedFastMessageToQueue): Use messageFactory member.
	(decideChoking): Use messageFactory member.
	(checkHave): Use messageFactory member.
	(sendKeepAlive): Use keepAliveInterval, messageFactory member.
	(receiveMessages): Use maxDownloadSpeedLimit member.
	(decideInterest): Use messageFactory member.
	* src/BtRequestMessage.cc
	(doReceivedAction): Use messageFactory, dispatcher member.
	(onQueued): Use dispatcher member.
	* src/BtPieceMessage.cc
	(doReceivedAction): Use dispatcher member.
	(send): Use peerConnection member.
	(onWrongPiece): Use requestFactory member.
	(handleChokingEvent): Use messageFactory, dispatcher member.
	(handleCancelSendingPieceEvent): Use messageFactory, dispatcher 
member.
	* src/BtMessageDispatcher.h
	(BtMessageDispatcherWeakHandle): New type definition.
	* src/SimpleBtMessage.cc
	(send): Use peerConnection member.
	* src/BtRejectMessage.cc
	(doReceivedAction): Use dispatcher member.
	* src/DefaultBtMessageDispatcher.h
	(Option.h): Removed include.
	(messageFactory): New variable.
	(option): Removed.
	(maxUploadSpeedLimit): New variable.
	(requestTimeout): New variable.
	(DefaultBtMessageDispatcher): Removed option.
	Added maxUploadSpeedLimit, requestTimeout.
	(setOption): Removed.
	(getOption): Removed.
	(setMaxUploadSpeedLimit): New function.
	(setRequestTimeout): New function.
	(setBtMessageFactory): New function.
	* src/DefaultBtInteractive.h
	(btMessageReceiver):
	BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
	(dispatcher):
	BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
	(btRequestFactory):
	BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
	(peerConnection):
	PeerConnectionHandle -> PeerConnectionWeakHandle
	(messageFactory): New variable.
	(option): Removed.
	(keepAliveInterval): New variable.
	(maxDownloadSpeedLimit): New variable.
	(DefaultBtInteractive): Added keepAliveInterval, 
maxDownloadSpeedLimit.
	(setBtMessageReceiver):
	BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
	(setDispatcher):
	BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
	(setBtRequestFactory):
	BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
	(setPeerConnection):
	PeerConnectionHandle -> PeerConnectionWeakHandle
	(setOption): Removed.
	(setKeepAliveInterval): New function.
	(setMaxDownloadSpeedLimit): New function.
	(setBtMessageFactory): New function.
	* src/BitfieldMan.h
	(cachedNumMissingBlock): New variable.
	(cachedNumFilteredBlock): New variable.
	(cachedCompletedLength): New variable.
	(cachedFilteredComletedLength): New variable.
	(cachedFilteredTotalLength): New variable.
	(countMissingBlockNow): New function.
	(countFilteredBlockNow): New function.
	(getFilteredTotalLengthNow): New function.
	(getCompletedLengthNow): New function.
	(getFilteredCompletedLengthNow): New function.
	(updateCache): New function.
	* src/AbstractBtMessage.h
	(BtMessageDispatcher.h): New include.
	(PeerConnection.h): New include.
	(BtRequestFactory.h): New include
	(BtMessageFactory.h): New include.
	(dispatcher): New variable.
	(messageFactory): New variable.
	(peerConnection: New variable.
	(setBtMessageDispatcher): New function.
	(setPeerConnection): New function.
	(setBtMessageFactory): New function.
	(setBtRequestFactory): New function.
	* src/DefaultBtMessageFactory.cc
	(setCommonProperty): Set dispatcher, requestFactory, this,
	peerConnection to msg.
	* src/BtRegistry.h
	(BT_MESSAGE_RECEIVER): New macro.
	* src/PeerConnection.h
	(PeerConnectionWeakHandle): New type definition.
	* src/BtMessageFactory.h
	(BtMessageFactoryWeakHandle): New type definition.
	* src/BitfieldMan.cc
	(BitfieldMan): Added cachedNumMissingBlock, 
cachedNumFilteredBlock,
	cachedCompletedLength, cachedFilteredComletedLength,
	cachedFilteredTotalLength.
	Call updateCache().
	(countMissingBlock): Return cachedNumMissingBlock.
	(countMissingBlockNow): New function.
	(countBlock): Return cachedNumFilteredBlock if filterEnabled is 
true.
	(countFilteredBlockNow): New function.
	(setBit): Call updateCache().
	(unsetBit): Call updateCache().
	(setBitfield): Call updateCache().
	(clearAllBit): Call updateCache().
	(setAllBit): Use setBitInternal instead of setBit.
	Call updateCache().
	(addFilter): Call updateCache().
	(enableFilter): Call updateCache().
	(disableFilter): Call updateCache().
	(clearFilter): Call updateCache().
	(getFilteredTotalLength): Return cachedFilteredTotalLength.
	(getFilteredTotalLengthNow): New function.
	(getCompletedLength): Return cachedCompletedLength.
	(getCompletedLengthNow): New function.
	(getFilteredCompletedLength): Return 
cachedFilteredComletedLength.
	(getFilteredCompletedLengthNow): New function.
	(updateCache): New function.
	* src/BtMessageReceiver.h
	(BtMessageReceiverWeakHandle): New type definition.
	* src/DefaultBtMessageReceiver.cc
	(receiveHandshake): Use messageFactory member.
	(sendHandshake): Use messageFactory member.
	(receiveMessage): Use messageFactory member.
	* src/DefaultBtMessageFactory.h
	(dispatcher): New variable.
	(requestFactory): New variable.
	(peerConnection): New variablle.
	(setBtMessageDispatcher): New function.
	(setBtRequestFactory): New function.
	(setPeerConnection): New function.
	* src/SharedHandle.h
	(RefCount): New class.
	(WeakHandle): New class.
	* src/PeerObject.h
	(BtMessageReceiver.h): New include.
	(PeerObject): Added btMessageReceiver.
	(btMessageReceiver): New variable.
	* src/Util.cc
	(countBit): Simplified.
	* src/BtCancelMessage.cc
	(doReceivedAction): Use dispatcher member.
	* src/BtRequestFactory.h
	(BtRequestFactoryWeakHandle): New type definition.
	
	* src/PeerStorage.h
	(downloadSpeed): int -> uint32_t
	(uploadSpeed): int -> uint32_t
	(sessionDownloadLength): long long int -> uint64_t
	(sessionUploadLength): long long int -> uint64_t
2007-01-16 15:20:26 +00:00
Tatsuhiro Tsujikawa a413cb50f7 2006-12-24 15:55:59 +00:00
Tatsuhiro Tsujikawa 9c3e8fbd9c 2006-12-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten a portion of bittorrent implementation:
	
	* src/BtMessageValidator.h: New class.
	* src/BtBitfieldMessageValidator.h: New class.
	* src/BtHandshakeMessageValidator.h: New class.
	* src/BtRequestMessageValidator.h: New class.
	* src/BtSuggestPieceMessageValidator.h: New class.
	* src/BtAllowedFastMessageValidator.h: New class.
	* src/BtRejectMessageValidator.h: New class.
	* src/BtCancelMessageValidator.h: New class.
	* src/BtPieceMessageValidator.h: New class.
	* src/BtHaveMessageValidator.h: New class.
	* src/BtEventListener.h: New class.
	* src/AbstractBtEventListener.h: New class.
	* src/BtEvent.h: New class.
	* src/BtChokingEvent.h: New class.
	* src/BtChokedEvent.h: New class.
	* src/BtCancelSendingPieceEvent.h: New class.
	* src/BtAbortOutstandingRequestEvent.h: New class.
	* src/Randomizer.h: New class.
	* src/SimpleRandomizer.h: New class.
	* src/BtMessage.h: New class.
	* src/AbstractBtMessage.h: New class.
	* src/SimpleBtMessage.h: New class.
	* src/BtHaveMessage.h: New class.
	* src/BtInterestedMessage.h: New class.
	* src/BtAllowedFastMessage.h: New class.
	* src/BtUnchokeMessage.h: New class.
	* src/BtCancelMessage.h: New class.
	* src/BtNotInterestedMessage.h: New class.
	* src/BtChokeMessage.h: New class.
	* src/BtHaveNoneMessage.h: New class.
	* src/BtHandshakeMessage.h: New class.
	* src/BtSuggestPieceMessage.h: New class.
	* src/BtHaveMessage.h: New class.
	* src/BtPieceMessage.h: New class.
	* src/BtHaveAllMessage.h: New class.
	* src/BtKeepAliveMessage.h: New class.
	* src/BtPortMessage.h: New class.
	* src/BtRejectMessage.h: New class.
	* src/BtBitfieldMessage.h: New class.
	* src/BtRequestMessage.h: New class.
	* src/DefaultBtRequestFactory.h: New class.
	* src/DefaultBtMessageReceiver.h: New class.
	* src/BtInteractive.h: New class.
	* src/BtMessageDispatcher.h: New class.
	* src/DefaultBtMessageDispatcher.h: New class.
	* src/DefaultBtInteractive.h: New class.
	* src/BitfieldManFactory.h: New class.
	* src/HandleRegistry.h: New class.
	* src/BtMessageFactory.h: New class.
	* src/BtMessageReceiver.h: New class.
	* src/DefaultBtMessageFactory.h: New class.
	* src/PeerObject.h: New class.
	* src/BtRequestFactory.h: New class.
2006-12-24 06:25:21 +00:00