Commit Graph

393 Commits (d56dddd553f4fa75254f35beb388265573d02ce0)

Author SHA1 Message Date
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
Tatsuhiro Tsujikawa 458cc27462 2006-12-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To know root cause of exception:
	
	* src/Exception.h
	(cause): New variable.
	(Exception): Added a parameter.
	(getMsg): Return const reference to msg.
	(getCause): New function.
	* src/DlRetryEx.h
	(DlRetryEx): Added a parameter 'cause'.
	Added an overloaded constructor.
	(DlAbortEx): Added a parameter 'cause'.
	Added an overloaded constructor.
	* src/SimpleLogger.cc
	(writeLog): Log nested exception messages recursively.
2006-12-01 09:31:46 +00:00
Tatsuhiro Tsujikawa ff3ab41b18 2006-11-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/DefaultBtProgressInfoFile.cc
	(load): Fixed memory leak when the infohash doesn't match.
2006-11-28 11:33:43 +00:00
Tatsuhiro Tsujikawa c2686b1c50 2006-11-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/DefaultPeerStorage.cc
	(calculateStat): Simplified the code by combining 2 loops into 
1.
2006-11-12 13:57:55 +00:00
Tatsuhiro Tsujikawa b14e4a5ac1 To fix the bug that causes the number of bytes uploaded is not
saved
	to .aria2 file:

	* src/DefaultPeerStorage.h
	(removedPeerSessionDownloadLength): New variable.
	(removedPeerSessionUploadLength): New variable.
	* src/DefaultPeerStorage.cc
	(DefaultPieceStorage): Added 
removedPeerSessionDownloadLength(0),
	removedPeerSessionUploadLength(0).
	(calculateStat): Calculate the number of bytes 
downloaded(uploaded)
	through all peers, and then add 
removedPeerSessionDownloadLength(
	removedPeerSessionUploadLength) to it.
	(deleteUnusedPeer): Add the number of bytes downloaded(uploaded) 
from
	 (to) the peer to removedPeerSessionDownloadLength
	 (removedPeerSessionUploadLength).
2006-11-09 14:48:59 +00:00
Tatsuhiro Tsujikawa 9b48e350c6 Move setSignalHander to Util::setGlobalSignalHandler:
* src/TorrentRequestInfo.cc:
	setSignalHander -> Util::setGlobalSignalHandler
	* src/main.cc
	(setSignalHander): Removed.
	(main): setSignalHander -> Util::setGlobalSignalHandler
	* src/Util.h
	(setGlobalSignalHandler): New function.
	* src/Util.cc
	(setGlobalSignalHandler): New function.
	* src/UrlRequestInfo.cc:
	setSignalHander -> Util::setGlobalSignalHandler
2006-11-09 14:04:46 +00:00
Tatsuhiro Tsujikawa 3c1ecc7d30 2006-11-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Introduce new preference PREF_BT_TIMEOUT. This is the timeout 
value
	for BitTorrent download.

	* src/PeerAbstractCommand.cc
	(PeerAbstractCommand): PREF_TIMEOUT -> PREF_BT_TIMEOUT
	* src/main.cc: 
	(timeoutSpecified): Removed.
	(main): Set the initial value of PREF_BT_TIMEOUT to 180.
	Removed timeoutSpecified. TODO: Add --bt-timeout command line 
option.
	* src/TorrentRequestInfo.cc
	(timeoutSpecified): Removed.
	(torrentHandler): Removed timeoutSpecified and the change of 
timeout
	value.
	* src/prefs.h
	(PREF_BT_TIMEOUT): New definition.
	
	Delete unused variables.
	
	* src/TorrentRequestInfo.cc
	(requestInfo): Removed.
2006-11-09 13:51:36 +00:00
Tatsuhiro Tsujikawa 19c3a4204a 2006-11-08 16:32:00 +00:00
Tatsuhiro Tsujikawa 8d0ef717e1 2006-11-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add Metalink location option:
	
	* src/MetalinkRequestInfo.cc
	(execute): Call MetalinkEntry::setLocationPreference()
	* src/main.cc
	(showUsage): Added the help message for --metalink-location 
option.
	(main): Added --metalink-location option.
	* src/prefs.h
	(PREF_METALINK_LOCATION): New definition.
	* src/MetalinkEntry.cc
	(AddLocationPreference): New function object.
	(setLocationPreference): New function.
	* src/Xml2MetalinkProcessor.cc
	(getResource): Set location attribute to MetalinkResource

	To show URLs to download

	* src/UrlRequestInfo.h
	(printUrls): New function.

	To add multiple <file> Metalink support:

	* src/MetalinkEntry.h
	(MetalinkResources): Removed.
	(setLocationPreference): New function.
	(MetalinkEntryHandle): New type definition.
	(MetalinkEntries): New type definition.
	* src/Xml2MetalinkProcessor.h
	(getEntry): MetalinkEntry* -> MetalinkEntryHandle
	(getResource): MetalinkResource* -> MetalinkResourceHandle
	(parseFile): Metalinker* -> MetalinkerHandle
	* src/UrlRequestInfo.h
	(execute): RequestInfo* -> RequestInfos
	* src/MetalinkRequestInfo.cc
	(AccumulateNonP2PUrl): MetalinkResource* -> 
MetalinkResourceHandle
	(FindBitTorrentUrl): MetalinkResource* -> MetalinkResourceHandle
	(execute): RequestInfo* -> RequestInfos
	Added multiple <file> support. Print filename when it is queued.
	* src/MetalinkRequestInfo.h
	(execute): RequestInfo* -> RequestInfos
	(getDownloadEngine): Removed.
	* src/RequestInfo.h
	(RequestInfoHandle): New type definition.
	(RequestInfos): New type definition.
	(execute): RequestInfo* -> RequestInfos
	(getDownloadEngine): Removed.
	* src/MetalinkResource.h
	(MetalinkResourceHandle): New type definition.
	(MetalinkResources): New type definition.
	* src/MetalinkEntry.cc
	(~MetalinkEntry): Removed the deletion of the elements of 
resources,
	because the element is now of type MetalinkResourceHandle.
	(PrefOrder): MetalinkResource* -> MetalinkResourceHandle
	(Supported): MetalinkResource* -> MetalinkResourceHandle
	(dropUnsupportedResource): Removed the deletion of the elements 
of
	resources because the element is now of type 
MetalinkResourceHandle.
	* src/Xml2MetalinkProcessor.cc
	(parseFile): Metalinker* -> MetalinkerHandle
	MetalinkEntry* -> MetalinkEntryHandle
	Removed try-catch block.
	(getEntry): MetalinkEntry* -> MetalinkEntryHandle
	MetalinkResource* -> MetalinkResourceHandle
	Removed try-catch block.
	(getResource): MetalinkResource* -> MetalinkResourceHandle
	Free result by using xmlXPathFreeObject()
	* src/Metalinker.cc
	(~Metalinker): Removed the deletion of entries.
	MetalinkEntry* -> MetalinkEntryHandle
	(queryEntry): Add multiple <file> Metalink support.
	* src/Metalinker.h
	(MetalinkEntries): Removed.
	(queryEntry): MetalinkEntry* -> MetalinkEntries
	* src/MetalinkProcessor.h
	(parseFile): Metalinker* -> MetalinkerHandle
	
	Bug fixes:

	* src/PeerChokeCommand.cc
	(execute): cat01->cat02
	* src/DefaultPieceStorage.cc
	(DefaultPieceStorage): Added diskAdaptor(0)
	* src/TrackerWatcherComand.cc:
	(execute): Use btAnnounce->noMoreAnnounce()
	to determin whether the function returns true or not.
	* src/TrackerUpdateCommand.cc:
	(execute): Use btAnnounce->noMoreAnnounce()
	to determin whether the function returns true or not.
	* src/FtpConnection.cc
	(bulkReceiveResponse): Throw DlRetryEx if EOF got.
	This is the fix of the busy loop bug.
	* src/DownloadCommand.cc
	(DownloadCommand): Reuse PeerStat. segmentMan->getPeerStat() 
