Merge pull request #945 from PhenomRetroShare/Add_RSLinkCreateAsStatic

Change RetroShareLink creation methodes as static
This commit is contained in:
csoler 2017-07-16 20:16:31 +02:00 committed by GitHub
commit 987c10522a
28 changed files with 273 additions and 234 deletions

View File

@ -110,9 +110,7 @@ void DetailsDialog::setFileHash(const RsFileHash & hash)
if(!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, nfo)) if(!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, nfo))
return ; return ;
RetroShareLink link ; RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(nfo.fname.c_str()),nfo.size,QString::fromStdString(nfo.hash.toStdString()));
link.createFile(QString::fromUtf8(nfo.fname.c_str()),nfo.size,QString::fromStdString(nfo.hash.toStdString())) ;
ui.Linktext->setText(link.toString()) ; ui.Linktext->setText(link.toString()) ;
} }

View File

@ -712,8 +712,8 @@ void SearchDialog::copySearchLink()
std::cerr << "SearchDialog::copySearchLink(): keywords: " << keywords.toStdString(); std::cerr << "SearchDialog::copySearchLink(): keywords: " << keywords.toStdString();
std::cerr << std::endl; std::cerr << std::endl;
RetroShareLink link; RetroShareLink link = RetroShareLink::createSearch(keywords);
if (link.createSearch(keywords)) { if (link.valid()) {
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);
@ -1443,11 +1443,11 @@ void SearchDialog::copyResultLink()
qulonglong fsize = item->text(SR_SIZE_COL).toULongLong(); qulonglong fsize = item->text(SR_SIZE_COL).toULongLong();
QString fname = item->text(SR_NAME_COL); QString fname = item->text(SR_NAME_COL);
RetroShareLink link; RetroShareLink link = RetroShareLink::createFile(fname, fsize, fhash);
if (link.createFile(fname, fsize, fhash)) { if (link.valid()) {
std::cerr << "new link added to clipboard: " << link.toString().toStdString() << std::endl ; std::cerr << "new link added to clipboard: " << link.toString().toStdString() << std::endl ;
urls.push_back(link) ; urls.push_back(link) ;
} }
} }
} }
RSLinkClipboard::copyLinks(urls) ; RSLinkClipboard::copyLinks(urls) ;

View File

@ -1464,8 +1464,8 @@ void TransfersDialog::copyLink ()
continue; continue;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash.toStdString()));
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash.toStdString()))) { if (link.valid()) {
links.push_back(link) ; links.push_back(link) ;
} }
} }
@ -1487,8 +1487,8 @@ void TransfersDialog::ulCopyLink ()
continue; continue;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash.toStdString()));
if (link.createFile(QString::fromUtf8(info.fname.c_str()), info.size, QString::fromStdString(info.hash.toStdString()))) { if (link.valid()) {
links.push_back(link) ; links.push_back(link) ;
} }
} }

View File

@ -467,8 +467,7 @@ void IdDetailsDialog::sendInvite()
composer->setTitleText(tr("You have a friend invite")); composer->setTitleText(tr("You have a friend invite"));
RsPeerId ownId = rsPeers->getOwnId(); RsPeerId ownId = rsPeers->getOwnId();
RetroShareLink link; RetroShareLink link = RetroShareLink::createCertificate(ownId);
link.createCertificate(ownId);
RsGxsId keyId(ui->lineEdit_KeyId->text().toStdString()); RsGxsId keyId(ui->lineEdit_KeyId->text().toStdString());

View File

@ -1943,8 +1943,7 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION: case RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION:
case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand. case RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE: // Identities are stamped regularly by crawlign the set of messages for all groups. That helps keepign the useful identities in hand.
{ {
RetroShareLink l; RetroShareLink l = RetroShareLink::createGxsMessageLink(service_type,u.mGrpId,u.mMsgId,tr("Message/vote/comment"));
l.createGxsMessageLink(service_type,u.mGrpId,u.mMsgId,tr("Message/vote/comment"));
return tr("%1 in %2 tab").arg(l.toHtml()).arg(service_name) ; return tr("%1 in %2 tab").arg(l.toHtml()).arg(service_name) ;
} }
case RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION: // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens. case RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION: // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens.
@ -2207,9 +2206,8 @@ void IdDialog::handleSerializedGroupData(uint32_t token)
QList<RetroShareLink> urls ; QList<RetroShareLink> urls ;
RetroShareLink link ; RetroShareLink link = RetroShareLink::createIdentity(gxs_id,QString::fromUtf8(details.mNickname.c_str()),QString::fromStdString(radix)) ;
link.createIdentity(gxs_id,QString::fromUtf8(details.mNickname.c_str()),QString::fromStdString(radix)) ; urls.push_back(link);
urls.push_back(link);
RSLinkClipboard::copyLinks(urls) ; RSLinkClipboard::copyLinks(urls) ;

