mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #907 from PhenomRetroShare/Add_GeneralDirectDLSetting
Add General Direct Download setting.
This commit is contained in:
commit
cb31a92a6e
@ -102,21 +102,24 @@ ftController::ftController(ftDataMultiplex *dm, p3ServiceControl *sc, uint32_t f
|
|||||||
: p3Config(),
|
: p3Config(),
|
||||||
last_save_time(0),
|
last_save_time(0),
|
||||||
last_clean_time(0),
|
last_clean_time(0),
|
||||||
|
mSearch(NULL),
|
||||||
mDataplex(dm),
|
mDataplex(dm),
|
||||||
|
mExtraList(NULL),
|
||||||
mTurtle(NULL),
|
mTurtle(NULL),
|
||||||
mFtServer(NULL),
|
mFtServer(NULL),
|
||||||
mServiceCtrl(sc),
|
mServiceCtrl(sc),
|
||||||
mFtServiceType(ftServiceId),
|
mFtServiceType(ftServiceId),
|
||||||
|
mDefaultEncryptionPolicy(RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE),
|
||||||
|
mFilePermDirectDLPolicy(RS_FILE_PERM_DIRECT_DL_PER_USER),
|
||||||
|
cnt(0),
|
||||||
ctrlMutex("ftController"),
|
ctrlMutex("ftController"),
|
||||||
doneMutex("ftController"),
|
doneMutex("ftController"),
|
||||||
mFtActive(false),
|
mFtActive(false),
|
||||||
mDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE)
|
mFtPendingDone(false),
|
||||||
|
mDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE),
|
||||||
|
_max_active_downloads(5), // default queue size
|
||||||
|
_max_uploads_per_friend(FT_FILECONTROL_MAX_UPLOAD_SLOTS_DEFAULT)
|
||||||
{
|
{
|
||||||
_max_active_downloads = 5 ; // default queue size
|
|
||||||
mDefaultEncryptionPolicy = RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE;
|
|
||||||
_max_uploads_per_friend = FT_FILECONTROL_MAX_UPLOAD_SLOTS_DEFAULT ;
|
|
||||||
/* TODO */
|
|
||||||
cnt = 0 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftController::setTurtleRouter(p3turtle *pt) { mTurtle = pt ; }
|
void ftController::setTurtleRouter(p3turtle *pt) { mTurtle = pt ; }
|
||||||
@ -278,17 +281,26 @@ void ftController::data_tick()
|
|||||||
void ftController::searchForDirectSources()
|
void ftController::searchForDirectSources()
|
||||||
{
|
{
|
||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
if (!mSearch) return;
|
||||||
|
|
||||||
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); ++it)
|
for(std::map<RsFileHash,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); ++it )
|
||||||
if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED)
|
if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED )
|
||||||
{
|
{
|
||||||
FileInfo info ; // info needs to be re-allocated each time, to start with a clear list of peers (it's not cleared down there)
|
FileInfo info ; // Info needs to be re-allocated each time, to start with a clear list of peers (it's not cleared down there)
|
||||||
|
|
||||||
if(mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info))
|
if( mSearch->search(it->first, RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY, info) )
|
||||||
for(std::list<TransferInfo>::const_iterator pit = info.peers.begin(); pit != info.peers.end(); ++pit)
|
for( std::list<TransferInfo>::const_iterator pit = info.peers.begin(); pit != info.peers.end(); ++pit )
|
||||||
if(rsPeers->servicePermissionFlags(pit->peerId) & RS_NODE_PERM_DIRECT_DL)
|
{
|
||||||
if(it->second->mTransfer->addFileSource(pit->peerId)) /* if the sources don't exist already - add in */
|
bool bAllowDirectDL = false;
|
||||||
setPeerState(it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceType, pit->peerId));
|
switch (rsFiles->filePermDirectDL()) {
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_YES: bAllowDirectDL = true; break;
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_NO: bAllowDirectDL = false; break;
|
||||||
|
default:bAllowDirectDL = (rsPeers->servicePermissionFlags(pit->peerId) & RS_NODE_PERM_DIRECT_DL); break;
|
||||||
|
}
|
||||||
|
if( bAllowDirectDL )
|
||||||
|
if( it->second->mTransfer->addFileSource(pit->peerId) ) /* if the sources don't exist already - add in */
|
||||||
|
setPeerState( it->second->mTransfer, pit->peerId, FT_CNTRL_STANDARD_RATE, mServiceCtrl->isPeerConnected(mFtServiceType, pit->peerId) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,6 +760,7 @@ bool ftController::completeFile(const RsFileHash& hash)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(mExtraList)
|
||||||
mExtraList->addExtraFile(path, hash, size, period, extraflags);
|
mExtraList->addExtraFile(path, hash, size, period, extraflags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -855,6 +868,7 @@ bool ftController::alreadyHaveFile(const RsFileHash& hash, FileInfo &info)
|
|||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
// check for file lists
|
// check for file lists
|
||||||
|
if (mSearch) return false;
|
||||||
if (mSearch->search(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY, info))
|
if (mSearch->search(hash, RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY, info))
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
@ -945,15 +959,24 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||||||
// remove the sources from the list, if they don't have clearance for direct transfer. This happens only for non cache files.
|
// remove the sources from the list, if they don't have clearance for direct transfer. This happens only for non cache files.
|
||||||
//
|
//
|
||||||
for(std::list<RsPeerId>::iterator it = srcIds.begin(); it != srcIds.end(); )
|
for(std::list<RsPeerId>::iterator it = srcIds.begin(); it != srcIds.end(); )
|
||||||
if(!(rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL))
|
|
||||||
{
|
{
|
||||||
std::list<RsPeerId>::iterator tmp(it) ;
|
bool bAllowDirectDL = false;
|
||||||
++tmp ;
|
switch (rsFiles->filePermDirectDL()) {
|
||||||
srcIds.erase(it) ;
|
case RS_FILE_PERM_DIRECT_DL_YES: bAllowDirectDL = true; break;
|
||||||
it = tmp ;
|
case RS_FILE_PERM_DIRECT_DL_NO: bAllowDirectDL = false; break;
|
||||||
|
default:bAllowDirectDL = (rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!bAllowDirectDL)
|
||||||
|
{
|
||||||
|
std::list<RsPeerId>::iterator tmp(it);
|
||||||
|
++tmp;
|
||||||
|
srcIds.erase(it);
|
||||||
|
it = tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++it ;
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
std::list<RsPeerId>::const_iterator it;
|
std::list<RsPeerId>::const_iterator it;
|
||||||
std::list<TransferInfo>::const_iterator pit;
|
std::list<TransferInfo>::const_iterator pit;
|
||||||
@ -1001,7 +1024,14 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
for(it = srcIds.begin(); it != srcIds.end(); ++it)
|
for(it = srcIds.begin(); it != srcIds.end(); ++it)
|
||||||
if(rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL)
|
{
|
||||||
|
bool bAllowDirectDL = false;
|
||||||
|
switch (rsFiles->filePermDirectDL()) {
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_YES: bAllowDirectDL = true; break;
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_NO: bAllowDirectDL = false; break;
|
||||||
|
default:bAllowDirectDL = (rsPeers->servicePermissionFlags(*it) & RS_NODE_PERM_DIRECT_DL); break;
|
||||||
|
}
|
||||||
|
if(bAllowDirectDL)
|
||||||
{
|
{
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
if ((dit->second)->mTransfer->getPeerState(*it, i, j))
|
if ((dit->second)->mTransfer->getPeerState(*it, i, j))
|
||||||
@ -1020,6 +1050,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||||||
(dit->second)->mTransfer->addFileSource(*it);
|
(dit->second)->mTransfer->addFileSource(*it);
|
||||||
setPeerState(dit->second->mTransfer, *it, rate, mServiceCtrl->isPeerConnected(mFtServiceType, *it));
|
setPeerState(dit->second->mTransfer, *it, rate, mServiceCtrl->isPeerConnected(mFtServiceType, *it));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (srcIds.empty())
|
if (srcIds.empty())
|
||||||
{
|
{
|
||||||
@ -1034,7 +1065,7 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||||||
} /******* UNLOCKED ********/
|
} /******* UNLOCKED ********/
|
||||||
|
|
||||||
|
|
||||||
if(!(flags & RS_FILE_REQ_NO_SEARCH))
|
if(mSearch && !(flags & RS_FILE_REQ_NO_SEARCH))
|
||||||
{
|
{
|
||||||
/* do a source search - for any extra sources */
|
/* do a source search - for any extra sources */
|
||||||
// add sources only in direct mode
|
// add sources only in direct mode
|
||||||
@ -1056,7 +1087,14 @@ bool ftController::FileRequest(const std::string& fname, const RsFileHash& hash
|
|||||||
#endif
|
#endif
|
||||||
// Because this is auto-add, we only add sources that we allow to DL from using direct transfers.
|
// Because this is auto-add, we only add sources that we allow to DL from using direct transfers.
|
||||||
|
|
||||||
if ((srcIds.end() == std::find( srcIds.begin(), srcIds.end(), pit->peerId)) && (RS_NODE_PERM_DIRECT_DL & rsPeers->servicePermissionFlags(pit->peerId)))
|
bool bAllowDirectDL = false;
|
||||||
|
switch (rsFiles->filePermDirectDL()) {
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_YES: bAllowDirectDL = true; break;
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_NO: bAllowDirectDL = false; break;
|
||||||
|
default:bAllowDirectDL = (rsPeers->servicePermissionFlags(pit->peerId) & RS_NODE_PERM_DIRECT_DL); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((srcIds.end() == std::find( srcIds.begin(), srcIds.end(), pit->peerId)) && bAllowDirectDL)
|
||||||
{
|
{
|
||||||
srcIds.push_back(pit->peerId);
|
srcIds.push_back(pit->peerId);
|
||||||
|
|
||||||
@ -1729,6 +1767,7 @@ const std::string max_uploads_per_friend_ss("MAX_UPLOADS_PER_FRIEND");
|
|||||||
const std::string default_chunk_strategy_ss("DEFAULT_CHUNK_STRATEGY");
|
const std::string default_chunk_strategy_ss("DEFAULT_CHUNK_STRATEGY");
|
||||||
const std::string free_space_limit_ss("FREE_SPACE_LIMIT");
|
const std::string free_space_limit_ss("FREE_SPACE_LIMIT");
|
||||||
const std::string default_encryption_policy_ss("DEFAULT_ENCRYPTION_POLICY");
|
const std::string default_encryption_policy_ss("DEFAULT_ENCRYPTION_POLICY");
|
||||||
|
const std::string file_perm_direct_dl_ss("FILE_PERM_DIRECT_DL");
|
||||||
|
|
||||||
|
|
||||||
/* p3Config Interface */
|
/* p3Config Interface */
|
||||||
@ -1779,6 +1818,15 @@ bool ftController::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
|||||||
|
|
||||||
configMap[default_encryption_policy_ss] = (mDefaultEncryptionPolicy==RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE)?"PERMISSIVE":"STRICT" ;
|
configMap[default_encryption_policy_ss] = (mDefaultEncryptionPolicy==RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE)?"PERMISSIVE":"STRICT" ;
|
||||||
|
|
||||||
|
switch (mFilePermDirectDLPolicy) {
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_YES: configMap[file_perm_direct_dl_ss] = "YES" ;
|
||||||
|
break;
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_NO: configMap[file_perm_direct_dl_ss] = "NO" ;
|
||||||
|
break;
|
||||||
|
default: configMap[file_perm_direct_dl_ss] = "PER_USER" ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
rs_sprintf(s, "%lu", RsDiscSpace::freeSpaceLimit());
|
rs_sprintf(s, "%lu", RsDiscSpace::freeSpaceLimit());
|
||||||
configMap[free_space_limit_ss] = s ;
|
configMap[free_space_limit_ss] = s ;
|
||||||
|
|
||||||
@ -1995,9 +2043,9 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
|
|||||||
{
|
{
|
||||||
std::map<std::string, std::string>::iterator mit;
|
std::map<std::string, std::string>::iterator mit;
|
||||||
|
|
||||||
std::string str_true("true");
|
//std::string str_true("true");
|
||||||
std::string empty("");
|
//std::string empty("");
|
||||||
std::string dir = "notempty";
|
//std::string dir = "notempty";
|
||||||
|
|
||||||
if (configMap.end() != (mit = configMap.find(download_dir_ss)))
|
if (configMap.end() != (mit = configMap.find(download_dir_ss)))
|
||||||
setDownloadDirectory(mit->second);
|
setDownloadDirectory(mit->second);
|
||||||
@ -2072,6 +2120,26 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
|
|||||||
_max_uploads_per_friend = n ;
|
_max_uploads_per_friend = n ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(configMap.end() != (mit = configMap.find(file_perm_direct_dl_ss)))
|
||||||
|
{
|
||||||
|
if(mit->second == "YES")
|
||||||
|
{
|
||||||
|
mFilePermDirectDLPolicy = RS_FILE_PERM_DIRECT_DL_YES ;
|
||||||
|
std::cerr << "Note: loading default value for file permission direct download: YES" << std::endl;
|
||||||
|
}
|
||||||
|
else if(mit->second == "NO")
|
||||||
|
{
|
||||||
|
mFilePermDirectDLPolicy = RS_FILE_PERM_DIRECT_DL_NO ;
|
||||||
|
std::cerr << "Note: loading default value for file permission direct download: NO" << std::endl;
|
||||||
|
}
|
||||||
|
else if(mit->second == "PER_USER")
|
||||||
|
{
|
||||||
|
mFilePermDirectDLPolicy = RS_FILE_PERM_DIRECT_DL_PER_USER ;
|
||||||
|
std::cerr << "Note: loading default value for file permission direct download: PER_USER" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2097,6 +2165,22 @@ uint32_t ftController::defaultEncryptionPolicy()
|
|||||||
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
return mDefaultEncryptionPolicy ;
|
return mDefaultEncryptionPolicy ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ftController::setFilePermDirectDL(uint32_t perm)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
if (mFilePermDirectDLPolicy != perm)
|
||||||
|
{
|
||||||
|
mFilePermDirectDLPolicy = perm;
|
||||||
|
IndicateConfigChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32_t ftController::filePermDirectDL()
|
||||||
|
{
|
||||||
|
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
|
||||||
|
return mFilePermDirectDLPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
void ftController::setFreeDiskSpaceLimit(uint32_t size_in_mb)
|
void ftController::setFreeDiskSpaceLimit(uint32_t size_in_mb)
|
||||||
{
|
{
|
||||||
RsDiscSpace::setFreeSpaceLimit(size_in_mb) ;
|
RsDiscSpace::setFreeSpaceLimit(size_in_mb) ;
|
||||||
|
@ -149,6 +149,9 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C
|
|||||||
void setMaxUploadsPerFriend(uint32_t m) ;
|
void setMaxUploadsPerFriend(uint32_t m) ;
|
||||||
uint32_t getMaxUploadsPerFriend() ;
|
uint32_t getMaxUploadsPerFriend() ;
|
||||||
|
|
||||||
|
void setFilePermDirectDL(uint32_t perm) ;
|
||||||
|
uint32_t filePermDirectDL() ;
|
||||||
|
|
||||||
bool FileCancel(const RsFileHash& hash);
|
bool FileCancel(const RsFileHash& hash);
|
||||||
bool FileControl(const RsFileHash& hash, uint32_t flags);
|
bool FileControl(const RsFileHash& hash, uint32_t flags);
|
||||||
bool FileClearCompleted();
|
bool FileClearCompleted();
|
||||||
@ -237,7 +240,8 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C
|
|||||||
ftServer *mFtServer ;
|
ftServer *mFtServer ;
|
||||||
p3ServiceControl *mServiceCtrl;
|
p3ServiceControl *mServiceCtrl;
|
||||||
uint32_t mFtServiceType;
|
uint32_t mFtServiceType;
|
||||||
uint32_t mDefaultEncryptionPolicy ;
|
uint32_t mDefaultEncryptionPolicy;
|
||||||
|
uint32_t mFilePermDirectDLPolicy;
|
||||||
|
|
||||||
uint32_t cnt ;
|
uint32_t cnt ;
|
||||||
RsMutex ctrlMutex;
|
RsMutex ctrlMutex;
|
||||||
|
@ -291,18 +291,28 @@ bool ftServer::activateTunnels(const RsFileHash& hash,uint32_t encryption_policy
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftServer::setDestinationName(const RsFileHash& hash,const std::string& name)
|
|
||||||
{
|
|
||||||
return mFtController->setDestinationName(hash,name);
|
|
||||||
}
|
|
||||||
bool ftServer::setDestinationDirectory(const RsFileHash& hash,const std::string& directory)
|
bool ftServer::setDestinationDirectory(const RsFileHash& hash,const std::string& directory)
|
||||||
{
|
{
|
||||||
return mFtController->setDestinationDirectory(hash,directory);
|
return mFtController->setDestinationDirectory(hash,directory);
|
||||||
}
|
}
|
||||||
|
bool ftServer::setDestinationName(const RsFileHash& hash,const std::string& name)
|
||||||
|
{
|
||||||
|
return mFtController->setDestinationName(hash,name);
|
||||||
|
}
|
||||||
|
|
||||||
bool ftServer::setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy s)
|
bool ftServer::setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy s)
|
||||||
{
|
{
|
||||||
return mFtController->setChunkStrategy(hash,s);
|
return mFtController->setChunkStrategy(hash,s);
|
||||||
}
|
}
|
||||||
|
void ftServer::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
||||||
|
{
|
||||||
|
mFtController->setDefaultChunkStrategy(s) ;
|
||||||
|
}
|
||||||
|
FileChunksInfo::ChunkStrategy ftServer::defaultChunkStrategy()
|
||||||
|
{
|
||||||
|
return mFtController->defaultChunkStrategy() ;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ftServer::freeDiskSpaceLimit()const
|
uint32_t ftServer::freeDiskSpaceLimit()const
|
||||||
{
|
{
|
||||||
return mFtController->freeDiskSpaceLimit() ;
|
return mFtController->freeDiskSpaceLimit() ;
|
||||||
@ -311,9 +321,10 @@ void ftServer::setFreeDiskSpaceLimit(uint32_t s)
|
|||||||
{
|
{
|
||||||
mFtController->setFreeDiskSpaceLimit(s) ;
|
mFtController->setFreeDiskSpaceLimit(s) ;
|
||||||
}
|
}
|
||||||
void ftServer::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s)
|
|
||||||
|
void ftServer::setDefaultEncryptionPolicy(uint32_t s)
|
||||||
{
|
{
|
||||||
mFtController->setDefaultChunkStrategy(s) ;
|
mFtController->setDefaultEncryptionPolicy(s) ;
|
||||||
}
|
}
|
||||||
uint32_t ftServer::defaultEncryptionPolicy()
|
uint32_t ftServer::defaultEncryptionPolicy()
|
||||||
{
|
{
|
||||||
@ -329,14 +340,15 @@ uint32_t ftServer::getMaxUploadSlotsPerFriend()
|
|||||||
return mFtController->getMaxUploadsPerFriend() ;
|
return mFtController->getMaxUploadsPerFriend() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ftServer::setDefaultEncryptionPolicy(uint32_t s)
|
void ftServer::setFilePermDirectDL(uint32_t perm)
|
||||||
{
|
{
|
||||||
mFtController->setDefaultEncryptionPolicy(s) ;
|
mFtController->setFilePermDirectDL(perm);
|
||||||
}
|
}
|
||||||
FileChunksInfo::ChunkStrategy ftServer::defaultChunkStrategy()
|
uint32_t ftServer::filePermDirectDL()
|
||||||
{
|
{
|
||||||
return mFtController->defaultChunkStrategy() ;
|
return mFtController->filePermDirectDL() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ftServer::FileCancel(const RsFileHash& hash)
|
bool ftServer::FileCancel(const RsFileHash& hash)
|
||||||
{
|
{
|
||||||
// Remove from both queue and ftController, by default.
|
// Remove from both queue and ftController, by default.
|
||||||
|
@ -140,6 +140,8 @@ public:
|
|||||||
virtual uint32_t defaultEncryptionPolicy() ;
|
virtual uint32_t defaultEncryptionPolicy() ;
|
||||||
virtual void setMaxUploadSlotsPerFriend(uint32_t n) ;
|
virtual void setMaxUploadSlotsPerFriend(uint32_t n) ;
|
||||||
virtual uint32_t getMaxUploadSlotsPerFriend() ;
|
virtual uint32_t getMaxUploadSlotsPerFriend() ;
|
||||||
|
virtual void setFilePermDirectDL(uint32_t perm) ;
|
||||||
|
virtual uint32_t filePermDirectDL() ;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Control of Downloads Priority.
|
* Control of Downloads Priority.
|
||||||
|
@ -46,6 +46,10 @@ const uint32_t RS_FILE_CTRL_FORCE_CHECK = 0x00000400;
|
|||||||
const uint32_t RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT = 0x00000001 ;
|
const uint32_t RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT = 0x00000001 ;
|
||||||
const uint32_t RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE = 0x00000002 ;
|
const uint32_t RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE = 0x00000002 ;
|
||||||
|
|
||||||
|
const uint32_t RS_FILE_PERM_DIRECT_DL_YES = 0x00000001 ;
|
||||||
|
const uint32_t RS_FILE_PERM_DIRECT_DL_NO = 0x00000002 ;
|
||||||
|
const uint32_t RS_FILE_PERM_DIRECT_DL_PER_USER = 0x00000003 ;
|
||||||
|
|
||||||
const uint32_t RS_FILE_RATE_TRICKLE = 0x00000001;
|
const uint32_t RS_FILE_RATE_TRICKLE = 0x00000001;
|
||||||
const uint32_t RS_FILE_RATE_SLOW = 0x00000002;
|
const uint32_t RS_FILE_RATE_SLOW = 0x00000002;
|
||||||
const uint32_t RS_FILE_RATE_STANDARD = 0x00000003;
|
const uint32_t RS_FILE_RATE_STANDARD = 0x00000003;
|
||||||
@ -165,10 +169,12 @@ class RsFiles
|
|||||||
virtual void setFreeDiskSpaceLimit(uint32_t size_in_mb) =0;
|
virtual void setFreeDiskSpaceLimit(uint32_t size_in_mb) =0;
|
||||||
virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0;
|
virtual bool FileControl(const RsFileHash& hash, uint32_t flags) = 0;
|
||||||
virtual bool FileClearCompleted() = 0;
|
virtual bool FileClearCompleted() = 0;
|
||||||
virtual void setDefaultEncryptionPolicy(uint32_t policy)=0 ; // RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT/PERMISSIVE
|
virtual void setDefaultEncryptionPolicy(uint32_t policy)=0; // RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT/PERMISSIVE
|
||||||
virtual uint32_t defaultEncryptionPolicy()=0 ;
|
virtual uint32_t defaultEncryptionPolicy()=0;
|
||||||
virtual void setMaxUploadSlotsPerFriend(uint32_t n)=0 ;
|
virtual void setMaxUploadSlotsPerFriend(uint32_t n)=0;
|
||||||
virtual uint32_t getMaxUploadSlotsPerFriend()=0 ;
|
virtual uint32_t getMaxUploadSlotsPerFriend()=0;
|
||||||
|
virtual void setFilePermDirectDL(uint32_t perm)=0;
|
||||||
|
virtual uint32_t filePermDirectDL()=0;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Control of Downloads Priority.
|
* Control of Downloads Priority.
|
||||||
|
@ -43,6 +43,7 @@ TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags)
|
|||||||
QObject::connect(ui._e2e_encryption_CB,SIGNAL(activated(int)),this,SLOT(updateEncryptionPolicy(int))) ;
|
QObject::connect(ui._e2e_encryption_CB,SIGNAL(activated(int)),this,SLOT(updateEncryptionPolicy(int))) ;
|
||||||
QObject::connect(ui._diskSpaceLimit_SB,SIGNAL(valueChanged(int)),this,SLOT(updateDiskSizeLimit(int))) ;
|
QObject::connect(ui._diskSpaceLimit_SB,SIGNAL(valueChanged(int)),this,SLOT(updateDiskSizeLimit(int))) ;
|
||||||
QObject::connect(ui._max_tr_up_per_sec_SB, SIGNAL( valueChanged( int ) ), this, SLOT( updateMaxTRUpRate(int) ) );
|
QObject::connect(ui._max_tr_up_per_sec_SB, SIGNAL( valueChanged( int ) ), this, SLOT( updateMaxTRUpRate(int) ) );
|
||||||
|
QObject::connect(ui._filePermDirectDL_CB,SIGNAL(activated(int)),this,SLOT(updateFilePermDirectDL(int)));
|
||||||
|
|
||||||
QObject::connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
|
QObject::connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
|
||||||
QObject::connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
|
QObject::connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
|
||||||
@ -77,6 +78,16 @@ void TransferPage::updateEncryptionPolicy(int b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransferPage::updateFilePermDirectDL(int i)
|
||||||
|
{
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0: rsFiles->setFilePermDirectDL(RS_FILE_PERM_DIRECT_DL_YES); break;
|
||||||
|
case 1: rsFiles->setFilePermDirectDL(RS_FILE_PERM_DIRECT_DL_NO); break;
|
||||||
|
default: rsFiles->setFilePermDirectDL(RS_FILE_PERM_DIRECT_DL_PER_USER); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TransferPage::load()
|
void TransferPage::load()
|
||||||
{
|
{
|
||||||
whileBlocking(ui.shareDownloadDirectoryCB)->setChecked(rsFiles->getShareDownloadDirectory());
|
whileBlocking(ui.shareDownloadDirectoryCB)->setChecked(rsFiles->getShareDownloadDirectory());
|
||||||
@ -107,6 +118,13 @@ void TransferPage::load()
|
|||||||
whileBlocking(ui._diskSpaceLimit_SB)->setValue(rsFiles->freeDiskSpaceLimit()) ;
|
whileBlocking(ui._diskSpaceLimit_SB)->setValue(rsFiles->freeDiskSpaceLimit()) ;
|
||||||
whileBlocking(ui._max_tr_up_per_sec_SB)->setValue(rsTurtle->getMaxTRForwardRate()) ;
|
whileBlocking(ui._max_tr_up_per_sec_SB)->setValue(rsTurtle->getMaxTRForwardRate()) ;
|
||||||
whileBlocking(ui._max_up_SB)->setValue(rsFiles->getMaxUploadSlotsPerFriend()) ;
|
whileBlocking(ui._max_up_SB)->setValue(rsFiles->getMaxUploadSlotsPerFriend()) ;
|
||||||
|
|
||||||
|
switch (rsFiles->filePermDirectDL())
|
||||||
|
{
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_YES: whileBlocking(ui._filePermDirectDL_CB)->setCurrentIndex(0) ; break ;
|
||||||
|
case RS_FILE_PERM_DIRECT_DL_NO: whileBlocking(ui._filePermDirectDL_CB)->setCurrentIndex(1) ; break ;
|
||||||
|
default: whileBlocking(ui._filePermDirectDL_CB)->setCurrentIndex(2) ; break ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferPage::updateDefaultStrategy(int i)
|
void TransferPage::updateDefaultStrategy(int i)
|
||||||
|
@ -49,6 +49,7 @@ class TransferPage: public ConfigPage
|
|||||||
void updateMaxTRUpRate(int);
|
void updateMaxTRUpRate(int);
|
||||||
void updateEncryptionPolicy(int);
|
void updateEncryptionPolicy(int);
|
||||||
void updateMaxUploadSlots(int);
|
void updateMaxUploadSlots(int);
|
||||||
|
void updateFilePermDirectDL(int);
|
||||||
|
|
||||||
void editDirectories() ;
|
void editDirectories() ;
|
||||||
void setIncomingDirectory();
|
void setIncomingDirectory();
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
<height>1099</height>
|
<height>1099</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="TransferPageVLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_4">
|
<widget class="QGroupBox" name="sharedGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Shared Directories</string>
|
<string>Shared Directories</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="sharedGBoxVLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="shareDownloadHLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="shareDownloadDirectoryCB">
|
<widget class="QCheckBox" name="shareDownloadDirectoryCB">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -42,10 +42,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3"/>
|
<layout class="QHBoxLayout" name="autoCheckDirectoriesHLayout">
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoCheckDirectories_CB">
|
<widget class="QCheckBox" name="autoCheckDirectories_CB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -74,6 +71,8 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="followSymLinksHLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="followSymLinks_CB">
|
<widget class="QCheckBox" name="followSymLinks_CB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -88,14 +87,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="incomingGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Incoming Directory</string>
|
<string>Incoming Directory</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="_3">
|
<layout class="QGridLayout" name="incomingGBoxGLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLineEdit" name="incomingDir">
|
<widget class="QLineEdit" name="incomingDir">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
@ -139,11 +140,11 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_3">
|
<widget class="QGroupBox" name="partialGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Partials Directory</string>
|
<string>Partials Directory</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="_2">
|
<layout class="QGridLayout" name="partialGBoxGLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLineEdit" name="partialsDir">
|
<widget class="QLineEdit" name="partialsDir">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
@ -187,61 +188,68 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="transfertGBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Transfer options</string>
|
<string>Transfer options</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="transfertGBoxVLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="transfertHLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="transfertLabelVLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="_queueSize_Label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Maximum simultaneous downloads:</string>
|
<string>Maximum simultaneous downloads:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="_max_up_Label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Maximum uploads per friend (0 = no limit)</string>
|
<string>Maximum uploads per friend (0 = no limit)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="_defaultStrategy_Label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Default chunk strategy:</string>
|
<string>Default chunk strategy:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="_diskSpaceLimit_Label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Safety disk space limit :</string>
|
<string>Safety disk space limit :</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="_max_tr_up_per_sec_Label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Max. tunnel req. forwarded per second:</string>
|
<string>Max. tunnel req. forwarded per second:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="_e2e_encryption_Label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>End-to-end encryption:</string>
|
<string>End-to-end encryption:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="_filePermDirectDL_Label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Allow direct download:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="transfertValuesVLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="_queueSize_SB">
|
<widget class="QSpinBox" name="_queueSize_SB">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@ -344,6 +352,28 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="_filePermDirectDL_CB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>How RS manage direct download setting.</p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Yes</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>No</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Per user</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user