mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
replaced the few bools in RsIdentityDetail by a set of flags
This commit is contained in:
parent
738dadadc9
commit
1de55d8fc5
@ -103,10 +103,8 @@ void GxsResponseTask::streamGxsId(RsGxsId id, StreamBase &stream)
|
||||
{
|
||||
stream << makeKeyValueReference("id", id)
|
||||
<< makeKeyValueReference("gxs_id", id)
|
||||
<< makeKeyValueReference("is_own", vit->mIsOwnId)
|
||||
<< makeKeyValueReference("name", vit->mNickname)
|
||||
<< makeKeyValueReference("pgp_linked", vit->mPgpLinked)
|
||||
<< makeKeyValueReference("pgp_known", vit->mPgpKnown);
|
||||
<< makeKeyValueReference("flags", vit->mFlags)
|
||||
<< makeKeyValueReference("name", vit->mNickname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -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()) ;
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -235,7 +235,7 @@ static bool trimAnonIds(std::list<RsGxsId>& lst)
|
||||
RsIdentityDetails idd ;
|
||||
|
||||
for(std::list<RsGxsId>::iterator it = lst.begin();it!=lst.end();)
|
||||
if(!rsIdentity->getIdDetails(*it,idd) || !idd.mPgpLinked)
|
||||
if(!rsIdentity->getIdDetails(*it,idd) || !(idd.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
|
||||
{
|
||||
it = lst.erase(it) ;
|
||||
removed= true ;
|
||||
|
@ -1333,7 +1333,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
|
||||
if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details))
|
||||
{
|
||||
if(gxs_details.mIsOwnId)
|
||||
if(gxs_details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID)
|
||||
{
|
||||
QMessageBox::warning(NULL,QString("Cannot send message to yourself"),QString("This identity is owned by you. You wouldn't want to send yourself a message right?"));
|
||||
break ;
|
||||
|
@ -110,7 +110,7 @@ void CreateLobbyDialog::checkTextFields()
|
||||
|
||||
rsIdentity->getIdDetails(id,idd) ;
|
||||
|
||||
if( (!idd.mPgpKnown) && ui->pgp_signed_CB->isChecked())
|
||||
if( (!(idd.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)) && ui->pgp_signed_CB->isChecked())
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false) ;
|
||||
}
|
||||
|
||||
|
@ -895,11 +895,11 @@ QString nickname = details.mNickname.empty()?tr("[Unknown]"):QString::fromUtf8(d
|
||||
QApplication::translate("GxsIdDetails", "Identity Id"),
|
||||
QString::fromStdString(details.mId.toStdString()));
|
||||
|
||||
if (details.mPgpLinked)
|
||||
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
|
||||
{
|
||||
comment += QString("<br/>%1:%2 ").arg(QApplication::translate("GxsIdDetails", "Authentication"), QApplication::translate("GxsIdDetails", "Signed by"));
|
||||
|
||||
if (details.mPgpKnown)
|
||||
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
|
||||
{
|
||||
/* look up real name */
|
||||
std::string authorName = rsPeers->getGPGName(details.mPgpId);
|
||||
@ -937,9 +937,9 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
|
||||
{
|
||||
// ICON Logic.
|
||||
QIcon baseIcon;
|
||||
if (details.mPgpLinked)
|
||||
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED)
|
||||
{
|
||||
if (details.mPgpKnown)
|
||||
if (details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN)
|
||||
baseIcon = QIcon(IMAGE_PGPKNOWN);
|
||||
else
|
||||
baseIcon = QIcon(IMAGE_PGPUNKNOWN);
|
||||
|
Loading…
Reference in New Issue
Block a user