/* */ #ifndef _D_DOWNLOAD_COMMAND_H_ #define _D_DOWNLOAD_COMMAND_H_ #include "AbstractCommand.h" namespace aria2 { class Decoder; class PeerStat; #ifdef ENABLE_MESSAGE_DIGEST class MessageDigestContext; #endif // ENABLE_MESSAGE_DIGEST class DownloadCommand : public AbstractCommand { private: unsigned char* buf_; time_t startupIdleTime_; unsigned int lowestDownloadSpeedLimit_; SharedHandle peerStat_; #ifdef ENABLE_MESSAGE_DIGEST bool pieceHashValidationEnabled_; SharedHandle messageDigestContext_; #endif // ENABLE_MESSAGE_DIGEST void validatePieceHash(const SharedHandle& segment, const std::string& expectedPieceHash, const std::string& actualPieceHash); void checkLowestDownloadSpeed() const; SharedHandle transferEncodingDecoder_; SharedHandle contentEncodingDecoder_; protected: virtual bool executeInternal(); virtual bool prepareForNextSegment(); // This is file local offset virtual off_t getRequestEndOffset() const = 0; public: DownloadCommand(cuid_t cuid, const SharedHandle& req, const SharedHandle& fileEntry, RequestGroup* requestGroup, DownloadEngine* e, const SharedHandle& s); virtual ~DownloadCommand(); const SharedHandle& getTransferEncodingDecoder() const { return transferEncodingDecoder_; } void setTransferEncodingDecoder(const SharedHandle& decoder); const SharedHandle& getContentEncodingDecoder() const { return contentEncodingDecoder_; } void setContentEncodingDecoder(const SharedHandle& decoder); void setStartupIdleTime(time_t startupIdleTime) { startupIdleTime_ = startupIdleTime; } void setLowestDownloadSpeedLimit(unsigned int lowestDownloadSpeedLimit) { lowestDownloadSpeedLimit_ = lowestDownloadSpeedLimit; } }; } // namespace aria2 #endif // _D_DOWNLOAD_COMMAND_H_