Commit Graph

1134 Commits (bf9d99f291c9514cb4fe6bac4484aa575b713f18)

Author SHA1 Message Date
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 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 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 6620c8d878 2006-08-07 16:43:58 +00:00
Tatsuhiro Tsujikawa 58dbaafc85 2006-08-08 Tatsuhiro Tsujikawa <tujikawa@rednoah.com>
* src/FtpNegotiateCommand.cc
	(recvGreeting): Call disableWriteCheckSocket just after
	socket->setBlockingMode(). This avoids unnecessary CPU-hog loop.

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

	* src/PeerChokeCommand.h
	(PeerChokeCommand): Rearranged the arguments.
	* src/PeerChokeCommand.cc
	(PeerChokeCommand): Rearranged the arguments.

	* src/MetalinkEntry.h
	(Checksum.h): Included.
	(md5): Removed.
	(sha1): Removed.
	(checksum): New variable.
	(operator=): Updated.
	(check): Removed.

	* src/prefs.h
	(PREF_LOWEST_SPEED_LIMIT): New definition.
	(PREF_FOLLOW_TORRENT): New definition.
	(PREF_SELECT_FILE): New definition.
	(PREF_FOLLOW_METALINK): New definition.

	* src/MetalinkResource.h
	(TYPE_HTTPS): Added to enum TYPE.

	* src/TorrentMan.cc
	(~TorrentMan): Rewritten.

	* src/MultiDiskWriter.cc
	(MultiDiskAdaptor): Updated according to the changes in
	MessageDigestContext.
	(~MultiDiskAdaptor): Updated according to the changes in
	MessageDigestContext.
	(hashUpdate): Updated according to the changes in 
MessageDigestContext.
	(sha1Sum): Updated according to the changes in 
MessageDigestContext.

	* src/Util.h
	(fileChecksum): Updated according to the changes in
	MessageDigestContext.
	* src/Util.cc
	(sha1Sum): Updated according to the changes in 
MessageDigestContext.
	(fileChecksum): Updated according to the changes in
	MessageDigestContext.

	* src/messageDigest.h: Rewritten.

	* src/MetalinkEntry.cc
	(check): Removed.
	(Supported): Updated.
	(dropUnsupportedResource): Fixed a memory leak.

	* src/ShaVisitor.cc
	(ShaVisitor): Updated according to the changes in 
MessageDigestContext.
	(~ShaVisitor): Updated according to the changes in
	MessageDigestContext.
	(visit): Updated according to the changes in 
MessageDigestContext.

	* src/main.cc
	(main): Rewritten the portion of download loop. 
--lowest-speed-limit
	command-line option added.

	* src/DownloadEngine.h
	(SocketEntry): New class.
	(SocketEntries): New definition.
	(PairFind): Removed.
	(SockCmdMap): Removed.
	* src/DownloadEngine.cc
	(DownloadEngine): Rewritten.
	(~DownloadEngine): Rewritten.
	(run): Renamed activeCommandUuids as activeUuids.
	(SetDescriptor): Rewritten.
	(AccumulateActiveCommandUuid): Removed.
	(AccumulateActiveUuid): New function object.
	(waitData): Rewritten.
	(updateFdSet): Rewritten.
	(addSocket): Rewritten.
	(deleteSocket): Rewritten.
	(addSocketForReadCheck): Rewritten.
	(deleteSocketForReadCheck): Rewritten.
	(addSocketForWriteCheck): Rewritten.
	(deleteSocketForWriteCheck): Rewritten.
	
	* src/Xml2MetalinkProcessor.cc
	(getEntry): Rewritten the portion of MetalinkEntry creation.

	* src/DownloadCommand.cc
	(executeInternal): Added the check routine for lowest speed 
limit.

	* src/AbstractDiskWriter.cc
	(AbstractDiskWriter): Updated according to the changes in
	MessageDigestContext.
	(~AbstractDiskWriter): Updated according to the changes in
	MessageDigestContext.
	(sha1Sum): Updated according to the changes in 
MessageDigestContext.

	* src/RequestInfo.h: New class.

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

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

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

	* src/Checksum.h: New class.

	* src/DownloadEngineFactory.h: New class.
	* src/DownloadEngineFactory.cc: New class.
