From 048a2cf59737f761876e81a77e8d064c45c752d7 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 11 Oct 2007 16:58:24 +0000 Subject: 2007-10-12 Tatsuhiro Tsujikawa Implemented BitTorrent/http/ftp integrated download. I've rewritten lots of files and now some headers have forward class declarations to reduce compile time. The implementation is extremely alpha stage, I recommend to use this for testing purpose only. --- src/StreamFileAllocationEntry.cc | 69 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/StreamFileAllocationEntry.cc (limited to 'src/StreamFileAllocationEntry.cc') diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc new file mode 100644 index 00000000..b229a0a2 --- /dev/null +++ b/src/StreamFileAllocationEntry.cc @@ -0,0 +1,69 @@ +/* */ +#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 { + 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; +} -- cgit