cleaned the RS link code, factorized the parsing into a single class. Still missing: copy/paste of multiple links

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2514 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-10 21:38:26 +00:00
parent a208efdaf9
commit a657def956
13 changed files with 316 additions and 170 deletions

View file

@ -23,6 +23,7 @@
#include <QFileInfo>
#include "common/vmessagebox.h"
#include <gui/mainpagestack.h>
#include <gui/RetroShareLink.h>
#include "rshare.h"
#include "PeersDialog.h"
@ -1635,24 +1636,13 @@ void PeersDialog::anchorClicked (const QUrl& link )
if (link.scheme() == "retroshare")
{
QStringList L = link.toString().split("|") ;
RetroShareLink rslnk(link.toString()) ;
std::string fileName = L.at(1).toStdString() ;
uint64_t fileSize = L.at(2).toULongLong();
std::string fileHash = L.at(3).toStdString() ;
if(fileHash.length() > 40)
fileHash.resize(40) ;
#ifdef PEERS_DEBUG
std::cerr << "PeersDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize << std::endl;
#endif
if (fileName != "" && fileHash != "")
if (rslnk.valid())
{
std::list<std::string> srcIds;
if(rsFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
if(rsFiles->FileRequest(rslnk.name().toStdString(), rslnk.hash().toStdString(), rslnk.size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
{
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0);
mb.setButtonText( QMessageBox::Ok, "OK" );