2006-08-07 16:05:00 +00:00
Tatsuhiro Tsujikawa 9251b47f6c 2006-08-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Option.h
	(getAsBool): New function.
	* src/Option.cc
	(prefs.h): Included.
	(defined): 0-length value is now recognized as undefined.
	(getAsInt): Rewritten.
	(getAsLLInt): Rewritten.
	(getAsBool): New function.
	
	* src/FeatureConfig.h: Rewritten.
	* src/FeatureConfig.cc: Rewritten.

	* src/prefs.h
	(PREF_STDOUT_LOG): New definition.
	(PREF_LOG): New definition.
	(PREF_DIR): New definition.
	(PREF_OUT): New definition.
	(PREF_SPLIT): New definition.
	(PREF_DAEMON): New definition.
	(PREF_REFERER): New definition.
	(PREF_TORRENT_FILE): New definition.
	(PREF_LISTEN_PORT): New definition.
	(PREF_METALINK_FILE): New definition.
	(PREF_METALINK_VERSION): New definition.
	(PREF_METALINK_LANGUAGE): New definition.
	(PREF_METALINK_OS): New definition.
	(PREF_METALINK_SERVERS): New definition.

	* src/main.cc
	(main): Following command-line parameters are now put into 
Option
	class: stdoutLog, logfile, dir, ufilename, split, daemonMode,
	referer, torrentFile, metalinkFile, listenPort, metalinkVersion,
	metalinkLanguage, metalinkOs, metalinkServers
	To fix the bug that aria2 can not handle http response header 
properly.
	
	* src/HttpHeader.cc
	(put): Made name lowercased.
	(defined): Made name lowercased.
	(getFirst): Made name lowercased.
	(get): Made name lowercased.
	(getFirstAsInt): Rewritten.
	(getFirstAsLLInt): Rewritten.
2006-08-03 12:36:02 +00:00
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 7db2b0596d 2006-07-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the support for Metalink3.0 backward compatible links:
	
	* src/Request.h
	(SAFE_CHARS): Added '#'.
	(METALINK_MARK): New definition.
	* src/Request.cc
	(parseUrl): Added the support for Metalink3.0 backward 
compatible
	links.

	etc

	* src/PeerInteraction.cc
	(MsgPushBack): Removed.
	(sendMessages): Use STL copy and back_inserter.
	(rejectAllPieceMessageInQueue): Use STL copy and back_inserter.
	(rejectPieceMessageInQueue): Use STL copy and back_inserter.
	* src/TorrentMan.h
	(MAX_PEER_LIST_SIZE): Changed to 100 from 250.
2006-07-20 15:48:12 +00:00
Tatsuhiro Tsujikawa 39d27f9902 2006-07-04 12:04:47 +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 8d340992d6 2006-07-03 14:19:59 +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 d02d80d9e9 2006-06-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To make a listening socket non-block:
	
	* src/SocketCore.h
	(setNonBlockingMode): New function.
	* src/SocketCore.cc
	(setNonBlockingMode): New function.
	(beginListen): Added a call to setNonBlockingMode().
	(acceptConnection): Call setNonBlockingMode().
	(setBlockingMode): Updated.

	To handle tracker's NAT-checking:
	
	* src/PeerConnection.cc
	(receiveHandshake): 'msg' param is filled with received data and
	its length is assigned to 'length' param, even if all handshake
	message is not yet received.
	* src/PeerInteractionCommand.cc
	(executeInternal): Use peerInteraction->receiveHandshake(true) 
when
	a new peer connects to localhost.
	A call to peerInteraction->sendHandshake() was removed because 
	it is called from peerInteraction->receiveHandshake(true).
	* src/PeerInteraction.h
	(quickReplied): New variable.
	(receiveHandshake): Added an argument.
	* src/PeerInteraction.cc
	(PeerInteraction): Added the initialization of quickReplied.
	(receiveHandshake): Send handshake message as soon as the info 
hash
	in a handshake message from a peer is correct.

	
	To change the random part of peer id and key parameter:

	* src/TorrentMan.h
	(key): New variable.
	* src/TorrentMan.cc
	(setupInternal1): Use Util::randomAlpha() to generate random 
part
	of peer id, which is now "-aria2-"+13 alphabet 
characters([A-Za-z]).
	key is also generated by Util::randomAlpha() and it is now 8 
character
	long.
	* src/Util.h
	(randomAlpha): New function.
	* src/Util.cc
	(randomAlpha): New function.
	* src/TrackerWatcherCommand.cc
	(execute): In a tracker request: Use torrentMan->key as key 
parameter.
	Added no_peer_id=1.
	
	Set snubbing flag to false when a choke message is received from 
