mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed up GUI parameters in Directories. Removed HashCache duration handles since this is now automatic
This commit is contained in:
parent
04c908e046
commit
de104d3e34
@ -337,6 +337,8 @@ void LocalDirectoryStorage::setSharedDirectoryList(const std::list<SharedDirInfo
|
||||
|
||||
for(std::list<SharedDirInfo>::const_iterator it(processed_list.begin());it!=processed_list.end();++it)
|
||||
mLocalDirs[it->filename] = *it;
|
||||
|
||||
mTSChanged = true ;
|
||||
}
|
||||
void LocalDirectoryStorage::getSharedDirectoryList(std::list<SharedDirInfo>& lst)
|
||||
{
|
||||
@ -388,7 +390,10 @@ void LocalDirectoryStorage::updateShareFlags(const SharedDirInfo& info)
|
||||
}
|
||||
|
||||
if(changed)
|
||||
{
|
||||
setDirectoryLocalModTime(0,time(NULL)) ;
|
||||
mTSChanged = true ;
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::convertSharedFilePath(const std::string& path, std::string& fullpath)
|
||||
@ -411,13 +416,24 @@ bool LocalDirectoryStorage::convertSharedFilePath(const std::string& path, std::
|
||||
return true;
|
||||
}
|
||||
|
||||
void LocalDirectoryStorage::notifyTSChanged()
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
mTSChanged = true ;
|
||||
}
|
||||
void LocalDirectoryStorage::updateTimeStamps()
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
time_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0)) ;
|
||||
if(mTSChanged)
|
||||
{
|
||||
std::cerr << "Updating recursive TS for local shared dirs..." << std::endl;
|
||||
|
||||
std::cerr << "LocalDirectoryStorage: global last modf time is " << last_modf_time << " (which is " << time(NULL) - last_modf_time << " secs ago)" << std::endl;
|
||||
time_t last_modf_time = mFileHierarchy->recursUpdateLastModfTime(EntryIndex(0)) ;
|
||||
mTSChanged = false ;
|
||||
|
||||
std::cerr << "LocalDirectoryStorage: global last modf time is " << last_modf_time << " (which is " << time(NULL) - last_modf_time << " secs ago)" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::string LocalDirectoryStorage::locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const
|
||||
|
@ -201,7 +201,17 @@ public:
|
||||
void updateShareFlags(const SharedDirInfo& info) ;
|
||||
bool convertSharedFilePath(const std::string& path_with_virtual_name,std::string& fullpath) ;
|
||||
|
||||
/*!
|
||||
* \brief updateTimeStamps
|
||||
* Checks recursive TS and update the if needed.
|
||||
*/
|
||||
void updateTimeStamps();
|
||||
|
||||
/*!
|
||||
* \brief notifyTSChanged
|
||||
* Use this to force an update of the recursive TS, when calling updateTimeStamps();
|
||||
*/
|
||||
void notifyTSChanged();
|
||||
/*!
|
||||
* \brief getFileInfo Converts an index info a full file info structure.
|
||||
* \param i index in the directory structure
|
||||
@ -239,11 +249,13 @@ private:
|
||||
std::string locked_getVirtualPath(EntryIndex indx) const ;
|
||||
std::string locked_getVirtualDirName(EntryIndex indx) const ;
|
||||
|
||||
bool locked_getFileSharingPermissions(const EntryIndex& indx, FileStorageFlags &flags, std::list<RsNodeGroupId>& parent_groups);
|
||||
std::string locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const;
|
||||
bool locked_getFileSharingPermissions(const EntryIndex& indx, FileStorageFlags &flags, std::list<RsNodeGroupId>& parent_groups);
|
||||
std::string locked_findRealRootFromVirtualFilename(const std::string& virtual_rootdir) const;
|
||||
|
||||
std::map<std::string,SharedDirInfo> mLocalDirs ; // map is better for search. it->first=it->second.filename
|
||||
std::string mFileName;
|
||||
std::map<std::string,SharedDirInfo> mLocalDirs ; // map is better for search. it->first=it->second.filename
|
||||
std::string mFileName;
|
||||
|
||||
bool mTSChanged ;
|
||||
};
|
||||
|
||||
|
||||
|
@ -42,16 +42,35 @@ LocalDirectoryUpdater::LocalDirectoryUpdater(HashStorage *hc,LocalDirectoryStora
|
||||
mLastTSUpdateTime = 0;
|
||||
|
||||
mDelayBetweenDirectoryUpdates = DELAY_BETWEEN_DIRECTORY_UPDATES;
|
||||
mIsEnabled = false ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryUpdater::isEnabled() const
|
||||
{
|
||||
return mIsEnabled ;
|
||||
}
|
||||
void LocalDirectoryUpdater::setEnabled(bool b)
|
||||
{
|
||||
if(mIsEnabled == b)
|
||||
return ;
|
||||
|
||||
if(b)
|
||||
start() ;
|
||||
else
|
||||
shutdown();
|
||||
|
||||
mIsEnabled = b ;
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::data_tick()
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
if(now > DELAY_BETWEEN_DIRECTORY_UPDATES + mLastSweepTime)
|
||||
if(now > mDelayBetweenDirectoryUpdates + mLastSweepTime)
|
||||
{
|
||||
sweepSharedDirectories() ;
|
||||
mLastSweepTime = now;
|
||||
mSharedDirectories->notifyTSChanged() ;
|
||||
}
|
||||
|
||||
if(now > DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE + mLastTSUpdateTime)
|
||||
@ -177,10 +196,24 @@ void LocalDirectoryUpdater::hash_callback(uint32_t client_param, const std::stri
|
||||
{
|
||||
if(!mSharedDirectories->updateHash(DirectoryStorage::EntryIndex(client_param),hash))
|
||||
std::cerr << "(EE) Cannot update file. Something's wrong." << std::endl;
|
||||
|
||||
mSharedDirectories->notifyTSChanged() ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryUpdater::hash_confirm(uint32_t client_param)
|
||||
{
|
||||
return mSharedDirectories->getEntryType(DirectoryStorage::EntryIndex(client_param)) == DIR_TYPE_FILE ;
|
||||
}
|
||||
|
||||
void LocalDirectoryUpdater::setFileWatchPeriod(int seconds)
|
||||
{
|
||||
mDelayBetweenDirectoryUpdates = seconds ;
|
||||
}
|
||||
uint32_t LocalDirectoryUpdater::fileWatchPeriod() const
|
||||
{
|
||||
return mDelayBetweenDirectoryUpdates ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -41,13 +41,18 @@ public:
|
||||
void forceUpdate();
|
||||
bool inDirectoryCheck() const ;
|
||||
|
||||
void setFileWatchPeriod(uint32_t seconds) { mDelayBetweenDirectoryUpdates = seconds ; }
|
||||
uint32_t fileWatchPeriod() const { return mDelayBetweenDirectoryUpdates ; }
|
||||
void setFileWatchPeriod(int seconds) ;
|
||||
uint32_t fileWatchPeriod() const ;
|
||||
|
||||
void setEnabled(bool b) ;
|
||||
bool isEnabled() const ;
|
||||
|
||||
protected:
|
||||
virtual void data_tick() ;
|
||||
|
||||
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size);
|
||||
virtual bool hash_confirm(uint32_t client_param) ;
|
||||
|
||||
void recursUpdateSharedDir(const std::string& cumulated_path,DirectoryStorage::EntryIndex indx);
|
||||
void sweepSharedDirectories();
|
||||
|
||||
@ -59,5 +64,6 @@ private:
|
||||
time_t mLastTSUpdateTime;
|
||||
|
||||
uint32_t mDelayBetweenDirectoryUpdates;
|
||||
bool mIsEnabled ;
|
||||
};
|
||||
|
||||
|
@ -28,15 +28,17 @@
|
||||
|
||||
static const uint32_t DELAY_BETWEEN_DIRECTORY_UPDATES = 600 ; // 10 minutes
|
||||
static const uint32_t DELAY_BETWEEN_REMOTE_DIRECTORY_SYNC_REQ = 120 ; // 2 minutes
|
||||
static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 300 ; // 5 minutes
|
||||
static const uint32_t DELAY_BETWEEN_LOCAL_DIRECTORIES_TS_UPDATE = 20 ; // 20 sec. Buy we only update for real if something has changed.
|
||||
|
||||
static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // key string to store hash remembering time
|
||||
static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files
|
||||
static const std::string HASH_CACHE_DURATION_SS = "HASH_CACHE_DURATION" ; // key string to store hash remembering time
|
||||
static const std::string WATCH_FILE_DURATION_SS = "WATCH_FILES_DELAY" ; // key to store delay before re-checking for new files
|
||||
static const std::string WATCH_FILE_ENABLED_SS = "WATCH_FILES_ENABLED"; // key to store ON/OFF flags for file whatch
|
||||
|
||||
static const std::string FILE_SHARING_DIR_NAME = "file_sharing" ; // hard-coded directory name to store friend file lists, hash cache, etc.
|
||||
static const std::string HASH_CACHE_FILE_NAME = "hash_cache.bin" ; // hard-coded directory name to store encrypted hash cache.
|
||||
static const std::string FILE_SHARING_DIR_NAME = "file_sharing" ; // hard-coded directory name to store friend file lists, hash cache, etc.
|
||||
static const std::string HASH_CACHE_FILE_NAME = "hash_cache.bin" ; // hard-coded directory name to store encrypted hash cache.
|
||||
|
||||
static const uint32_t MIN_INTERVAL_BETWEEN_HASH_CACHE_SAVE = 20 ; // never save hash cache more often than every 20 secs.
|
||||
static const uint32_t MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE = 23 ; // never save remote directories more often than this
|
||||
static const uint32_t MIN_INTERVAL_BETWEEN_HASH_CACHE_SAVE = 20 ; // never save hash cache more often than every 20 secs.
|
||||
static const uint32_t MIN_INTERVAL_BETWEEN_REMOTE_DIRECTORY_SAVE = 23 ; // never save remote directories more often than this
|
||||
|
||||
static const uint32_t MAX_DIR_SYNC_RESPONSE_DATA_SIZE = 20000 ; // Maximum RsItem data size in bytes for serialised directory transmission
|
||||
static const uint32_t DEFAULT_HASH_STORAGE_DURATION_DAYS = 30 ; // remember deleted/inaccessible files for 30 days
|
||||
|
@ -43,6 +43,7 @@ HashStorage::HashStorage(const std::string& save_file_name)
|
||||
mLastSaveTime = 0 ;
|
||||
mTotalSizeToHash = 0;
|
||||
mTotalFilesToHash = 0;
|
||||
mMaxStorageDurationDays = DEFAULT_HASH_STORAGE_DURATION_DAYS ;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mHashMtx) ;
|
||||
@ -138,40 +139,42 @@ void HashStorage::data_tick()
|
||||
mFilesToHash.erase(mFilesToHash.begin()) ;
|
||||
}
|
||||
|
||||
std::cerr << "Hashing file " << job.full_path << "..." ; std::cerr.flush();
|
||||
|
||||
std::string tmpout;
|
||||
rs_sprintf(tmpout, "%lu/%lu (%s - %d%%) : %s", mHashCounter+1, mTotalFilesToHash, friendlyUnit(mTotalHashedSize).c_str(), int(mTotalHashedSize/double(mTotalSizeToHash)*100.0), job.full_path.c_str()) ;
|
||||
|
||||
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, tmpout) ;
|
||||
|
||||
if(!RsDirUtil::getFileHash(job.full_path, hash,size, this))
|
||||
std::cerr << "ERROR: cannot hash file " << job.full_path << std::endl;
|
||||
else
|
||||
std::cerr << "done."<< std::endl;
|
||||
|
||||
// store the result
|
||||
|
||||
if(job.client->hash_confirm(job.client_param))
|
||||
{
|
||||
RS_STACK_MUTEX(mHashMtx) ;
|
||||
HashStorageInfo& info(mFiles[job.full_path]);
|
||||
std::cerr << "Hashing file " << job.full_path << "..." ; std::cerr.flush();
|
||||
|
||||
info.filename = job.full_path ;
|
||||
info.size = size ;
|
||||
info.modf_stamp = job.ts ;
|
||||
info.time_stamp = time(NULL);
|
||||
info.hash = hash;
|
||||
std::string tmpout;
|
||||
rs_sprintf(tmpout, "%lu/%lu (%s - %d%%) : %s", mHashCounter+1, mTotalFilesToHash, friendlyUnit(mTotalHashedSize).c_str(), int(mTotalHashedSize/double(mTotalSizeToHash)*100.0), job.full_path.c_str()) ;
|
||||
|
||||
mChanged = true ;
|
||||
++mHashCounter ;
|
||||
mTotalHashedSize += size ;
|
||||
RsServer::notify()->notifyHashingInfo(NOTIFY_HASHTYPE_HASH_FILE, tmpout) ;
|
||||
|
||||
if(!RsDirUtil::getFileHash(job.full_path, hash,size, this))
|
||||
std::cerr << "ERROR: cannot hash file " << job.full_path << std::endl;
|
||||
else
|
||||
std::cerr << "done."<< std::endl;
|
||||
|
||||
// store the result
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mHashMtx) ;
|
||||
HashStorageInfo& info(mFiles[job.full_path]);
|
||||
|
||||
info.filename = job.full_path ;
|
||||
info.size = size ;
|
||||
info.modf_stamp = job.ts ;
|
||||
info.time_stamp = time(NULL);
|
||||
info.hash = hash;
|
||||
|
||||
mChanged = true ;
|
||||
++mHashCounter ;
|
||||
mTotalHashedSize += size ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// call the client
|
||||
|
||||
if(!hash.isNull())
|
||||
job.client->hash_callback(job.client_param, job.full_path, hash, size);
|
||||
|
||||
}
|
||||
|
||||
bool HashStorage::requestHash(const std::string& full_path,uint64_t size,time_t mod_time,RsFileHash& known_hash,HashStorageClient *c,uint32_t client_param)
|
||||
@ -234,14 +237,11 @@ void HashStorage::clean()
|
||||
{
|
||||
RS_STACK_MUTEX(mHashMtx) ;
|
||||
|
||||
#ifdef HASHSTORAGE_DEBUG
|
||||
std::cerr << "Cleaning HashStorage..." << std::endl ;
|
||||
#endif
|
||||
time_t now = time(NULL) ;
|
||||
time_t duration = mMaxStorageDurationDays * 24 * 3600 ; // seconds
|
||||
|
||||
#ifdef HASHSTORAGE_DEBUG
|
||||
std::cerr << "cleaning hash cache." << std::endl ;
|
||||
std::cerr << "Cleaning hash cache." << std::endl ;
|
||||
#endif
|
||||
|
||||
for(std::map<std::string,HashStorageInfo>::iterator it(mFiles.begin());it!=mFiles.end();)
|
||||
|
@ -36,7 +36,14 @@ public:
|
||||
HashStorageClient() {}
|
||||
virtual ~HashStorageClient() {}
|
||||
|
||||
// the result of the hashing info is sent to this method
|
||||
|
||||
virtual void hash_callback(uint32_t client_param, const std::string& name, const RsFileHash& hash, uint64_t size)=0;
|
||||
|
||||
// this method is used to check that the client param is still valid just before hashing. This avoids hashing files
|
||||
// that are still in queue while removed from shared lists.
|
||||
|
||||
virtual bool hash_confirm(uint32_t client_param)=0 ;
|
||||
};
|
||||
|
||||
class HashStorage: public RsTickingThread
|
||||
@ -90,7 +97,7 @@ private:
|
||||
// Local configuration and storage
|
||||
|
||||
uint32_t mMaxStorageDurationDays ; // maximum duration of un-requested cache entries
|
||||
std::map<std::string, HashStorageInfo> mFiles ; // stored as (full_path, hash_info)
|
||||
std::map<std::string, HashStorageInfo> mFiles ; // stored as (full_path, hash_info)
|
||||
std::string mFilePath ;
|
||||
bool mChanged ;
|
||||
|
||||
|
@ -312,6 +312,15 @@ cleanup = true;
|
||||
rskv->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
||||
{
|
||||
RsTlvKeyValue kv;
|
||||
|
||||
kv.key = WATCH_FILE_ENABLED_SS;
|
||||
kv.value = watchEnabled()?"YES":"NO" ;
|
||||
|
||||
rskv->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
||||
/* Add KeyValue to saveList */
|
||||
sList.push_back(rskv);
|
||||
|
||||
@ -354,6 +363,10 @@ bool p3FileDatabase::loadList(std::list<RsItem *>& load)
|
||||
if(sscanf(kit->value.c_str(),"%d",&t) == 1)
|
||||
setWatchPeriod(t);
|
||||
}
|
||||
else if(kit->key == WATCH_FILE_ENABLED_SS)
|
||||
{
|
||||
setWatchEnabled(kit->value == "YES") ;
|
||||
}
|
||||
delete *it ;
|
||||
continue ;
|
||||
}
|
||||
@ -788,14 +801,23 @@ uint32_t p3FileDatabase::getType(void *ref) const
|
||||
|
||||
void p3FileDatabase::forceDirectoryCheck() // Force re-sweep the directories and see what's changed
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
mLocalDirWatcher->forceUpdate();
|
||||
}
|
||||
bool p3FileDatabase::inDirectoryCheck()
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return mLocalDirWatcher->inDirectoryCheck();
|
||||
}
|
||||
void p3FileDatabase::setWatchEnabled(bool b)
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
mLocalDirWatcher->setEnabled(b) ;
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
bool p3FileDatabase::watchEnabled()
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
return mLocalDirWatcher->isEnabled() ;
|
||||
}
|
||||
void p3FileDatabase::setWatchPeriod(uint32_t seconds)
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
@ -808,31 +830,6 @@ uint32_t p3FileDatabase::watchPeriod()
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
return mLocalDirWatcher->fileWatchPeriod();
|
||||
}
|
||||
void p3FileDatabase::setRememberHashCacheDuration(uint32_t days)
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
mHashCache->setRememberHashFilesDuration(days) ;
|
||||
}
|
||||
uint32_t p3FileDatabase::rememberHashCacheDuration()
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
return mHashCache->rememberHashFilesDuration() ;
|
||||
}
|
||||
void p3FileDatabase::clearHashCache()
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
mHashCache->clear() ;
|
||||
}
|
||||
bool p3FileDatabase::rememberHashCache()
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
void p3FileDatabase::setRememberHashCache(bool)
|
||||
{
|
||||
NOT_IMPLEMENTED();
|
||||
}
|
||||
|
||||
bool p3FileDatabase::findLocalFile(const RsFileHash& hash,FileSearchFlags flags,const RsPeerId& peer_id, std::string &fullpath, uint64_t &size,FileStorageFlags& storage_flags,std::list<std::string>& parent_groups) const
|
||||
{
|
||||
RS_STACK_MUTEX(mFLSMtx) ;
|
||||
|
@ -135,11 +135,8 @@ class p3FileDatabase: public p3Service, public p3Config, public ftSearch //, pub
|
||||
|
||||
void setWatchPeriod(uint32_t seconds);
|
||||
uint32_t watchPeriod() ;
|
||||
void setRememberHashCacheDuration(uint32_t days) ;
|
||||
uint32_t rememberHashCacheDuration() ;
|
||||
void clearHashCache() ;
|
||||
bool rememberHashCache() ;
|
||||
void setRememberHashCache(bool) ;
|
||||
void setWatchEnabled(bool b) ;
|
||||
bool watchEnabled() ;
|
||||
|
||||
// interfact for directory parsing
|
||||
|
||||
|
@ -675,35 +675,11 @@ bool ftServer::removeSharedDirectory(std::string dir)
|
||||
|
||||
return true;
|
||||
}
|
||||
void ftServer::setWatchPeriod(int minutes)
|
||||
{
|
||||
mFileDatabase->setWatchPeriod(minutes*60) ;
|
||||
}
|
||||
int ftServer::watchPeriod() const
|
||||
{
|
||||
return mFileDatabase->watchPeriod()/60 ;
|
||||
}
|
||||
bool ftServer::watchEnabled() { return mFileDatabase->watchEnabled() ; }
|
||||
int ftServer::watchPeriod() const { return mFileDatabase->watchPeriod()/60 ; }
|
||||
|
||||
void ftServer::setRememberHashFiles(bool b)
|
||||
{
|
||||
mFileDatabase->setRememberHashCache(b) ;
|
||||
}
|
||||
bool ftServer::rememberHashFiles() const
|
||||
{
|
||||
return mFileDatabase->rememberHashCache() ;
|
||||
}
|
||||
void ftServer::setRememberHashFilesDuration(uint32_t days)
|
||||
{
|
||||
mFileDatabase->setRememberHashCacheDuration(days) ;
|
||||
}
|
||||
uint32_t ftServer::rememberHashFilesDuration() const
|
||||
{
|
||||
return mFileDatabase->rememberHashCacheDuration() ;
|
||||
}
|
||||
void ftServer::clearHashCache()
|
||||
{
|
||||
mFileDatabase->clearHashCache() ;
|
||||
}
|
||||
void ftServer::setWatchEnabled(bool b) { mFileDatabase->setWatchEnabled(b) ; }
|
||||
void ftServer::setWatchPeriod(int minutes) { mFileDatabase->setWatchPeriod(minutes*60) ; }
|
||||
|
||||
bool ftServer::getShareDownloadDirectory()
|
||||
{
|
||||
|
@ -208,13 +208,10 @@ public:
|
||||
virtual bool getShareDownloadDirectory();
|
||||
virtual bool shareDownloadDirectory(bool share);
|
||||
|
||||
virtual void setRememberHashFilesDuration(uint32_t days) ;
|
||||
virtual uint32_t rememberHashFilesDuration() const ;
|
||||
virtual bool rememberHashFiles() const ;
|
||||
virtual void setRememberHashFiles(bool) ;
|
||||
virtual void clearHashCache() ;
|
||||
virtual void setWatchPeriod(int minutes) ;
|
||||
virtual int watchPeriod() const ;
|
||||
virtual void setWatchEnabled(bool b) ;
|
||||
virtual bool watchEnabled() ;
|
||||
|
||||
/***************************************************************/
|
||||
/*************** Data Transfer Interface ***********************/
|
||||
|
@ -213,13 +213,11 @@ class RsFiles
|
||||
virtual bool addSharedDirectory(const SharedDirInfo& dir) = 0;
|
||||
virtual bool updateShareFlags(const SharedDirInfo& dir) = 0; // updates the flags. The directory should already exist !
|
||||
virtual bool removeSharedDirectory(std::string dir) = 0;
|
||||
virtual void setRememberHashFilesDuration(uint32_t days) = 0 ;
|
||||
virtual uint32_t rememberHashFilesDuration() const = 0 ;
|
||||
virtual void clearHashCache() = 0 ;
|
||||
virtual bool rememberHashFiles() const =0;
|
||||
virtual void setRememberHashFiles(bool) =0;
|
||||
virtual void setWatchPeriod(int minutes) =0;
|
||||
virtual int watchPeriod() const =0;
|
||||
|
||||
virtual void setWatchPeriod(int minutes) =0;
|
||||
virtual void setWatchEnabled(bool b) =0;
|
||||
virtual int watchPeriod() const =0;
|
||||
virtual bool watchEnabled() =0;
|
||||
|
||||
virtual bool getShareDownloadDirectory() = 0;
|
||||
virtual bool shareDownloadDirectory(bool share) = 0;
|
||||
|
@ -1239,8 +1239,8 @@ int RsServer::StartupRetroShare()
|
||||
//pqih = new pqipersongrpDummy(none, flags);
|
||||
|
||||
/****** New Ft Server **** !!! */
|
||||
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
|
||||
ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory());
|
||||
ftServer *ftserver = new ftServer(mPeerMgr, serviceCtrl);
|
||||
ftserver->setConfigDirectory(rsAccounts->PathAccountDirectory());
|
||||
|
||||
ftserver->SetupFtServer() ;
|
||||
|
||||
|
@ -36,18 +36,9 @@ DirectoriesPage::DirectoriesPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
connect(ui.incomingButton, SIGNAL(clicked( bool ) ), this , SLOT( setIncomingDirectory() ) );
|
||||
connect(ui.partialButton, SIGNAL(clicked( bool ) ), this , SLOT( setPartialsDirectory() ) );
|
||||
connect(ui.editShareButton, SIGNAL(clicked()), this, SLOT(editDirectories()));
|
||||
connect(ui.cleanHashCachePB, SIGNAL(clicked()), this, SLOT(clearHashCache()));
|
||||
connect(ui.rememberHashesCB, SIGNAL(clicked(bool)), this, SLOT(clickedRememberHashes(bool)));
|
||||
connect(ui.rememberHashesCB, SIGNAL(clicked(bool)), this, SLOT(toggleRememberHashes()));
|
||||
connect(ui.autoCheckDirectories_CB, SIGNAL(clicked(bool)), this, SLOT(toggleAutoCheckDirectories(bool)));
|
||||
}
|
||||
|
||||
void DirectoriesPage::clearHashCache()
|
||||
{
|
||||
if(QMessageBox::question(this, tr("Cache cleaning confirmation"), tr("This will forget any former hash of non shared files. Do you confirm ?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
|
||||
rsFiles->clearHashCache() ;
|
||||
}
|
||||
|
||||
void DirectoriesPage::toggleAutoCheckDirectories(bool b)
|
||||
{
|
||||
ui.autoCheckDirectoriesDelay_SB->setEnabled(b);
|
||||
@ -58,28 +49,9 @@ void DirectoriesPage::editDirectories()
|
||||
ShareManager::showYourself() ;
|
||||
}
|
||||
|
||||
void DirectoriesPage::clickedRememberHashes(bool b)
|
||||
{
|
||||
if (!b) {
|
||||
if (QMessageBox::question(this,tr("Cache cleaning confirmation"), tr("This will forget any former hash of non shared files. Do you confirm ?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||
ui.rememberHashesCB->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DirectoriesPage::toggleRememberHashes()
|
||||
{
|
||||
bool b = ui.rememberHashesCB->isChecked();
|
||||
ui.rememberHashesSB->setEnabled(b);
|
||||
ui.cleanHashCachePB->setEnabled(b);
|
||||
}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
bool DirectoriesPage::save(QString &/*errmsg*/)
|
||||
{
|
||||
rsFiles->setRememberHashFilesDuration(ui.rememberHashesSB->value());
|
||||
rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value());
|
||||
|
||||
std::string dir = ui.incomingDir->text().toUtf8().constData();
|
||||
if (!dir.empty())
|
||||
{
|
||||
@ -92,18 +64,8 @@ bool DirectoriesPage::save(QString &/*errmsg*/)
|
||||
rsFiles->setPartialsDirectory(dir);
|
||||
}
|
||||
|
||||
if (ui.rememberHashesCB->isChecked()) {
|
||||
rsFiles->setRememberHashFiles(true);
|
||||
} else {
|
||||
rsFiles->setRememberHashFiles(false);
|
||||
rsFiles->clearHashCache() ;
|
||||
}
|
||||
|
||||
if (ui.autoCheckDirectories_CB->isChecked()) {
|
||||
rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value());
|
||||
} else {
|
||||
rsFiles->setWatchPeriod(-ui.autoCheckDirectoriesDelay_SB->value());
|
||||
}
|
||||
rsFiles->setWatchEnabled(ui.autoCheckDirectories_CB->isChecked()) ;
|
||||
rsFiles->setWatchPeriod(ui.autoCheckDirectoriesDelay_SB->value());
|
||||
|
||||
rsFiles->shareDownloadDirectory(ui.shareDownloadDirectoryCB->isChecked());
|
||||
|
||||
@ -115,14 +77,9 @@ void DirectoriesPage::load()
|
||||
{
|
||||
ui.shareDownloadDirectoryCB->setChecked(rsFiles->getShareDownloadDirectory());
|
||||
|
||||
ui.rememberHashesSB->setValue(rsFiles->rememberHashFilesDuration());
|
||||
ui.rememberHashesCB->setChecked(rsFiles->rememberHashFiles());
|
||||
toggleRememberHashes();
|
||||
|
||||
int u = rsFiles->watchPeriod() ;
|
||||
ui.autoCheckDirectoriesDelay_SB->setValue(abs(u)) ;
|
||||
ui.autoCheckDirectories_CB->setChecked(u>0) ;
|
||||
ui.autoCheckDirectoriesDelay_SB->setEnabled(u>0) ;
|
||||
ui.autoCheckDirectoriesDelay_SB->setValue(u) ;
|
||||
ui.autoCheckDirectories_CB->setChecked(rsFiles->watchEnabled()) ; ;
|
||||
|
||||
ui.incomingDir->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()));
|
||||
ui.partialsDir->setText(QString::fromUtf8(rsFiles->getPartialsDirectory().c_str()));
|
||||
|
@ -45,9 +45,6 @@ private slots:
|
||||
void editDirectories() ;
|
||||
void setIncomingDirectory();
|
||||
void setPartialsDirectory();
|
||||
void clearHashCache();
|
||||
void clickedRememberHashes(bool);
|
||||
void toggleRememberHashes();
|
||||
void toggleAutoCheckDirectories(bool);
|
||||
|
||||
private:
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>485</width>
|
||||
<width>895</width>
|
||||
<height>549</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -144,50 +144,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="rememberHashesCB">
|
||||
<property name="toolTip">
|
||||
<string>Remember file hashes even if not shared.
|
||||
This might be useful if you're sharing an
|
||||
external HD, to avoid re-hashing files when
|
||||
you plug it in.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remember hashed files for </string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="rememberHashesSB">
|
||||
<property name="suffix">
|
||||
<string> days</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>365</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cleanHashCachePB">
|
||||
<property name="toolTip">
|
||||
<string>Forget any hashed file that is not anymore shared.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clean Hash Cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
@ -240,9 +197,6 @@ you plug it in.</string>
|
||||
<tabstops>
|
||||
<tabstop>shareDownloadDirectoryCB</tabstop>
|
||||
<tabstop>editShareButton</tabstop>
|
||||
<tabstop>rememberHashesCB</tabstop>
|
||||
<tabstop>rememberHashesSB</tabstop>
|
||||
<tabstop>cleanHashCachePB</tabstop>
|
||||
<tabstop>autoCheckDirectories_CB</tabstop>
|
||||
<tabstop>autoCheckDirectoriesDelay_SB</tabstop>
|
||||
<tabstop>incomingDir</tabstop>
|
||||
|
Loading…
Reference in New Issue
Block a user