webui: allow to set peer flags when adding friends (whitelist flag is set to false)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8364 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-06-04 12:57:09 +00:00
parent 399340ef38
commit aea5a77aeb
6 changed files with 69 additions and 5 deletions

View file

@ -224,6 +224,7 @@ StreamBase& JsonStream::getStreamToMember(std::string name)
mChild = new JsonStream();
if(!serialise())
{
mChild->mSerialise = false;
if(checkDeserialisation() && checkObjectMember(name))
{
mChild->mValue = mObject[name];

View file

@ -191,11 +191,32 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
{
std::string cert_string;
req.mStream << makeKeyValueReference("cert_string", cert_string);
ServicePermissionFlags flags;
StreamBase& flags_stream = req.mStream.getStreamToMember("flags");
if(req.mStream.isOK())
{
bool direct_dl = RS_NODE_PERM_DEFAULT & RS_NODE_PERM_DIRECT_DL;
flags_stream << makeKeyValueReference("allow_direct_download", direct_dl);
if(direct_dl) flags |= RS_NODE_PERM_DIRECT_DL;
bool allow_push = RS_NODE_PERM_DEFAULT & RS_NODE_PERM_ALLOW_PUSH;
flags_stream << makeKeyValueReference("allow_push", allow_push);
if(allow_push) flags |= RS_NODE_PERM_ALLOW_PUSH;
bool require_whitelist = RS_NODE_PERM_DEFAULT & RS_NODE_PERM_REQUIRE_WL;
flags_stream << makeKeyValueReference("require_whitelist", require_whitelist);
if(require_whitelist) flags |= RS_NODE_PERM_REQUIRE_WL;
}
else
{
flags = RS_NODE_PERM_DEFAULT;
}
RsPeerId peer_id;
RsPgpId pgp_id;
std::string error_string;
if(mRsPeers->loadCertificateFromString(cert_string, peer_id, pgp_id, error_string)
&& mRsPeers->addFriend(peer_id, pgp_id))
&& mRsPeers->addFriend(peer_id, pgp_id, flags))
{
ok = true;
resp.mDataStream << makeKeyValueReference("pgp_id", pgp_id);