mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-31 09:43:25 -05:00
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:
parent
77cb7314bc
commit
00a0fdfbbf
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user