mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -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
|
@ -1840,7 +1840,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
|
|||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " Request not from us. Performing local search" << std::endl ;
|
||||
#endif
|
||||
found = (_sharing_strategy != SHARE_FRIENDS_ONLY || item->depth < 2) && performLocalHashSearch(item->file_hash,info) ;
|
||||
found = (_sharing_strategy != SHARE_FRIENDS_ONLY || item->depth < 2) && performLocalHashSearch(item->file_hash,item->PeerId(),info) ;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -2092,7 +2092,7 @@ void RsTurtleStringSearchRequestItem::performLocalSearch(std::list<TurtleFileInf
|
|||
std::cerr << "Performing rsFiles->search()" << std::endl ;
|
||||
#endif
|
||||
// now, search!
|
||||
rsFiles->SearchKeywords(words, initialResults,DIR_FLAGS_LOCAL | DIR_FLAGS_NETWORK_WIDE);
|
||||
rsFiles->SearchKeywords(words, initialResults,RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE,PeerId());
|
||||
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << initialResults.size() << " matches found." << std::endl ;
|
||||
|
@ -2130,12 +2130,20 @@ void RsTurtleRegExpSearchRequestItem::performLocalSearch(std::list<TurtleFileInf
|
|||
return ;
|
||||
|
||||
// now, search!
|
||||
rsFiles->SearchBoolExp(exp,initialResults,DIR_FLAGS_LOCAL | DIR_FLAGS_NETWORK_WIDE);
|
||||
rsFiles->SearchBoolExp(exp,initialResults,RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_NETWORK_WIDE,PeerId());
|
||||
|
||||
result.clear() ;
|
||||
|
||||
for(std::list<DirDetails>::const_iterator it(initialResults.begin());it!=initialResults.end();++it)
|
||||
{
|
||||
// retain only file type
|
||||
if (it->type == DIR_TYPE_DIR)
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " Skipping directory " << it->name << std::endl ;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
TurtleFileInfo i ;
|
||||
i.hash = it->hash ;
|
||||
i.size = it->count ;
|
||||
|
@ -2276,9 +2284,25 @@ void p3turtle::returnSearchResult(RsTurtleSearchResultItem *item)
|
|||
/// Warning: this function should never be called while the turtle mutex is locked.
|
||||
/// Otherwize this is a possible source of cross-lock with the File mutex.
|
||||
//
|
||||
bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,FileInfo& info)
|
||||
bool p3turtle::performLocalHashSearch(const TurtleFileHash& hash,const std::string& peer_id,FileInfo& info)
|
||||
{
|
||||
return rsFiles->FileDetails(hash, RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_DOWNLOAD, info);
|
||||
bool res = rsFiles->FileDetails(hash, RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_LOCAL | RS_FILE_HINTS_EXTRA | RS_FILE_HINTS_SPEC_ONLY | RS_FILE_HINTS_DOWNLOAD, info);
|
||||
|
||||
// The call to computeHashPeerClearance() return a combination of RS_FILE_HINTS_NETWORK_WIDE and RS_FILE_HINTS_BROWSABLE
|
||||
// This is an additional computation cost, but the way it's written here, it's only called when res is true.
|
||||
//
|
||||
res = res && (RS_FILE_HINTS_NETWORK_WIDE & rsPeers->computePeerPermissionFlags(peer_id,info.storage_permission_flags,info.parent_groups)) ;
|
||||
|
||||
std::cerr << "p3turtle: performing local hash search for hash " << hash << std::endl;
|
||||
|
||||
if(res)
|
||||
{
|
||||
std::cerr << "Found hash: " << std::endl;
|
||||
std::cerr << " peer = " << peer_id << std::endl;
|
||||
std::cerr << " clear = " << rsPeers->computePeerPermissionFlags(peer_id,info.storage_permission_flags,info.parent_groups) << std::endl;
|
||||
}
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
static std::string printFloatNumber(float num,bool friendly=false)
|
||||
|
|
|
@ -213,7 +213,7 @@ class TurtleFileHashInfo
|
|||
// p3Config | ConfigChanged() | used to load/save .cfg file for turtle variales.
|
||||
// -----------+------------------+------------------------------------------------------
|
||||
//
|
||||
class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* public ftSearch */ public p3Config
|
||||
class p3turtle: public p3Service, public RsTurtle, public p3Config
|
||||
{
|
||||
public:
|
||||
p3turtle(p3LinkMgr *lm,ftServer *m);
|
||||
|
@ -371,8 +371,8 @@ class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* publ
|
|||
/// Returns a search result upwards (possibly to the gui)
|
||||
void returnSearchResult(RsTurtleSearchResultItem *item) ;
|
||||
|
||||
/// Returns true if the file with given hash is hosted locally.
|
||||
virtual bool performLocalHashSearch(const TurtleFileHash& hash,FileInfo& info) ;
|
||||
/// Returns true if the file with given hash is hosted locally, and accessible in anonymous mode the supplied peer.
|
||||
virtual bool performLocalHashSearch(const TurtleFileHash& hash,const std::string& client_peer_id,FileInfo& info) ;
|
||||
|
||||
//--------------------------- Local variables --------------------------------//
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue