mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
Merged branch that provide group-based file permissions.
Now users can sort peers into groups in the friend list, and attribute flags and parent groups to the directories in the share manager. Flags are B-B-N, meaning in order: - browsable for peers in the parent groups - browsable for everyone - network wide for everyone Backward compatibility makes previously BN flags been interpreted as -BN, meaning browsable/network wide for everyone. Be careful with this new feature. It has been tested, but it's a bit early to rely on it for highly sensitive data. The merge also includes a significant improvement of the naming of flags with incompatible types which should sort out some existing bugs as well, since inconsistencies in flag usage have been found during the process. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5787 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
6edb9eb4f8
64 changed files with 1389 additions and 824 deletions
|
@ -1100,6 +1100,43 @@ bool p3Peers::assignPeersToGroup(const std::string &groupId, const std::list<std
|
|||
return mPeerMgr->assignPeersToGroup(groupId, peerIds, assign);
|
||||
}
|
||||
|
||||
FileSearchFlags p3Peers::computePeerPermissionFlags(const std::string& peer_ssl_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.
|
||||
//
|
||||
|
||||
bool found = false ;
|
||||
std::string pgp_id = getGPGId(peer_ssl_id) ;
|
||||
|
||||
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 == pgp_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) ;
|
||||
|
||||
FileSearchFlags final_flags ;
|
||||
|
||||
if(network_wide) final_flags |= RS_FILE_HINTS_NETWORK_WIDE ;
|
||||
if(browsable ) final_flags |= RS_FILE_HINTS_BROWSABLE ;
|
||||
|
||||
return final_flags ;
|
||||
}
|
||||
|
||||
RsPeerDetails::RsPeerDetails()
|
||||
:isOnlyGPGdetail(false),
|
||||
|
|
|
@ -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 FileSearchFlags computePeerPermissionFlags(const std::string& peer_id,FileStorageFlags share_flags,const std::list<std::string>& parent_groups) ;
|
||||
private:
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue