Added .cc file for classes/structs that only provided by header
file. Defined non-POD classes' ctor, dtor in .cc file. Moved
implementation code in header file to .cc file for major
classes/strucsts.
Made public member variable in Metalinker private
* src/MetalinkParserController.cc
* src/Metalinker.cc
* src/Metalinker.h
* test/MetalinkParserControllerTest.cc
* test/MetalinkProcessorTest.cc
* test/MetalinkerTest.cc
Fixed possible memory leak when an exception is thrown.
* src/XML2SAXMetalinkProcessor.cc
Added Expat support. If both libxml2 and Expat are installed,
then
libxml2 is used by default.
MetalinkProcessorFactory chooses from XML2SAXMetalinkProcessor
and
ExpatMetalinkProcessor according to the configuration.
* src/ExpatMetalinkProcessor.{h, cc}
* src/main.cc: Removed libxml2 specific header and init/free
function.
* src/MetalinkProcessorFactory.{h, cc}
* src/MetalinkHelper.cc
* src/Metalinker.h: Removed unnecessary libxml2 header.
* src/MetalinkProcessor.h
* test/XML2SAXMetalinkProcessorTest.cc: Removed because
MetalinkProcessorTest is used instead.
* test/MetalinkProcessorTest.cc: Added. It is actually the same
with
XML2SAXMetalinkProcessor, replaced XML2SAXMetalinkProcessor with
MetalinkProcessorFactory::newInstance().
* m4/libexpat.m4
* configure.ac: Added configuration options for libexpat.
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.
* src/PeerMessage.h
(Piece.h): Included.
(SharedHandle.h): Included.
(invalidate): New variable.
(uploading): New variable.
(isInvalidate): New function.
(isUploading): New function.
(onPush): New function.
(onChoked): New function.
(onCanceled): New function.
(onAbortPiece): New function.
(PeerMessageHandle): New type definition.
* src/PeerMessage.cc
(PeerMessage): Added the initialization for invalidate and
uploading.
* src/CancelMessage.h
(CancelMessage): Rewritten.
* src/RejectMessage.h
(RejectMessage): Rewritten.
* src/Metalinker.h
(operator=): Defined.
* src/MetaEntry.h
(operator=): Defined.
* src/MetalinkResource.h
(operator=): Defined.
* src/AllowedFastMessage.h
(AllowedFastMessage): Rewritten.
* src/HandshakeMessage.h
(HandshakeMessage): New function(overload).
* src/HandshakeMessage.cc
(HandshakeMessage): Rewritten.
(init): New function.
* src/HaveMessage.h
(HaveMessage): Rewritten.
* src/Time.h
(operator=): Defined the function body here.
* src/Time.cc
(operator=): Removed.
* src/SocketCore.h
(operator==): Defined here.
(operator!=): Defined here.
(operator<): Defined here.
* src/SocketCore.cc
(operator==): Removed.
(operator<): Removed.
* src/BitfieldMan.h
(operator=): Defined the function body here.
* src/BitfieldMan.cc
(operator=): Removed.
* src/TorrentMan.h
(deleteErrorPeer): Removed.
(deleteUnusedPeer); New function.
* src/TorrentMan.cc
(addPeer): Call deleteUnusedPeer.
(deleteErrorPeer): Removed.
(deleteUnusedPeer): New function.
* src/PeerAbstractCommand.h
(setNoCheck): New function.
(noCheck): New variable.
* src/PeerAbstractCommand.cc
(PeerAbstractCommand): Added the initialization of noCheck.
(execute): Added a check for noCheck.
(setNoCheck): New function.
* src/Util.h
(stdio.h): Included.
* src/Util.cc
(unistd.h): Included.
* src/DefaultDiskWriter.cc
(unistd.h): Included.
* src/Peer.h
(operator==): Defined the function body here.
(operator!=): Defined the function body here.
* src/Peer.cc
(operator==): Removed.
(operator!=): Removed.
* src/Piece.h
(Piece): Defined the function body here(copy constructor).
(operator=): Defined the function body here.
(operator==): Defined the function body here.
* src/Piece.cc
(Piece): Removed(copy constructor).
(operator=): Removed.
(operator==): Removed.
* src/PeerMessageUtil.h
(ChokeMessage.h): Removed.
(UnchokeMessage.h): Removed.
(InterestedMessage.h): Removed.
(NotInterestedMessage.h): Removed.
(HaveMessage.h): Removed.
(BitfieldMessage.h): Removed.
(RequestMessage.h): Removed.
(CancelMessage.h): Removed.
(PieceMessage.h): Removed.
(HandshakeMessage.h): Removed.
(KeepAliveMessage.h): Removed.
(PortMessage.h): Removed.
(HaveAllMessage.h): Removed.
(HaveNoneMessage.h): Removed.
(PeerConnection.h): Removed.
(HandshakeMessage.h): Included.
* src/BitfieldMessage.h
(init): New function.
(BitfieldMessage): Rewritten.
(BitfieldMessage): New function(overload).
* src/RequestSlot.h
(operator=): Defined the function body here.
(operator==): Defined the function body here.
* src/RequestSlot.cc
(operator=): Removed.
(operator==): Removed.
To remove the dependency on the PeerMessage subclass from
PeerInteraction:
* src/PeerMessageFactory.h: New class.
* src/PeerMessageFactory.cc: New class.
* src/SimplePeerMessage.cc
(send): If invalidate is true then do nothing.
* src/PeerInteractionCommand.cc
(HandshakeMessage.h): Included.
(KeepAliveMessage.h): Included.
(ChokeMessage.h): Included.
(UnchokeMessage.h): Included.
(HaveMessage.h): Included.
(executeInternal): Call setNoCheck().
Removed setWriteCheckSocket(socket).
* src/PeerInteraction.h
(ChokeMessage.h): Removed.
(UnchokeMessage.h): Removed.
(InterestedMessage.h): Removed.
(NotInterestedMessage.h): Removed.
(HaveMessage.h): Removed.
(BitfieldMessage.h): Removed.
(RequestMessage.h): Removed.
(CancelMessage.h): Removed.
(PieceMessage.h): Removed.
(HandshakeMessage.h): Removed.
(KeepAliveMessage.h): Removed.
(PortMessage.h): Removed.
(HaveAllMessage.h): Removed.
(HaveNoneMessage.h): Removed.
(RejectMessage.h): Removed.
(AllowedFastMessage.h): Removed.
(SuggestPieceMessage.h): Removed.
(PeerMessageFactory.h): Included.
(PeerMessageHandle): Removed typedef of PeerMessageHandle.
(HandshakeMessageHandle): Removed typedef of
HandshakeMessageHandle.
(PeerMessageFactory): New variable.
(createPeerMessage): Removed.
(createHandshakeMessage): Removed.
(setPeerMessageCommonProperty): Removed.
(addRequestSlot): New function.
(receiveHandshake): Changed the return value type to
PeerMessageHandle.
(getPeerMessageFactory): New function.
(createRequestMessage): Removed.
(createCancelMessage): Removed.
(createPieceMessage): Removed.
(createHaveMessage): Removed.
(createChokeMessage): Removed.
(createUnchokeMessage): Removed.
(createInterestedMessage): Removed.
(createNotInterestedMessage): Removed.
(createBitfieldMessage): Removed.
(createKeepAliveMessage): Removed.
(createHaveAllMessage): Removed.
(createHaveNoneMessage): Removed.
(createRejectMessage): Removed.
(createAllowedFastMessage): Removed.
* src/PeerInteraction.cc
(PeerInteraction): Allocate PeerMessageFactory here.
(~PeerInteraction): Deallocate PeerMessageFactory here.
(sendMessages): Use msg->isUploading() instead of msg->getId()
==
PieceMessage::ID.
(addMessage): Simplified by using PeerMessage::onPush().
(addRequestSlot): New function.
(rejectAllPieceMessageInQueue): Simplified by using
PeerMessage::onChoked().
(rejectPieceMessageInQueue): Simplified by using
PeerMessage::onCanceled().
(abortPiece): Simplified by using PeerMessage::abortPiece().
(receiveHandshake): Changed the return value type to
PeerMessageHandle.
(createHandshakeMessage): Removed.
(createPeerMessage): Removed.
(sendHandshake): Call
PeerMessageFactory::createHandshakeMessage().
(setPeerMessageCommonProperty): Removed.
(createRequestMessage): Removed.
(createCancelMessage): Removed.
(createPieceMessage): Removed.
(createHaveMessage): Removed.
(createChokeMessage): Removed.
(createUnchokeMessage): Removed.
(createInterestedMessage): Removed.
(createNotInterestedMessage): Removed.
(createBitfieldMessage): Removed.
(createKeepAliveMessage): Removed.
(createHaveAllMessage): Removed.
(createHaveNoneMessage): Removed.
(createRejectMessage): Removed.
(createAllowedFastMessage): Removed.
* src/PieceMessage.h
(createRejectMessage): New function.
(PieceMessage): Rewritten.
(onChoked): New function.
(onCanceled): New function.
* src/PieceMessage.cc
(send): If invalidate is true then do nothing, just return.
(createRejectMessage): New function.
(onChoked): New function.
(onCanceled): New function.
* src/RequestMessage.h
(RequestMessage): Rewritten.
(onPush): New function.
(onAbortPiece): New function.
* src/RequestMessage.cc
(onPush): New function.
(onAbortPiece): New function.
Update fd_set when a socket is added or deleted in order to
improve
performance:
* src/DownloadEngine.h
(rfdset): New variable.
(wfdset): New variable.
(updateFdSet): New function.
* src/DownloadEngine.cc
(SetDescriptor::operator()): Use SockCmdMap::value_type.
(AccumulateActiveCommandUuid::operator()): Use
SockCmdMap::value_type.
(waitData): Copy rfdset and wfdset.
(updateFdSet): New function.
(addSocket): Call updateFdSet.
(deleteSocket): Call updateFdSet.
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().