View File

@ -323,8 +323,8 @@ void NetworkDialog::copyLink()
RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ; RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ;
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
RetroShareLink link; RetroShareLink link = RetroShareLink::createPerson(peer_id);
if (link.createPerson(peer_id)) { if (link.valid()) {
urls.push_back(link); urls.push_back(link);
} }

View File

@ -352,211 +352,235 @@ RetroShareLink::RetroShareLink()
clear(); clear();
} }
bool RetroShareLink::createIdentity(const RsGxsId& id, const QString& name, const QString& radix_data) RetroShareLink RetroShareLink::createIdentity(const RsGxsId& id, const QString& name, const QString& radix_data)
{ {
clear(); RetroShareLink link;
link.clear();
_name = name; link._name = name;
_hash = QString::fromStdString(id.toStdString()); link._hash = QString::fromStdString(id.toStdString());
_radix_group_data = radix_data ; link._radix_group_data = radix_data ;
_type = TYPE_IDENTITY; link._type = TYPE_IDENTITY;
check(); link.check();
return valid(); return link;
} }
bool RetroShareLink::createExtraFile(const QString& name, uint64_t size, const QString& hash,const QString& ssl_id) RetroShareLink RetroShareLink::createExtraFile(const QString& name, uint64_t size, const QString& hash,const QString& ssl_id)
{ {
clear(); RetroShareLink link;
link.clear();
_name = name; link._name = name;
_size = size; link._size = size;
_hash = hash; link._hash = hash;
_SSLid = ssl_id; link._SSLid = ssl_id;
_type = TYPE_EXTRAFILE; link._type = TYPE_EXTRAFILE;
check(); link.check();
return valid(); return link;
}
bool RetroShareLink::createFile(const QString& name, uint64_t size, const QString& hash)
{
clear();
_name = name;
_size = size;
_hash = hash;
_type = TYPE_FILE;
check();
return valid();
} }
bool RetroShareLink::createPublicMsgInvite(time_t time_stamp,const QString& issuer_pgp_id,const QString& hash) RetroShareLink RetroShareLink::createFile(const QString& name, uint64_t size, const QString& hash)
{ {
clear() ; RetroShareLink link;
link.clear();
_type = TYPE_PUBLIC_MSG ; link._name = name;
_time_stamp = time_stamp ; link._size = size;
_hash = hash ; link._hash = hash;
_GPGid = issuer_pgp_id ;
check() ; link._type = TYPE_FILE;
return valid() ; link.check();
return link;
} }
bool RetroShareLink::createPerson(const RsPgpId& id) RetroShareLink RetroShareLink::createPublicMsgInvite(time_t time_stamp,const QString& issuer_pgp_id,const QString& hash)
{ {
clear(); RetroShareLink link;
link.clear() ;
link._type = TYPE_PUBLIC_MSG ;
link._time_stamp = time_stamp ;
link._hash = hash ;
link._GPGid = issuer_pgp_id ;
link.check() ;
return link;
}
RetroShareLink RetroShareLink::createPerson(const RsPgpId& id)
{
RetroShareLink link;
link.clear();
RsPeerDetails detail; RsPeerDetails detail;
if (rsPeers->getGPGDetails(id, detail) == false) { if (rsPeers->getGPGDetails(id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << id << std::endl; std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << id << std::endl;
return false; } else {
link._hash = QString::fromStdString(id.toStdString());
link._name = QString::fromUtf8(detail.name.c_str());
link._type = TYPE_PERSON;
} }
_hash = QString::fromStdString(id.toStdString()); link.check();
_name = QString::fromUtf8(detail.name.c_str());
_type = TYPE_PERSON; return link;
check();
return valid();
} }
bool RetroShareLink::createCertificate(const RsPeerId& ssl_id) RetroShareLink RetroShareLink::createCertificate(const RsPeerId& ssl_id)
{ {
// This is baaaaaad code: RetroShareLink link;
link.clear();
#warning csoler 2012-08-14: This is baaaaaad code:
// - we should not need to parse and re-read a cert in old format. // - we should not need to parse and re-read a cert in old format.
// //
RsPeerDetails detail; RsPeerDetails detail;
if (rsPeers->getPeerDetails(ssl_id, detail) == false) { if (rsPeers->getPeerDetails(ssl_id, detail) == false) {
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl; std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_id << std::endl;
return false; } else {
link._type = TYPE_CERTIFICATE;
link._radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id,false).c_str());
link._name = QString::fromUtf8(detail.name.c_str());
link._location = QString::fromUtf8(detail.location.c_str());
link._radix.replace("\n","");
std::cerr << "Found radix = " << link._radix.toStdString() << std::endl;
} }
_type = TYPE_CERTIFICATE; link.check();
_radix = QString::fromUtf8(rsPeers->GetRetroshareInvite(ssl_id,false).c_str());
_name = QString::fromUtf8(detail.name.c_str());
_location = QString::fromUtf8(detail.location.c_str());
_radix.replace("\n","");
std::cerr << "Found radix = " << _radix.toStdString() << std::endl; return link;
return true;
} }
bool RetroShareLink::createUnknwonSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId) RetroShareLink RetroShareLink::createUnknwonSslCertificate(const RsPeerId& sslId, const RsPgpId& gpgId)
{ {
RetroShareLink link;
link.clear();
// first try ssl id // first try ssl id
if (createCertificate(sslId)) { link = createCertificate(sslId);
if (gpgId.isNull() || _GPGid.toStdString() == gpgId.toStdString()) { if (link.valid()) {
return true; if (gpgId.isNull() || link._GPGid.toStdString() == gpgId.toStdString()) {
return link;
} }
// wrong gpg id // wrong gpg id
return false; link.clear();
return link;
} }
// then gpg id // then gpg id
if (createPerson(gpgId)) { link = createPerson(gpgId);
if (!_SSLid.isEmpty()) { if (link.valid()) {
return false; if (!link._SSLid.isEmpty()) {
link.clear();
return link;
} }
if (sslId.isNull()) { if (sslId.isNull()) {
return true; link.check();
return link;
} }
_SSLid = QString::fromStdString(sslId.toStdString()); link._SSLid = QString::fromStdString(sslId.toStdString());
if (_location.isEmpty()) { if (link._location.isEmpty()) {
_location = _name; link._location = link._name;
} }
return true; link.check();
return link;
} }
return false; link.clear();
return link;
} }
bool RetroShareLink::createGxsGroupLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const QString &groupName) RetroShareLink RetroShareLink::createGxsGroupLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const QString &groupName)
{ {
clear(); RetroShareLink link;
link.clear();
if (!groupId.isNull()) { if (!groupId.isNull()) {
_hash = QString::fromStdString(groupId.toStdString()); link._hash = QString::fromStdString(groupId.toStdString());
_type = linkType; link._type = linkType;
_name = groupName; link._name = groupName;
} }
check(); link.check();
return valid(); return link;
} }
bool RetroShareLink::createGxsMessageLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &msgName) RetroShareLink RetroShareLink::createGxsMessageLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &msgName)
{ {
clear(); RetroShareLink link;
link.clear();
if (!groupId.isNull() && !msgId.isNull()) { if (!groupId.isNull() && !msgId.isNull()) {
_hash = QString::fromStdString(groupId.toStdString()); link._hash = QString::fromStdString(groupId.toStdString());
_msgId = QString::fromStdString(msgId.toStdString()); link._msgId = QString::fromStdString(msgId.toStdString());
_type = linkType; link._type = linkType;
_name = msgName; link._name = msgName;
} }
check(); link.check();
return valid(); return link;
} }
bool RetroShareLink::createSearch(const QString& keywords) RetroShareLink RetroShareLink::createSearch(const QString& keywords)
{ {
clear(); RetroShareLink link;
link.clear();
_name = keywords; link._name = keywords;
_type = TYPE_SEARCH; link._type = TYPE_SEARCH;
check(); link.check();
return valid(); return link;
} }
bool RetroShareLink::createMessage(const RsPeerId& peerId, const QString& subject) RetroShareLink RetroShareLink::createMessage(const RsPeerId& peerId, const QString& subject)
{ {
clear(); RetroShareLink link;
link.clear();
_hash = QString::fromStdString(peerId.toStdString()); link._hash = QString::fromStdString(peerId.toStdString());
PeerDefs::rsidFromId(peerId, &_name); PeerDefs::rsidFromId(peerId, &link._name);
_subject = subject; link._subject = subject;
_type = TYPE_MESSAGE; link._type = TYPE_MESSAGE;
check(); link.check();
return valid(); return link;
} }
bool RetroShareLink::createMessage(const RsGxsId& peerId, const QString& subject) RetroShareLink RetroShareLink::createMessage(const RsGxsId& peerId, const QString& subject)
{ {
clear(); RetroShareLink link;
link.clear();
_hash = QString::fromStdString(peerId.toStdString()); link._hash = QString::fromStdString(peerId.toStdString());
PeerDefs::rsidFromId(peerId, &link._name);
link._subject = subject;
PeerDefs::rsidFromId(peerId, &_name); link._type = TYPE_MESSAGE;
//_name = QString::fromStdString("GXS_id("+peerId.toStdString()+")") ;
// do something better here!!
_subject = subject;
_type = TYPE_MESSAGE; link.check();
check(); return link;
return valid();
} }
void RetroShareLink::clear() void RetroShareLink::clear()
{ {
_valid = false; _valid = false;
@ -1640,6 +1664,8 @@ static void processList(const QStringList &list, const QString &textSingular, co
return process(links, flag); return process(links, flag);
} }
/**** RSLinkClipboard ********************************************/
void RSLinkClipboard::copyLinks(const QList<RetroShareLink>& links) void RSLinkClipboard::copyLinks(const QList<RetroShareLink>& links)
{ {
QString res ; QString res ;

View File

@ -77,19 +77,18 @@ class RetroShareLink
RetroShareLink(const QUrl& url); RetroShareLink(const QUrl& url);
RetroShareLink(const QString& url); RetroShareLink(const QString& url);
#warning csoler 2017-01-04: These methods should be static and return a created link static RetroShareLink createIdentity(const RsGxsId& gxs_id,const QString& name,const QString& radix_data) ;
bool createFile(const QString& name, uint64_t size, const QString& hash); static RetroShareLink createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id);
bool createExtraFile(const QString& name, uint64_t size, const QString& hash, const QString& ssl_id); static RetroShareLink createFile(const QString& name, uint64_t size, const QString& hash);
bool createPerson(const RsPgpId &id); static RetroShareLink createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ;
bool createGxsGroupLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const QString &groupName); static RetroShareLink createPerson(const RsPgpId &id);
bool createGxsMessageLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &msgName); static RetroShareLink createCertificate(const RsPeerId &ssl_id) ;
bool createSearch(const QString& keywords); static RetroShareLink createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ;
bool createMessage(const RsPeerId &peerId, const QString& subject); static RetroShareLink createGxsGroupLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const QString &groupName);
bool createMessage(const RsGxsId &peerId, const QString& subject); static RetroShareLink createGxsMessageLink(const RetroShareLink::enumType &linkType, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &msgName);
bool createIdentity(const RsGxsId& gxs_id,const QString& name,const QString& radix_data) ; static RetroShareLink createSearch(const QString& keywords);
bool createCertificate(const RsPeerId &ssl_id) ; static RetroShareLink createMessage(const RsPeerId &peerId, const QString& subject);
bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ; static RetroShareLink createMessage(const RsGxsId &peerId, const QString& subject);
bool createUnknwonSslCertificate(const RsPeerId &sslId, const RsPgpId &gpgId = RsPgpId()) ;
enumType type() const {return _type; } enumType type() const {return _type; }
uint64_t size() const { return _size ; } uint64_t size() const { return _size ; }

