Commit Graph

116 Commits (c63ceff5dd1ac7bca6aa0f447c2b7648ee16cb5a)

Author SHA1 Message Date
Tatsuhiro Tsujikawa 928465b7bc 2006-07-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentMan.h:
	(advertisePiece): Updated doc.
	(getAdvertisedPieceIndexes): Updated doc.
	(removeAdvertisedPiece); New function.
	
	* src/TorrentMan.cc
	(FindElapsedHave): New function object.
	(removeAdvertisedPiece): New function.

	* src/HaveEraseCommand.h: New class.
	* src/HaveEraseCommand.cc: New class.

	* src/FeatureConfig.h: New class.
	* src/FeatureConfig.cc: New class.
	
	* src/Request.h
	(defaultPorts): Removed.
	* src/Request.cc
	(FeatureConfig.h): Included.
	(Request): Removed the statements related to defaultPorts.
	(parseUrl): Removed metalinkEnabled. Use FeatureConfig instead.
	A default port number is now retrieved from FeatureConfig.
	
	* src/main.cc
	(HaveEraseCommand.h): Included.
	(showVersion): Added the output of feature list.
	(main): Added HaveEraseCommand to command queue in BitTorrent
	downloading.
	
	* src/PeerInteractionCommand.h
	(chokeCheckPoint): Commented out.
	(periodicExecPoint): New variable.
	* src/PeerInteractionCommand.cc
	(executeInternal): Following methods are now called in at least 
every
	0.5 seconds to reduce CPU usage:
	detectMessageFlooding(), peerInteraction->checkRequestSlot(),
	checkHave(), sendKeepAlive().
	(checkLongTimePeerChoking): Commented out.

	* src/BitfieldMan.h
	(getNthBitIndex): Changed the method signature.
	(getMissingIndexRandomly): Changed the method signature.
	* src/BitfieldMan.cc
	(getNthBitIndex): Rewritten
	(getMissingIndexRandomly): Rewritten.
	(hasMissingPiece): Rewritten.
	(getMissingIndex): Refactored.
	(getMissingUnusedIndex); Refactored.
	(getMissingIndex): Refactored.
2006-07-30 12:58:27 +00:00
Tatsuhiro Tsujikawa 31cf446f6d 2006-07-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To improve the conditional compilation:

	* src/MultiDiskWriter.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.	
	* src/MultiDiskWriter.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/Util.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	Added ENABLE_BITTORRENT around computeFastSet().
	* src/Util.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	Added ENABLE_BITTORRENT around computeFastSet().	
	* src/messageDigest.h:
	Replaced ENABLE_BITTORRENT with ENABLE_SSL.
	* src/ShaVisitor.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/ShaVisitor.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/main.cc:
	Added ENABLE_BITTORRENT around includes and blocks related to
	BitTorrent.
	* src/AbstractDiskWriter.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/AbstractDiskWriter.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	
	To add command-line options for Metalink:

	* src/main.cc:
	Added metalink-version, metalink-language, metalink-os,
	follow-metalink.

	To use EXIT_SUCCESS and EXIT_FAILURE with exit():

	* src/main.cc: Use these definition.
2006-07-04 10:57:56 +00:00
Tatsuhiro Tsujikawa 78eff23254 2006-07-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add Metalink support(http/ftp only):

	* src/AbstractCommand.h
	(tryReserved): New function.
	* src/AbstractCommand.cc
	(execute): Call tryReserved().
	(tryReserved): New function.
	* src/Request.h
	(Requests): New type definition.
	* src/SegmentMan.h
	(reserved): New variable.
	* src/Util.h
	(fileChecksum): New function.
	(toUpper): New function.
	(toLower): New function.
	* src/Util.cc
	(messageDigest.h): Included.
	(trim): Trim \r\n\t.
	(fileChecksum): New function.
	(toUpper): New function.
	(toLower): New function.
	* src/main.cc
	(normalDownload): New function.
	(main): Added 2 command-line options: metalink-file,
	metalink-connection. Their usage has not been written yet.
	* src/MetalinkProcessor.h: New class.
	* src/Xml2MetalinkProcessor.h: New class.
	* src/Xml2MetalinkProcessor.cc: New class.
	* src/MetalinkEntry.h: New class.
	* src/MetalinkEntry.cc: New class.
	* src/MetalinkResource.h: New class.
	* src/MetalinkResource.cc: New class.
	
	To add md5 message digest checking:

	* src/messageDigest.h: Rewritten.
	* src/MultiDiskWriter.cc: Updated according to the changes in
	messageDigest.h.
	* src/ShaVisitor.cc: Updated according to the changes in
	messageDigest.h.
	* src/Util.cc: Updated according to the changes in 
