add code for cancen file transfer

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@854 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
ewensun 2008-11-29 22:03:36 +00:00
parent 77cb7314bc
commit 00a0fdfbbf
2 changed files with 42 additions and 9 deletions

View File

@ -279,7 +279,7 @@ bool ftController::completeFile(std::string hash)
if (doCallback)
{
#ifdef CONTROL_DEBUG
std::cerr << "ftController::completeFile() doing Callback";
std::cerr << "ftController::completeFile() doing Callback, callbackCode:" << callbackCode;
std::cerr << std::endl;
#endif
switch (callbackCode)
@ -663,9 +663,44 @@ bool ftController::FileCancel(std::string hash)
return false;
}
/* check if finished */
if ((mit->second).mCreator->finished())
{
#ifdef CONTROL_DEBUG
std::cerr << "ftController:FileCancel(" << hash << ")";
std::cerr << " Transfer Already finished";
std::cerr << std::endl;
std::cerr << "FileSize: ";
std::cerr << (mit->second).mCreator->getFileSize();
std::cerr << " and Recvd: ";
std::cerr << (mit->second).mCreator->getRecvd();
#endif
return false;
}
/*find the point to transfer module*/
ftTransferModule* ft=(mit->second).mTransfer;
ft->cancelTransfer();
ftFileControl *fc = &(mit->second);
mDataplex->removeTransferModule(fc->mTransfer->hash());
if (fc->mTransfer)
{
delete fc->mTransfer;
fc->mTransfer = NULL;
}
if (fc->mCreator)
{
delete fc->mCreator;
fc->mCreator = NULL;
}
fc->mState = ftFileControl::ERROR_COMPLETION;
mDownloads.erase(mit);
return true;
}

View File

@ -23,9 +23,7 @@
*
*/
/*******
* #define FT_DEBUG 1
******/
#define FT_DEBUG 1
#include "fttransfermodule.h"
@ -411,9 +409,10 @@ bool ftTransferModule::cancelTransfer()
bool ftTransferModule::completeFileTransfer()
{
#ifdef FT_DEBUG
std::cerr << "ftTransferModule::completeFileTransfer()";
std::cerr << std::endl;
#endif
if (mFtController)
mFtController->FlagFileComplete(mHash);
return true;
@ -454,14 +453,13 @@ int ftTransferModule::tick()
switch (flags)
{
case 0:
case 0: //file transfer not complete
adjustSpeed();
break;
case 1:
case 1: //file transfer complete
completeFileTransfer();
break;
case 2:
/* tell me what to do here */
case 2: //file transfer canceled
break;
default:
break;