mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 00:19:30 -05:00
Merge pull request #2224 from csoler/v0.6-BugFixing_5
continue bug fixing for 0.6.6 (See commits)
This commit is contained in:
commit
5ec3ae8640
@ -834,7 +834,7 @@ int RsGenExchange::createMessage(RsNxsMsg* msg)
|
||||
std::cerr << "RsGenExchange::createMessage() " << std::endl;
|
||||
#endif
|
||||
RsGxsGrpMetaTemporaryMap metaMap ;
|
||||
metaMap.insert(std::make_pair(id, (RsGxsGrpMetaData*)(NULL)));
|
||||
metaMap[id] = std::make_shared<RsGxsGrpMetaData>();
|
||||
mDataStore->retrieveGxsGrpMetaData(metaMap);
|
||||
|
||||
RsGxsMsgMetaData &meta = *(msg->metaData);
|
||||
@ -2231,7 +2231,7 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
|
||||
bool ok = false;
|
||||
|
||||
RsGxsGrpMetaTemporaryMap grpMetaMap;
|
||||
grpMetaMap.insert(std::make_pair(grpId, (RsGxsGrpMetaData*)(NULL)));
|
||||
grpMetaMap[grpId] = std::make_shared<RsGxsGrpMetaData>();
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||
auto mit = grpMetaMap.find(grpId);
|
||||
|
@ -5424,6 +5424,12 @@ bool RsGxsNetService::search( const std::string& substring,
|
||||
group_infos.clear();
|
||||
|
||||
#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;
|
||||
DeepChannelsIndex::search(substring, results);
|
||||
|
||||
@ -5470,7 +5476,7 @@ bool RsGxsNetService::search( const std::string& substring,
|
||||
|
||||
RsGroupNetworkStats stats;
|
||||
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);
|
||||
|
||||
|
@ -66,7 +66,6 @@ p3HistoryMgr::~p3HistoryMgr()
|
||||
|
||||
/***** p3HistoryMgr *****/
|
||||
|
||||
//void p3HistoryMgr::addMessage(bool incoming, const RsPeerId &chatPeerId, const RsPeerId &msgPeerId, const RsChatMsgItem *chatItem)
|
||||
void p3HistoryMgr::addMessage(const ChatMessage& cm)
|
||||
{
|
||||
uint32_t addMsgId = 0;
|
||||
@ -99,7 +98,8 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
|
||||
}
|
||||
if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
|
||||
peerName = cm.lobby_peer_gxs_id.toStdString();
|
||||
enabled = true;
|
||||
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
if(cm.chat_id.isDistantChatId()&& mDistantEnable == true)
|
||||
@ -114,6 +114,8 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
|
||||
peerName = det.mNickname;
|
||||
else
|
||||
peerName = writer_id.toStdString();
|
||||
|
||||
msgPeerId = cm.incoming?RsPeerId(dcpinfo.own_id):RsPeerId(dcpinfo.to_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -420,10 +420,14 @@ public:
|
||||
/**
|
||||
* @brief Update identity data (name, avatar...)
|
||||
* @jsonapi{development}
|
||||
* @param[in] identityData updated identiy data
|
||||
* @return false on error, true otherwise
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
@ -637,9 +641,6 @@ public:
|
||||
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
|
||||
bool absOpinion, int score) = 0;
|
||||
|
||||
RS_DEPRECATED
|
||||
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
||||
|
||||
RS_DEPRECATED
|
||||
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
|
||||
|
||||
|
@ -1041,37 +1041,87 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters ¶ms)
|
||||
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)
|
||||
{
|
||||
// 1 - get back the identity group
|
||||
|
||||
std::vector<RsGxsIdGroup> idsInfo;
|
||||
|
||||
if(!getIdentitiesInfo(std::set<RsGxsId>{ id }, idsInfo))
|
||||
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;
|
||||
if(!updateGroup(token, identityData))
|
||||
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;
|
||||
return false;
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group." << std::endl;
|
||||
ret = false;
|
||||
goto LabelUpdateIdentityCleanup;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
|
||||
<< std::endl;
|
||||
return false;
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." << std::endl;
|
||||
ret = false;
|
||||
goto LabelUpdateIdentityCleanup;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
LabelUpdateIdentityCleanup:
|
||||
if(!pseudonimous && !pgpPassword.empty())
|
||||
rsNotify->clearPgpPassphrase();
|
||||
|
||||
bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::updateIdentity()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
group.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;
|
||||
|
||||
updateGroup(token, group);
|
||||
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool p3IdService::deleteIdentity(RsGxsId& id)
|
||||
|
@ -261,10 +261,7 @@ public:
|
||||
virtual bool createIdentity(uint32_t& token, RsIdentityParameters ¶ms) override;
|
||||
|
||||
/// @see RsIdentity
|
||||
bool updateIdentity(RsGxsIdGroup& identityData) override;
|
||||
|
||||
RS_DEPRECATED
|
||||
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) override;
|
||||
bool updateIdentity( const RsGxsId& id, const std::string& name, const RsGxsImage& avatar, bool pseudonimous, const std::string& pgpPassword) override;
|
||||
|
||||
/// @see RsIdentity
|
||||
bool deleteIdentity(RsGxsId& id) override;
|
||||
|
@ -611,8 +611,31 @@ void IdEditDialog::updateId()
|
||||
else
|
||||
mEditGroup.mImage.clear();
|
||||
|
||||
uint32_t dummyToken = 0;
|
||||
rsIdentity->updateIdentity(mEditGroup);
|
||||
RsGxsId keyId;
|
||||
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();
|
||||
}
|
||||
|
@ -406,25 +406,18 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
|
||||
{
|
||||
RsIdentityDetails details;
|
||||
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());
|
||||
else
|
||||
name = QString::fromUtf8(historyIt->peerName.c_str());
|
||||
} else {
|
||||
name = QString::fromUtf8(historyIt->peerName.c_str());
|
||||
else if(!historyIt->peerName.empty())
|
||||
name = QString::fromUtf8(historyIt->peerName.c_str());
|
||||
else
|
||||
name = QString::fromUtf8(historyIt->peerId.toStdString().c_str());
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -907,7 +907,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Chatlobbies</string>
|
||||
<string>Chat rooms</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -920,7 +920,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Private chat</string>
|
||||
<string>Node-to-node chat</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -933,7 +933,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Group chat</string>
|
||||
<string>Broadcast</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user