a
	snubbed peer.

	* src/ChokeMessage.cc
	(receivedAction): Set snubbing flag to false.
2006-06-22 15:26:18 +00:00
Tatsuhiro Tsujikawa 70ff0c0b3b 2006-06-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentMan.cc (setupInternal1): Fixed peerId generation 
bug.

	* src/SimpleLogger.h (writeHeader): New function.
	* src/SimpleLogger.cc (writeHeader): New function.
	(writeLog): Fixed the bug that causes segfaults if exception 
message
	contains an unescaped "%" character.

	* src/TrackerWatcherCommand.cc (execute): Added a short sleep
	when a tracker request fails.

	* src/Request.cc (parseUrl): Query string is now handled 
properly.
2006-06-18 09:23:25 +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 ebfdbefb7f 2006-05-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Each peer message has its own class.
	
	* src/PendingMessages.h: Removed.
	* src/PendingMessages.cc: Removed. The sending process was moved 
to
	each message class.
	* src/RequestSlotMan.h: Removed.
	* src/RequestSlotMan.cc: Removed. All functionarities were moved 
to
	SendMessageQueue.
	* src/RequestMessage.h: New class.
	* src/RequestMessage.cc: New class.
	* src/CancelMessage.h: New class.
	* src/CancelMessage.cc: New class.
	* src/BitfieldMessage.h: New class.
	* src/BitfieldMessage.cc: New class.
	* src/ChokeMessage.h: New class.
	* src/ChokeMessage.cc: New class.
	* src/KeepAliveMessage.h: New class.
	* src/KeepAliveMessage.cc: New class.
	* src/PortMessage.h: New class.
	* src/UnchokeMessage.h: New class.
	* src/UnchokeMessage.cc: New class.
	* src/PieceMessage.h: New class.
	* src/PieceMessage.cc: New class.
	* src/HaveMessage.h: New class.
	* src/HaveMessage.cc: New class.
	* src/BitfieldMessage.h: New class.
	* src/BitfieldMessage.cc: New class.
	* src/NotInterestedMessage.h: New class.
	* src/NotInterestedMessage.cc: New class.
	* src/InterestedMessage.h: New class.
	* src/InterestedMessage.cc: New class.
	* src/HandshakeMessage.h (sendMessageQueue): New variable.
	(getSendMessageQueue): New function.
	(setSendMessageQueue): New function.
	* src/HandshakeMessage.cc: New class.
	* src/PeerConnection.h (receiveMessage): Changed return value 
and
	arguments.
	(receiveHandshake): Changed return value and arguments.
	* src/PeerConnection.cc (receiveMessage): Do not create message 
class
	here.
	(receiveHandshake): Do not create handshake class here.
	* src/PeerInteractionCommand.h (peerConnection): Removed.
	(piece): Removed.
	(syncPiece): Removed.
	(sendInterest): Removed.
	(sendMessages): Removed.
	(createRequestPendingMessage): Removed.
	(checkPieceHash): Removed.
	(erasePieceOnDisk): Removed.
	(getNewPieceAndSendInterest): Removed.
	(onGotNewPice): Removed.
	(onGotWrongPiece): Removed.
	* src/PeerInteractionCommand.cc (PeerInteractionCommand):
	Removed peerConnection, piece.
	(~PeerInteractionCommand): Removed peerConnection.
	(executeInternal): Use sendMessageQueue instead of 
peerConnection.
	(syncPiece): Moved to SendMessageQueue.
	(decideChoking): Removed PendingMessage.
	(receiveMessage): Use sendMessageQueue instead of 
peerConnection.
	The action after receiving peer message was moved to each 
message
	class.
	(onGotNewPice): Moved to SendMessageQueue.
	(onGotWrongPiece): Moved to SendMessageQueue.
	(getNewPieceAndSendInterest): Moved to SendMessageQueue.
	(sendInterest): Moved to SendMessageQueue.
	(createRequestPendingMessage): Removed.
	(sendMessages): Moved to SendMessageQueue.
	(onAbort): Use SendMessageQueue::abortPiece()
	(keepAlive): Use sendMessageQueue instead of peerConnection.
	(beforeSocketCheck): Use sendMessageQueue instead of 