View File

@ -609,8 +609,8 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
continue; continue;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str());
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) { if (link.valid()) {
urls.push_back(link) ; urls.push_back(link) ;
} }
} }
@ -622,8 +622,8 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
has_unhashed_files = true; has_unhashed_files = true;
continue; continue;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str());
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) { if (link.valid()) {
urls.push_back(link) ; urls.push_back(link) ;
} }
} }

View File

@ -1556,14 +1556,14 @@ void ChatWidget::fileHashingFinished(QList<HashedFile> hashedFiles)
QList<HashedFile>::iterator it; QList<HashedFile>::iterator it;
for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
HashedFile& hashedFile = *it; HashedFile& hashedFile = *it;
QString ext = QFileInfo(hashedFile.filename).suffix(); //QString ext = QFileInfo(hashedFile.filename).suffix();
RetroShareLink link; RetroShareLink link;
if(mDefaultExtraFileFlags & RS_FILE_REQ_ANONYMOUS_ROUTING) if(mDefaultExtraFileFlags & RS_FILE_REQ_ANONYMOUS_ROUTING)
link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString())); link = RetroShareLink::createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString()));
else else
link.createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString()),QString::fromStdString(rsPeers->getOwnId().toStdString())); link = RetroShareLink::createExtraFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString()),QString::fromStdString(rsPeers->getOwnId().toStdString()));
if (hashedFile.flag & HashedFile::Picture) { if (hashedFile.flag & HashedFile::Picture) {
message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath); message += QString("<img src=\"file:///%1\" width=\"100\" height=\"100\">").arg(hashedFile.filepath);
@ -1575,6 +1575,7 @@ void ChatWidget::fileHashingFinished(QList<HashedFile> hashedFiles)
} }
} }
message += link.toHtmlSize(); message += link.toHtmlSize();
if (it != hashedFiles.end()) { if (it != hashedFiles.end()) {
message += "<BR>"; message += "<BR>";
} }

