/* */ #include "BtSetup.h" #include "RequestGroup.h" #include "DownloadEngine.h" #include "Option.h" #include "BtRegistry.h" #include "PeerListenCommand.h" #include "TrackerWatcherCommand.h" #include "SeedCheckCommand.h" #include "PeerChokeCommand.h" #include "ActivePeerConnectionCommand.h" #include "UnionSeedCriteria.h" #include "TimeSeedCriteria.h" #include "ShareRatioSeedCriteria.h" #include "DefaultPieceStorage.h" #include "DefaultBtProgressInfoFile.h" #include "CUIDCounter.h" #include "prefs.h" Commands BtSetup::setup(RequestGroup* requestGroup, DownloadEngine* e, const Option* option) { Commands commands; BtContextHandle btContext = requestGroup->getDownloadContext(); if(btContext.isNull()) { return commands; } // TODO following process is moved to BtSetup // commands commands.push_back(new TrackerWatcherCommand(CUIDCounterSingletonHolder::instance()->newID(), requestGroup, e, btContext)); commands.push_back(new PeerChokeCommand(CUIDCounterSingletonHolder::instance()->newID(), requestGroup, e, btContext, 10)); commands.push_back(new ActivePeerConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), requestGroup, e, btContext, 30)); SharedHandle unionCri = new UnionSeedCriteria(); if(option->defined(PREF_SEED_TIME)) { unionCri->addSeedCriteria(new TimeSeedCriteria(option->getAsInt(PREF_SEED_TIME)*60)); } if(option->defined(PREF_SEED_RATIO)) { unionCri->addSeedCriteria(new ShareRatioSeedCriteria(option->getAsDouble(PREF_SEED_RATIO), btContext)); } if(unionCri->getSeedCriterion().size() > 0) { commands.push_back(new SeedCheckCommand(CUIDCounterSingletonHolder::instance()->newID(), requestGroup, e, btContext, unionCri)); } BT_RUNTIME(btContext)->setReady(true); return commands; }