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

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