View File

@ -1394,14 +1394,12 @@ void FriendList::copyFullCertificate()
{ {
QTreeWidgetItem *c = getCurrentPeer(); QTreeWidgetItem *c = getCurrentPeer();
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
RetroShareLink link ; RetroShareLink link = RetroShareLink::createCertificate(RsPeerId(getRsId(c)));
link.createCertificate(RsPeerId(getRsId(c))) ;
urls.push_back(link); urls.push_back(link);
std::cerr << "link: " << std::endl; std::cerr << "link: " << std::endl;
std::cerr<< link.toString().toStdString() << std::endl; std::cerr<< link.toString().toStdString() << std::endl;
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);
} }

View File

@ -271,10 +271,10 @@ void MimeTextEdit::pasteLink()
void MimeTextEdit::pasteOwnCertificateLink() void MimeTextEdit::pasteOwnCertificateLink()
{ {
RetroShareLink link;
RsPeerId ownId = rsPeers->getOwnId(); RsPeerId ownId = rsPeers->getOwnId();
RetroShareLink link = RetroShareLink::createCertificate(ownId);
if (link.createCertificate(ownId)) { if (link.valid()) {
insertHtml(link.toHtml() + " "); insertHtml(link.toHtml() + " ");
} }
} }

View File

@ -142,11 +142,9 @@ void ConfCertDialog::load()
ui.headerFrame->setHeaderText(nameAndLocation); ui.headerFrame->setHeaderText(nameAndLocation);
RetroShareLink link; RetroShareLink link = RetroShareLink::createPerson(detail.gpg_id);
link.createPerson(detail.gpg_id); ui.pgpfingerprint->setText(link.toHtml());
ui.pgpfingerprint->setToolTip(link.title());
ui.pgpfingerprint->setText(link.toHtml());
ui.pgpfingerprint->setToolTip(link.title());
ui.avatar->setId(ChatId(peerId)); ui.avatar->setId(ChatId(peerId));

