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:
csoler 2012-11-01 10:06:12 +00:00
parent 03d4936b12
commit dc82cee700
27 changed files with 567 additions and 336 deletions

View file

@ -1100,6 +1100,38 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std
return mPeerMgr->assignPeersToGroup(groupId, peerIds, assign);
}
TransferInfoFlags p3Peers::computePeerPermissionFlags(const std::string& peer_id,
FileStorageFlags share_flags,
const std::list<std::string>& directory_parent_groups)
{
// We should be able to do that in O(1), using groups based on packs of bits.
//
// But for now, because the implementation of groups is not totally decided yet, we revert to this
// very simple algorithm.
//
TransferInfoFlags final_flags = 0 ;
bool found = false ;
for(std::list<std::string>::const_iterator it(directory_parent_groups.begin());it!=directory_parent_groups.end() && !found;++it)
{
RsGroupInfo info ;
if(!getGroupInfo(*it,info))
{
std::cerr << "(EE) p3Peers::computePeerPermissionFlags: no group named " << *it << ": cannot get info." << std::endl;
continue ;
}
for(std::list<std::string>::const_iterator it2(info.peerIds.begin());it2!=info.peerIds.end() && !found;++it2)
if(*it2 == peer_id)
found = true ;
}
bool network_wide = (share_flags & DIR_FLAGS_NETWORK_WIDE_OTHERS) || ( (share_flags & DIR_FLAGS_NETWORK_WIDE_GROUPS) && found) ;
bool browsable = (share_flags & DIR_FLAGS_BROWSABLE_OTHERS) || ( (share_flags & DIR_FLAGS_BROWSABLE_GROUPS) && found) ;
return network_wide * RS_FILE_HINTS_NETWORK_WIDE + browsable * RS_FILE_HINTS_BROWSABLE ;
}
RsPeerDetails::RsPeerDetails()
:isOnlyGPGdetail(false),

View file

@ -121,6 +121,7 @@ virtual bool getGroupInfoList(std::list<RsGroupInfo> &groupInfoList);
virtual bool assignPeerToGroup(const std::string &groupId, const std::string &peerId, bool assign);
virtual bool assignPeersToGroup(const std::string &groupId, const std::list<std::string> &peerIds, bool assign);
virtual TransferInfoFlags computePeerPermissionFlags(const std::string& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
private:
p3LinkMgr *mLinkMgr;