mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
fixed problem in ID creation code.
This commit is contained in:
parent
9226ccc5ca
commit
37f3e1a62a
@ -109,7 +109,7 @@ void ForumHandler::handleWildcard(Request &req, Response &resp)
|
||||
//KeyValueReference<RsPgpId> pgp_id("pgp_id",grp.mPgpId );
|
||||
// not very happy about this, i think the flags should stay hidden in rsidentities
|
||||
bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||
bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility);
|
||||
bool subscribed = IS_GROUP_SUBSCRIBED(grp.mMeta.mSubscribeFlags);
|
||||
resp.mDataStream.getStreamToMember()
|
||||
<< id
|
||||
|
@ -156,8 +156,7 @@ void IdentityHandler::handleWildcard(Request & /*req*/, Response &resp)
|
||||
RsGxsIdGroup& grp = *vit;
|
||||
//electron: not very happy about this, i think the flags should stay hidden in rsidentities
|
||||
bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN);
|
||||
bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||
resp.mDataStream.getStreamToMember()
|
||||
bool pgp_linked = (grp.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecateRSGXSID_GROUPFLAG_REALID_kept_for_compatibilityMember()
|
||||
<< makeKeyValueReference("id", grp.mMeta.mGroupId) /// @deprecated using "id" as key can cause problems in some JS based languages like Qml @see gxs_id instead
|
||||
<< makeKeyValueReference("gxs_id", grp.mMeta.mGroupId)
|
||||
<< makeKeyValueReference("pgp_id",grp.mPgpId )
|
||||
|
@ -1569,7 +1569,9 @@ bool RsGenExchange::checkGroupMetaConsistency(const RsGroupMetaData& meta)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_PUBLIC && meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_RESTRICTED && meta.mGroupFlags != GXS_SERV::FLAG_PRIVACY_PRIVATE)
|
||||
uint32_t gf = meta.mGroupFlags & GXS_SERV::FLAG_PRIVACY_MASK ;
|
||||
|
||||
if(gf != GXS_SERV::FLAG_PRIVACY_PUBLIC && gf != GXS_SERV::FLAG_PRIVACY_RESTRICTED && gf != GXS_SERV::FLAG_PRIVACY_PRIVATE)
|
||||
{
|
||||
std::cerr << "(EE) mGroupFlags has incorrect value " << std::hex << meta.mGroupFlags << std::dec << ". A value among GXS_SERV::FLAG_PRIVACY_{PUBLIC,RESTRICTED,PRIVATE} is expected." << std::endl;
|
||||
return false ;
|
||||
|
@ -43,8 +43,12 @@ extern RsIdentity *rsIdentity;
|
||||
|
||||
|
||||
// GroupFlags: Only one so far:
|
||||
#warning THIS FLAG OVERLAPS THE FLAGS FOR mGroupFlags. This is an error that should be fixed.
|
||||
#define RSGXSID_GROUPFLAG_REALID 0x0001
|
||||
|
||||
// The deprecated flag overlaps the privacy flags for mGroupFlags. This is an error that should be fixed. For the sake of keeping some
|
||||
// backward compatibility, we need to make the change step by step.
|
||||
|
||||
#define RSGXSID_GROUPFLAG_REALID_deprecated 0x0001
|
||||
#define RSGXSID_GROUPFLAG_REALID 0x0100
|
||||
|
||||
// THESE ARE FLAGS FOR INTERFACE.
|
||||
#define RSID_TYPE_MASK 0xff00
|
||||
|
@ -1602,7 +1602,7 @@ void p3GxsCircles::checkDummyIdData()
|
||||
std::vector<RsGxsIdGroup>::iterator it;
|
||||
for(it = ids.begin(); it != ids.end(); ++it)
|
||||
{
|
||||
if (it->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (it->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << "p3GxsCircles::checkDummyIdData() PgpLinkedId: " << it->mMeta.mGroupId;
|
||||
|
@ -695,12 +695,26 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
|
||||
if (params.isPgpLinked)
|
||||
{
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
#warning Backward compatibility issue to fix here in v0.7.0
|
||||
|
||||
// This is a hack, because a bad decision led to having RSGXSID_GROUPFLAG_REALID be equal to GXS_SERV::FLAG_PRIVACY_PRIVATE.
|
||||
// In order to keep backward compatibility, we'll also add the new value
|
||||
// When the ID is not PGP linked, the group flag cannot be let empty, so we use PUBLIC.
|
||||
//
|
||||
// The correct combination of flags should be:
|
||||
// PGP-linked: GXS_SERV::FLAGS_PRIVACY_PUBLIC | RSGXSID_GROUPFLAG_REALID
|
||||
// Anonymous : GXS_SERV::FLAGS_PRIVACY_PUBLIC
|
||||
|
||||
id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PRIVATE; // this is also equal to RSGXSID_GROUPFLAG_REALID_deprecated
|
||||
id.mMeta.mGroupFlags |= RSGXSID_GROUPFLAG_REALID;
|
||||
|
||||
// The current version should be able to produce new identities that old peers will accept as well.
|
||||
// In the future, we need to:
|
||||
// - set the current group flags here (see above)
|
||||
// - replace all occurences of RSGXSID_GROUPFLAG_REALID_deprecated by RSGXSID_GROUPFLAG_REALID in the code.
|
||||
}
|
||||
else
|
||||
{
|
||||
id.mMeta.mGroupFlags = 0;
|
||||
}
|
||||
id.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;
|
||||
|
||||
createGroup(token, id);
|
||||
|
||||
@ -1260,7 +1274,7 @@ bool p3IdService::opinion_handlerequest(uint32_t token)
|
||||
}
|
||||
|
||||
// update IdScore too.
|
||||
bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||
bool pgpId = (meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated);
|
||||
ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature);
|
||||
ssdata.score.rep.update();
|
||||
|
||||
@ -1876,7 +1890,7 @@ void RsGxsIdCache::init(const RsGxsIdGroupItem *item, const RsTlvPublicRSAKey& i
|
||||
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;
|
||||
if(item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated) details.mFlags |= RS_IDENTITY_FLAGS_PGP_LINKED;
|
||||
|
||||
// do some tests
|
||||
if(details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID)
|
||||
@ -2830,7 +2844,7 @@ RsGenExchange::ServiceCreate_Return p3IdService::service_CreateGroup(RsGxsGrpIte
|
||||
|
||||
ServiceCreate_Return createStatus;
|
||||
|
||||
if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated)
|
||||
{
|
||||
/* create the hash */
|
||||
Sha1CheckSum hash;
|
||||
@ -3033,7 +3047,7 @@ bool p3IdService::pgphash_handlerequest(uint32_t token)
|
||||
#endif // DEBUG_IDS
|
||||
|
||||
/* Filter based on IdType */
|
||||
if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID))
|
||||
if (!(vit->mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated))
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::pgphash_request() discarding AnonID";
|
||||
@ -3609,7 +3623,7 @@ bool p3IdService::recogn_process()
|
||||
ssdata.recogntags.publishTs = item->meta.mPublishTs;
|
||||
|
||||
// update IdScore too.
|
||||
bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||
bool pgpId = (item->meta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_deprecated);
|
||||
ssdata.score.rep.updateIdScore(pgpId, ssdata.pgp.validatedSignature);
|
||||
ssdata.score.rep.update();
|
||||
|
||||
@ -3830,7 +3844,7 @@ void p3IdService::generateDummy_FriendPGP()
|
||||
|
||||
RsGxsIdGroup id;
|
||||
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_deprecated;
|
||||
|
||||
int idx = RSRandom::random_f32() * (gpgids.size() - 1);
|
||||
it = gpgids.begin();
|
||||
@ -3867,7 +3881,7 @@ void p3IdService::generateDummy_UnknownPGP()
|
||||
RsGxsIdGroup id;
|
||||
|
||||
// FAKE DATA.
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_deprecated;
|
||||
id.mPgpIdHash = Sha1CheckSum::random() ;
|
||||
id.mPgpIdSign = RSRandom::random_alphaNumericString(20) ;
|
||||
id.mMeta.mGroupName = RSRandom::random_alphaNumericString(10) ;
|
||||
|
@ -795,9 +795,9 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
|
||||
if (acceptAnonymous)
|
||||
ok = true;
|
||||
else if (acceptAllPGP)
|
||||
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
|
||||
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ;
|
||||
else if (idGroup.mPgpKnown)
|
||||
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID ;
|
||||
ok = idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility ;
|
||||
|
||||
if (!ok) {
|
||||
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
|
||||
@ -816,7 +816,7 @@ void CreateCircleDialog::loadIdentities(uint32_t token)
|
||||
if(idGroup.mImage.mSize == 0 || !pixmap.loadFromData(idGroup.mImage.mData, idGroup.mImage.mSize, "PNG"))
|
||||
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(idGroup.mMeta.mGroupId))) ;
|
||||
|
||||
if (idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (idGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
if (idGroup.mPgpKnown) {
|
||||
RsPeerDetails details;
|
||||
|
@ -204,7 +204,7 @@ void IdDetailsDialog::insertIdDetails(uint32_t token)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
RSGXSID_GROUPFLAG_REALID_kept_for_compatibilitySID_GROUPFLAG_REALID_deprecated)
|
||||
{
|
||||
ui->lineEdit_GpgName->setText(tr("Unknown real name"));
|
||||
}
|
||||
@ -236,9 +236,7 @@ void IdDetailsDialog::insertIdDetails(uint32_t token)
|
||||
ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ;
|
||||
else
|
||||
ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ;
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLRSGXSID_GROUPFLAG_REALID_kept_for_compatibility.mPgpKnown)
|
||||
if (rsPeers->isGPGAccepted(data.mPgpId))
|
||||
ui->lineEdit_Type->setText(tr("Owned by a friend Retroshare node")) ;
|
||||
else
|
||||
|
@ -1416,7 +1416,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||
|
||||
/* do filtering */
|
||||
bool ok = false;
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
if (isLinkedToOwnNode && (accept & RSID_FILTER_YOURSELF))
|
||||
{
|
||||
@ -1518,7 +1518,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||
|
||||
QString tooltip;
|
||||
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
{
|
||||
@ -1760,7 +1760,7 @@ void IdDialog::insertIdDetails(uint32_t token)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
ui->lineEdit_GpgName->setText(tr("[Unknown node]"));
|
||||
else
|
||||
ui->lineEdit_GpgName->setText(tr("Anonymous Id"));
|
||||
@ -1796,7 +1796,7 @@ void IdDialog::insertIdDetails(uint32_t token)
|
||||
ui->lineEdit_Type->setText(tr("Identity owned by you, linked to your Retroshare node")) ;
|
||||
else
|
||||
ui->lineEdit_Type->setText(tr("Anonymous identity, owned by you")) ;
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID)
|
||||
else if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility)
|
||||
{
|
||||
if (data.mPgpKnown)
|
||||
if (rsPeers->isGPGAccepted(data.mPgpId))
|
||||
|
@ -262,7 +262,7 @@ void IdEditDialog::loadExistingId(uint32_t token)
|
||||
|
||||
setAvatar(avatar);
|
||||
|
||||
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID_kept_for_compatibility);
|
||||
|
||||
if (realid)
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ bool GxsPeerNode::createIdentity(const std::string &name,
|
||||
id.mMeta.mGroupName = name;
|
||||
if (pgpLinked)
|
||||
{
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID_kept_for_compatibility;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user