View File

@ -267,7 +267,7 @@ void PGPKeyDialog::load()
RetroShareLink link ; RetroShareLink link ;
for(std::list<RsPgpId>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) { for(std::list<RsPgpId>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) {
link.createPerson(*it); link = RetroShareLink::createPerson(*it);
if (link.valid()) { if (link.valid()) {
text += link.toHtml() + "<BR>"; text += link.toHtml() + "<BR>";
} }

View File

@ -127,8 +127,7 @@ void GxsChannelGroupItem::fill()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RetroShareLink link; RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mGroup.mMeta.mGroupId, groupName());
link.createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mGroup.mMeta.mGroupId, groupName());
ui->nameLabel->setText(link.toHtml()); ui->nameLabel->setText(link.toHtml());
ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));

View File

@ -410,13 +410,11 @@ void GxsChannelPostItem::fill()
} }
title = tr("Channel Feed") + ": "; title = tr("Channel Feed") + ": ";
RetroShareLink link; RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, groupName());
link.createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, groupName());
title += link.toHtml(); title += link.toHtml();
ui->titleLabel->setText(title); ui->titleLabel->setText(title);
RetroShareLink msgLink; RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName());
msgLink.createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName());
ui->subjectLabel->setText(msgLink.toHtml()); ui->subjectLabel->setText(msgLink.toHtml());
if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags))