returns
	cached PeerStat.
	
	The value of "name" entry in torrent file is now set by
	*DiskAdaptor::setTopDir(...) methods.
	
	* src/MultiDiskAdaptor.h
	(topDir): New variable.
	(setTopDir): New function.
	(getTopDir): New function.
	* src/MultiDiskAdaptor.cc
	(getFilePath): Concat storDir, "/" and topDir.
	(mkdir): Use getFilePath() to get the directory path for output.
	* src/DefaultPieceStorage.cc
	(initStorage): Set the value of "name" entry to 
MultiDiskAdaptor,
	CopyDiskAdaptor.
	* src/CopyDiskAdaptor.h
	(topDir): New variable.
	(setTopDir): New function.
	(getTopDir): New function.
	* src/CopyDiskAdaptor.cc
	(fixFilename): Updated.
	
	Misc

	* src/UrlRequestInfo.h
	(e): Removed.
	(UrlRequestInfo): Removed e.
	(getDownloadEngine): Removed.
	* src/UrlRequestInfo.cc
	(handler): Rewritten.
	(printUrls): New function.
	(execute): Call printUrls().
	
	* src/HandshakeMessage.cc
	(check): peerinteraction->getBtContext() -> btContext

	* src/PeerInteraction.h
	(getBtContext): Removed.

	* src/TorrentRequestInfo.h
	(execute): RequestInfo* -> RequestInfos
	(getDownloadEngine): Removed.
	* src/TorrentRequestInfo.cc
	(haltRequested): Removed.
	(btHaltRequested): New variable.
	(torrentHandler): haltRequested -> btHaltRequested
	(execute): RequestInfo* -> RequestInfos
	* src/TorrentConsoleDownloadEngine.cc
	(afterEachIteration): haltRequested -> btHaltRequested.
	
	* src/ConsoleDownloadEngine.h
	(initStatistics): Added virtual.
	(calculateStatistics): Added virtual.
	(onEndOfRun): Added virtual.
	(afterEachIteration): Added virtual.
	* src/ConsoleDownloadEngine.cc
	(haltRequested): New variable.
	(afterEachIteration): New function.

	* src/main.cc
	(requestInfo): Removed.

	* src/SegmentMan.cc
	(findSlowerSegmentEntry): Refactored.
2006-11-08 16:25:38 +00:00
Tatsuhiro Tsujikawa 45463f935f 2006-11-05 15:12:36 +00:00
Tatsuhiro Tsujikawa ec642ad294 2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To divide TorrentMan into 6 classes: BtContext, BtRuntime,
	PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile

	* src/TrackerWatcherComand.h: Made subclass of 
BtContextAwareCommand.
	* src/SeedCheckCommand.cc: Use pieceStorage, btRuntime
	* src/PeerAbstractCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/PeerAbstractCommand.cc: Use btRuntime.
	* src/BtContextAwareCommand.h: New class.
	* src/FileEntry.h: Added accessor methods for following 
variables.
	(path): Made private.
	(length): Made private.
	(offset): Made private.
	(extracted): Made private.
	(requested): Made private.
	(FileEntries): New definition.
	(FileEntryHandle): New definition.
	* src/FileEntry.cc: New file.
	* src/HaveEraseCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/HaveEraseCommand.cc: Use btRuntime, pieceStorage.
	* src/PeerChokeCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/PeerChokeCommand.cc: Use btRuntime, peerStorage, 
pieceStorage.
	* src/PieceStorage.h: New file.
	* src/PeerInteractionCommand.h: Use btContext.
	* src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage,
	btRuntime.
	* src/DefaultBtProgressInfoFile.h: New file.
	* src/DefaultBtProgressInfoFile.cc: New file.
	* src/File.cc
	(Util.h): New include.
	(mkdirs): New function.
	* src/MultiDiskAdaptor.h
	(mkdir): New function.
	* src/PeerListProcessor.h
	(Peers): Removed.
	* src/PeerInteraction.h
	(torrentMan): Removed.
	(btContext): New variable.
	(peerStorage): New variable.
	(pieceStorage): New variable.
	(btAnnounce): New variable.
	(getTorrentMan): Removed.
	(getBtContext): New function.
	* src/PeerInteraction.cc: Use btContext, peerStorage, 
pieceStorage,
	btAnnounce.
	* src/HandshakeMessage.h
	(TorrentMan.h): Removed.
	* src/HandshakeMessage.cc: Use btContext.
	* src/DefaultBtAnnounce.cc: New file.
	* src/MultiDiskWriter.cc: Use the accessor methods of FileEntry.
	* src/DefaultPieceStorage.cc: New file.
	* src/DefaultBtContext.h: New file.
	* src/TorrentRequestInfo.cc: Use btContext, pieceStorage.
	Use the accessor methods of FileEntry.
	* src/CookieBox.cc: Updated to use Util::slice().
	* src/PieceMessage.cc: Use btContext, pieceStorage.
	* src/common.h (SharedHandle.h): New include.
	* src/PeerMessage.cc (PeerMessage): Added btContext, 
peerStorage,
	pieceStorage.
	* src/TorrentAutoSaveCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/DiskAdaptor.h
	(topDir): Removed.
	(getFileEntryFromPath): Changed the return type to 
FileEntryHandle.
	(setTopDir): Removed.
	(getTopDir): Removed.
	* src/BtContext.h: New file.
	* src/DefaultPeerStorage.h: New file.
	* src/PieceMessage.h (TorrentMan.h): Removed.
	* src/RequestMessage.h (TorrentMan.h): Removed.
	* src/TorrentDownloadEngine.h
	(uploadLength): New variable.
	(btContext): New variable.
	(btRuntime): New variable.
	(pieceStorage): New variable.
	(peerStorage): New variable.
	(btAnnounce): New variable.
	(btProgressInfoFile): New variable.
	(torrentMan): Removed.
	(setBtContext): New function.
	* src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, 
