mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-23 13:15:51 -04:00
Provide more usable method to create GXS circles
Fix some compiler warnings with out of definition default destructors
This commit is contained in:
parent
c2cb63b40c
commit
6862e642e8
3 changed files with 109 additions and 14 deletions
|
@ -27,7 +27,7 @@
|
|||
#include "util/rsdir.h"
|
||||
#include "util/radix64.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "pgp/pgpauxutils.h"
|
||||
#include "retroshare/rsgxscircles.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
@ -153,8 +153,76 @@ RsServiceInfo p3GxsCircles::getServiceInfo()
|
|||
GXS_CIRCLES_MIN_MINOR_VERSION);
|
||||
}
|
||||
|
||||
bool p3GxsCircles::createCircle(RsGxsCircleGroup& cData)
|
||||
bool p3GxsCircles::createCircle(
|
||||
const std::string& circleName, RsGxsCircleType circleType,
|
||||
RsGxsCircleId& circleId, const RsGxsCircleId& restrictedId,
|
||||
const RsGxsId& authorId, const std::set<RsGxsId>& gxsIdMembers,
|
||||
const std::set<RsPgpId>& localMembers )
|
||||
{
|
||||
if(circleName.empty())
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Circle name is empty" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(circleType)
|
||||
{
|
||||
case RsGxsCircleType::PUBLIC:
|
||||
if(!restrictedId.isNull())
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " restrictedId: " << restrictedId
|
||||
<< " must be null with RsGxsCircleType::PUBLIC"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case RsGxsCircleType::EXTERNAL:
|
||||
if(restrictedId.isNull())
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " restrictedId can't be null "
|
||||
<< "with RsGxsCircleType::EXTERNAL" << std::endl;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case RsGxsCircleType::NODES_GROUP:
|
||||
if(localMembers.empty())
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " localMembers can't be empty "
|
||||
<< "with RsGxsCircleType::NODES_GROUP" << std::endl;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case RsGxsCircleType::LOCAL:
|
||||
break;
|
||||
case RsGxsCircleType::EXT_SELF:
|
||||
if(!restrictedId.isNull())
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " restrictedId: " << restrictedId
|
||||
<< " must be null with RsGxsCircleType::EXT_SELF"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
if(gxsIdMembers.empty())
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " gxsIdMembers can't be empty "
|
||||
<< "with RsGxsCircleType::EXT_SELF" << std::endl;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case RsGxsCircleType::YOUR_EYES_ONLY:
|
||||
break;
|
||||
default:
|
||||
RsErr() << __PRETTY_FUNCTION__ << " Invalid circle type: "
|
||||
<< static_cast<uint32_t>(circleType) << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
RsGxsCircleGroup cData;
|
||||
cData.mMeta.mGroupName = circleName;
|
||||
cData.mMeta.mAuthorId = authorId;
|
||||
cData.mMeta.mCircleType = static_cast<uint32_t>(circleType);
|
||||
cData.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
|
||||
uint32_t token;
|
||||
createGroup(token, cData);
|
||||
|
||||
|
@ -172,8 +240,9 @@ bool p3GxsCircles::createCircle(RsGxsCircleGroup& cData)
|
|||
return false;
|
||||
}
|
||||
|
||||
circleId = static_cast<RsGxsCircleId>(cData.mMeta.mGroupId);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
bool p3GxsCircles::editCircle(RsGxsCircleGroup& cData)
|
||||
{
|
||||
|
@ -2157,3 +2226,8 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token)
|
|||
|
||||
return true ;
|
||||
}
|
||||
|
||||
RsGxsCircles::~RsGxsCircles() = default;
|
||||
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
|
||||
RsGxsCircleDetails::~RsGxsCircleDetails() = default;
|
||||
RsGxsCircleGroup::~RsGxsCircleGroup() = default;
|
||||
|
|
|
@ -180,7 +180,14 @@ virtual RsServiceInfo getServiceInfo();
|
|||
/*********** External Interface ***************/
|
||||
|
||||
/// @see RsGxsCircles
|
||||
bool createCircle(RsGxsCircleGroup& cData) override;
|
||||
bool createCircle(
|
||||
const std::string& circleName, RsGxsCircleType circleType,
|
||||
RsGxsCircleId& circleId = RS_DEFAULT_STORAGE_PARAM(RsGxsCircleId),
|
||||
const RsGxsCircleId& restrictedId = RsGxsCircleId(),
|
||||
const RsGxsId& authorId = RsGxsId(),
|
||||
const std::set<RsGxsId>& gxsIdMembers = std::set<RsGxsId>(),
|
||||
const std::set<RsPgpId>& localMembers = std::set<RsPgpId>()
|
||||
) override;
|
||||
|
||||
/// @see RsGxsCircles
|
||||
bool editCircle(RsGxsCircleGroup& cData) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue