/* */ #include "TimedHaltCommand.h" #include "DownloadEngine.h" #include "RequestGroupMan.h" #include "Logger.h" #include "LogFactory.h" #include "message.h" #include "fmt.h" namespace aria2 { TimedHaltCommand::TimedHaltCommand(cuid_t cuid, DownloadEngine* e, std::chrono::seconds secondsToHalt, bool forceHalt) : TimeBasedCommand(cuid, e, std::move(secondsToHalt), true), forceHalt_(forceHalt) { } TimedHaltCommand::~TimedHaltCommand() = default; void TimedHaltCommand::preProcess() { if (getDownloadEngine()->getRequestGroupMan()->downloadFinished() || getDownloadEngine()->isHaltRequested()) { enableExit(); } } void TimedHaltCommand::process() { if (!getDownloadEngine()->isHaltRequested()) { A2_LOG_NOTICE( fmt(MSG_TIME_HAS_PASSED, static_cast(getInterval().count()))); if (forceHalt_) { getDownloadEngine()->requestForceHalt(); } else { getDownloadEngine()->requestHalt(); } enableExit(); } } } // namespace aria2