messageDigest.h.
	* src/AbstractDiskWriter.cc: Updated according to the changes in
	messageDigest.h.
	
	To fix a bug that causes segfault when the payload length in 
peer
	message is less than 0:

	* src/PeerConnection.cc:
	(receiveMessage): Fixed the bug.
	* src/PeerMessageUtil.cc
	(checkLength): Throw an exception if length is less than or 
equals to
	0.
	
	To add new interfaces to Base64 encoding/decoding:

	* src/Base64.h
	(part_encode): Changed the method signature.
	(encode): New function(overload).
	(decode): New function(overload).
	* src/Base64.cc
	(part_encode): Rewritten.
	(encode): Rewritten.
	(encode): New function(overload).

	To prevent a peer to download same piece if there is an error in
	checksum:

	* src/PieceMessage.cc
	(receivedAction): Call peerInteraction->abortPiece().
2006-07-03 14:19:23 +00:00
Tatsuhiro Tsujikawa d018b3a609 2006-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To remove a wait from download loop:

	* src/DownloadEngine.cc
	(run): Comment out shortSleep.
	
        To rewrite the message handling:
	
	* src/CancelMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/CancelMessage.cc
	(create): New function.
	(receivedAction): Replaced deleteRequestMessageInQueue with
	rejectPieceMessageInQueue.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/BitfieldMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(msgLength): New variable.
	(~BitfieldMessage): Deleted msg.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/BitfieldMessage.cc
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/ChokeMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPredicate): New function.
	(onSendComplete): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	(create): New function.
	* src/ChokeMessage.cc
	(create): New function.
	(send): Removed.
	(sendPredicate): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/KeepAliveMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.	
	* src/KeepAliveMessage.cc
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/PortMessage.h
	(create): New function.
	(receivedAction): Updated log message.
	* src/PortMessage.cc: New file.
	* src/UnchokeMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPredicate): New function.
	(onSendComplete): New function.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/UnchokeMessage.cc
	(create): New function.
	(send): Removed.
	(sendPredicate): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/PieceMessage.h
	(leftPieceDataLength): Removed.
	(leftDataLength): New variable.
	(headerSend): New variable.
	(pendingCount): New variable.
	(msgHeader): New variable.
	(sendPieceData): New function.
	(incrementPendingCount): New function.
	(isPendingCountMax): New function.
	(create): New function.
	(getMessageHeader): New function.
	(getMessageHeaderLength): New function.
	* src/PieceMessage.cc
	(create): New function.
	(getMessageHeader): New function.
	(getMessageHeaderLength): New function.
	(send): Rewritten.
	(sendPieceData): New function.
	* src/HaveMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(create): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/HaveMessage.cc
	(create): New function.
	(send): Removed.
	(sendPieceData): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/RequestMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/RequestMessage.cc
	(create): New function.
	(receivedAction): Added the handling of fast extension.
	Deleted torrentMan->addUploadLength, 