pieceStorage,
	peerStorage, btAnnounce, btProgressInfoFile.
	* src/Piece.h
	(toString): New function.
	(Pieces): New type definition.
	* src/Peer.h
	(active): New variable.
	(Peer): Added active.
	(activate): Set active to true.
	(deactivate): Set active to false.
	(isActive): New function.
	(Peers): New type definition.
	* src/DirectDiskAdaptor.cc
	(getFilePath): Use the accessor methods of FileEntry.
	* src/TorrentConsoleDownloadEngine.h
	(afterEachIteration): New function.
	* src/TorrentConsoleDownloadEngine.cc
	(haltRequested): New variable.
	(sendStatistics): Use pieceStorage, btRuntime.
	(afterEachIteration): New function.
	* src/AnnounceList: AnnounceTier->AnnounceTierHandle.
	* src/Directry.h
	(Directory): New function.
	(DirectoryHandle): New type definition.
	* src/BtProgressInfoFile.h: New file.
	* src/RequestMessage.cc: Use pieceStorage.
	* src/BtRuntime.h: New file.
	* src/DefaultBtContext.cc: New file.
	* src/BitfieldMan.h
	(getCompletedLength): New function(private).
	(getCompletedLength): New function.
	(getFilteredCompletedLength): New function.
	* src/BitfieldMan.h
	(getCompletedLength): New function(private).
	(getCompletedLength): New function.
	(getFilteredCompletedLength): New function.
	* src/MultiDiskAdaptor.cc
	(mkdir): New function.
	(openFile): Call mkdir().
	(initAndOpenFile): Call mkdir().
	* src/CancelMessage.h
	(TorrentMan.h): Removed.
	* src/RejectMessage.h
	(TorrentMan.h): Removed.
	* src/DownloadEngineFactory.cc
	(DefaultPieceStorage.h): New include.
	(DefaultPeerStorage.h): New include.
	(DefaultBtAnnounce.h): New include.
	(DefaultBtProgressInfoFile.h): New include.
	(newTorrentConsoleEngine): Rewritten.
	* src/ShareRatioSeedCriteria.h
	(torrentMan): Removed.
	(btContext): New variable.
	(peerStorage): New variable.
	(btRuntime): New variable.
	(evaluate): Use btContext, btRuntime, peerStorage.
	* src/AnnounceTier.h: New file.
	* src/BtAnnounce.h: New file.
	* src/BtRegistry.h: New file.
	* src/PeerInitiateConnectionCommand.h: Added btContext.
	* src/PeerConnection.h (TorrentMan.h): Removed.
	* src/PeerMessageFactory.cc: Use btContext, pieceStorage.
	* src/Util.h
	(slice): Added an argument.
	* src/Util.cc
	(slice): Added an argument to control whether trim is made or 
not.
	* src/PeerStorage.h: New file.
	* src/BtRegistry.cc: New file.
	* src/TrackerUpdateCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry.
	* src/MultiDiskWriter.h: FileEntry -> FileEntryHandle
	* src/PeerListenCommand.cc: Use btRuntime, peerStorage, 
btContext.
	* src/TorrentRequestInfo.h
	(e): Removed.
	(showFileEntry): Added an argument.
	(getDownloadEngine): Return 0.
	* src/DefaultBtAnnounce.h: New file.
	* src/TorrentAutoSaveCommand.cc: Use btRuntime, 
btProgressInfoFile.
	* src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce,
	* src/PeerMessageFactory.h
	(btContext): New variable.
	(pieceStorage): New variable.
	* src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, 
btContext,
	btAnnounce.
	* src/DiskAdaptor.cc
	(DiskAdaptor): Removed topDir.
	(~DiskAdaptor): Removed topDir.
	* src/PeerListenCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/SeedCheckCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/File.h (mkdirs): New function.
	* src/DefaultPeerStorage): New file.
	* src/DownloadEngineFactory.h
	(newTorrentConsoleEngine): Use btContext.
	* src/BtContextAwareCommand.cc: New file.
	* src/PeerInitiateConnectionCommand.cc: Use btRuntime, 
peerStorage.
	* src/PeerMessage.h
	(btContext): New variable.
	(peerStorage): New variable.
	(pieceStorage): New variable.
	(setBtContext): New function.
	* src/Directry.cc
	(Directory): New function.
	(createDir): Do nothing if name.size() == 0.
	* src/AnnounceList.h
	(AnnounceTier): Removed. 
	(AnnounceTiers): Removed.
	* src/DefaultPieceStorage.h: New file.
	* src/Piece.cc (toString): New function.
	
	To fix typo:
	
	* src/main.cc (showVersion): Fixed typo.

	To fix compile warning:
	
	* src/DelegatingPeerListProcessor.cc
	(canHandle): Added "return false".
2006-11-05 15:04:17 +00:00
Tatsuhiro Tsujikawa b8737b0e7c 2006-10-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To simplify TrackerWatherCommand, TrackerUpdateCommand and
	make the process of announce request testable.
	
	* src/TrackerWatcherCommand.h
	(TimeA2.h): Removed.
	(interval): Removed.
	(checkPoint): Removed.
	(createRequestCommand): Added an argument 'url'.
	(TrackerWatherCommand): Removed interval.
	(createCommand): New function.
	* src/DownloadEngineFactory.cc
	(newTorrentConsoleEngine): Updated according to the changes in
	TrackerWatherCommand.
	* src/TorrentMan.cc
	(DelegatingPeerListProcessor.h): New includes.
	(TorrentMan): Added the initialization of announceInterval.
	(isStoppedAnnounceReady): New function.
	(isCompletedAnnounceReady): New function.
	(isDefaultAnnounceReady): New function.
	(isAnnounceReady): New function.
	(getAnnounceUrl): New function.
	(announceStart): New function.
	(announceFailure): New function.
	(announceSuccess): New function.
	(isAllAnnounceFailed): New function.
	(resetAnnounce): New function.
	(processAnnounceResponse): New function.
	(needMorePeerConnection): New function.
	(noMoreAnnounce): New function.
	* src/TrackerUpdateCommand.h
	(getTrackerResponse): int->size_t
	* src/TorrentMan.h
	(isStoppedAnnounceReady): New function.
	(isCompletedAnnounceReady): New function.
	(isDefaultAnnounceReady): New function.
	(announceInterval): New variable.
	(isAnnounceReady): New function.
	(getAnnounceUrl): New function.
	(announceStart): New function.
	(announceFailure): New function.
	(announceSuccess): New function.
	(isAllAnnounceFailed): New function.
	(resetAnnounce): New function.
	(processAnnounceResponse): New function.
	(needMorePeerConnection): New function.
	(noMoreAnnounce): New function.
	* src/TrackerWatcherCommand.cc
	(TrackerWatherCommand): Removed interval and checkPoint.
	(execute): Rewritten.
	(createCommand): New function.
	(createRequestCommand): Rewritten.
	* src/TrackerUpdateCommand.cc
	(MetaFileUtil.h): Removed.
	(DelegatingPeerListProcessor.h): Removed.
	(getTrackerResponse): int->size_t. Use torrentMan's new 
functions.
2006-10-20 13:20:50 +00:00
Tatsuhiro Tsujikawa c0fd1fff2a 2006-10-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Request -> RequestHandle:
	
	* src/HttpResponseCommand.h: Request->RequestHandle
	* src/AbstractCommand.cc: Request->RequestHandle
	* src/HttpDownloadCommand.cc: Request->RequestHandle
	* src/HttpRequestCommand.cc: Request->RequestHandle
	* src/FtpInitiateConnectionCommand.h: Request->RequestHandle
	* src/AbstractCommand.h: Request->RequestHandle
	* src/HttpProxyRequestCommand.h: Request->RequestHandle
	* src/HttpResponseCommand.cc: Request->RequestHandle
	* src/HttpInitiateConnectionCommand.h: Request->RequestHandle
	* src/FtpNegotiateCommand.cc: Request->RequestHandle
	* src/FtpTunnelResponseCommand.h: Request->RequestHandle
	* src/HttpConnection.h: Request->RequestHandle
	* src/HttpProxyResponseCommand.cc: Request->RequestHandle
	* src/InitiateConnectionCommandFactory.h: Request->RequestHandle
	* src/FtpTunnelResponseCommand.cc: Request->RequestHandle
	* src/DownloadCommand.h: Request->RequestHandle
	* src/FtpDowndloadCommand.cc: Request->RequestHandle
	* src/HttpInitiateConnectionCommand.cc: Request->RequestHandle
	* src/HttpRequestCommand.h: Request->RequestHandle
	* src/FtpNegotiateCommand.h: Request->RequestHandle
	* src/FtpTunnelResponseCommand.cc: Request->RequestHandle
	* src/FtpInitiateConnectionCommand.cc: Request->RequestHandle
	* src/HttpDownloadCommand.h: Request->RequestHandle
	* src/FtpConnection.cc: Request->RequestHandle
	* src/InitiateConnectionCommandFactory.cc: 
