Merge pull request #2224 from csoler/v0.6-BugFixing_5

continue bug fixing for 0.6.6 (See commits)
This commit is contained in:
csoler 2021-01-18 13:24:31 +01:00 committed by GitHub
commit 5ec3ae8640
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 128 additions and 56 deletions

View file

@ -834,7 +834,7 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
std::cerr << "RsGenExchange::createMessage() " << std::endl; std::cerr << "RsGenExchange::createMessage() " << std::endl;
#endif #endif
RsGxsGrpMetaTemporaryMap metaMap ; RsGxsGrpMetaTemporaryMap metaMap ;
metaMap.insert(std::make_pair(id, (RsGxsGrpMetaData*)(NULL))); metaMap[id] = std::make_shared<RsGxsGrpMetaData>();
mDataStore->retrieveGxsGrpMetaData(metaMap); mDataStore->retrieveGxsGrpMetaData(metaMap);
RsGxsMsgMetaData &meta = *(msg->metaData); RsGxsMsgMetaData &meta = *(msg->metaData);
@ -2231,7 +2231,7 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
bool ok = false; bool ok = false;
RsGxsGrpMetaTemporaryMap grpMetaMap; RsGxsGrpMetaTemporaryMap grpMetaMap;
grpMetaMap.insert(std::make_pair(grpId, (RsGxsGrpMetaData*)(NULL))); grpMetaMap[grpId] = std::make_shared<RsGxsGrpMetaData>();
mDataStore->retrieveGxsGrpMetaData(grpMetaMap); mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
auto mit = grpMetaMap.find(grpId); auto mit = grpMetaMap.find(grpId);

View file

