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:
csoler 2013-08-30 20:40:28 +00:00
parent 8aaa4db85c
commit abd8c1e32f
3 changed files with 47 additions and 8 deletions

View File

@ -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 ;

View File

@ -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 {

View File

@ -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;
}