Request->RequestHandle
	* src/UrlRequestInfo.cc: Request->RequestHandle
	* src/HttpProxyResponseCommand.h: Request->RequestHandle
	* src/HttpConnection.h: Request->RequestHandle
	* src/DownloadCommand.cc: Request->RequestHandle
	* src/FtpConnection.h: Request->RequestHandle
	* src/FtpDowndloadCommand.h: Request->RequestHandle
	* src/HttpProxyRequestCommand.cc: Request->RequestHandle
	* src/FtpTunnelRequestCommand.h: Request->RequestHandle
	* src/Request.h
	(SharedHandle.h): New include.
	(RequestHandle): New type definition.
	(Requests): Redefined.
	
	To add MULTITRACKER support:

	* src/TrackerWatcherCommand.h
	(createRequestCommand): New function.
	* src/DownloadEngineFactory.cc
	(newTorrentConsoleEngine): Removed req.
	* src/prefs.h
	(PREF_TRACKER_MAX_TRIES): New definition.
	* src/TorrentMan.cc
	(TorrentMan): Removed req. Added trackerNumTry.
	(~TorrentMan): Removed req.
	(setupInternal1): Added announceList.
	* src/TorrentRequestInfo.cc
	(execute): Set PREF_MAX_TIRES to 1. The max number of tries for
	announces is now specified by PREF_TRACKER_MAX_TRIES.
	* src/main.cc
	(main): Added PREF_TRACKER_MAX_TRIES.
	* src/TorrentMan.h
	(Request.h): Removed.
	(AnnounceList.h): New include.
	(trackerNumTry): New variable.
	(req): Removed.
	(announceList): New variable.
	* src/TrackerWatcherCommand.cc
	(execute): Rewritten.
	(createRequestCommand): New function.
	* src/TrackerUpdateCommand.cc
	(execute): Updated with the use of AnnounceList.
	* src/AnnounceList.cc: New class.
	* src/AnnounceList.h: New class.
	
	To fix typo:

	* src/prefs.h
	(PREF_MAX_TRIES): max_try->max_tries

	To not to decode "+" as space in URL decode:

	* src/Util.cc
	(urldecode): Removed "+"->space decoding rule. Test case was 
updated.
2006-10-18 14:57:00 +00:00
Tatsuhiro Tsujikawa c35b680825 2006-10-01 15:50:17 +00:00
Tatsuhiro Tsujikawa 98378a98c8 Added doc/Makefile.in 2006-10-01 14:16:14 +00:00
Tatsuhiro Tsujikawa d354e48441 Added man page 2006-10-01 14:11:29 +00:00
Tatsuhiro Tsujikawa 07e91896e1 2006-10-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add timeout to async name resolution:

	* src/AbstractCommand.h
	(nameResolveFinished): New function. This is not elegant way. It needs
	to be more refined.
	(nameResolverCheck): New variable.
	* src/AbstractCommand.cc
	(AbstractCommand): Added nameResolverCheck.
	(execute): Added the check whether the name resolution has finished.
	(setNameResolverCheck): Set nameResolverCheck to true.
	(disableNameResolverCheck): Set nameResolverCheck to false.
	(nameResolverFinished): New function.
	* src/FtpInitiateConnectionCommand.h
	(nameResolverFinished): New function.
	* src/HttpInitiateConnectionCommand.h
	(nameResolverFinished): New function.

	To add the support for a non-compact response from a tracker:

	* src/PeerListProcessor.h: New class.
	* src/DefaultPeerListProcessor.h: New class.
	* src/DefaultPeerListProcessor.cc: New class.
	* src/CompactPeerListProcessor.h: New class.
	* src/CompactPeerListProcessor.cc: New class.
	* src/DelegatingPeerListProcessor.h: New class.
	* src/DelegatingPeerListProcessor.cc: New class.	
	* src/TorrentMan.cc
	(addPeer): New function(overload).
	(addPeer): Delete unused peers only when new peer is added.
	* src/TorrentMan.h
	(PeerListProcessor.h): Included.
	(Peers): Removed.
	(addPeer): New function(overload).
	* src/TrackerUpdateCommand.cc
	(netinet/in.h): Removed.
	(DelegatingPeerListProcessor.h): Included.
	(execute): Updated to use DelegatingPeerListProcessor.
	
	To fix the memory leak in TorrentMan::peers:

	* src/PeerAbstractCommand.cc
	(onAbort): Added peer->resetStatus().
	* src/Peer.h
	(resetStatus): Made public.
	
	To improve the precision of the speed calculation:

	* src/SpeedCalc.h
	(nextInterval): New variable.
	* src/SpeedCalc.cc
	(reset): Added nextInterval.
	(isIntervalOver): Use nextInterval instead of CHANGE_INTERVAL_SEC.
	(changeSw): Set nextInterval to 15 seconds relative to the current
	instant time.

	* src/main.cc
	(showVersion): Updated.