@ -5424,6 +5424,12 @@ bool RsGxsNetService::search( const std::string& substring,
group_infos.clear(); group_infos.clear();
#ifdef RS_DEEP_CHANNEL_INDEX #ifdef RS_DEEP_CHANNEL_INDEX
#warning TODO: filter deep index search result to non circle-restricted groups.
// /!\
// /!\ These results should be filtered to only return results coming from a non restricted group!
// /!\
std::vector<DeepChannelsSearchResult> results; std::vector<DeepChannelsSearchResult> results;
DeepChannelsIndex::search(substring, results); DeepChannelsIndex::search(substring, results);
@ -5470,7 +5476,7 @@ bool RsGxsNetService::search( const std::string& substring,
RsGroupNetworkStats stats; RsGroupNetworkStats stats;
for(auto it(grpMetaMap.begin());it!=grpMetaMap.end();++it) for(auto it(grpMetaMap.begin());it!=grpMetaMap.end();++it)
if(termSearch(it->second->mGroupName,substring)) if(it->second->mCircleType==GXS_CIRCLE_TYPE_PUBLIC && termSearch(it->second->mGroupName,substring))
{ {
getGroupNetworkStats(it->first,stats); getGroupNetworkStats(it->first,stats);

View file

@ -66,7 +66,6 @@ p3HistoryMgr::~p3HistoryMgr()
/***** p3HistoryMgr *****/ /***** p3HistoryMgr *****/
//void p3HistoryMgr::addMessage(bool incoming, const RsPeerId &chatPeerId, const RsPeerId &msgPeerId, const RsChatMsgItem *chatItem)
void p3HistoryMgr::addMessage(const ChatMessage& cm) void p3HistoryMgr::addMessage(const ChatMessage& cm)
{ {
uint32_t addMsgId = 0; uint32_t addMsgId = 0;
@ -99,6 +98,7 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
} }
if (cm.chat_id.isLobbyId() && mLobbyEnable == true) { if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
peerName = cm.lobby_peer_gxs_id.toStdString(); peerName = cm.lobby_peer_gxs_id.toStdString();
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
enabled = true; enabled = true;
} }
@ -114,6 +114,8 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
peerName = det.mNickname; peerName = det.mNickname;
else else
peerName = writer_id.toStdString(); peerName = writer_id.toStdString();
msgPeerId = cm.incoming?RsPeerId(dcpinfo.own_id):RsPeerId(dcpinfo.to_id);
} }
else else
{ {

View file

@ -420,10 +420,14 @@ public:
/** /**
* @brief Update identity data (name, avatar...) * @brief Update identity data (name, avatar...)
* @jsonapi{development} * @jsonapi{development}
* @param[in] identityData updated identiy data * @param[in] id Id of the identity
* @param[in] name New name of the identity
* @param[in] avatar New avatar for the identity
* @param[in] pseudonimous Set to true to make the identity anonymous. If set to false, updating will require the profile passphrase.
* @param[in] pgpPassword Profile passphrase, if non pseudonymous.
* @return false on error, true otherwise * @return false on error, true otherwise
*/ */
virtual bool updateIdentity(RsGxsIdGroup& identityData) = 0; virtual bool updateIdentity( const RsGxsId& id, const std::string& name, const RsGxsImage& avatar, bool pseudonimous, const std::string& pgpPassword) =0;
/** /**
* @brief Get identity details, from the cache * @brief Get identity details, from the cache
@ -637,9 +641,6 @@ public:
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id, virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
bool absOpinion, int score) = 0; bool absOpinion, int score) = 0;
RS_DEPRECATED
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
RS_DEPRECATED RS_DEPRECATED
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0; virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;

View file

@ -1041,37 +1041,87 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
return true; return true;
} }
bool p3IdService::updateIdentity(RsGxsIdGroup& identityData) bool p3IdService::updateIdentity( const RsGxsId& id, const std::string& name, const RsGxsImage& avatar, bool pseudonimous, const std::string& pgpPassword)
{ {
uint32_t token; // 1 - get back the identity group
if(!updateGroup(token, identityData))
{ std::vector<RsGxsIdGroup> idsInfo;
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group."
<< std::endl; if(!getIdentitiesInfo(std::set<RsGxsId>{ id }, idsInfo))
return false; return false;
RsGxsIdGroup& group(idsInfo[0]);
// 2 - update it with the new information
group.mMeta.mGroupName = name;
group.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;
group.mImage = avatar;
if(!pseudonimous)
{
#warning csoler 2020-01-21: 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
group.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PRIVATE; // this is also equal to RSGXSID_GROUPFLAG_REALID_deprecated
group.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
group.mMeta.mGroupFlags |= GXS_SERV::FLAG_PRIVACY_PUBLIC;
uint32_t token;
bool ret = true;
// Cache pgp passphrase to allow a proper re-signing of the group data
if(!pseudonimous && !pgpPassword.empty())
{
if(!rsNotify->cachePgpPassphrase(pgpPassword))
{
RsErr() << __PRETTY_FUNCTION__ << " Failure caching password" << std::endl;
ret = false;
goto LabelUpdateIdentityCleanup;
}
if(!rsNotify->setDisableAskPassword(true))
{
RsErr() << __PRETTY_FUNCTION__ << " Failure disabling password user request" << std::endl;
ret = false;
goto LabelUpdateIdentityCleanup;
}
}
if(!updateGroup(token, group))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group." << std::endl;
ret = false;
goto LabelUpdateIdentityCleanup;
} }
if(waitToken(token) != RsTokenService::COMPLETE) if(waitToken(token) != RsTokenService::COMPLETE)
{ {
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." << std::endl;
<< std::endl; ret = false;
return false; goto LabelUpdateIdentityCleanup;
} }
return true; LabelUpdateIdentityCleanup:
} if(!pseudonimous && !pgpPassword.empty())
rsNotify->clearPgpPassphrase();
bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group) return ret;
{
#ifdef DEBUG_IDS
std::cerr << "p3IdService::updateIdentity()";
std::cerr << std::endl;
#endif
group.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;
updateGroup(token, group);
return false;
} }
bool p3IdService::deleteIdentity(RsGxsId& id) bool p3IdService::deleteIdentity(RsGxsId& id)

View file

@ -261,10 +261,7 @@ public:
virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params) override; virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params) override;
/// @see RsIdentity /// @see RsIdentity
bool updateIdentity(RsGxsIdGroup& identityData) override; bool updateIdentity( const RsGxsId& id, const std::string& name, const RsGxsImage& avatar, bool pseudonimous, const std::string& pgpPassword) override;
RS_DEPRECATED
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) override;
/// @see RsIdentity /// @see RsIdentity
bool deleteIdentity(RsGxsId& id) override; bool deleteIdentity(RsGxsId& id) override;

View file

@ -611,8 +611,31 @@ void IdEditDialog::updateId()
else else
mEditGroup.mImage.clear(); mEditGroup.mImage.clear();
uint32_t dummyToken = 0; RsGxsId keyId;
rsIdentity->updateIdentity(mEditGroup); std::string gpg_password;
if(!mEditGroup.mPgpId.isNull())
{
std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId());
bool cancelled;
rsNotify->clearPgpPassphrase(); // just in case
if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(),
gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")",
false,
gpg_password,cancelled))
{
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create an identity linked to your profile without your profile password."));
return;
}
}
if(!rsIdentity->updateIdentity(RsGxsId(mEditGroup.mMeta.mGroupId),mEditGroup.mMeta.mGroupName,mEditGroup.mImage,mEditGroup.mPgpId.isNull(),gpg_password))
{
QMessageBox::critical(NULL,tr("Identity update failed"),tr("Cannot update identity. Something went wrong. Check your profile password."));
return;
}
accept(); accept();
} }

View file

@ -406,25 +406,18 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
{ {
RsIdentityDetails details; RsIdentityDetails details;
time_t start = time(nullptr); time_t start = time(nullptr);
while (!rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details))
{
std::this_thread::sleep_for(std::chrono::milliseconds(10));
if (time(nullptr)>start+2)
{
std::cerr << "ChatWidget History haven't found Id Details and have wait 1 sec for it." << std::endl;
break;
}
}
if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details)) if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerId), details))
name = QString::fromUtf8(details.mNickname.c_str()); name = QString::fromUtf8(details.mNickname.c_str());
else if(!historyIt->peerName.empty())
name = QString::fromUtf8(historyIt->peerName.c_str());
else else
name = QString::fromUtf8(historyIt->peerName.c_str()); name = QString::fromUtf8(historyIt->peerId.toStdString().c_str());
} else { } else {
name = QString::fromUtf8(historyIt->peerName.c_str()); name = QString::fromUtf8(historyIt->peerId.toStdString().c_str());
} }
addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerName.c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY); addChatMsg(historyIt->incoming, name, RsGxsId(historyIt->peerId.toStdString().c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), MSGTYPE_HISTORY);
} }
} }
} }

View file

@ -907,7 +907,7 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Chatlobbies</string> <string>Chat rooms</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -920,7 +920,7 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Private chat</string> <string>Node-to-node chat</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -933,7 +933,7 @@
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>Group chat</string> <string>Broadcast</string>
</property> </property>
</widget> </widget>
</item> </item>