mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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:
parent
2da8acd967
commit
a946504bb5
@ -50,7 +50,7 @@
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
//#include <retroshare/rsforums.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
//#include <retroshare/rschannels.h>
|
||||
|
||||
//#define DEBUG_RSLINK 1
|
||||
@ -736,30 +736,30 @@ QString RetroShareLink::title() const
|
||||
static QString encodeItem(QString item)
|
||||
{
|
||||
return item
|
||||
// .replace("{", "%"+QString::number((int)'{', 16))
|
||||
// .replace("}", "%"+QString::number((int)'}', 16))
|
||||
// .replace("[", "%"+QString::number((int)'[', 16))
|
||||
// .replace("]", "%"+QString::number((int)']', 16))
|
||||
// .replace("^", "%"+QString::number((int)'^', 16))
|
||||
// .replace("~", "%"+QString::number((int)'~', 16))
|
||||
// .replace(";", "%"+QString::number((int)';', 16))
|
||||
// .replace(":", "%"+QString::number((int)':', 16))
|
||||
// .replace("=", "%"+QString::number((int)'=', 16))
|
||||
// .replace("+", "%"+QString::number((int)'+', 16))
|
||||
// .replace("$", "%"+QString::number((int)'$', 16))
|
||||
// .replace(",", "%"+QString::number((int)',', 16))
|
||||
// .replace("\"", "%"+QString::number((int)'\"', 16))
|
||||
// .replace("|", "%"+QString::number((int)'|', 16))
|
||||
// .replace("?", "%"+QString::number((int)'?', 16))
|
||||
// .replace("@", "%"+QString::number((int)'@', 16))
|
||||
// .replace("{", "%"+QString::number((int)'{', 16))
|
||||
// .replace("}", "%"+QString::number((int)'}', 16))
|
||||
// .replace("[", "%"+QString::number((int)'[', 16))
|
||||
// .replace("]", "%"+QString::number((int)']', 16))
|
||||
// .replace("^", "%"+QString::number((int)'^', 16))
|
||||
// .replace("~", "%"+QString::number((int)'~', 16))
|
||||
// .replace(";", "%"+QString::number((int)';', 16))
|
||||
// .replace(":", "%"+QString::number((int)':', 16))
|
||||
// .replace("=", "%"+QString::number((int)'=', 16))
|
||||
// .replace("+", "%"+QString::number((int)'+', 16))
|
||||
// .replace("$", "%"+QString::number((int)'$', 16))
|
||||
// .replace(",", "%"+QString::number((int)',', 16))
|
||||
// .replace("\"", "%"+QString::number((int)'\"', 16))
|
||||
// .replace("|", "%"+QString::number((int)'|', 16))
|
||||
// .replace("?", "%"+QString::number((int)'?', 16))
|
||||
// .replace("@", "%"+QString::number((int)'@', 16))
|
||||
.replace("&", "%"+QString::number((int)'&', 16))//Not necessary: only for text link
|
||||
.replace("/", "%"+QString::number((int)'/', 16))
|
||||
.replace(" ", "%"+QString::number((int)' ', 16))
|
||||
.replace("#", "%"+QString::number((int)'#', 16))
|
||||
// .replace("£", "%"+QString::number((int)'£', 16))
|
||||
// .replace("µ", "%"+QString::number((int)'µ', 16))
|
||||
// .replace("§", "%"+QString::number((int)'§', 16))
|
||||
// .replace("!", "%"+QString::number((int)'!', 16))
|
||||
// .replace("£", "%"+QString::number((int)'£', 16))
|
||||
// .replace("µ", "%"+QString::number((int)'µ', 16))
|
||||
// .replace("§", "%"+QString::number((int)'§', 16))
|
||||
// .replace("!", "%"+QString::number((int)'!', 16))
|
||||
;
|
||||
}
|
||||
|
||||
@ -1246,7 +1246,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
std::cerr << link.radix().toStdString() << std::endl;
|
||||
|
||||
ConnectFriendWizard connectFriendWizard;
|
||||
// connectFriendWizard.setCertificate(RS_Certificate, (link.subType() == RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST) ? true : false);
|
||||
// connectFriendWizard.setCertificate(RS_Certificate, (link.subType() == RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST) ? true : false);
|
||||
connectFriendWizard.setCertificate(link.radix(), (link.subType() == RSLINK_SUBTYPE_CERTIFICATE_USER_REQUEST) ? true : false);
|
||||
connectFriendWizard.exec();
|
||||
needNotifySuccess = false;
|
||||
@ -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!
|
||||
|
||||
RsPgpId pgp_id(link.hash().toStdString()) ;
|
||||
RsPeerId ssl_id(link.hash().toStdString()) ;
|
||||
|
||||
if(!pgp_id.isNull() && rsPeers->getGPGDetails(pgp_id, detail)
|
||||
|| !ssl_id.isNull() && rsPeers->getPeerDetails(ssl_id,detail))
|
||||
if(!ssl_id.isNull() && rsPeers->getPeerDetails(ssl_id,detail) && detail.accept_connection)
|
||||
{
|
||||
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();
|
||||
msg->addRecipient(MessageComposer::TO, detail.id);
|
||||
if (link.subject().isEmpty() == false) {
|
||||
@ -1537,31 +1535,28 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
}
|
||||
msg->show();
|
||||
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();
|
||||
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->show();
|
||||
messageStarted.append(PeerDefs::nameWithLocation(detail));
|
||||
|
||||
msg->show();
|
||||
messageStarted.append(PeerDefs::nameWithLocation(gxs_details));
|
||||
|
||||
break ;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
messageReceipientNotAccepted.append(PeerDefs::nameWithLocation(detail));
|
||||
}
|
||||
} else {
|
||||
messageReceipientUnknown.append(PeerDefs::rsidFromId(RsPeerId(link.hash().toStdString())));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
std::cerr << " RetroShareLink::process unknown type: " << link.type() << std::endl;
|
||||
|
@ -35,6 +35,10 @@ const QString PeerDefs::nameWithLocation(const RsPeerDetails &details)
|
||||
|
||||
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)
|
||||
{
|
||||
if (name.empty()) {
|
||||
@ -64,6 +68,40 @@ const QString PeerDefs::rsid(const RsPeerDetails &details)
|
||||
{
|
||||
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*/)
|
||||
{
|
||||
QString rsid;
|
||||
|
@ -32,6 +32,7 @@ class PeerDefs
|
||||
{
|
||||
public:
|
||||
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 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 rsidFromId(const RsPgpId &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);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user