summaryrefslogtreecommitdiff
path: root/src/HaveEraseCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-10-11 16:58:24 +0000
commit048a2cf59737f761876e81a77e8d064c45c752d7 (patch)
tree65c9d5498aafe6a8c8e640ddfcc43c7013504d0d /src/HaveEraseCommand.cc
parente26bbbb9eee140ba24402fe872a752b42f0077de (diff)
2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
Diffstat (limited to 'src/HaveEraseCommand.cc')
-rw-r--r--src/HaveEraseCommand.cc36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/HaveEraseCommand.cc b/src/HaveEraseCommand.cc
index ecb209c9..c901829f 100644
--- a/src/HaveEraseCommand.cc
+++ b/src/HaveEraseCommand.cc
@@ -33,23 +33,29 @@
*/
/* copyright --> */
#include "HaveEraseCommand.h"
+#include "DownloadEngine.h"
+#include "RequestGroupMan.h"
+#include "PieceStorage.h"
+#include "RequestGroup.h"
-HaveEraseCommand::HaveEraseCommand(int32_t cuid,
- TorrentDownloadEngine* e,
- const BtContextHandle& btContext,
- int32_t interval)
- :BtContextAwareCommand(cuid, btContext),
- e(e),
- interval(interval) {}
+HaveEraseCommand::HaveEraseCommand(int32_t cuid, DownloadEngine* e, int32_t interval)
+ :TimeBasedCommand(cuid, e, interval) {}
-bool HaveEraseCommand::execute() {
- if(btRuntime->isHalt()) {
- return true;
+HaveEraseCommand::~HaveEraseCommand() {}
+
+void HaveEraseCommand::preProcess()
+{
+ if(_e->_requestGroupMan->downloadFinished() || _e->isHaltRequested()) {
+ _exit = true;
}
- if(cp.elapsed(interval)) {
- cp.reset();
- pieceStorage->removeAdvertisedPiece(5);
+}
+
+void HaveEraseCommand::process()
+{
+ for(int32_t i = 0; i < _e->_requestGroupMan->countRequestGroup(); ++i) {
+ PieceStorageHandle ps = _e->_requestGroupMan->getRequestGroup(i)->getPieceStorage();
+ if(!ps.isNull()) {
+ ps->removeAdvertisedPiece(5);
+ }
}
- e->commands.push_back(this);
- return false;
}