peerConnection.
	(checkPieceHash): Moved to SendMessageQueue.
	(erasePieceOnDisk): Moved to SendMessageQueue.
	* src/PeerMessageUtil.h
	(createBitfieldMessage): Removed.
	(createHaveMessage): Changed return value and arguments.
	(createBitfieldMessage): Changed return value and arguments.
	(createRequestCancelMessage): Removed.
	(createPieceMessage): Changed return value and arguments.
	(getShortIntParam): New function.
	(checkIndex): Changed arguments.
	(checkBegin): Changed arguments.
	(checkLength): Changed arguments.
	(checkPieceOffset): Removed.
	(checkRange): New function.
	(checkBitfield): Changed arguments.
	(createPeerMessage): Removed.
	(checkIntegrity): Removed.
	(createHandshakeMessage): Changed arguments.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPortMessage): New function.
	* src/PeerMessageUtil.cc
	(createBitfieldMessage): Removed.
	(createHaveMessage): Changed return value and arguments.
	(createBitfieldMessage): Changed return value and arguments.
	(createRequestCancelMessage): Removed.
	(createPieceMessage): Changed return value and arguments.
	(getShortIntParam): New function.
	(checkIndex): Changed arguments.
	(checkBegin): Changed arguments.
	(checkLength): Changed arguments.
	(checkPieceOffset): Removed.
	(checkRange): New function.
	(checkBitfield): Changed arguments.
	(createPeerMessage): Removed.
	(checkIntegrity): Removed.
	(createHandshakeMessage): Changed arguments.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPortMessage): New function.
	* src/PeerMessage.h
	(id): Removed.
	(index): Removed.
	(begin): Removed.
	(length): Removed.
	(bitfield): Removed.
	(bitfieldLength): Removed.
	(block): Removed.
	(blockLength): Removed.
	(inProgress): New variable.
	(cuid): New variable.
	(peer): New variable.
	(sendMessageQueue): New variable.
	(logger): New variable.
	(setBitfield): Removed.
	(getBitfield): Removed.
	(setBlock): Removed.
	(getBlock): Removed.
	(getBitfieldLength): Removed.
	(getBlockLength): Removed.
	(isInProgress): New function.
	(toString): Made pure virtual.
	(check): New function.
	(send): New function.
	(receivedAction): New function.
	(getId): Made pure virtual.
	(setId): Removed.
	(getIndex): Removed.
	(setIndex): Removed.
	(getBegin): Removed.
	(setBegin): Removed.
	(getLength): Removed.
	(setLength): Removed.
	(getCuid): New function.
	(setCuid): New function.
	(getPeer): New function.
	(setPeer): New function.
	(getSendMessageQueue): New function.
	(setSendMessageQueue): New function.
	(ID): Removed.
	* src/PeerMessage.cc
	(setBitfield): Removed.
	(setBlock): Removed.
	(toString): Removed.
	* src/TorrentMan.h
	(getPieceLength): New function.
	(getPieceLength): New function.
	* src/SendMessageQueue.h
	(REQUEST_TIME_OUT): New definition.
	(RequestSlots): New definition.
	(MessageQueue): New definition.
	(requestSlotMan): Removed.
	(pendingMessages): Removed.
	(requestSlots): New variable.
	(messageQueue): New variable.
	(torrentMan): New variable.
	(peerConnection): New variable.
	(peer): New variable.
	(piece): New variable.
	(getNewPieceAndSendInterest): New function.
	(createPeerMessage): New function.
	(createHandshakeMessage): New function.
	(send): Made private.
	(setPeerMessageCommonProperty): New function.
	(deleteAllRequestSlot): New function.
	(deleteRequestMessageInQueue): New function.
	(cancelAllRequest): Made private.
	(cancelAllRequest): Made private.
	(countRequestSlot): Made private.
	(addPendingMessage): Removed.
	(deletePendingPieceMessage): Removed.
	(deletePendingRequestMessage): Removed.
	(addMessage): New function.
	(deletePieceMessageInQueue): New function.
	(deleteTimeoutRequestSlot): Changed argument.
	(deleteCompletedRequestSlot): Changed argument.
	(getCorrespoindingRequestSlot): Renamed to 
getCorrespondingRequestSlot.
	(getCorrespondingRequestSlot): New function.
	(countPendingMessage): Removed.
	(countMessageInQueue): New function.
	(getTorrentMan): New function.
	(getPeerConnection): New function.
	(hasDownloadPiece): New function.
	(getDownloadPiece): New function.
	(setDownloadPiece): New function.
	(syncPiece): New function.
	(sendMessages): New function.
	(sendNow): New function.
	(trySendNow): New function.
	(abortPiece): New function.
	(sendHandshake): New function.
	(receiveMessage): New function.
	(receiveHandshake): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPieceMessage): New function.
	(createHaveMessage): New function.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createBitfieldMessage): New function.
	(createKeepAliveMessage): New function.
	* src/SendMessageQueue.cc
	(SendMessageQueue): Removed requestSlotMan.
	Instantiated peerConnection here.
	(~SendMessageQueue): Removed requestSlotMan.
	Added deletion of peerConnection and the contents of 
