/* */ #include "DownloadHandlerFactory.h" #include "MemoryBufferPreDownloadHandler.h" #include "MetalinkPostDownloadHandler.h" #include "BtPostDownloadHandler.h" #include "DownloadHandlerConstants.h" #include "ContentTypeRequestGroupCriteria.h" #include "UTMetadataPostDownloadHandler.h" namespace aria2 { #ifdef ENABLE_METALINK SharedHandle DownloadHandlerFactory::metalinkPreDownloadHandler_; SharedHandle DownloadHandlerFactory::metalinkPostDownloadHandler_; #endif // ENABLE_METALINK #ifdef ENABLE_BITTORRENT SharedHandle DownloadHandlerFactory::btPreDownloadHandler_; SharedHandle DownloadHandlerFactory::btPostDownloadHandler_; SharedHandle DownloadHandlerFactory::btMetadataPostDownloadHandler_; #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK SharedHandle DownloadHandlerFactory::getMetalinkPreDownloadHandler() { if(!metalinkPreDownloadHandler_) { metalinkPreDownloadHandler_.reset(new MemoryBufferPreDownloadHandler()); RequestGroupCriteriaHandle criteria (new ContentTypeRequestGroupCriteria (DownloadHandlerConstants::getMetalinkContentTypes().begin(), DownloadHandlerConstants::getMetalinkContentTypes().end(), DownloadHandlerConstants::getMetalinkExtensions().begin(), DownloadHandlerConstants::getMetalinkExtensions().end())); metalinkPreDownloadHandler_->setCriteria(criteria); } return metalinkPreDownloadHandler_; } SharedHandle DownloadHandlerFactory::getMetalinkPostDownloadHandler() { if(!metalinkPostDownloadHandler_) { metalinkPostDownloadHandler_.reset(new MetalinkPostDownloadHandler()); } return metalinkPostDownloadHandler_; } #endif // ENABLE_METALINK #ifdef ENABLE_BITTORRENT SharedHandle DownloadHandlerFactory::getBtPreDownloadHandler() { if(!btPreDownloadHandler_) { btPreDownloadHandler_.reset(new MemoryBufferPreDownloadHandler()); RequestGroupCriteriaHandle criteria (new ContentTypeRequestGroupCriteria (DownloadHandlerConstants::getBtContentTypes().begin(), DownloadHandlerConstants::getBtContentTypes().end(), DownloadHandlerConstants::getBtExtensions().begin(), DownloadHandlerConstants::getBtExtensions().end())); btPreDownloadHandler_->setCriteria(criteria); } return btPreDownloadHandler_; } SharedHandle DownloadHandlerFactory::getBtPostDownloadHandler() { if(!btPostDownloadHandler_) { btPostDownloadHandler_.reset(new BtPostDownloadHandler()); } return btPostDownloadHandler_; } SharedHandle DownloadHandlerFactory::getUTMetadataPostDownloadHandler() { if(!btMetadataPostDownloadHandler_) { btMetadataPostDownloadHandler_.reset(new UTMetadataPostDownloadHandler()); } return btMetadataPostDownloadHandler_; } #endif // ENABLE_BITTORRENT } // namespace aria2