cleaned the config->Transfers tab, made the default chunk strategy combobox effective.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2576 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-17 21:10:10 +00:00
parent 8305fe0bf7
commit 589711d482
8 changed files with 110 additions and 150 deletions

View file

@ -1147,6 +1147,8 @@ bool ftController::FileRequest(std::string fname, std::string hash,
ftFileCreator *fc = new ftFileCreator(savepath, size, hash);
ftTransferModule *tm = new ftTransferModule(fc, mDataplex,this);
fc->setChunkStrategy(mDefaultChunkStrategy) ;
/* add into maps */
ftFileControl *ftfc = new ftFileControl(fname, savepath, destination, size, hash, flags, fc, tm, callbackCode);
ftfc->mCreateTime = time(NULL);
@ -1726,6 +1728,7 @@ bool ftController::CancelCacheFile(RsPeerId id, std::string path, std::string ha
const std::string download_dir_ss("DOWN_DIR");
const std::string partial_dir_ss("PART_DIR");
const std::string share_dwl_dir("SHARE_DWL_DIR");
const std::string default_chunk_strategy_ss("DEFAULT_CHUNK_STRATEGY");
/* p3Config Interface */
@ -1757,6 +1760,7 @@ std::list<RsItem *> ftController::saveList(bool &cleanup)
configMap[download_dir_ss] = getDownloadDirectory();
configMap[partial_dir_ss] = getPartialsDirectory();
configMap[share_dwl_dir] = mShareDownloadDir ? "YES" : "NO";
configMap[default_chunk_strategy_ss] = (mDefaultChunkStrategy==FileChunksInfo::CHUNK_STRATEGY_STREAMING) ? "STREAMING" : "RANDOM";
RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet();
@ -1940,15 +1944,39 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
}
}
if (configMap.end() != (mit = configMap.find(default_chunk_strategy_ss)))
{
if(mit->second == "STREAMING")
setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_STREAMING) ;
else if(mit->second == "RANDOM")
setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM) ;
}
return true;
}
FileChunksInfo::ChunkStrategy ftController::defaultChunkStrategy()
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
return mDefaultChunkStrategy ;
}
void ftController::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy S)
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
mDefaultChunkStrategy = S ;
IndicateConfigChanged() ;
}
void ftController::setShareDownloadDirectory(bool value)
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
mShareDownloadDir = value;
IndicateConfigChanged() ;
}
bool ftController::getShareDownloadDirectory()
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
return mShareDownloadDir;
}

View file

@ -144,6 +144,8 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
bool alreadyHaveFile(const std::string& hash) ;
bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s);
void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s);
FileChunksInfo::ChunkStrategy defaultChunkStrategy();
bool FileCancel(std::string hash);
bool FileControl(std::string hash, uint32_t flags);
@ -265,6 +267,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
/* share incoming directory */
bool mShareDownloadDir;
FileChunksInfo::ChunkStrategy mDefaultChunkStrategy ;
uint32_t _max_active_downloads ; // maximum number of simultaneous downloads
};

View file

@ -272,6 +272,14 @@ bool ftServer::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStr
{
return mFtController->setChunkStrategy(hash,s);
}
void ftServer::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy)
{
mFtController->defaultChunkStrategy() ;
}
FileChunksInfo::ChunkStrategy ftServer::defaultChunkStrategy()
{
return mFtController->defaultChunkStrategy() ;
}
bool ftServer::FileCancel(std::string hash)
{

View file

@ -125,6 +125,9 @@ virtual bool FileCancel(std::string hash);
virtual bool FileControl(std::string hash, uint32_t flags);
virtual bool FileClearCompleted();
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s) ;
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) ;
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() ;
/***
* Control of Downloads Priority.

View file

@ -113,6 +113,8 @@ class RsFiles
virtual bool FileRequest(std::string fname, std::string hash, uint64_t size, std::string dest, uint32_t flags, std::list<std::string> srcIds) = 0;
virtual bool FileCancel(std::string hash) = 0;
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 0;
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0;
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() = 0;
virtual bool FileControl(std::string hash, uint32_t flags) = 0;
virtual bool FileClearCompleted() = 0;