messageQueue.
	(send): Updated according to the change of messageQueue.
	(addPendingMessage): Renamed to addMessage.
	(addMessage): New function.
	(deletePendingPieceMessage): Renamed to 
deletePieceMessageInQueue.
	(deletePieceMessageInQueue): New function.
	(deletePendingRequestMessage): Renamed to 
deleteRequestMessageInQueue.
	(deleteRequestMessageInQueue): New function.
	(deleteRequestSlot): RequestSlotMan::deleteRequestSlot(...) was 
moved
	here.
	(deleteTimeoutRequestSlot): 
RequestSlotMan::deleteTimeoutRequestSlot
	(...) was moved here.
	(deleteAllRequestSlot): 
RequestSlotMan::deleteAllRequestSlot(...) was
	moved here.
	(deleteCompletedRequestSlot):
	RequestSlotMan::deleteCompletedRequestSlot(...) was moved here.
	(getCorrespondingRequestSlot):
	RequestSlotMan::getCorrespoindingRequestSlot(...) was moved 
here.
	And renamed to getCorrespondingRequestSlot, correcting a typo.
	(countPendingMessage): Renamed to countMessageInQueue.
	(countMessageInQueue): New function.
	(countRequestSlot): RequestSlotMan::countRequestSlot() was moved 
here.
	(receiveHandshake): New function.
	(createHandshakeMessage): New function.
	(receiveMessage): New function.
	(createPeerMessage): New function.
	(syncPiece): New function.
	(getNewPieceAndSendInterest): New function.
	(sendMessages): New function.
	(sendNow): New function.
	(trySendNow): New function.
	(sendHandshake): New function.
	(abortPiece): New function.
	(getDownloadPiece): New function.
	(getPeerMessageCommonProperty): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPieceMessage): New function.
	(createHaveMessage): New function.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createBitfieldMessage): New function.
	(createKeepAliveMessage): New function.
	
	
	To add simple Content-Disposition support:

	* src/HttpResponseCommand.h (determinFilename): New function.
	* src/HttpResponseCommand.cc (executeInternal):
	Use determinFilename(headers) instead of req->getFile() when 
comparing
	filename.
	(determinFilename): New function.
	(handleDefaultEncoding): Use determinFilename(headers) instead 
of
	req->getFile().
	(handleOtherEncoding): Use determinFilename(headers) instead of
	req->getFile().
	* src/Util.h (getContentDispositionFilename): New function.
	* src/Util.cc (getContentDispositionFilename): New function.
	
	* src/LogFactory.h (release): New function.
	* src/LogFactory.cc (release): New function.

	To fix a bug that causes out-of-bound exception when HTTP status
	line is wrong:
	
	* src/HttpConnection.cc (receiveResponse): Added a check for 
header
	size.

	* src/common.h (Deleter): New class.

	* src/SegmentMan.cc
	(~SegmentMan): Added deletion of splitter and diskWriter.
	* src/DownloadEngine.h
	(Commands): Use deque.
	(clearQueue): New function.
	* src/DownloadEngine.cc
	(~DownloadEngine): Added deletion of segmentMan.
	(cleanQueue): New function.
	* src/TorrentDownloadEngine.h
	(TorrentDownloadEngine): The implementation was moved to
	TorrentDownloadEngine.cc.
	(~TorrentDownloadEngine): The implementation was moved to
	TorrentDownloadEngine.cc.
	* src/TorrentDownloadEngine.cc
	(~TorrentDownloadEngine): Added deletion of torrentMan.
	* src/main.cc
	(clearRequest): Removed.
	(handler): Added deletion of e.
	(torrentHandler): Added deletion of te.
	(main): Do not share splitter.
	Use Deleter instead of clearRequest.
	Deletion of classes were updated.
2006-05-09 15:54:14 +00:00
Tatsuhiro Tsujikawa ba23d6061a 2006-04-18 17:21:59 +00:00
Tatsuhiro Tsujikawa 2a84b9de43 2006-04-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentConsoleDownloadEngine.cc
	(onPartialDownloadingCompletes): Renamed as
	onSelectiveDownloadingCompletes.
	(onSelectiveDownloadingCompletes): Updated message.

	To add DiskAdaptor which abstract DiskWriter family:

	* src/PeerConnection.cc: Use diskAdaptor instead of diskWriter.
	* src/PeerInteractionCommand.cc: Use diskAdaptor instead of 