View File

@ -127,8 +127,7 @@ void GxsForumGroupItem::fill()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RetroShareLink link; RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_FORUM, mGroup.mMeta.mGroupId, groupName());
link.createGxsGroupLink(RetroShareLink::TYPE_FORUM, mGroup.mMeta.mGroupId, groupName());
ui->nameLabel->setText(link.toHtml()); ui->nameLabel->setText(link.toHtml());
ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));

View File

@ -271,8 +271,7 @@ void GxsForumMsgItem::fill()
} }
QString title = tr("Forum Feed") + ": "; QString title = tr("Forum Feed") + ": ";
RetroShareLink link; RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, groupName());
link.createGxsGroupLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, groupName());
title += link.toHtml(); title += link.toHtml();
ui->titleLabel->setText(title); ui->titleLabel->setText(title);
@ -310,8 +309,7 @@ void GxsForumMsgItem::fill()
// nameLabel->setText(tr("Anonymous")); // nameLabel->setText(tr("Anonymous"));
// } // }
RetroShareLink msgLink; RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, mMessage.mMeta.mMsgId, messageName());
msgLink.createGxsMessageLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, mMessage.mMeta.mMsgId, messageName());
ui->subLabel->setText(msgLink.toHtml()); ui->subLabel->setText(msgLink.toHtml());
if (wasExpanded() || ui->expandFrame->isVisible()) { if (wasExpanded() || ui->expandFrame->isVisible()) {
fillExpandFrame(); fillExpandFrame();
@ -324,8 +322,7 @@ void GxsForumMsgItem::fill()
} else { } else {
// ui->parentAvatar->setId(msgParent.srcId, true); // ui->parentAvatar->setId(msgParent.srcId, true);
RetroShareLink linkParent; RetroShareLink linkParent = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mParentMessage.mMeta.mGroupId, mParentMessage.mMeta.mMsgId, QString::fromUtf8(mParentMessage.mMeta.mMsgName.c_str()));
linkParent.createGxsMessageLink(RetroShareLink::TYPE_FORUM, mParentMessage.mMeta.mGroupId, mParentMessage.mMeta.mMsgId, QString::fromUtf8(mParentMessage.mMeta.mMsgName.c_str()));
ui->parentSubLabel->setText(linkParent.toHtml()); ui->parentSubLabel->setText(linkParent.toHtml());
ui->parentMsgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mParentMessage.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->parentMsgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mParentMessage.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));

View File

@ -130,9 +130,8 @@ void PostedGroupItem::fill()
#endif #endif
// No link type at this moment // No link type at this moment
RetroShareLink link; RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName());
link.createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName()); ui->nameLabel->setText(link.toHtml());
ui->nameLabel->setText(link.toHtml());
// ui->nameLabel->setText(groupName()); // ui->nameLabel->setText(groupName());
ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str()));

View File

@ -727,8 +727,8 @@ void SubFileItem::copyLink()
return; return;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(mFileName.c_str()), mFileSize, QString::fromStdString(mFileHash.toStdString()));
if (link.createFile(QString::fromUtf8(mFileName.c_str()), mFileSize, QString::fromStdString(mFileHash.toStdString()))) { if (link.valid()) {
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);

View File

@ -81,8 +81,8 @@ void GxsFeedItem::copyMessageLink()
return; return;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createGxsMessageLink(getLinkType(), groupId(), mMessageId, messageName());
if (link.createGxsMessageLink(getLinkType(), groupId(), mMessageId, messageName())) { if (link.valid()) {
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);

View File

@ -155,8 +155,8 @@ void GxsGroupFeedItem::copyGroupLink()
return; return;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createGxsGroupLink(getLinkType(), mGroupId, groupName());
if (link.createGxsGroupLink(getLinkType(), mGroupId, groupName())) { if (link.valid()) {
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);

View File

@ -480,12 +480,12 @@ void GxsGroupFrameDialog::copyGroupLink()
return; return;
} }
RetroShareLink link;
QString name; QString name;
if(!getCurrentGroupName(name)) return; if(!getCurrentGroupName(name)) return;
if (link.createGxsGroupLink(getLinkType(), mGroupId, name)) { RetroShareLink link = RetroShareLink::createGxsGroupLink(getLinkType(), mGroupId, name);
if (link.valid()) {
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);

View File

@ -498,9 +498,9 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
QList<HashedFile>::iterator it; QList<HashedFile>::iterator it;
for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) { for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
HashedFile& hashedFile = *it; HashedFile& hashedFile = *it;
RetroShareLink link; RetroShareLink link = RetroShareLink::createFile(hashedFile.filename, hashedFile.size,
if (link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash.toStdString()));
QString::fromStdString(hashedFile.hash.toStdString()))) { if (link.valid()) {
mesgString += link.toHtmlSize() + "<br>"; mesgString += link.toHtmlSize() + "<br>";
} }
} }

