Removed member ftController::mShareDownloadDir and calculate the value from the shared directories.

Combined the two methods for share and unshare of the download dir.
Added share incoming directory to the QuickStartWizard.
Recompile of the GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4089 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-03-08 20:05:36 +00:00
parent 4779d83ab7
commit af4dd635e3
11 changed files with 68 additions and 143 deletions

View file

@ -100,7 +100,6 @@ ftController::ftController(CacheStrapper *cs, ftDataMultiplex *dm, std::string c
mDataplex(dm),
mTurtle(NULL),
mFtActive(false),
mShareDownloadDir(true),
mDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM)
{
_max_active_downloads = 5 ; // default queue size
@ -1845,7 +1844,6 @@ bool ftController::CancelCacheFile(RsPeerId id, std::string path, std::string ha
const std::string active_downloads_size_ss("MAX_ACTIVE_DOWNLOADS");
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");
const std::string free_space_limit_ss("FREE_SPACE_LIMIT");
@ -1880,7 +1878,6 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
configMap[active_downloads_size_ss] = strm.str() ;
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";
std::ostringstream s ;
@ -2074,18 +2071,6 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
setPartialsDirectory(mit->second);
}
if (configMap.end() != (mit = configMap.find(share_dwl_dir)))
{
if (mit->second == "YES")
{
setShareDownloadDirectory(true);
}
else if (mit->second == "NO")
{
setShareDownloadDirectory(false);
}
}
if (configMap.end() != (mit = configMap.find(default_chunk_strategy_ss)))
{
if(mit->second == "STREAMING")
@ -2143,17 +2128,3 @@ void ftController::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy S)
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

@ -126,9 +126,6 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
bool activate();
bool isActiveAndNoPending();
void setShareDownloadDirectory(bool value);
bool getShareDownloadDirectory();
virtual void run();
/***************************************************************/
@ -259,8 +256,6 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
std::list<ftPendingRequest> mPendingRequests;
std::map<std::string,RsFileTransfer*> mPendingChunkMaps ;
/* share incoming directory */
bool mShareDownloadDir;
FileChunksInfo::ChunkStrategy mDefaultChunkStrategy ;
uint32_t _max_active_downloads ; // maximum number of simultaneous downloads

View file

@ -665,27 +665,33 @@ void ftServer::clearHashCache()
mFiMon->clearHashCache() ;
}
void ftServer::setShareDownloadDirectory(bool value)
{
mFtController->setShareDownloadDirectory(value);
}
bool ftServer::getShareDownloadDirectory()
{
return mFtController->getShareDownloadDirectory();
std::list<SharedDirInfo> dirList;
mFiMon->getSharedDirectories(dirList);
std::string dir = mFtController->getDownloadDirectory();
// check if the download directory is in the list.
for (std::list<SharedDirInfo>::const_iterator it(dirList.begin()); it != dirList.end(); ++it)
if ((*it).filename == dir)
return true;
return false;
}
bool ftServer::shareDownloadDirectory()
bool ftServer::shareDownloadDirectory(bool share)
{
SharedDirInfo inf ;
inf.filename = mFtController->getDownloadDirectory();
inf.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
if (share) {
/* Share */
SharedDirInfo inf ;
inf.filename = mFtController->getDownloadDirectory();
inf.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
return addSharedDirectory(inf);
}
return addSharedDirectory(inf);
}
bool ftServer::unshareDownloadDirectory()
{
/* Unshare */
std::string dir = mFtController->getDownloadDirectory();
return removeSharedDirectory(dir);
}

View file

@ -197,10 +197,8 @@ virtual bool addSharedDirectory(const SharedDirInfo& dir);
virtual bool updateShareFlags(const SharedDirInfo& dir); // updates the flags. The directory should already exist !
virtual bool removeSharedDirectory(std::string dir);
virtual void setShareDownloadDirectory(bool value);
virtual bool getShareDownloadDirectory();
virtual bool shareDownloadDirectory();
virtual bool unshareDownloadDirectory();
virtual bool shareDownloadDirectory(bool share);
virtual void setRememberHashFilesDuration(uint32_t days) ;
virtual uint32_t rememberHashFilesDuration() const ;

View file

@ -190,10 +190,8 @@ class RsFiles
virtual bool rememberHashFiles() const =0;
virtual void setRememberHashFiles(bool) =0;
virtual void setShareDownloadDirectory(bool value) = 0;
virtual bool getShareDownloadDirectory() = 0;
virtual bool shareDownloadDirectory() = 0;
virtual bool unshareDownloadDirectory() = 0;
virtual bool shareDownloadDirectory(bool share) = 0;
};