diskWriter.
	* src/BitfieldMan.cc (isAllBitSet): bug fix.
	* src/TorrentMan.cc : Included CopyDiskAdaptor.h, 
DirectDiskAdaptor.h,
	MultiDiskAdaptor.h.
	(readFileEntry): Changed its arguments.
	(setup): setupDiskWriter is merged into this function.
	(setupDiskWriter): Removed.
	(setFileFilter): New function.
	(readFileEntryFromMetaInfoFile): Updated according to the 
changes
	made in readFileEntry.
	(getFilePath): Removed.
	(getTempFilePath): Removed.
	(getSegmentFilePath): Updated due to the removal of getFilePath.
	(fixFilename): Removed.
	(copySingleFile): Removed.
	(splitMultiFile): Removed.
	(deleteTempFile): Removed.
	(setFileEntriesToDownload): Removed.
	(isPartialDownloadingMode): Renamed as 
isSelectiveDownloadingMode.
	(isSelectiveDownloadingMode): New function.
	(setAllMultiFileRequestedState): Removed.
	(finishPartialDownloadingMode): Renamed as
	finishSelectiveDownloadingMode.
	(finishSelectiveDownloadingMode): New function.
	(getPartialTotalLength): Renamed as getSelectedTotalLength.
	(getSelectedTotalLength): New function.
	(onDownloadComplete): Use diskAdaptor.
	* src/MultiDiskWriter.cc (Constructor): Added the argument 
pieceLength
	(Range): Removed.
	(setMultiFileEntries): Renamed as setFileEntries.
	(setFileEntries): New function.
	* src/MultiDiskWriter.h [DiskWriterEntry](enabled): Removed.
	(pieceLength): New variable.
	* src/main.cc (printDownloadCompeleteMessage): New function.
	(torrentHandler): Use diskAdaptor instead of diskWriter.
	(main): Renamed torrent-show-files to show-files.
	Rewritten file contents listing.
	* src/TorrentMan.h (FileEntry): Removed.
	(multiFileTopDir): Removed.
	(multiFileEntries): Removed.
	(diskWriter): Removed.
	(diskAdaptor): New variable.
	* src/DefaultDiskWriter.h (totalLength): New variable.
	* src/DefaultDiskWriter.cc (initAndOpenFile): Added ftruncate.
	* src/TorrentDownloadEngine.cc (onEndOfRun): Use diskAdaptor 
instead of
	diskWriter.
	* src/TorrentConsoleDownloadEngine.h
	(partialDownloadLengthDiff): Renamed as 
selectedDownloadLengthDiff.
	(partialTotalLength): Renamed as selectedTotalLength.
	* src/AbstractDiskWriter.cc (openFile): If file exists, call
	openExistingFile, otherwise call initAndOpenFile.
	(closeFile): fd > 0, not fd != 0.
	
	* src/prefs.h (PREF_TORRENT_SHOW_FILES): Renamed as 
PREF_SHOW_FILES
	(PREF_SHOW_FILES): New definition.
2006-04-16 14:38:19 +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 29374cd70c 2006-03-21 15:21:11 +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 20ba8c707a * Util.{h,cc}: added startsWith().
* CookieBox.cc: rewrited criteriaFind() using Util::startsWith() 
and
	Util::endsWith().
	* SocketCore.cc: struct addrinfo is now  zero-initialized.
	* common.h: added #include directive of limit.h.
	* DownloadEngine.cc: added #include directive of sys/time.h and
	algorithm.
	* Exception.h: added #include directive of stdio.h.
	* AbstractCommand.h: added #include directive of sys/time.h.
	* DownloadCommand.h: added #include directive of sys/time.h.
	* *.h: added #include directive of common.h to all base classes.
	subclasses' one was removed.
2006-02-28 02:25:45 +00:00
Tatsuhiro Tsujikawa 28fc3405dd 2006-02-21 15:01:05 +00:00
Tatsuhiro Tsujikawa 5a8710676d 2006-02-21 12:27:17 +00:00
Tatsuhiro Tsujikawa 62d3659410 Added Referer support 2006-02-18 03:59:26 +00:00
Tatsuhiro Tsujikawa 52634627bc Initial import 2006-02-17 13:35:04 +00:00