View File

@ -2018,12 +2018,13 @@ void GxsForumThreadWidget::copyMessageLink()
return; return;
} }
RetroShareLink link; QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
QString thread_title = (item != NULL)?item->text(COLUMN_THREAD_TITLE):QString() ; QString thread_title = (item != NULL)?item->text(COLUMN_THREAD_TITLE):QString() ;
if (link.createGxsMessageLink(RetroShareLink::TYPE_FORUM, groupId(), mThreadId, thread_title)) { RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, groupId(), mThreadId, thread_title);
if (link.valid()) {
QList<RetroShareLink> urls; QList<RetroShareLink> urls;
urls.push_back(link); urls.push_back(link);
RSLinkClipboard::copyLinks(urls); RSLinkClipboard::copyLinks(urls);
@ -2068,8 +2069,7 @@ void GxsForumThreadWidget::createthread()
static QString buildReplyHeader(const RsMsgMetaData &meta) static QString buildReplyHeader(const RsMsgMetaData &meta)
{ {
RetroShareLink link; RetroShareLink link = RetroShareLink::createMessage(meta.mAuthorId, "");
link.createMessage(meta.mAuthorId, "");
QString from = link.toHtml(); QString from = link.toHtml();
QString header = QString("<span>-----%1-----").arg(QApplication::translate("GxsForumThreadWidget", "Original Message")); QString header = QString("<span>-----%1-----").arg(QApplication::translate("GxsForumThreadWidget", "Original Message"));

View File

@ -521,8 +521,8 @@ static QString buildRecommendHtml(const std::set<RsPeerId> &sslIds, const RsPeer
if (*sslIt == excludeId) { if (*sslIt == excludeId) {
continue; continue;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createCertificate(*sslIt);
if (link.createCertificate(*sslIt)) { if (link.valid()) {
text += link.toHtml() + "<br>"; text += link.toHtml() + "<br>";
} }
} }
@ -558,8 +558,7 @@ void MessageComposer::recommendFriend(const std::set <RsPeerId> &sslIds, const R
composer->addRecipient(TO, to); composer->addRecipient(TO, to);
} }
RsPgpId ownPgpId = rsPeers->getGPGOwnId(); RsPgpId ownPgpId = rsPeers->getGPGOwnId();
RetroShareLink link; RetroShareLink link = RetroShareLink::createPerson(ownPgpId);
link.createPerson(ownPgpId);
QString sMsgText = msg.isEmpty() ? recommendMessage() : msg; QString sMsgText = msg.isEmpty() ? recommendMessage() : msg;
sMsgText += "<br><br>"; sMsgText += "<br><br>";
@ -595,8 +594,8 @@ void MessageComposer::sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId
return; return;
} }
RetroShareLink link; RetroShareLink link = RetroShareLink::createUnknwonSslCertificate(sslId, gpgId);
if (link.createUnknwonSslCertificate(sslId, gpgId) == false) { if (link.valid() == false) {
return; return;
} }
@ -1053,44 +1052,52 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo) QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
{ {
RetroShareLink link; RetroShareLink link = RetroShareLink::createMessage(msgInfo.rspeerid_srcId, "");
link.createMessage(msgInfo.rspeerid_srcId, "");
QString from = link.toHtml(); QString from = link.toHtml();
QString to; QString to;
for ( std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it) for ( std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); ++it)
if (link.createMessage(*it, "")) {
link = RetroShareLink::createMessage(*it, "");
if (link.valid())
{ {
if (!to.isEmpty()) if (!to.isEmpty())
to += ", "; to += ", ";
to += link.toHtml(); to += link.toHtml();
} }
}
for ( std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it) for ( std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); ++it)
if (link.createMessage(*it, "")) {
link = RetroShareLink::createMessage(*it, "");
if (link.valid())
{ {
if (!to.isEmpty()) if (!to.isEmpty())
to += ", "; to += ", ";
to += link.toHtml(); to += link.toHtml();
} }
}
QString cc; QString cc;
for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it) for (std::set<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); ++it) {
if (link.createMessage(*it, "")) { link = RetroShareLink::createMessage(*it, "");
if (link.valid()) {
if (!cc.isEmpty()) { if (!cc.isEmpty()) {
cc += ", "; cc += ", ";
} }
cc += link.toHtml(); cc += link.toHtml();
} }
for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it) }
if (link.createMessage(*it, "")) { for (std::set<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); ++it) {
link = RetroShareLink::createMessage(*it, "");
if (link.valid()) {
if (!cc.isEmpty()) { if (!cc.isEmpty()) {
cc += ", "; cc += ", ";
} }
cc += link.toHtml(); cc += link.toHtml();
} }
}
QString header = QString("<span>-----%1-----").arg(tr("Original Message")); QString header = QString("<span>-----%1-----").arg(tr("Original Message"));
@ -2780,8 +2787,7 @@ void MessageComposer::sendInvite(const RsGxsId &to, const QString &/*msg*/, bool
RsPeerId ownId = rsPeers->getOwnId(); RsPeerId ownId = rsPeers->getOwnId();
RetroShareLink link; RetroShareLink link = RetroShareLink::createCertificate(ownId);
link.createCertificate(ownId);
QString sMsgText = inviteMessage(); QString sMsgText = inviteMessage();
sMsgText += "<br><br>"; sMsgText += "<br><br>";

View File

@ -515,8 +515,16 @@ void MessageWidget::fill(const std::string &msgId)
RetroShareLink link; RetroShareLink link;
QString text; QString text;
for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); ++pit) {
for(std::set<RsGxsId >::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; link = RetroShareLink::createMessage(*pit, "");
if (link.valid())
text += link.toHtml() + " ";
}
for(std::set<RsGxsId >::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); ++pit) {
link = RetroShareLink::createMessage(*pit, "");
if (link.valid())
text += link.toHtml() + " ";
}
ui.toText->setText(text); ui.toText->setText(text);
@ -526,8 +534,16 @@ void MessageWidget::fill(const std::string &msgId)
ui.ccText->setVisible(true); ui.ccText->setVisible(true);
text.clear(); text.clear();
for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); ++pit) {
for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; link = RetroShareLink::createMessage(*pit, "");
if (link.valid())
text += link.toHtml() + " ";
}
for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); ++pit) {
link = RetroShareLink::createMessage(*pit, "");
if (link.valid())
text += link.toHtml() + " ";
}
ui.ccText->setText(text); ui.ccText->setText(text);
} else { } else {
@ -536,14 +552,22 @@ void MessageWidget::fill(const std::string &msgId)
ui.ccText->clear(); ui.ccText->clear();
} }
if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty()) if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty())
{ {
ui.bccLabel->setVisible(true); ui.bccLabel->setVisible(true);
ui.bccText->setVisible(true); ui.bccText->setVisible(true);
text.clear(); text.clear();
for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; for(std::set<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); ++pit) {
for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); ++pit) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; link = RetroShareLink::createMessage(*pit, "");
if (link.valid())
text += link.toHtml() + " ";
}
for(std::set<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); ++pit) {
link = RetroShareLink::createMessage(*pit, "");
if (link.valid())
text += link.toHtml() + " ";
}
ui.bccText->setText(text); ui.bccText->setText(text);
} else { } else {

View File

@ -102,10 +102,10 @@ CryptoPage::load()
void void
CryptoPage::copyRSLink() CryptoPage::copyRSLink()
{ {
RetroShareLink link ;
RsPeerId ownId = rsPeers->getOwnId() ; RsPeerId ownId = rsPeers->getOwnId() ;
RetroShareLink link = RetroShareLink::createCertificate(ownId);
if( link.createCertificate(ownId) ) if( link.valid() )
{ {
QList<RetroShareLink> urls ; QList<RetroShareLink> urls ;