mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-22 22:21:09 -04:00
Change RetroShareLink creation methodes as static
And remove this warning:
This commit is contained in:
parent
2d5e1d637f
commit
82addce867
28 changed files with 273 additions and 234 deletions
|
@ -352,211 +352,235 @@ RetroShareLink::RetroShareLink()
|
|||
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;
|
||||
_hash = QString::fromStdString(id.toStdString());
|
||||
_radix_group_data = radix_data ;
|
||||
link._name = name;
|
||||
link._hash = QString::fromStdString(id.toStdString());
|
||||
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;
|
||||
_size = size;
|
||||
_hash = hash;
|
||||
_SSLid = ssl_id;
|
||||
link._name = name;
|
||||
link._size = size;
|
||||
link._hash = hash;
|
||||
link._SSLid = ssl_id;
|
||||
|
||||
_type = TYPE_EXTRAFILE;
|
||||
link._type = TYPE_EXTRAFILE;
|
||||
|
||||
check();
|
||||
link.check();
|
||||
|
||||
return valid();
|
||||
}
|
||||
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();
|
||||
return link;
|
||||
}
|
||||
|
||||
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 ;
|
||||
_time_stamp = time_stamp ;
|
||||
_hash = hash ;
|
||||
_GPGid = issuer_pgp_id ;
|
||||
link._name = name;
|
||||
link._size = size;
|
||||
link._hash = hash;
|
||||
|
||||
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;
|
||||
if (rsPeers->getGPGDetails(id, detail) == false) {
|
||||
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());
|
||||
_name = QString::fromUtf8(detail.name.c_str());
|
||||
link.check();
|
||||
|
||||
_type = TYPE_PERSON;
|
||||
|
||||
check();
|
||||
|
||||
return valid();
|
||||
return link;
|
||||
}
|
||||
|
||||
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.
|
||||
//
|
||||
RsPeerDetails detail;
|
||||
if (rsPeers->getPeerDetails(ssl_id, detail) == false) {
|
||||
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;
|
||||
_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","");
|
||||
link.check();
|
||||
|
||||
std::cerr << "Found radix = " << _radix.toStdString() << std::endl;
|
||||
|
||||
return true;
|
||||
return link;
|
||||
}
|
||||
|
||||
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
|
||||
if (createCertificate(sslId)) {
|
||||
if (gpgId.isNull() || _GPGid.toStdString() == gpgId.toStdString()) {
|
||||
return true;
|
||||
link = createCertificate(sslId);
|
||||
if (link.valid()) {
|
||||
if (gpgId.isNull() || link._GPGid.toStdString() == gpgId.toStdString()) {
|
||||
return link;
|
||||
}
|
||||
// wrong gpg id
|
||||
return false;
|
||||
link.clear();
|
||||
return link;
|
||||
}
|
||||
|
||||
// then gpg id
|
||||
if (createPerson(gpgId)) {
|
||||
if (!_SSLid.isEmpty()) {
|
||||
return false;
|
||||
link = createPerson(gpgId);
|
||||
if (link.valid()) {
|
||||
if (!link._SSLid.isEmpty()) {
|
||||
link.clear();
|
||||
return link;
|
||||
}
|
||||
if (sslId.isNull()) {
|
||||
return true;
|
||||
link.check();
|
||||
return link;
|
||||
}
|
||||
_SSLid = QString::fromStdString(sslId.toStdString());
|
||||
if (_location.isEmpty()) {
|
||||
_location = _name;
|
||||
link._SSLid = QString::fromStdString(sslId.toStdString());
|
||||
if (link._location.isEmpty()) {
|
||||
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()) {
|
||||
_hash = QString::fromStdString(groupId.toStdString());
|
||||
_type = linkType;
|
||||
_name = groupName;
|
||||
link._hash = QString::fromStdString(groupId.toStdString());
|
||||
link._type = linkType;
|
||||
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()) {
|
||||
_hash = QString::fromStdString(groupId.toStdString());
|
||||
_msgId = QString::fromStdString(msgId.toStdString());
|
||||
_type = linkType;
|
||||
_name = msgName;
|
||||
link._hash = QString::fromStdString(groupId.toStdString());
|
||||
link._msgId = QString::fromStdString(msgId.toStdString());
|
||||
link._type = linkType;
|
||||
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());
|
||||
PeerDefs::rsidFromId(peerId, &_name);
|
||||
_subject = subject;
|
||||
link._hash = QString::fromStdString(peerId.toStdString());
|
||||
PeerDefs::rsidFromId(peerId, &link._name);
|
||||
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);
|
||||
//_name = QString::fromStdString("GXS_id("+peerId.toStdString()+")") ;
|
||||
// do something better here!!
|
||||
_subject = subject;
|
||||
link._type = TYPE_MESSAGE;
|
||||
|
||||
_type = TYPE_MESSAGE;
|
||||
link.check();
|
||||
|
||||
check();
|
||||
|
||||
return valid();
|
||||
return link;
|
||||
}
|
||||
|
||||
void RetroShareLink::clear()
|
||||
{
|
||||
_valid = false;
|
||||
|
@ -1640,6 +1664,8 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||
return process(links, flag);
|
||||
}
|
||||
|
||||
/**** RSLinkClipboard ********************************************/
|
||||
|
||||
void RSLinkClipboard::copyLinks(const QList<RetroShareLink>& links)
|
||||
{
|
||||
QString res ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue