replaced the few bools in RsIdentityDetail by a set of flags

This commit is contained in:
csoler 2015-11-19 21:14:32 -05:00
parent 738dadadc9
commit 1de55d8fc5
9 changed files with 32 additions and 33 deletions

View file

@ -168,7 +168,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
{
RsIdentityDetails details;
if(!rsIdentity->getIdDetails(cli->signature.keyId,details) || !details.mPgpKnown)
if(!rsIdentity->getIdDetails(cli->signature.keyId,details) || !( details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
{
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (id=" << cli->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
@ -665,7 +665,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
{
RsIdentityDetails details;
if(!rsIdentity->getIdDetails(item->signature.keyId,details) || !details.mPgpKnown)
if(!rsIdentity->getIdDetails(item->signature.keyId,details) || !(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
{
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (ID=" << item->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
@ -1699,7 +1699,7 @@ bool DistributedChatService::setIdentityForChatLobby(const ChatLobbyId& lobby_id
// Only send a nickname change event if the two Identities are not anonymous
if(rsIdentity->getIdDetails(nick,det1) && rsIdentity->getIdDetails(it->second.gxs_id,det2) && det1.mPgpLinked && det2.mPgpLinked)
if(rsIdentity->getIdDetails(nick,det1) && rsIdentity->getIdDetails(it->second.gxs_id,det2) && (det1.mFlags & det2.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
sendLobbyStatusPeerChangedNickname(lobby_id, nick.toStdString()) ;
}

View file

@ -64,6 +64,11 @@ extern RsIdentity *rsIdentity;
std::string rsIdTypeToString(uint32_t idtype);
static const uint32_t RS_IDENTITY_FLAGS_IS_A_CONTACT = 0x0001;
static const uint32_t RS_IDENTITY_FLAGS_PGP_LINKED = 0x0002;
static const uint32_t RS_IDENTITY_FLAGS_PGP_KNOWN = 0x0004;
static const uint32_t RS_IDENTITY_FLAGS_IS_OWN_ID = 0x0008;
class GxsReputation
{
public:
@ -153,23 +158,19 @@ class RsRecognTagDetails
bool is_pending;
};
class RsIdentityDetails
{
public:
RsIdentityDetails()
:mIsOwnId(false), mPgpLinked(false), mPgpKnown(false),
mReputation(), mLastUsageTS(0) { return; }
RsIdentityDetails() :mFlags(0), mReputation(), mLastUsageTS(0) { return; }
RsGxsId mId;
// identity details.
std::string mNickname;
bool mIsOwnId;
uint32_t mFlags ;
// PGP Stuff.
bool mPgpLinked;
bool mPgpKnown;
RsPgpId mPgpId;
// Recogn details.

View file

@ -932,7 +932,7 @@ bool p3GxsCircles::cache_load_for_token(uint32_t token)
RsIdentityDetails details;
if (mIdentities->getIdDetails(*pit, details))
{
if (details.mPgpLinked && details.mPgpKnown)
if ((details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) &&(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
{
#ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::cache_load_for_token() Is Known -> AllowedPeer: " << *pit;
@ -1115,7 +1115,7 @@ bool p3GxsCircles::cache_reloadids(const RsGxsCircleId &circleId)
RsIdentityDetails details;
if (mIdentities->getIdDetails(*pit, details))
{
if (details.mPgpLinked && details.mPgpKnown)
if ((details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) &&(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
{
cache.addAllowedPeer(details.mPgpId, *pit);

View file

@ -1593,8 +1593,10 @@ RsGxsIdCache::RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey
std::cerr << std::endl;
#endif // DEBUG_IDS
details.mIsOwnId = (item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
details.mPgpLinked = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
details.mFlags = 0 ;
if(item->meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) details.mFlags |= RS_IDENTITY_FLAGS_IS_OWN_ID;
if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED;
/* rest must be retrived from ServiceString */
updateServiceString(item->meta.mServiceString);
@ -1603,21 +1605,19 @@ RsGxsIdCache::RsGxsIdCache(const RsGxsIdGroupItem *item, const RsTlvSecurityKey
void RsGxsIdCache::updateServiceString(std::string serviceString)
{
details.mRecognTags.clear();
details.mFlags = 0 ;
SSGxsIdGroup ssdata;
if (ssdata.load(serviceString))
{
if (details.mPgpLinked)
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
{
details.mPgpKnown = ssdata.pgp.idKnown;
if (details.mPgpKnown)
{
if(ssdata.pgp.idKnown) details.mFlags |= RS_IDENTITY_FLAGS_PGP_KNOWN ;
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
details.mPgpId = ssdata.pgp.pgpId;
}
else
{
details.mPgpId.clear();
}
}
@ -1673,7 +1673,7 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
}
else
{
details.mPgpKnown = false;
details.mFlags &= ~RS_IDENTITY_FLAGS_PGP_KNOWN ;
details.mPgpId.clear();
details.mReputation.updateIdScore(false, false);
details.mReputation.update();