torrentMan->addDeltaUploadLength.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/InterestedMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPredicate): New function.
	(onSendComplete): New function.
	(create): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/InterestedMessage.cc
	(create): New function.
	(send): Removed.
	(sendPieceData): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/NotInterestedMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPieceData): New function.
	(onSendComplete): New function.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/NotInterestedMessage.cc
	(create): New function.
	(send): Removed.
	(sendPredicate): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/AllowedFastMessage.h: New class.
	* src/AllowedFastMessage.cc: New class.
	* src/RejectMessage.h: New class.
	* src/RejectMessage.cc: New class.
	* src/SuggestPieceMessage.h: New class.
	* src/SuggestPieceMessage.cc: New class.
	* src/HaveAllMessage.h: New class.
	* src/HaveAllMessage.cc: New class.
	* src/HaveNoneMessage.h: New class.
	* src/HaveNoneMessage.cc: New class.
	* src/HandshakeMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(reserved): New variable.
	(create): New function.
	(getId): New function.
	(receivedAction): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(isFastExtensionSupported): New function.
	* src/HandshakeMessage.cc
	(HandshakeMessage): Moved here from HandshakeMessage.h.
	(create): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(toString): Added the output of reserved field.
	(check): Added const qualifier.
	(isFastExtensionSupported): New function.
	* src/PeerMessageUtil.h
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createHaveMessage): Removed.
	(createBitfieldMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createPortMessage): Removed.
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createHaveMessage): Removed.
	(createBitfieldMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createKeepAliveMessage): Removed.
	(createHandshakeMessage): Removed.
	(setIntParam): New function.
	(createPeerMessageString): New function.
	* src/PeerMessageUtil.cc
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createHaveMessage): Removed.
	(createBitfieldMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createPortMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createHaveMessage): Removed.
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createBitfieldMessage): Removed.
	(createKeepAliveMessage): Removed.
	(createHandshakeMessage): Removed.
	(setIntParam): New function.
	(createPeerMessageString): New function.
	* src/PeerConnection.h
	(peer): Removed.
	(torrentMan): Removed.
	(createNLengthMessage): Removed.
	(setIntParam): Removed.
	(writeOutgoingMessageLog): Removed all overloaded functions.
	(PeerConnection): Deleted peer and torrentMan from its 
arguments.
	(sendMessage): New function.
	(sendHandshake): Removed.
	(sendKeepAlive): Removed.
	(sendChoke): Removed.
	(sendUnchoke): Removed.
	(sendInterested): Removed.
	(sendNotInterested): Removed.
	(sendHave): Removed.
	(sendBitfield): Removed.
	(sendRequest): Removed.
	(sendPiece): Removed.
	(sendPieceHeader): Removed.
	(sendPieceData): Removed.
	(sendCancel): Removed.
	(getPeer): Removed.
	* src/PeerConnection.cc
	(PeerConnection): Deleted peer and torrentMan from its 
arguments.
	(sendHandshake): Removed.
	(sendKeepAlive): Removed.
	(createNLengthMessage): Removed.
	(setIntParam): Removed.
	(writeOutgoingMessageLog): Removed all overloaded functions.
	(sendChoke): Removed.
	(sendUnchoke): Removed.
	(sendInterested): Removed.
	(sendNotInterested): Removed.
	(sendHave): Removed.
	(sendBitfield): Removed.
	(sendRequest): Removed.
	(sendPiece): Removed.
	(sendPieceHeader): Removed.
	(sendPieceData): Removed.
	(sendMessage): New function.
	(sendCancel): Removed.
	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Call setUploadLimit.
	(executeInternal): Call setUploadLimit.
	Added the handling of "inProgress" state of handshake message.
	Call sendBitfield() or sendAllowdFast() instead of deprecated
	sendNow().
	(keepAlive): Call addMessage and sendMessage instead of 
deprecated
	sendNow().
	(beforeSocketCheck): Call addMessage instead of deprecated 
trySendNow()
	* src/TorrentMan.h
	(PEER_ID_LENGTH): New definition.
	(hasAllPieces): New function.
	* src/TorrentMan.cc
	(getMissingPiece): Added the handling of fast extension.
	(cancelPiece): Call updatePiece().
	(hasAllPieces): New function.
	* src/PeerInteraction.h
	(fastSet): New variable.
	(getNewPieceAndSendInterest): Changed the return type to void.
	(send): Renamed as sendMessages.
	(deleteAllRequestSlot): Removed.
	(deleteRequestMessageInQueue): Renamed as 
rejectPieceMessageInQueue.
	(cancelAllRequest): Removed all overloaded functions.
	(deleteAllRequestSlot): Removed.
	(deletePieceMessageInQueue): Renamed as 
rejectAllPieceMessageInQueue.
	(rejectPieceMessageInQueue): New function.
	(rejectAllPieceMessageInQueue): New function.
	(onChoked): New function.
	(isSendingMessageInProgress): New function.
	(getCorrespondingRequestSlot): Changed its arguments.
	(isInFastSet): New function.
	(addFastSetIndex): New function.
	(addRequests): New function.
	(sendNow): Removed.
	(trySendNow): Removed.
	(sendBitfield): New function.
	(sendAllowdFast): New function.
	(createHaveAllMessage): New function.
	(createHaveNoneMessage): New function.
	(createRejectMessage): New function.
	(createAllowedFastMessage): New function.
	* src/PeerInteraction.cc
	(send): Renamed as sendMessages.
	(sendMessages): New function.
	(MsgPushBack): New class.
	(isSendingMessageInProgress): New function.
	(deletePieceMessageInQueue): Renamed as 
rejectAllPieceMessageInQueue.
	(rejectAllPieceMessageInQueue): New function.
	Added the handling of fast extension.
	(deleteRequestMessageInQueue): Renamed as 
rejectPieceMessageInQueue.
	(rejectPieceMessageInQueue): New function.
	Added the handling of fast extension.
	(deleteRequestSlot): Replaced for loop with  std::find.
	(onChoked): New function.
	(deleteAllRequestSlot): Removed.
	(abortPiece): Rewirtten.
	(deleteTimeoutRequestSlot): Updated log messages.
	(getCorrespondingRequestSlot): Changed its arguments.
	(cancelAllRequest): Removed all overloaded functions.
	(receiveHandshake): Added the check to see whether an incoming 
peer
	supports fast extension.
	(createHandshakeMessage): Use HandshakeMessage::create instead 
of
	PeerMessageUtil.
	(createPeerMessage): Use create() of each message class instead 
of
	PeerMessageUtil.
	HaveAllMessage, HaveNoneMessage, RejectMessage, 
SuggestPieceMessage,
	AllowedFastMessage were added.
	(getNewPieceAndSendInterest): Changed its return value type to 
void.
	Added the handling of fast extension.
	(addRequests): New function.
	(sendNow): Removed.
	(sendHandshake): Rewritten.
	(trySendNow): Removed.
	(sendBitfield): New function.
	(sendAllowdFast): New function.
	(isInFastSet): New function.
	(addFastSetIndex): New function.
	(createRequestMessage): Use RequestMessage::create instead of
	PeerMessageUtil.
	(createCancelMessage): Use CancelMessage::create instead of
	PeerMessageUtil.
	(createPieceMessage): Use PieceMessage::create instead of
	PeerMessageUtil.
	(createHaveMessage): Use HaveMessage::create instead of
	PeerMessageUtil.
	(createChokeMessage): Use ChokeMessage::create instead of
	PeerMessageUtil.
	(createUnchokeMessage): Use UnchokeMessage::create instead of
	PeerMessageUtil.
	(createInterestedMessage): Use InterestedMessage::create instead 
of
	PeerMessageUtil.
	(createNotInterestedMessage): Use NotInterestedMessage::create 
instead
	of PeerMessageUtil.
	(createBitfieldMessage): Use BitfieldMessage::create instead of
	PeerMessageUtil.
	(createKeepAliveMessage): Use KeepAliveMessage::create instead 
