mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
First shot of file sharing permissions. Compiles, but needs some testing/debugging.
- added type-safe flags in retroshare/rsflags.h. This should be used to make new flags types in order to prevent mixing flags up in function prototypes. - group handling is left to rsPeers. We'll move it to rsCircles later. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-FileSharingPermissions@5754 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
03d4936b12
commit
dc82cee700
27 changed files with 567 additions and 336 deletions
|
@ -92,38 +92,70 @@ bool CacheSource::loadLocalCache(const CacheData &data)
|
|||
}
|
||||
|
||||
/* control Caches available */
|
||||
bool CacheSource::refreshCache(const CacheData &data)
|
||||
bool CacheSource::refreshCache(const CacheData &data,const std::list<std::string>& destination_peers)
|
||||
{
|
||||
lockData(); /* LOCK MUTEX */
|
||||
|
||||
bool ret = false;
|
||||
if (data.cid.type == getCacheType())
|
||||
{
|
||||
int subid = 0;
|
||||
if (isMultiCache())
|
||||
{
|
||||
subid = data.cid.subid;
|
||||
}
|
||||
RsStackMutex mtx(cMutex); /* LOCK MUTEX */
|
||||
|
||||
/* Backup the old Caches */
|
||||
CacheSet::const_iterator it;
|
||||
if (caches.end() != (it = caches.find(subid)))
|
||||
if (data.cid.type == getCacheType())
|
||||
{
|
||||
mOldCaches[it->second.hash] = it->second;
|
||||
}
|
||||
int subid = 0;
|
||||
if (isMultiCache())
|
||||
{
|
||||
subid = data.cid.subid;
|
||||
}
|
||||
|
||||
/* store new cache */
|
||||
caches[subid] = data;
|
||||
ret = true;
|
||||
/* Backup the old Caches */
|
||||
CacheSet::const_iterator it;
|
||||
if (caches.end() != (it = caches.find(subid)))
|
||||
{
|
||||
mOldCaches[it->second.hash] = it->second;
|
||||
}
|
||||
|
||||
/* store new cache */
|
||||
caches[subid] = data;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
unlockData(); /* UNLOCK MUTEX */
|
||||
if (mStrapper) /* allow testing without full feedback */
|
||||
mStrapper->refreshCache(data,destination_peers);
|
||||
|
||||
return ret;
|
||||
}
|
||||
bool CacheSource::refreshCache(const CacheData &data)
|
||||
{
|
||||
bool ret = false;
|
||||
{
|
||||
RsStackMutex mtx(cMutex); /* LOCK MUTEX */
|
||||
|
||||
if (data.cid.type == getCacheType())
|
||||
{
|
||||
int subid = 0;
|
||||
if (isMultiCache())
|
||||
{
|
||||
subid = data.cid.subid;
|
||||
}
|
||||
|
||||
/* Backup the old Caches */
|
||||
CacheSet::const_iterator it;
|
||||
if (caches.end() != (it = caches.find(subid)))
|
||||
{
|
||||
mOldCaches[it->second.hash] = it->second;
|
||||
}
|
||||
|
||||
/* store new cache */
|
||||
caches[subid] = data;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (mStrapper) /* allow testing without full feedback */
|
||||
mStrapper->refreshCache(data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
bool CacheSource::clearCache(CacheId id)
|
||||
{
|
||||
lockData(); /* LOCK MUTEX */
|
||||
|
@ -567,6 +599,26 @@ void CacheStrapper::statusChange(const std::list<pqipeer> &plist)
|
|||
|
||||
/**************** from pqimonclient ********************/
|
||||
|
||||
void CacheStrapper::refreshCache(const CacheData &data,const std::list<std::string>& destination_peers)
|
||||
{
|
||||
/* we've received an update
|
||||
* send to all online peers + self
|
||||
*/
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() : " << data << std::endl;
|
||||
#endif
|
||||
|
||||
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
for(std::list<std::string>::const_iterator it = destination_peers.begin(); it != destination_peers.end(); ++it)
|
||||
{
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() Send To: " << *it << std::endl;
|
||||
#endif
|
||||
mCacheUpdates.push_back(std::make_pair(*it, data));
|
||||
}
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
}
|
||||
|
||||
void CacheStrapper::refreshCache(const CacheData &data)
|
||||
{
|
||||
|
@ -578,26 +630,12 @@ void CacheStrapper::refreshCache(const CacheData &data)
|
|||
#endif
|
||||
|
||||
std::list<std::string> ids;
|
||||
std::list<std::string>::iterator it;
|
||||
|
||||
mLinkMgr->getOnlineList(ids);
|
||||
ids.push_back(mLinkMgr->getOwnId()) ;
|
||||
|
||||
RsStackMutex stack(csMtx); /******* LOCK STACK MUTEX *********/
|
||||
for(it = ids.begin(); it != ids.end(); it++)
|
||||
{
|
||||
#ifdef CS_DEBUG
|
||||
std::cerr << "CacheStrapper::refreshCache() Send To: " << *it << std::endl;
|
||||
#endif
|
||||
|
||||
mCacheUpdates.push_back(std::make_pair(*it, data));
|
||||
}
|
||||
|
||||
mCacheUpdates.push_back(std::make_pair(mLinkMgr->getOwnId(), data));
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
refreshCache(data,ids) ;
|
||||
}
|
||||
|
||||
|
||||
void CacheStrapper::refreshCacheStore(const CacheData & /* data */ )
|
||||
{
|
||||
/* indicate to save data */
|
||||
|
|
|
@ -181,7 +181,8 @@ class CacheSource
|
|||
virtual bool loadLocalCache(const CacheData &data);
|
||||
|
||||
/* control Caches available */
|
||||
bool refreshCache(const CacheData &data);
|
||||
bool refreshCache(const CacheData &data,const std::list<std::string>& destination_peers);
|
||||
bool refreshCache(const CacheData &data);
|
||||
bool clearCache(CacheId id);
|
||||
|
||||
/* get private data */
|
||||
|
@ -394,11 +395,12 @@ virtual void statusChange(const std::list<pqipeer> &plist);
|
|||
/* Feedback from CacheSources */
|
||||
|
||||
/*!
|
||||
* send data to peers online and selfe
|
||||
* send data to peers online and self
|
||||
* @param data
|
||||
*
|
||||
*/
|
||||
void refreshCache(const CacheData &data);
|
||||
void refreshCache(const CacheData &data,const std::list<std::string>& destination_peers); // specify a particular list of destination peers (self not added!)
|
||||
|
||||
/*!
|
||||
* forces config savelist
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "serialiser/rsserviceids.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rsnotify.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "util/folderiterator.h"
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -266,7 +267,7 @@ FileIndexMonitor::~FileIndexMonitor()
|
|||
/* Data cleanup - TODO */
|
||||
}
|
||||
|
||||
int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags)
|
||||
int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags,const std::string& peer_id)
|
||||
{
|
||||
results.clear();
|
||||
std::list<FileEntry *> firesults;
|
||||
|
@ -276,10 +277,10 @@ int FileIndexMonitor::SearchKeywords(std::list<std::string> keywords, std::list<
|
|||
fi.searchTerms(keywords, firesults);
|
||||
}
|
||||
|
||||
return filterResults(firesults,results,flags) ;
|
||||
return filterResults(firesults,results,flags,peer_id) ;
|
||||
}
|
||||
|
||||
int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,uint32_t flags) const
|
||||
int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& results,uint32_t flags,const std::string& peer_id) const
|
||||
{
|
||||
results.clear();
|
||||
std::list<FileEntry *> firesults;
|
||||
|
@ -289,11 +290,15 @@ int FileIndexMonitor::SearchBoolExp(Expression *exp, std::list<DirDetails>& resu
|
|||
fi.searchBoolExp(exp, firesults);
|
||||
}
|
||||
|
||||
return filterResults(firesults,results,flags) ;
|
||||
return filterResults(firesults,results,flags,peer_id) ;
|
||||
}
|
||||
|
||||
int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,uint32_t flags) const
|
||||
int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,TransferInfoFlags flags,const std::string& peer_id) const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if((flags & ~RS_FILE_HINTS_PERMISSION_MASK) > 0)
|
||||
std::cerr << "(EE) ***** FileIndexMonitor:: Flags ERROR in filterResults!!" << std::endl;
|
||||
#endif
|
||||
/* translate/filter results */
|
||||
|
||||
for(std::list<FileEntry*>::const_iterator rit(firesults.begin()); rit != firesults.end(); ++rit)
|
||||
|
@ -304,7 +309,9 @@ int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<D
|
|||
std::cerr << "Filtering candidate " << (*rit)->name << ", flags=" << cdetails.flags ;
|
||||
#endif
|
||||
|
||||
if (cdetails.type == DIR_TYPE_FILE && ( cdetails.flags & flags & (DIR_FLAGS_BROWSABLE | DIR_FLAGS_NETWORK_WIDE)) > 0)
|
||||
TransferInfoFlags permission_flags = rsPeers->computePeerPermissionFlags(peer_id,cdetails.flags,cdetails.parent_groups) ;
|
||||
|
||||
if (cdetails.type == DIR_TYPE_FILE && (( permission_flags & flags & RS_FILE_HINTS_PERMISSION_MASK) > 0 ))
|
||||
{
|
||||
cdetails.id = "Local";
|
||||
results.push_back(cdetails);
|
||||
|
@ -320,7 +327,7 @@ int FileIndexMonitor::filterResults(std::list<FileEntry*>& firesults,std::list<D
|
|||
return !results.empty() ;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::findLocalFile(std::string hash,uint32_t hint_flags, std::string &fullpath, uint64_t &size) const
|
||||
bool FileIndexMonitor::findLocalFile(std::string hash,uint32_t hint_flags, const std::string& peer_id,std::string &fullpath, uint64_t &size) const
|
||||
{
|
||||
std::list<FileEntry *> results;
|
||||
bool ok = false;
|
||||
|
@ -340,12 +347,19 @@ bool FileIndexMonitor::findLocalFile(std::string hash,uint32_t hint_flags, std::
|
|||
FileEntry *fe = results.front();
|
||||
DirEntry *de = fe->parent; /* all files must have a valid parent! */
|
||||
|
||||
uint32_t share_flags = locked_findShareFlags(fe) ;
|
||||
std::list<std::string> parent_groups ;
|
||||
FileStorageFlags share_flags ;
|
||||
|
||||
locked_findShareFlagsAndParentGroups(fe,share_flags,parent_groups) ;
|
||||
|
||||
// turn share flags into hint flags
|
||||
|
||||
uint32_t shflh = rsPeers->computePeerPermissionFlags(peer_id,share_flags,parent_groups) ;
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::findLocalFile: Filtering candidate " << fe->name << ", flags=" << share_flags << ", hint_flags=" << hint_flags << std::endl ;
|
||||
#endif
|
||||
|
||||
if((share_flags & hint_flags & (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE)) > 0)
|
||||
if(shflh & (hint_flags & RS_FILE_HINTS_PERMISSION_MASK))
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::findLocalFile() Found Name: " << fe->name << std::endl;
|
||||
|
@ -423,7 +437,11 @@ bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with sto
|
|||
|
||||
/* More error checking needed here! */
|
||||
|
||||
std::string name = data.name ; // this trick allows to load the complete file. Not the one being shared.
|
||||
std::string name = data.name ;
|
||||
|
||||
name[name.length()-4] = 'r' ;// this trick allows to load the complete file. Not the one being shared.
|
||||
name[name.length()-3] = 's' ;
|
||||
name[name.length()-2] = 'f' ;
|
||||
name[name.length()-1] = 'c' ;
|
||||
|
||||
if ((ok = fi.loadIndex(data.path + '/' + name, "", data.size)))
|
||||
|
@ -445,17 +463,18 @@ bool FileIndexMonitor::loadLocalCache(const CacheData &data) /* called with sto
|
|||
|
||||
fi.updateMaxModTime() ;
|
||||
}
|
||||
|
||||
#ifdef REMOVED
|
||||
if (ok)
|
||||
{
|
||||
return updateCache(data);
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileIndexMonitor::updateCache(const CacheData &data) /* we call this one */
|
||||
bool FileIndexMonitor::updateCache(const CacheData &data,const std::list<std::string>& destination_peers) /* we call this one */
|
||||
{
|
||||
return refreshCache(data);
|
||||
return refreshCache(data,destination_peers);
|
||||
}
|
||||
|
||||
|
||||
|
@ -986,67 +1005,103 @@ void FileIndexMonitor::locked_saveFileIndexes()
|
|||
|
||||
std::string path = getCacheDir();
|
||||
|
||||
// Two files are saved: one with only browsable dirs, which will be shared by the cache system,
|
||||
// and one with the complete file collection.
|
||||
// Multiple files are saved: for every kind of peers, the set of browsable files will be different. A specific file is
|
||||
// prepared for all situations, and shared by all peers having the same situation.
|
||||
//
|
||||
// A complete file collection is also saved, and serves as memory for the FileIndexMonitor system.
|
||||
//
|
||||
std::string tmpname_browsable;
|
||||
rs_sprintf(tmpname_browsable, "fc-own-%ld.rsfb", time(NULL));
|
||||
std::string fname_browsable = path + "/" + tmpname_browsable;
|
||||
|
||||
std::string tmpname_total;
|
||||
rs_sprintf(tmpname_total, "fc-own-%ld.rsfc", time(NULL));
|
||||
std::string fname_total = path + "/" + tmpname_total;
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::updateCycle() FileIndex modified ... updating";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "FileIndexMonitor::updateCycle() saving browsable file list to: " << fname_browsable << std::endl ;
|
||||
std::cerr << "FileIndexMonitor::updateCycle() FileIndex modified ... updating" << std::endl;
|
||||
std::cerr << "FileIndexMonitor::updateCycle() saving total file list to to: " << fname_total << std::endl ;
|
||||
std::cerr << "FileIndexMonitor::updateCycle() saving browsable file list to: " << fname_browsable << std::endl ;
|
||||
#endif
|
||||
// Make for each peer the list of forbidden shared directories. Make a separate cache file for each different set.
|
||||
// To figure out which sets are different, we index them by the set of forbidden indexes from the directory list.
|
||||
// This is probably a bit costly, but we can't suppose that the number of shared directories is bounded.
|
||||
//
|
||||
std::list<std::string> online_ids ;
|
||||
rsPeers->getOnlineList(online_ids);
|
||||
|
||||
std::string calchash;
|
||||
uint64_t size;
|
||||
std::map<std::set<std::string>, std::list<std::string> > peers_per_directory_combination ;
|
||||
|
||||
std::cerr << "About to save, with the following restrictions:" << std::endl ;
|
||||
std::set<std::string> forbidden_dirs ;
|
||||
for(std::map<std::string,SharedDirInfo>::const_iterator it(directoryMap.begin());it!=directoryMap.end();++it)
|
||||
for(std::list<std::string>::const_iterator it(online_ids.begin());it!=online_ids.end();++it)
|
||||
{
|
||||
std::cerr << " dir=" << it->first << " : " ;
|
||||
if((it->second.shareflags & RS_FILE_HINTS_BROWSABLE) == 0)
|
||||
std::cerr << "About to save, with the following restrictions:" << std::endl ;
|
||||
|
||||
std::set<std::string> forbidden_dirs ;
|
||||
for(std::map<std::string,SharedDirInfo>::const_iterator dit(directoryMap.begin());dit!=directoryMap.end();++dit)
|
||||
{
|
||||
std::cerr << "forbidden" << std::endl;
|
||||
forbidden_dirs.insert(it->first) ;
|
||||
std::cerr << " dir=" << dit->first << " : " ;
|
||||
|
||||
uint32_t permission_flags = rsPeers->computePeerPermissionFlags(*it,dit->second.shareflags,dit->second.parent_groups) ;
|
||||
|
||||
if(!(permission_flags & RS_FILE_HINTS_BROWSABLE))
|
||||
{
|
||||
std::cerr << "forbidden" << std::endl;
|
||||
forbidden_dirs.insert(dit->first) ;
|
||||
}
|
||||
else
|
||||
std::cerr << "autorized" << std::endl;
|
||||
}
|
||||
else
|
||||
std::cerr << "autorized" << std::endl;
|
||||
|
||||
peers_per_directory_combination[forbidden_dirs].push_back(*it) ;
|
||||
}
|
||||
std::string ownId = rsPeers->getOwnId() ;
|
||||
peers_per_directory_combination[std::set<std::string>()].push_back(ownId) ; // add full configuration to self, i.e. no forbidden directories.
|
||||
|
||||
uint64_t sizetmp ;
|
||||
int n=0 ;
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
fi.saveIndex(fname_total, calchash, sizetmp,std::set<std::string>()); // save all files
|
||||
fi.saveIndex(fname_browsable, calchash, size,forbidden_dirs); // save only browsable files
|
||||
|
||||
if(size > 0)
|
||||
for(std::map<std::set<std::string>, std::list<std::string> >::const_iterator it(peers_per_directory_combination.begin());
|
||||
it!=peers_per_directory_combination.end();++it,++n)
|
||||
{
|
||||
std::string tmpname_browsable;
|
||||
|
||||
if(it->first.empty())
|
||||
rs_sprintf(tmpname_browsable, "fc-own-%ld.rsfc",now,n);
|
||||
else
|
||||
rs_sprintf(tmpname_browsable, "fc-own-%ld.%04d",now,n);
|
||||
|
||||
std::string fname_browsable = path + "/" + tmpname_browsable;
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::updateCycle() saved with hash:" << calchash;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Sending file list: " << std::endl;
|
||||
std::cerr << " filename : " << tmpname_browsable << std::endl;
|
||||
std::cerr << " to peers : " << std::endl;
|
||||
for(std::list<std::string>::const_iterator itt(it->second.begin());itt!= it->second.end();++itt)
|
||||
std::cerr << " " << *itt << std::endl;
|
||||
std::cerr << " forbidden : " << std::endl;
|
||||
for(std::set<std::string>::const_iterator itt(it->first.begin());itt!= it->first.end();++itt)
|
||||
std::cerr << " " << *itt << std::endl;
|
||||
#endif
|
||||
|
||||
/* should clean up the previous cache.... */
|
||||
std::string hash ;
|
||||
uint64_t size ;
|
||||
|
||||
/* flag as new info */
|
||||
CacheData data;
|
||||
data.pid = fi.root->id;
|
||||
data.cid.type = getCacheType();
|
||||
data.cid.subid = 0;
|
||||
data.path = path;
|
||||
data.name = tmpname_browsable;
|
||||
data.hash = calchash;
|
||||
data.size = size;
|
||||
data.recvd = time(NULL);
|
||||
fi.saveIndex(fname_browsable, hash, size,it->first); // save only browsable files
|
||||
|
||||
updateCache(data);
|
||||
if(size > 0)
|
||||
{
|
||||
#ifdef FIM_DEBUG
|
||||
std::cerr << "FileIndexMonitor::updateCycle() saved with hash:" << calchash;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* should clean up the previous cache.... */
|
||||
|
||||
/* flag as new info */
|
||||
CacheData data;
|
||||
data.pid = fi.root->id;
|
||||
data.cid.type = getCacheType();
|
||||
data.cid.subid = 0;
|
||||
data.path = path;
|
||||
data.name = tmpname_browsable;
|
||||
data.hash = hash;
|
||||
data.size = size;
|
||||
data.recvd = time(NULL);
|
||||
|
||||
updateCache(data,it->second);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FIM_DEBUG
|
||||
|
@ -1353,18 +1408,15 @@ int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t
|
|||
if(ref != NULL)
|
||||
{
|
||||
FileEntry *file = (FileEntry *) ref;
|
||||
|
||||
uint32_t share_flags = locked_findShareFlags(file) ;
|
||||
|
||||
details.flags |= (( (share_flags & RS_FILE_HINTS_BROWSABLE )>0)?DIR_FLAGS_BROWSABLE :0) ;
|
||||
details.flags |= (( (share_flags & RS_FILE_HINTS_NETWORK_WIDE)>0)?DIR_FLAGS_NETWORK_WIDE:0) ;
|
||||
locked_findShareFlagsAndParentGroups(file,details.flags,details.parent_groups) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
uint32_t FileIndexMonitor::locked_findShareFlags(FileEntry *file) const
|
||||
void FileIndexMonitor::locked_findShareFlagsAndParentGroups(FileEntry *file,FileStorageFlags& flags,std::list<std::string>& parent_groups) const
|
||||
{
|
||||
uint32_t flags = 0 ;
|
||||
flags = 0 ;
|
||||
static const FileStorageFlags PERMISSION_MASK = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | DIR_FLAGS_NETWORK_WIDE_GROUPS ;
|
||||
|
||||
DirEntry *dir = dynamic_cast<DirEntry*>(file) ;
|
||||
if(dir == NULL)
|
||||
|
@ -1384,13 +1436,14 @@ uint32_t FileIndexMonitor::locked_findShareFlags(FileEntry *file) const
|
|||
if(it == directoryMap.end())
|
||||
std::cerr << "*********** ERROR *********** In " << __PRETTY_FUNCTION__ << std::endl ;
|
||||
else
|
||||
flags = it->second.shareflags & (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE) ;
|
||||
{
|
||||
flags = it->second.shareflags & PERMISSION_MASK ;
|
||||
parent_groups = it->second.parent_groups ;
|
||||
}
|
||||
#ifdef FIM_DEBUG2
|
||||
std::cerr << "flags = " << flags << std::endl ;
|
||||
#endif
|
||||
}
|
||||
|
||||
return flags ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -111,10 +111,12 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
|||
virtual ~FileIndexMonitor();
|
||||
|
||||
/* external interface for filetransfer */
|
||||
bool findLocalFile(std::string hash,uint32_t f, std::string &fullpath, uint64_t &size) const;
|
||||
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) ;
|
||||
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,uint32_t flags) const ;
|
||||
int filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,uint32_t flags) const ;
|
||||
bool findLocalFile(std::string hash,uint32_t flags,const std::string& peer_id, std::string &fullpath, uint64_t &size) const;
|
||||
|
||||
int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags,const std::string& peer_id) ;
|
||||
int SearchBoolExp(Expression *exp, std::list<DirDetails> &results,uint32_t flags,const std::string& peer_id) const ;
|
||||
|
||||
int filterResults(std::list<FileEntry*>& firesults,std::list<DirDetails>& results,TransferInfoFlags flags,const std::string& peer_id) const ;
|
||||
|
||||
|
||||
/* external interface for local access to files */
|
||||
|
@ -124,7 +126,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
|||
/* Interacting with CacheSource */
|
||||
/* overloaded from CacheSource */
|
||||
virtual bool loadLocalCache(const CacheData &data); /* called with stored data */
|
||||
bool updateCache(const CacheData &data); /* we call when we have a new cache for others */
|
||||
bool updateCache(const CacheData &data,const std::list<std::string>& dest_peers); /* we call when we have a new cache for others */
|
||||
|
||||
|
||||
/* the FileIndexMonitor inner workings */
|
||||
|
@ -169,7 +171,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
|||
void locked_saveFileIndexes() ;
|
||||
|
||||
// Finds the share flags associated with this file entry.
|
||||
uint32_t locked_findShareFlags(FileEntry *fe) const ;
|
||||
void locked_findShareFlagsAndParentGroups(FileEntry *fe,FileStorageFlags& shareflags,std::list<std::string>& parent_groups) const ;
|
||||
|
||||
std::string locked_findRealRoot(std::string base) const;
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ virtual int print(std::string &out);
|
|||
/* References for easy manipulation */
|
||||
DirEntry *parent;
|
||||
int row;
|
||||
std::list<std::string> parent_groups ;
|
||||
};
|
||||
|
||||
/******************************************************************************************
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue