mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
improved name support for distant peers in messages
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6653 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8aaa4db85c
commit
abd8c1e32f
@ -1914,6 +1914,10 @@ bool p3MsgService::decryptMessage(const std::string& mId)
|
||||
std::cerr << " Decrypted message was succesfully deserialized. New message:" << std::endl;
|
||||
item->print(std::cerr,0) ;
|
||||
#endif
|
||||
std::string own_hash ;
|
||||
std::string own_pgp_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
getDistantMessageHash(own_pgp_id,own_hash) ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
@ -1925,6 +1929,10 @@ bool p3MsgService::decryptMessage(const std::string& mId)
|
||||
msgi.msgFlags &= ~RS_MSG_FLAGS_ENCRYPTED ; // just in case.
|
||||
msgi.PeerId(senders_id.toStdString()) ;
|
||||
|
||||
for(std::list<std::string>::iterator it(msgi.msgto.ids.begin());it!=msgi.msgto.ids.end();++it) if(*it == own_hash) *it = own_pgp_id ;
|
||||
for(std::list<std::string>::iterator it(msgi.msgcc.ids.begin());it!=msgi.msgcc.ids.end();++it) if(*it == own_hash) *it = own_pgp_id ;
|
||||
for(std::list<std::string>::iterator it(msgi.msgbcc.ids.begin());it!=msgi.msgbcc.ids.end();++it) if(*it == own_hash) *it = own_pgp_id ;
|
||||
|
||||
if(signature_present)
|
||||
{
|
||||
msgi.msgFlags |= RS_MSG_FLAGS_SIGNED ;
|
||||
|
@ -1481,7 +1481,10 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
std::cerr << " RetroShareLink::process MessageRequest : id : " << link.hash().toStdString() << ", subject : " << link.name().toStdString() << std::endl;
|
||||
#endif
|
||||
RsPeerDetails detail;
|
||||
if (rsPeers->getPeerDetails(link.hash().toStdString(), detail)) {
|
||||
std::string dm_hash ;
|
||||
|
||||
if (rsPeers->getPeerDetails(link.hash().toStdString(), detail))
|
||||
{
|
||||
if (detail.accept_connection || detail.id == rsPeers->getOwnId() || detail.id == rsPeers->getGPGOwnId()) {
|
||||
MessageComposer *msg = MessageComposer::newMsg();
|
||||
msg->addRecipient(MessageComposer::TO, detail.id, false);
|
||||
@ -1490,7 +1493,21 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
}
|
||||
msg->show();
|
||||
messageStarted.append(PeerDefs::nameWithLocation(detail));
|
||||
} else {
|
||||
}
|
||||
else if(rsMsgs->getDistantMessageHash(detail.gpg_id,dm_hash))
|
||||
{
|
||||
MessageComposer *msg = MessageComposer::newMsg();
|
||||
msg->addRecipient(MessageComposer::TO, dm_hash,detail.gpg_id) ;
|
||||
|
||||
if (link.subject().isEmpty() == false) {
|
||||
msg->setTitleText(link.subject());
|
||||
}
|
||||
msg->show();
|
||||
messageStarted.append(PeerDefs::nameWithLocation(detail));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
messageReceipientNotAccepted.append(PeerDefs::nameWithLocation(detail));
|
||||
}
|
||||
} else {
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
||||
#include "PeerDefs.h"
|
||||
|
||||
@ -53,19 +54,32 @@ const QString PeerDefs::rsidFromId(const std::string &id, QString *name /* = NUL
|
||||
QString rsid;
|
||||
|
||||
std::string peerName = rsPeers->getPeerName(id);
|
||||
if (peerName.empty()) {
|
||||
rsid = PeerDefs::rsid("", id);
|
||||
std::string hash ;
|
||||
|
||||
if (name) {
|
||||
*name = qApp->translate("PeerDefs", "Unknown");
|
||||
}
|
||||
} else {
|
||||
if(!peerName.empty())
|
||||
{
|
||||
rsid = PeerDefs::rsid(peerName, id);
|
||||
|
||||
if (name) {
|
||||
*name = QString::fromUtf8(peerName.c_str());
|
||||
}
|
||||
}
|
||||
else if(rsMsgs->getDistantMessageHash(rsPeers->getGPGOwnId(),hash) && hash == id)
|
||||
{
|
||||
// not a real peer. Try from hash for distant messages
|
||||
|
||||
peerName = rsPeers->getGPGName(rsPeers->getGPGOwnId()) ;
|
||||
rsid = PeerDefs::rsid(peerName, rsPeers->getGPGOwnId());
|
||||
if(name)
|
||||
*name = QString::fromUtf8(peerName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
rsid = PeerDefs::rsid("", id);
|
||||
|
||||
if (name)
|
||||
*name = qApp->translate("PeerDefs", "Unknown");
|
||||
}
|
||||
|
||||
return rsid;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user