of
	PeerMessageUtil.
	(createHaveAllMessage): New function.
	(createHaveNoneMessage): New function.
	(createRejectMessage): New function.
	(createAllowedFastMessage: New function.
	* src/Util.h
	(sha1Sum): New function.
	(computeFastSet): New function.
	* src/Util.cc
	(sha1Sum): New function.
	(computeFastSet): New function.
	* src/Peer.h
	(fastExtensionEnabled): New variable.
	(fastSet): New variable.
	(setAllBitfield): New function.
	(setFastExtensionEnabled): New function.
	(isFastExtensionEnabled): New function.
	(addFastSetIndex): New function.
	(getFastSet): New function.
	(isInFastSet): New function.
	(countFastSet): New function.
	* src/Peer.cc
	(isInFastSet): New function.
	(addFastSetIndex): New function.
	(setAllBitfield): New function.
	
	* src/AbstractCommand.cc (execute): Changed the procedure of 
checking
	sockets.
	* src/PeerAbstractCommand.cc
	(PeerAbstractCommand): Added the initialization for 
uploadLimitCheck
	and uploadLimit.
	(execute): Changed the procedure of checking sockets. The upload 
speed
	checking were added.
	(setUploadLimit): New function.
	(setUploadLimitCheck): New function.
	* src/PeerAbstractCommand.h
	(setUploadLimit): New function.
	(setUploadLimitCheck): New function.
	(uploadLimit): New variable.
	(uploadLimitCheck): New variable.

	To contact a tracker regularly:
	
	* src/TrackerWatcherCommand.h (interval): New variable.
	(checkPoint): New variable.
	(TrackerWatcherCommand): Added interval argument.
	* src/TrackerWatcherCommand.cc
	(TrackerWatcherCommand): Initialized checkPoint.
	(execute): Now a tracker is contacted in every specified period.
	If peer list is not needed, send request with numwant=0.

	* src/TrackerUpdateCommand.cc
	(execute): Updated log messages.

	* src/DownloadEngine.cc
	(~DownloadEngine): Removed two asserts.
	(waitData): Uncommented wfds. May be a bug fix.
2006-05-18 17:08:29 +00:00
Tatsuhiro Tsujikawa ba23d6061a 2006-04-18 17:21:59 +00:00
Tatsuhiro Tsujikawa 2f4b3f7d02 2006-04-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the ability to download multi torrent into respective 
files
	directly:
	
	* src/DiskWriter.h (openFile): New function.
	(seek): Removed.
	* src/MultiDiskWriter.h: New class.
	* src/MultiDiskWriter.cc: New class.
	* src/AbstractDiskWriter.h (seek): Changed its scope from public 
to
	protected.
	(openFile): New function.
	* src/AbstractDiskWriter.cc (openFile): New function.
	* src/prefs.h (V_FALSE): New definition.
	(PREF_DIRECT_FILE_MAPPING): New definition.
	* src/TorrentMan.h (setupDiskWriter): New function.
	(setAllMultiFileRequestedState): New function.
	(onDownloadComplete): New function.
	* src/TorrentMan.cc : Included MultiDiskWriter.h
	(setupDiskWriter): New function.
	(getFilePath): Updated.
	(getTempFilePath): Updated.
	(getSegmentFilePath): Updated.
	(fixFilename): Updated.
	(deleteTempFile): Updated.
	(setAllMultiFileRequestedState): New function.
	(setFileEntriesToDownload): Use setAllMultiFileRequestedState().
	(finishPartialDownloadingMode): Reset requested flags.
	(onDownloadComplete): New function.
	* src/main.cc: Added --direct-file-mapping option.
	Use TorretMan::setupDiskWriter().
	* src/TorrentDownloadEngine.cc (afterEachIteration): Use 
TorrentMan::
	onDownloadComplete().
	
	
	To fix ETA bug:

	* src/Util.h (difftvsec): New function.
	* src/Util.cc (difftvsec): New function.
	* src/TorrentConsoleDownloadEngine.cc (calculateSpeed): Use int 
for the
	type of "elapsed" instead of long long int.
	(calculateStatistics): Use Util::difftvsec instead of 
Util::difftv.
	The updates of statistics takes place every 1 seconds.
	* src/TorrentConsoleDownloadEngine.h (lastElapsed): Changed its 
type.
	(calculateSpeed): Changed its argument signature.
	
	* src/PeerMessage.cc (toString): Fixed message.
2006-04-12 13:55:43 +00:00
Tatsuhiro Tsujikawa 9a52be6a29 2006-04-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To print ETA:

	* src/TorrentDownloadEngine.cc (afterEachIteration): Added 
download
	completion handling when dealing with
	TorrentMan::isPartialDownloadingMode() == true.
	* src/TorrentDownloadEngine.h (onPartialDownloadingCompletes):
	New function.
	* src/TorrentConsoleDownloadEngine.h (startup): New variable.
	(sessionDownloadLength): New variable.
	(avgSpeed): New variable.
	(eta): New variable.
	* src/TorrentConsoleDownloadEngine.cc (initStatistics): 
Initialized
	new variables: eta, avgSpeed, startup.
	(calculateSpeed): Calculate average speed and ETA.
	(printStatistics): Added ETA.

	* src/Util.h (secfmt): New function.
	* src/Util.cc (secfmt): New function.
	
2006-04-05  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	To detect "keep alive" flooding:

	* src/PeerInteractionCommand.h (keepAliveCount): New variable
	* src/PeerInteractionCommand.cc (Constructor): Initialized new
	variable: keepAliveCount.
	(detectMessageFlooding): Added "keep alive" flooding detection.
	(receiveMessage): Increase keepAliveCount when "keep alive" 
message
	received.
	
	To add the ability to download only specified files in 
multi-file
	torrent:

	* src/BitfieldMan.h (filterBitfield): New variable.
	(filterEnabled): New variable.
	(setFilterBit): New function.
	(enableFilter): New function.
	(disableFilter): New function.
	(isFilterEnabled): New function.
	(getFilteredTotalLength): New function.
	(getCompletedLength): New function.
	* src/BitfieldMan.cc (Constructor): Initialized new variable:
	filterBitfield, filterEnabled.
	(CopyConstructor): Added filterBitfield and filterEnabled.
	(operator==): Added filterBitfield and filterEnabled.
	(Destructor): Added filterBitfield.
	(getMissingIndex): Use filterBitfield.
	(getMissingUnusedIndex): Use filterBitfield.
	(getFirstMissingUnusedIndex): Use filterBitfield.
	(getFirstMissingUnusedIndex): Use filterBitfield.
	(getAllMissingIndexes): Use filterBitfield.
	(countMissingBlock): Use filterBitfield.
	(countBlock): Use filterBitfield.
	(setBitInternal): Added new argument on.
	(setUseBit): Use setBitInternal.
	(unsetUseBit): Use setBitInternal.
	(setBit): Use setBitInternal.
	(unsetBit): Use setBitInternal.
	(isAllBitSet): Use filterBitfield.
	(setFilterBit): New function.
	(addFilter): New function.
	(enableFilter): New function.
	(disableFilter): New function.
	(clearFilter): New function.
	(isFilterEnabled): New function.
	(getFilteredTotalLength): New function.
	(getCompletedLength): New function.

	* src/TorrentMan.h [FileEntry](Constructor): Updated signature.
	Initalized newly added variables.
	[FileEntry](offset): New variable.
	[FileEntry](extracted): New variable.
	[FileEntry](requested): New variable.
	(readFileEntry): New function.
	(option): New variable.
	(splitMultiFile): Removed const qualifier.
	(fixFilename): Removed const qualifier.
	(readFileEntryFromMetaInfoFile): New function.
	(finishPartialDownloadingMode): New function.
	(isPartialDownloadingMode): New function.
	(setFileEntriesToDownload): New function.
	(getCompletedLength): New function.
	(getPartialTotalLength): New function.
	* src/TorrentMan.cc (readFileEntry): New function.
	(setup): Use readFileEntry. If no-preallocation option is 
specified,
	use DefaultDiskWriter.
	(readFileEntryFromMetaInfoFile): New function.
	(fixFilename): Removed const qualifier.
	(splitMultiFile): Removed const qualifier.
	(setFileEntriesToDownload): New function.
	(isPartialDownloadingMode): New function.
	(finishPartialDownloadingMode): New function.
	(getCompletedLength): New function.
	(getPartialTotalLength): New function.
	
	* src/TorrentConsoleDownloadEngine.h 
(partialDownloadLengthDiff):
	New variable.
	(partialTotalLength): New variable.
	(downloadLength): New variable.
	(totalLength): New variable.
	* src/TorrentConsoleDownloadEngine.cc 
(onPartialDownloadingCompletes):
	Added log.
	(initStatistics): Initialized new variables: 
partialDownloadLengthDiff,
	partialTotalLength, downloadLength, totalLength.
	(calculate): Calculate downloadLength and totalLength.
	
	* src/prefs.h :New definition PREF_NO_PREALLOCATION

	* src/main.cc (addCommand): Changed argument signature.
	(main): Added new variable: args. Added new option 
"torrent-show-files"
	"no-preallocation". Usage is not updated yet.
	
2006-04-02  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	* src/PeerMessage.cc (setBitfield): Fixed invalid memory 
de-allocation.
2006-04-06 12:52:16 +00:00
Tatsuhiro Tsujikawa 40cb1ca9ce 2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
	* m4/openssl.m4: Added.
	* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
	readData(), peekData(). Added gnutls support.
	* src/HttpDownloadCommand.cc: Removed SleepCommand.h
	* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
	TrackerInitCommand periodicaly(TorrentMan::minInterval).
	* src/TorrentMan.cc: Remove downloadedSize == 0 check from 
save().
	Instead, added a check for whether setup method has executed
	successfully.
	* src/TorrentMan.h: Added member vaiable setupComplete. Updated
	DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to 
300.
	* src/Makefile.am: Updated.
	* src/messageDigest.h: Added. This is a macro calculating SHA1 
digest
	using whether OpenSSL or gcrypt, depending on the result of 
configure
	script.
	* src/ShaVisitor.{h,cc}: Removed direct	dependency on OpenSSL by 
using
	messageDigest.h. 
	* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
	* src/PeerListenCommand.cc: Added log about port binded 
successfully.
	Fixed memory leak.
	* src/main.cc: Added gnutls support. Replaced LIB_SSL with
	ENABLE_BITTORRENT where they are not related to OpenSSL but 
BitTorrent.
	Removed instantiation of TrackerInitCommand. Instead,
	TrackerWatcherCommand is instantiated and pushed to the command 
queue.
	* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL 
with
	ENABLE_SSL.
	* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
	* src/RequestSlotMan.cc:
	(deleteCompletedRequestSlot)
	If a piece is already acquired by another command, delete the 
request
	slots for the piece.
	* src/TrackerUpdateCommand.cc:
	(execute)
	Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to 
warn.
	Added a check whether peer list is null.
	Fixed the bug that causes sending completed event to the tracker
	several times.
	* src/TrackerInitCommand.cc:
	(execute)
	Fixed the bug that causes sending completed event to the tracker
	several times.
	* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on 
OpenSSL
	by using messageDigest.h.
	
	
2006-03-26  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	* PeerConnection.cc: Replaced log message "keep-alive" with
	"keep alive".
	* PeerInteractionCommand.{h,cc}: Close connection if peer is 
choking
	localhost long time.
	* TorrentMan.cc: When adding new peer with duplicate = true, if 
the
	number of peer list is equal to or grater than MAX_PEER_LIST, 
delete
	at most 100 failure entry from the list. If with duplicate = 
false,
	MAX_PEER_LIST is not checked.
	* PeerListenCommand.cc: Fixed the argument order of log message.

2006-03-25  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
	Added warn().
	* SimpleLogger.h: Moved enum LEVEL to Logger.h.
	Implemented warn().
	Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated 
code.
2006-03-27 14:47:26 +00:00
Tatsuhiro Tsujikawa 01118364a5 2006-03-21 16:07:22 +00:00
Tatsuhiro Tsujikawa df6c7c0385 added bittorrent support(experimental) 2006-03-21 14:12:51 +00:00
Tatsuhiro Tsujikawa 46354b7c91 Added intl/*
Added src/alloca.c
2006-03-07 13:08:09 +00:00
Tatsuhiro Tsujikawa 8d980589e3 2006-03-05 06:32:01 +00:00
Tatsuhiro Tsujikawa 0276b3bb37 * DownloadEngine.{h, cc}:
* ConsoleDownloadEngine.{h, cc}: Console output message(size, 
speed)
	is now generated by ConsoleDownloadEngine not by DownloadEngine.
	* main.cc: Download complete/abort message is now generated by 
main.
	* Makefile.am (SUBDIRS): Add m4.
	(ACLOCAL_AMFLAGS): New variable.
	(EXTRA_DIST): New variable.
	* configure.in (AC_CONFIG_FILES): Add po/Makefile.in,
	* gettext: added gettext functionality
2006-03-02 10:43:00 +00:00
Tatsuhiro Tsujikawa a8f0186af2 2006-03-01 08:12:01 +00:00
Tatsuhiro Tsujikawa 4a5fa077b3 * ChunkedEncoding.cc: Added #include directive for strings.h 2006-03-01 07:46:21 +00:00
Tatsuhiro Tsujikawa 52634627bc Initial import 2006-02-17 13:35:04 +00:00