/* */ #include "StreamFileAllocationEntry.h" #include "CUIDCounter.h" #include "Command.h" #include "DownloadEngine.h" #include "Option.h" #include "Request.h" #include "prefs.h" #include "RequestGroup.h" #include "InitiateConnectionCommandFactory.h" StreamFileAllocationEntry::StreamFileAllocationEntry(const RequestHandle& currentRequest, RequestGroup* requestGroup, Command* nextCommand): FileAllocationEntry(requestGroup, nextCommand), _currentRequest(currentRequest) {} StreamFileAllocationEntry::~StreamFileAllocationEntry() {} Commands StreamFileAllocationEntry::prepareForNextAction(DownloadEngine* e) { Commands commands; if(_timer.difference() <= e->option->getAsInt(PREF_DIRECT_DOWNLOAD_TIMEOUT) && _nextCommand) { commands.push_back(popNextCommand()); } else { if(_currentRequest.isNull()) { commands = _requestGroup->createNextCommandWithAdj(e, 0); } else { Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1); Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), _currentRequest, _requestGroup, e); commands.push_back(command); copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands)); } } return commands; }