From fee083e6b89e96d78e35ba2ccc71fcb05ffcdf7d Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 16 Jan 2010 14:31:32 +0000 Subject: [PATCH] fixed downloading of links attached to forums git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2054 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ForumsDialog.cpp | 75 ++++++++++--------- retroshare-gui/src/gui/ForumsDialog.h | 3 +- retroshare-gui/src/gui/TransfersDialog.cpp | 2 +- .../src/gui/chat/PopupChatDialog.cpp | 2 +- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index f758aea82..e974db63e 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -1076,43 +1076,44 @@ void ForumsDialog::anchorClicked (const QUrl& link ) std::cerr << "ForumsDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl; #endif - if (link.scheme() == "retroshare://") { - std::string fileName = link.queryItemValue(QString("fileName")).toStdString(); - std::string fileHash = link.queryItemValue(QString("fileHash")).toStdString(); - uint32_t fileSize = link.queryItemValue(QString("fileSize")).toInt(); - - #ifdef FORUM_DEBUG - std::cerr << "ForumsDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize; - std::cerr << ". source id : " << dialogId << std::endl; - #endif + if (link.scheme() == "retroshare") + { + QStringList L = link.toString().split("|") ; - if (fileName != "" && fileHash != "") { - - std::list srcIds; - //srcIds.push_front(); - rsFiles->FileRequest(fileName, fileHash, fileSize, "", 0, srcIds); + std::string fileName = L.at(1).toStdString() ; + uint64_t fileSize = L.at(2).toULongLong(); + std::string fileHash = L.at(3).toStdString() ; - 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" ); - mb.exec(); - } - else - { - QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0); - mb.setButtonText( QMessageBox::Ok, "OK" ); - mb.exec(); - } - } - else if (link.scheme() == "http") - { - QDesktopServices::openUrl(link); - } - else if (link.scheme() == "") - { - //it's probably a web adress, let's add http:// at the beginning of the link - QString newAddress = link.toString(); - newAddress.prepend("http://"); - QDesktopServices::openUrl(QUrl(newAddress)); - } +#ifdef FORUM_DEBUG + std::cerr << "ForumsDialog::anchorClicked FileRequest : fileName : " << fileName << ". fileHash : " << fileHash << ". fileSize : " << fileSize << std::endl; +#endif -} \ No newline at end of file + if (fileName != "" && fileHash != "") + { + std::list srcIds; + //srcIds.push_front(); + rsFiles->FileRequest(fileName, fileHash, fileSize, "", 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" ); + mb.exec(); + } + else + { + QMessageBox mb(tr("File Request Error"), tr("The file link is malformed."),QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setButtonText( QMessageBox::Ok, "OK" ); + mb.exec(); + } + } + else if (link.scheme() == "http") + { + QDesktopServices::openUrl(link); + } + else if (link.scheme() == "") + { + //it's probably a web adress, let's add http:// at the beginning of the link + QString newAddress = link.toString(); + newAddress.prepend("http://"); + QDesktopServices::openUrl(QUrl(newAddress)); + } +} diff --git a/retroshare-gui/src/gui/ForumsDialog.h b/retroshare-gui/src/gui/ForumsDialog.h index 72496f32e..810cbbfd3 100644 --- a/retroshare-gui/src/gui/ForumsDialog.h +++ b/retroshare-gui/src/gui/ForumsDialog.h @@ -38,10 +38,9 @@ public: void loadForumEmoticons(); - void anchorClicked (const QUrl &); - private slots: + void anchorClicked (const QUrl &); void insertThreads(); /** Create the context popup menu and it's submenus */ void forumListCustomPopupMenu( QPoint point ); diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index eec62d79e..c6a6aa6f9 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -1197,7 +1197,7 @@ void TransfersDialog::pasteLink() //downloadFileRequested(linkData.getName (), linkData.getSize ().toInt (), // linkData.getHash (), "", -1, -1, -1, -1); rsFiles->FileRequest (linkData.getName ().toStdString (), linkData.getHash ().toStdString (), - linkData.getSize().toULongLong(), "", 0, srcIds); + linkData.getSize().toULongLong(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds); } } diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 0b82e66cc..2cce1b7fc 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -810,7 +810,7 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) { fileHash != "") { std::list srcIds; srcIds.push_front(dialogId); - rsFiles->FileRequest(fileName, fileHash, fileSize, "", 0, srcIds); + rsFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_ASSUME_AVAILABILITY, 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" );