fixed RS link so as to send messages to GXS ids. Remaining issue: a link might need to be clicked several times before it works

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7351 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-05-08 07:52:28 +00:00
parent 2da8acd967
commit a946504bb5
3 changed files with 1833 additions and 1798 deletions

View File

@ -50,7 +50,7 @@
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
//#include <retroshare/rsforums.h> #include <retroshare/rsidentity.h>
//#include <retroshare/rschannels.h> //#include <retroshare/rschannels.h>
//#define DEBUG_RSLINK 1 //#define DEBUG_RSLINK 1
@ -1523,13 +1523,11 @@ static void processList(const QStringList &list, const QString &textSingular, co
// This is awful, but apparently the hash can be multiple different types. Let's check! // This is awful, but apparently the hash can be multiple different types. Let's check!
RsPgpId pgp_id(link.hash().toStdString()) ;
RsPeerId ssl_id(link.hash().toStdString()) ; RsPeerId ssl_id(link.hash().toStdString()) ;
if(!pgp_id.isNull() && rsPeers->getGPGDetails(pgp_id, detail) if(!ssl_id.isNull() && rsPeers->getPeerDetails(ssl_id,detail) && detail.accept_connection)
|| !ssl_id.isNull() && rsPeers->getPeerDetails(ssl_id,detail))
{ {
if (detail.accept_connection || RsPeerId(detail.id) == rsPeers->getOwnId() || RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) { //if (detail.accept_connection || RsPeerId(detail.id) == rsPeers->getOwnId() || RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId())
MessageComposer *msg = MessageComposer::newMsg(); MessageComposer *msg = MessageComposer::newMsg();
msg->addRecipient(MessageComposer::TO, detail.id); msg->addRecipient(MessageComposer::TO, detail.id);
if (link.subject().isEmpty() == false) { if (link.subject().isEmpty() == false) {
@ -1537,31 +1535,28 @@ static void processList(const QStringList &list, const QString &textSingular, co
} }
msg->show(); msg->show();
messageStarted.append(PeerDefs::nameWithLocation(detail)); messageStarted.append(PeerDefs::nameWithLocation(detail));
break ;
} }
#ifdef SUSPENDED
else if(rsMsgs->getDistantMessagePeerId(detail.gpg_id,dm_pid)) RsIdentityDetails gxs_details ;
RsGxsId gxs_id(link.hash().toStdString()) ;
if(!gxs_id.isNull() && rsIdentity->getIdDetails(gxs_id,gxs_details))
{ {
MessageComposer *msg = MessageComposer::newMsg(); MessageComposer *msg = MessageComposer::newMsg();
msg->addRecipient(MessageComposer::TO, dm_pid,detail.gpg_id) ; msg->addRecipient(MessageComposer::TO, gxs_id) ;
if (link.subject().isEmpty() == false) { if (link.subject().isEmpty() == false)
msg->setTitleText(link.subject()); msg->setTitleText(link.subject());
}
msg->show();
messageStarted.append(PeerDefs::nameWithLocation(detail));
} msg->show();
#endif messageStarted.append(PeerDefs::nameWithLocation(gxs_details));
else
{
messageReceipientNotAccepted.append(PeerDefs::nameWithLocation(detail));
}
} else {
messageReceipientUnknown.append(PeerDefs::rsidFromId(RsPeerId(link.hash().toStdString())));
}
break ; break ;
} }
messageReceipientUnknown.append(PeerDefs::rsidFromId(RsPeerId(link.hash().toStdString())));
}
break;
default: default:
std::cerr << " RetroShareLink::process unknown type: " << link.type() << std::endl; std::cerr << " RetroShareLink::process unknown type: " << link.type() << std::endl;

View File

@ -35,6 +35,10 @@ const QString PeerDefs::nameWithLocation(const RsPeerDetails &details)
return name; return name;
} }
const QString PeerDefs::nameWithLocation(const RsIdentityDetails &details)
{
return QString::fromUtf8(details.mNickname.c_str()) + " (" + QString::fromStdString(details.mId.toStdString()) + ")";
}
const QString PeerDefs::rsid(const std::string &name, const RsPgpId &id) const QString PeerDefs::rsid(const std::string &name, const RsPgpId &id)
{ {
if (name.empty()) { if (name.empty()) {
@ -64,6 +68,40 @@ const QString PeerDefs::rsid(const RsPeerDetails &details)
{ {
return rsid(details.name, details.id); return rsid(details.name, details.id);
} }
const QString PeerDefs::rsidFromId(const RsGxsId &id, QString *name /* = NULL*/)
{
QString rsid;
// Check own GXS ids.
//
std::list<RsGxsId> gxs_ids ;
rsIdentity->getOwnIds(gxs_ids) ;
for(std::list<RsGxsId>::const_iterator it(gxs_ids.begin());it!=gxs_ids.end();++it)
if(*it == id)
{
// not a real peer. Try from hash for distant messages
RsIdentityDetails details ;
if(!rsIdentity->getIdDetails(*it,details))
continue ;
std::string peerName = details.mNickname ;
rsid = PeerDefs::rsid(peerName, *it);
if(name)
*name = QString::fromUtf8(peerName.c_str());
return rsid ;
}
rsid = PeerDefs::rsid("", id);
if (name)
*name = qApp->translate("PeerDefs", "Unknown");
return rsid;
}
const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/) const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/)
{ {
QString rsid; QString rsid;

View File

@ -32,6 +32,7 @@ class PeerDefs
{ {
public: public:
static const QString nameWithLocation(const RsPeerDetails &details); static const QString nameWithLocation(const RsPeerDetails &details);
static const QString nameWithLocation(const RsIdentityDetails &details);
static const QString rsid(const RsPeerDetails &details); static const QString rsid(const RsPeerDetails &details);
static const QString rsid(const std::string &name, const RsPeerId &id); static const QString rsid(const std::string &name, const RsPeerId &id);
@ -39,6 +40,7 @@ public:
static const QString rsid(const std::string &name, const RsGxsId &id); static const QString rsid(const std::string &name, const RsGxsId &id);
static const QString rsidFromId(const RsPgpId &id, QString *name = NULL); static const QString rsidFromId(const RsPgpId &id, QString *name = NULL);
static const QString rsidFromId(const RsPeerId &id, QString *name = NULL); static const QString rsidFromId(const RsPeerId &id, QString *name = NULL);
static const QString rsidFromId(const RsGxsId &id, QString *name = NULL);
static RsPeerId idFromRsid(const QString &rsid, bool check); static RsPeerId idFromRsid(const QString &rsid, bool check);
}; };