2006-10-01 11:29:14 +00:00
Tatsuhiro Tsujikawa f7f1770633 2006-09-23 12:43:42 +00:00
Tatsuhiro Tsujikawa d10b0f36dc 2006-09-23 12:27:16 +00:00
Tatsuhiro Tsujikawa 93ff03c9e3 2006-09-23 12:06:58 +00:00
Tatsuhiro Tsujikawa c0a53bf3e8 2006-09-23 11:58:23 +00:00
Tatsuhiro Tsujikawa 1b5af8e829 2006-09-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/*.{h,cc}:
	Added an exception to the license which allows linking with 
OpenSSL.
2006-09-21 15:31:24 +00:00
Tatsuhiro Tsujikawa c973c83bac * src/prefs.h
(PREF_MAX_SPEED_LIMIT): Renamed as PREF_MAX_DOWNLOAD_LIMIT.
	(PREF_UPLOAD_LIMIT): Renamed as PREF_MAX_UPLOAD_LIMIT.

	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Use PREF_MAX_UPLOAD_LIMIT.
	(receiveMessages): Use PREF_MAX_DOWNLOAD_LIMIT.

	* src/PeerInteraction.cc
	(sendMessages): Use PREF_MAX_UPLOAD_LIMIT.

	* src/main.cc
	(showUsage): Updated the description of "--lowest-speed-limit" 
option.
	Added the description of "--max-download-limit" option.
	Removed the description of "--upload-limit" option.
	Added the description of "--max-upload-limit" option.
	(main): Use PREF_MAX_UPLOAD_LIMIT, PREF_MAX_DOWNLOAD_LIMIT.
	Added "--max-download-limit" option and "--max-upload-limit" 
option.
	Added the warning message if "--upload-limit" option is used.

	* src/DownloadCommand.cc
	(executeInternal): Use PREF_MAX_DOWNLOAD_LIMIT.
2006-09-21 14:37:15 +00:00
Tatsuhiro Tsujikawa 8b8325cafc * src/PeerChokeCommand.cc
(optUnchokingPeer): Updated according to the changes in Peer.
	(ResetDelta): Removed.
	(UploadFaster): Updated according to the changes in Peer.
	(DownloadFaster): Updated according to the changes in Peer.
	(execute): I clarify the meaning of "upload" and "download" 
here.
	"upload" means the transfer from localhost to remote host.
	"download" means the transfer from remote host to localhost.
	Based on this rule, I swapped orderByUploadRate and
	orderByDownloadRate.

	* src/PeerInteractionCommand.cc
	(PeerInteraction): Removed peerInteraction->setUploadLImit().
	(executeInternal): Removed the argument of
	peerInteraction->sendMessages().
	(receiveMessages): Rewritten download speed limit.
	(sendKeepAlive): Removed peerInteraction->sendMessages().

	* src/HttpResponseCommand.cc
	(handleDefaultEncoding): If file size is unknown in torrent 
request,
	do not call segmentMan->initBitfield() here.
	Disabled persistent connection feature in torrent request.

	* src/UrlRequestInfo.h
	(UrlRequestInfo): Removed const qualifier from option.

	* src/TorrentMan.h
	(TransferStat): New class.
	(deltaDownloadLength): Removed.
	(deltaUploadLength): Removed.
	(addDeltaDownloadLength): Removed.
	(getDeltaDownloadLength): Removed.
	(resetDeltaDownloadLength): Removed.
	(addDeltaUploadLength): Removed.
	(getDeltaUploadLength): Removed.
	(resetDeltaUploadLength): Removed.
	(addActivePeer): Added peer->activate().
	(deleteActivePeer): Added peer->deactivate().
	(calculateStat): New function.
	* src/TorrentMan.cc
	(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
	(calculateStat): New function.

	* src/PeerInteraction.h
	(uploadLimit): Removed.
	(option): New variable.
	(setUploadLimit): Removed.
	(getUploadSpeed): Removed.
	(sendMessages): Removed the argument "currentUploadSpeed".
	* src/PeerInteraction.cc
	(prefs.h): Included.
	(PeerInteraction): Removed uploadLimit. Added option.
	(sendMessages): Rewritten upload speed limit.
	(sendHandshake): Removed the argument from sendMessages().
	(sendBitfield): Removed the argument from sendMessages().

	* src/PeerAbstractCommand.cc
	(execute): Commented out the portion of upload limit.
	(onAbort): Removed peer->resetStatus().

	* src/TorrentRequestInfo.cc
	(timeoutSpecified): Declared extern.
	(execute): Set timeout to 180 if timeout is not specified by.
	command-line.

	* src/PieceMessage.cc
	(receivedAction): Added peer->updateDownloadLength().
	Removed peer->addPeerUpload().
	Removed torrentMan->addDeltaDownloadLength().
	(send): Added peer->updateUploadLength().
	Removed peer->addPeerDownload().
	Removed torrentMan->addDeltaUploadLength().

	* src/main.cc
	(timeoutSpecified): New variable.
	(main): Set timeoutSpecified to false.
	If the command-line option "--upload-limit" is specified, then
	timeoutSpecified is set to true. This option will remain in the 
next
	release, but be deprecated in the future release.

	* src/TorrentRequestInfo.h
	(TorrentRequestInfo): Removed const qualifier from op.

	* src/PeerStat.h
	(uploadSpeed): New variable.
	(PeerStat): Added default value to cuid.
	(calculateUploadSpeed): New function.
	(updateUploadLength): New function.
	(getMaxUploadSpeed): New function.
	(getAvgUploadSpeed): New function.
	(reset): Added uploadSpeed. Set status to IDLE.

	* src/TorrentDownloadEngine.h
	(cp): Declared as Time.
	(sessionDownloadLengthArray): Removed.
	(sessionUploadLengthArray): Removed.
	(currentCp): Removed.
	(lastCalcStat): New variable
	(lastElapsed): Removed.
	(sessionDownloadLength): Removed.
	(calculateStat): New function.
	* src/TorrentDownloadEngine.cc
	(initStatistics): Removed lastElapsed, cp[],
	sessionDownloadLengthArray[], sessionUploadLengthArray[],
	currentCp, sessionDownloadLength.
	Added cp.reset() and lastCalcStat.reset().
	(calculateSpeed): Changed the name of the argument.
	(calculateStatistics): Rewritten.
	(calculateStat): New function.

	* src/Peer.h
	(PeerStat.h): Included.
	(peerUpload): Removed.
	(peerDownload): Removed.
	(peerStat): New variable.
	(sessionUploadLength): New variable.
	(sessionDownloadLength): New variable.
	(deltaUpload): Removed.
	(deltaDownload): Removed.
	(resetStatus): Made private.
	(Peer): Added sessionUploadLength, sessionDownloadLength.
	Removed peerUpload, peerDownload.
	(updateUploadLength): New function.
	(addDeltaUpload): Removed.
	(updateDownloadLength): New function.
	(resetDeltaUpload): Removed.
	(getDeltaUpload): Removed.
	(addDeltaDownload): Removed.
	(calculateUploadSpeed): New function.
	(resetDeltaDownload): Removed.
	(getDeltaDownload): Removed.
	(calculateDownloadSpeed): New function.
	(getSessionUploadLength): New function.
	(getSessionDownloadLength): New function.
	(activate): New function.
	(deactivate): New function.
	(addPeerUpload): Removed.
	(setPeerUpload): Removed.
	(getPeerUpload): Removed.
	(addPeerDownload): Removed.
	(setPeerDownload): Removed.
	(getPeerDownload): Removed.
	
	* src/Peer.cc
	(resetStatus): Removed resetDeltaUpload() and 
resetDeltaDownload().
	
	* src/MetalinkRequestInfo.h
	(MetalinkRequestInfo): Removed const qualifier from op.

	* src/RequestInfo.h
	(op): Removed const qualifier.
	(RequestInfo): Removed const qualifier from op.
2006-09-21 13:49:06 +00:00
Tatsuhiro Tsujikawa 65e0ffe6ca 2006-09-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/AbstractCommand.cc
	(execute): Check whether the download has finished before 
checking
	socket status.
	Return true if peerStat->getStatus() == REQUEST_IDLE.
	Do not exit even if no segment is available.

	* src/prefs.h
	(PREF_STARTUP_IDLE_TIME): New definition.

	* src/PeerInteractionCommand.cc
	(executeInternal): Removed max speed limit. Because it performs 
bad.
	(receiveMessages): Added max speed limit. This was better than 
above,
	but still a little bit to be desired. Sometimes the download 
speed
	became much faster than I specified.

	* src/SpeedCalc.h
	(start): New variable.
	(accumulatedLength): New variable.
	(getAvgSpeed): New function.
	* src/SpeedCalc.cc
	(reset): Added start, accumulatedLength.
	(update): Added calculation of an average speed.
	(getAvgSpeed): New function.

	* src/DownloadCommand.h
	(sw): Removed.

	* src/main.cc
	(main): Added PREF_STARTUP_IDLE_TIME.

	* src/PeerStat.h
	(STATUS): Added REQUEST_IDLE.
	(getMaxSpeed): Renamed as getMaxDownloadSpeed().
	(getAvgDownloadSpeed): New function
	(requestIdle): New function.

	* src/SegmentMan.h
	(SegmentEntryHandle): New type definition.
	(SegmentEntries): Now holds SegmentEntryHandle.
	(findSlowerSegmentEntry): New funtion.
	* src/SegmentMan.cc
	(save): Updated according to the changes in SegmentEntries.
	(read): Updated according to the changes in SegmentEntries.
	(FindSegmentEntryByIndex): Updated according to the changes in
	SegmentEntries.
	(FindSegmentEntryByCuid): Updated according to the changes in
	SegmentEntries.
	(checkoutSegment): Updated according to the changes in 
SegmentEntries.
	(onNullBitfield): Updated according to the changes in 
SegmentEntries.
	Renamed uitr as itr.
	(findSlowerSegmentEntry): New function.
	(getSegment): Updated according to the changes in 
SegmentEntries.
	Added the feature that cancels the segment with slow server and 
fast
	one takes it over.
	(cancelSegment): Updated according to the changes in 
SegmentEntries.
	(getDownloadLength): Updated according to the changes in
	SegmentEntries.
	(init): Assigned 0 to bitfield after deleting it.
	
	* src/DownloadCommand.cc
	(STARTUP_IDLE_TIME): Removed.
	(executeInternal): Use PREF_STARTUP_IDLE_TIME.
2006-09-21 06:56:54 +00:00
Tatsuhiro Tsujikawa 2fb9b5be97 2006-09-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To rewrite segment download mechanism for HTTP/FTP download.
	Use BitfieldMan to manage segment download.
	* src/HttpResponseCommand.h
	(executeInternal): Pass the reference of segment.
	* src/AbstractCommand.cc
	(prepareForRetry): Call segmentMan->cancelSegment here.
	(onAbort): Call segmentMan->cancelSegment here.
	* src/HttpDownloadCommand.cc
	(prepareForNextSegment): New function.
	* src/DownloadEngineFactory.cc
	(newConsoleEngine): Removed splitter.
	(newTorrentConsoleEngine): Removed splitter.
	* src/Request.h
	(segment): Renamed from seg.
	* src/FtpInitiateConnectionCommand.h
	(executeInternal): Pass the reference of segment.
	* src/AbstractCommand.h
	(executeInternal): Pass the reference of segment.
	* src/pref.h
	(PREF_SEGMENT_SIZE): New definition.
	* src/HttpProxyRequestCommand.h
	(executeInternal): Pass the reference of segment.
	* src/HttpResponseCommand.cc
	(checkResponse): Allowed status 206 when a request range starts 
0.
	(handleDefaultEncoding): Rewritten the code related to Segment.
	(handleOtherEncoding): Rewritten the code related to Segment.
	* src/SegmentMan.h
	(SegmentEntry): New class.
	(SegmentEntries): New type definition.
	(bitfield): New variable.
	(usedSegmentEntries): New variable.
	(onNullBitfield): New function.
	(checkoutSegment): New function.
	(segments): Removed.
	(splitter): Removed.
	(unregisterId): Removed.
	(getSegment): New function(overload)
	(getDownloadedSize): Removed.
	(cancelSegment): New function.
	(completeSegment): New function.
	(initBitfield): New function.
	(hasSegment): New function.
	(getDownloadLength): New function.
	* src/BitfieldMan.h
	(getStartIndex): New function.
	(getEndIndex): New function.
	(getMissingUnusedIndex): New function(overload).
	(getSparseMissingUnusedIndex): New function.	
	* src/BitfieldMan.cc
	(getMissingIndexRandomly): Handle the last byte of bitfield 
properly.
	(getMissingUnusedIndex): New function(overload).
	(Range): New class.
	(getStartIndex): New function.
	(getEndIndex): New function.
	(getSparseMissingUnusedIndex): New function.
	(isBitSetInternal): Return false if the given index is less than 
0.
	* src/HttpInitiateConnectionCommand.h
	(executeInternal): Pass the reference of segment.
	* src/FtpNegotiateCommand.h
	(executeInternal): Pass the reference of segment.
	* src/FtpNegotiateCommand.cc
	(recvSize): Initialize bitfield here.
	* src/FtpTunnelResponseCommand.h
	(executeInternal): Pass the reference of segment.
	* src/HttpConnection.cc
	(createRequest): Rewritten range header processing.
	* src/DownloadCommand.h
	(executeInternal): Pass the reference of segment.
	(prepareForRetry): Removed.
	(prepareForNextSegment): Added an argument segment. Made it a 
virtual
	function.
	* src/main.cc
	(main): Set the initial value of PREF_SEGMENT_SIZE to 1MB.
	* src/SegmentMan.cc
	(SegmentMan): Added bitfield. Removed splitter.
	(~SegmentMan): Added bitfield. Removed splitter.
	(unregisterId): Removed.
	(getSegment): Rewritten.
	(updateSegment): Rewritten.
	(save): Rewritten.
	(read): Rewritten.
	(finished): Rewritten.
	(getDownloadedSize): Removed.
	(initBitfield): New function.
	(FindSegmentEntryByIndex): New function object.
	(FindSegmentEntryByCuid): New function object.
	(checkoutSegment): New function.
	(onNullBitfield): New function.
	(getSegment): New function(overload).
	(CancelSegment): New function object.
	(cancelSegment): New function.
	(completeSegment): New function.
	(hasSegment): New function.
	(getDownloadLength): New function.
	* src/FtpInitiateConnectionCommand.cc
	(executeInternal): Load .aria2 file after hostname resolution 
finishes.
	* src/Segment.h: Rewritten.
	* src/Segment.cc (operator<<): New function.
	* src/HttpDownloadCommand.h
	(prepareForNextSegment): New function.
	* src/Request.cc
	(resetUrl): Made segment null.
	* src/DownloadEngine.cc
	(~DownloadEngine): Call cleanQueue before deleting segmentMan.
	* src/HttpProxyRequestCommand.h
	(executeInternal): Pass the reference of segment.
	* src/DownloadCommand.cc
	(executeInternal): Rewritten the code related to Segment.
	(prepareForRetry): Removed.
	(prepareForNextSegment): Rewritten.
	* src/FtpTunnelResponseCommand.h
	(executeInternal): Pass the reference of segment.
	
	To add HTTP 1.1 persistent connection support(experimental)
	* src/HttpRequestCommand.cc
	(executeInternal): Disable keep alive if it is disabled by
	configuration.
	* src/Request.h
	(keepAlive): New variable.
	(isKeepAlive): New function.
	(setKeepAlive): New function.
	* src/pref.h
	(PREF_HTTP_KEEP_ALIVE): New definition.
	* src/HttpResponseCommand.cc
	(executeInternal): Check the remote server supports keep alive.
	* src/HttpConnection.cc
	(createRequest): Send "Connection: close" only if keep alive is
	disabled.
	* src/main.cc
	(main):
	Set the initial value(false) of PREF_KEEP_ALIVE to false.

	To add max download speed limit:
	* src/pref.h
	(PREF_MAX_SPEED_LIMIT): New definition.
	* src/PeerInteractionCommand.cc
	(executeInternal): Added max download speed limit. Not tested 
yet.
	* src/SegmentMan.h
	(PeerStats): New type definition.
	(peerStats): New variable.
	(registerPeerStat): New function.
	(FindPeerStat): New function object.
	(getPeerStat): New function.
	(calculateDownloadSpeed): New function.
	* src/SpeedCalc.h: New class.
	* src/SpeedCalc.cc: New class.
	* src/main.cc
	(main):
	Set the initial value of PREF_MAX_SPEED_LIMIT to 0(which means 
the
	download speed is not restricted).
	* src/PeerStat.h: New class.
	* src/SegmentMan.cc
	(registerPeerStat): New function.
	(calculateDownloadSpeed): New function.
	* src/DownloadCommand.cc
	(STARTUP_IDLE_TIME): New definition.
	(DownloadCommand): Register peerStat to segmentMan. Call 
peerStat->
	downloadStart.
	(~DownloadCommand): Call peerStat->downloadStop.
	(executeInternal): Added download speed limitter. Rewritten 
lowest
	speed limitter.

	* src/HttpConnection.cc
	(receiveResponse): Fixed: eohIndex[headerBuf] -> 
headerBuf[eohIndex].
	
	* src/AbstractCommand.cc
	(resolveHostname): Throw DlAbortEx if a name resolution failes.
	Added hostname to the error message.
	
	* src/ConsoleDownloadEngine.cc
	(calculateStatistics): Initialize psize with dlSize.

	* src/PieceMessage.cc
	(receivedAction): Do not call peerInteraction->abortPiece here.
	(onGotWrongPiece): Call peerInteraction->abortPiece here.

	* src/BitfieldMan.h
	(clearAllUseBit): New function.
	(setAllUseBit): New function.
	* src/BitfieldMan.cc
	(clearAllBit): Do not clear useBitfield here.
	(clearAllUseBit): New function.
	(setAllUseBit): New function.
	* src/Piece.cc
	(clearAllBlock): Call bitfield->clearAllUseBit().
2006-09-19 14:52:59 +00:00
Tatsuhiro Tsujikawa 1d52ba244e 2006-08-28 15:40:50 +00:00
Tatsuhiro Tsujikawa d63e6fb052 To fix a bug that caused assertion failure in ares_strerror:
* src/NameResolver.cc (callback): Fixed the bug.
2006-08-28 13:30:24 +00:00
Tatsuhiro Tsujikawa c096a3a553 2006-08-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To make filename URL-decoded:
	* src/HttpResponseCommand.h: Updated doc.
	* src/HttpResponseCommand.cc
	(determinFilename): Made filename URL-decoded.
	* src/FtpInitiateConnectionCommand.cc
	(executeInternal): Made filename URL-decoded.
	* src/Util.h (urldecode): New function.
	* src/Util.cc (urldecode): New function.
2006-08-28 12:40:41 +00:00
Tatsuhiro Tsujikawa 531d456950 2006-08-27 12:51:12 +00:00
Tatsuhiro Tsujikawa 3b2a98393e 2006-08-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add --seed-time and --seed-ratio command-line option:
	* src/Option.h (getAsDouble): New function.
	* src/Option.cc (getAsDouble): New function.
	* src/SeedCheckCommand.h: New class.
	* src/SeedCheckCommand.cc: New class.
	* src/DownloadEngineFactory.cc
	(SeedCheckCommand.h): Included.
	(UnionSeedCriteria.h): Included.
	(TimeSeedCriteria.h): Included.
	(ShareRatioSeedCriteria.h): Included.
	(newTorrentConsoleEngine): Added the processing of seed option.
	* src/SeedCriteria.h: New class.
	* src/ShareRatioSeedCriteria.h: New class.
	* src/TimeSeedCriteria.h: New class.
	* src/UnionSeedCriteria.h: New class.
	* src/prefs.h
	(PREF_SEED_TIME): New definition.
	(PREF_SEED_RATIO): New definition.
	* src/main.cc
	(showUsage): Added --seed-time and --seed-ratio option.
	(main): Added --seed-time and --seed-ratio option.
	Made default log file name "/dev/null".
	* src/SharedHandle.h
	(SharedHandle): Copy constructor. Made it assignable from the
	SharedHandle of the subclasses.
	(operator=): Made it assignable from the SharedHandle of the
	subclasses.
	(getRefCount): New function.
	
	To add notice log level and the switch to write log to stdout. 
This
	switch is configurable per log level.
	* src/Logger.h
	(notice): New function.
	(LEVEL): Added NOTICE. Assigned an explicit value to each log 
level
	constant.
	* src/LogFactory.cc
	(getInstance): The use of NullLogger was removed. A log message 
with
	notice log level was made written to stdout along with log file.
	* src/NullLogger.h
	(notice): New function.
	* src/SimpleLogger.h
	(writeHeader): Added the 'file' argument.
	(writeLog): Added the 'file' argument.
	(writeFile): New function.
	(stdoutField): New variable.
	(SimpleLogger): Removed the default constructor.
	(SimpleLogger): Made the default value of logfile 0.
	(debug): Added 'virtual' keyword.
	(info): Added 'virtual' keyword.
	(warn): Added 'virtual' keyword.
	(error): Added 'virtual' keyword.
	(notice): New function.
	(setStdout): New function.
	* src/SimpleLogger.cc
	(WRITE_LOG): Replaced writeLog with writeFile.
	(WRITE_LOG_EX): Replaced writeLog with writeFile.
	(SimpleLogger): Removed the default constructor.
	(setStdout): New function.
	(writeLog): Added the handling of NOTICE log level.
	(writeFile): New function.
	(notice): New function.

	* src/TorrentMan.h: Updated doc.

	* src/BitfieldMan.h: Updated doc.
	
	* src/TrackerWatcherCommand.cc
	(execute): Return true if error occurred in the request to the 
tracker
	and halt is requested.

	* src/TrackerUpdateCommand.cc
	(execute): Return true if error occurred in the request to the 
tracker
	and halt is requested.

	* src/TorrentConsoleDownloadEngine.h
	(onSelectiveDownloadingCompletes): Removed.
	* src/TorrentConsoleDownloadEngine.cc
	(onSelectiveDownloadingCompletes): Removed.
	* src/TorrentDownloadEngine.h
	(onEndOfRun): Added 'virtual' keyword.
	(afterEachIteration): Removed.
	(onSelectiveDownloadingCompletes): Removed.
	* src/TorrentDownloadEngine.cc
	(onEndOfRun): Removed filenameFixed.
	(afterEachIteration): Removed.	
	* src/TorrentMan.cc
	(completePiece): Call onDownloadComplete here.
	(onDownloadComplete): Added 2 log messages.
2006-08-27 12:49:17 +00:00
Tatsuhiro Tsujikawa e9f907fe1e 2006-08-21 15:04:49 +00:00
Tatsuhiro Tsujikawa b4237e5752 2006-08-21 14:36:20 +00:00
Tatsuhiro Tsujikawa e13e16f559 2006-08-21 14:35:22 +00:00
Tatsuhiro Tsujikawa f45ad3b5d9 This is release 0.7.2 2006-08-21 14:34:42 +00:00
Tatsuhiro Tsujikawa 0c4ade346c 2006-08-21 14:31:18 +00:00
Tatsuhiro Tsujikawa 35f5dbb642 Fixed src/Makefile.am 2006-08-21 14:29:14 +00:00
Tatsuhiro Tsujikawa 23c323c1fc Added @LIBCARES_LIBS@ and @LIBCARES_CPPFLAGS@ in src/Makefile.am 2006-08-21 14:26:15 +00:00
Tatsuhiro Tsujikawa c3f7478a6e 2006-08-21 14:01:59 +00:00
Tatsuhiro Tsujikawa ded48c43f2 Added m4/libcares.m4 2006-08-21 13:54:15 +00:00
Tatsuhiro Tsujikawa fda031576c 2006-08-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix the bug that causes compilation failure with 
metalink-support
	disabled(bug#1543587):

	* src/main.cc: Fixed with the patch by tizianomueller.
2006-08-21 13:31:49 +00:00
Tatsuhiro Tsujikawa 4def45feb2 2006-08-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix compilation problem on gcc4.1.1(patch#1542283 by 
tizianomueller)
	* src/NameResolver.h: Added the prototype declaration of 
callback().
	
	To support c-ares library:
	
	* src/AbstractCommand.cc: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/FeatureConfig.cc: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/FtpInitiateConnectionCommand.h:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/AbstractCommand.h: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/HttpInitiateConnectionCommand.h:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/NameResolver.cc: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/HttpInitiateConnectionCommand.cc:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/FtpInitiateConnectionCommand.cc:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/DownloadEngine.h:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/DownloadEngine.cc:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
2006-08-21 13:18:51 +00:00
Tatsuhiro Tsujikawa 29d1723996 2006-08-14 15:19:11 +00:00
Tatsuhiro Tsujikawa 11dc664f83 2006-08-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/FeatureConfig.cc
	(FEATURE_ASYNC_DNS): New definition.
	(FeatureConfig): Added aysnc DNS entry.

	To replace CommandUuid with Command* in SocketEntry and
	NameResolverEntry:
	
	* src/DownloadEngine.h
	(CommandUuids): Removed.
	(SocketEntry::commandUuid): Removed.
	(SocketEntry::command): New variable.
	(SocketEntry::SocketEntry): Updated.
	(SocketEntry::operator==): Updated.
	(NameResolverEntry::commandUuid): Removed.
	(NameResolverEntry::command): New variable.
	(NameResolverEntry::NameResolverEntry): Updated.
	(NameResolverEntry::operator==): Updated.
	(waitData): Changed the argument type.
	(addSocketForReadCheck): Changed the argument type.
	(deleteSocketForReadCheck): Changed the argument type.
	(addSocketForWriteCheck): Changed the argument type.
	(deleteSocketForWriteCheck): Changed the argument type.
	(addNameResolverCheck): Changed the argument type.
	(deleteNameResolverCheck): Changed the argument type.
	* src/DownloadEngine.cc
	(FindCommand): Removed.
	(run): Removed activeUuid. Added activeCommands instead.
	(AccumulateActiveUuid): Renamed as AccumulateActiveCommand.
	(AccumulateActiveCommand): New function object.
	(waitData): Use AccumulateActiveCommand.
	(addSocketForReadCheck): Use Command instead of CommandUuid.
	(deleteSocketForReadCheck): Use Command instead of CommandUuid.
	(addSocketForWriteCheck): Use Command instead of CommandUuid.
	(deleteSocketForWriteCheck): Use Command instead of CommandUuid.
	(addNameResolverCheck): Use Command instead of CommandUuid.
	(deleteNameResolverCheck): Use Command instead of CommandUuid.	
	* src/AbstractCommand.cc
	(disableReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(disableWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setNameResolverCheck): Updated according to the changes in
	DownloadEngine.
	(disableNameResolverCheck): Updated according to the changes in
	DownloadEngine.
	* src/AbstractCommand.cc
	(disableReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(disableWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setWriteCheckSocket): Updated according to the changes in
	DownloadEngine.

	* release 0.7.1
2006-08-14 15:03:38 +00:00
Tatsuhiro Tsujikawa e3b0153e85 2006-08-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/main.cc
	(main): Added a message to inform users that aria2 is starting 
to
	verify checksum.
	* src/RequestInfo.cc
	(printDownloadAbortMessage): Added a message to inform users 
that
	transfer can be resumed.

2006-08-12  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	To handle the case where some BitTorrent tracker requires all 
letters
	except for [A-Za-z0-9] is URL encoded.
	
	* src/Util.h
	(torrentUrlencode): New function.
	* src/Util.cc
	(ctype.h): Included.
	(torrentUrlencode): New function.
	* src/TrackerWatcherCommand.cc
	(execute): Use Util::torrentUrlencode() instead of 
Util::urlencode().
2006-08-14 11:38:28 +00:00
Tatsuhiro Tsujikawa f2d4faad08 2006-08-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add asynchronous DNS support(libares):

	* src/AbstractCommand.h
	(setNameResolverCheck): New function.
	(disableNameResolverCheck): New function
	(resolveHostname): New function.
	* src/AbstractCommand.cc
	(setNameResolverCheck): New function.
	(disableNameResolverCheck): New function
	(resolveHostname): New function.
	* src/FtpInitiateConnectionCommand.h
	(nameResolver): New function.
	* src/FtpInitiateConnectionCommand.cc
	(Util.h): Included.
	(FtpInitiateConnectionCommand): Call disableReadCheckSocket,
	disableWriteCheckSocket.
	(~FtpInitiateConnectionCommand): Call disableNameResolverCheck.
	(executeInternal): Added async DNS support.
	* src/HttpInitiateConnectionCommand.h
	(nameResolver): New function.
	* src/HttpInitiateConnectionCommand.cc
	(DlRetryEx.h): Included.
	(HttpInitiateConnectionCommand): Call disableReadCheckSocket,
	disableWriteCheckSocket.
	(~HttpInitiateConnectionCommand): Call disableNameResolverCheck.
	(executeInternal): Added async DNS support.
	* src/NameResolver.h: New class. Note: #include <ares.h> is 
surrounded
	by extern "C" declaration.
	* src/NameResolver.cc: New class.
	* src/Util.h:
	(isNumberAndDotsNotation): New function
	* src/Util.cc
	(isNumberAndDotsNotation): New function.
	* src/DownloadEngine.h
	(NameResolver.h): Included.
	(NameResolverEntry): New class.
	(NameResolverEntries): New type definition.
	(addNameResolverCheck): New function.
	(deleteNameResolverCheck): New function.
	* src/DownloadEngine.cc
	(run): Initialize cp with 0.
	(SetDescriptor::operator()): Added for NameResolverEntry.
	(AccumulateActiveUuid::operator()): Added for NameResolverEntry.
	(waitData): Check nameResolver entries.
	(updateFdSet): Update fds in nameResolver entries.
	(addNameResolverCheck): New function.
	(deleteNameResolverCheck): new function.
	
	* src/PeerInteractionCommand.cc
	(executeInternal): Fixed wrong socket handling.

	* src/main.cc
	(main): Fixed the initial value of PREF_LOWEST_SPEED_LIMIT 
option to 0.

	* src/Util.cc
	(fileChecksum): Removed the call to ctx.digestReset().
2006-08-11 12:29:55 +00:00
Tatsuhiro Tsujikawa 7ca1b43edd 2006-08-08 14:09:13 +00:00
Tatsuhiro Tsujikawa 19a21795e0 * src/FtpNegotiateCommand.cc
(recvGreeting): Call disableWriteCheckSocket just after
	socket->setBlockingMode(). This avoids unnecessary CPU-hog loop.
	(recvRetr): Recognized status code 125 as a acceptable response 
code.
2006-08-07 17:21:09 +00:00
Tatsuhiro Tsujikawa d0068e5a9c Added src/Command.cc 2006-08-07 16:57:14 +00:00
Tatsuhiro Tsujikawa 8b8e769aaa Updated doc 2006-08-07 16:47:52 +00:00