diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index a86cdc0ea..b652f42b8 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -1741,7 +1741,7 @@ void ForumsDialog::anchorClicked (const QUrl& link ) std::cerr << "ForumsDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl; #endif - RetroShareLink::processUrl(link, NULL, RSLINK_PROCESS_NOTIFY_ALL); + RetroShareLink::processUrl(link, RSLINK_PROCESS_NOTIFY_ALL); } void ForumsDialog::filterRegExpChanged() diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 1d3bef6a1..f79ec0f6d 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -1863,7 +1863,7 @@ void MessagesDialog::anchorClicked (const QUrl& link ) { std::cerr << "MessagesDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl; - RetroShareLink::processUrl(link, NULL, RSLINK_PROCESS_NOTIFY_ALL); + RetroShareLink::processUrl(link, RSLINK_PROCESS_NOTIFY_ALL); } bool MessagesDialog::fileSave() diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index 11fd219ef..8b16ec45b 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -1829,7 +1829,7 @@ void PeersDialog::anchorClicked (const QUrl& link ) std::cerr << "PeersDialog::anchorClicked link.scheme() : " << link.scheme().toStdString() << std::endl; #endif - RetroShareLink::processUrl(link, NULL, RSLINK_PROCESS_NOTIFY_ALL); + RetroShareLink::processUrl(link, RSLINK_PROCESS_NOTIFY_ALL); } void PeersDialog::dropEvent(QDropEvent *event) diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 19ac1accd..a5c094de4 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -239,7 +239,7 @@ bool RetroShareLink::checkHash(const QString& hash) return true ; } -bool RetroShareLink::process(std::list *psrcIds, int flag) +bool RetroShareLink::process(int flag) { if (valid() == false) { std::cerr << " RetroShareLink::process invalid request" << std::endl; @@ -254,12 +254,18 @@ bool RetroShareLink::process(std::list *psrcIds, int flag) { std::cerr << " RetroShareLink::process FileRequest : fileName : " << name().toUtf8().constData() << ". fileHash : " << hash().toStdString() << ". fileSize : " << size() << std::endl; - std::list srcIds; - if (psrcIds) { - srcIds = *psrcIds; - } + // Get a list of available direct sources, in case the file is browsable only. + std::list srcIds; + FileInfo finfo ; + rsFiles->FileDetails(hash().toStdString(), RS_FILE_HINTS_REMOTE,finfo) ; - if (rsFiles->FileRequest(name().toUtf8().constData(), hash().toStdString(), size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) { + for(std::list::const_iterator it(finfo.peers.begin());it!=finfo.peers.end();++it) + { + std::cerr << " adding peerid " << (*it).peerId << std::endl ; + srcIds.push_back((*it).peerId) ; + } + + if (rsFiles->FileRequest(name().toUtf8().constData(), hash().toStdString(), size(), "", RS_FILE_HINTS_NETWORK_WIDE, srcIds)) { if (flag & RSLINK_PROCESS_NOTIFY_SUCCESS) { QMessageBox mb(QObject::tr("File Request Confirmation"), QObject::tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0); mb.setButtonText( QMessageBox::Ok, "OK" ); @@ -340,7 +346,7 @@ bool RetroShareLink::process(std::list *psrcIds, int flag) return false; } -/*static*/ bool RetroShareLink::processUrl(const QUrl &url, std::list *psrcIds, int flag) +/*static*/ bool RetroShareLink::processUrl(const QUrl &url, int flag) { if (url.scheme() == "http") { QDesktopServices::openUrl(url); @@ -359,7 +365,7 @@ bool RetroShareLink::process(std::list *psrcIds, int flag) // RetroShareLink link(url); // // if (link.valid()) { -// return link.process(psrcId, flag); +// return link.process(flag); // } // // if (flag & RSLINK_PROCESS_NOTIFY_ERROR) { @@ -502,7 +508,7 @@ bool RSLinkClipboard::empty(RetroShareLink::enumType type /*= RetroShareLink::TY for (uint32_t i = 0; i < links.size(); i++) { if (links[i].valid() && (type == RetroShareLink::TYPE_UNKNOWN || links[i].type() == type)) { - if (links[i].process(NULL, flag)) { + if (links[i].process(flag)) { count++; } } diff --git a/retroshare-gui/src/gui/RetroShareLink.h b/retroshare-gui/src/gui/RetroShareLink.h index bbb3d1fca..4bc5e8eec 100644 --- a/retroshare-gui/src/gui/RetroShareLink.h +++ b/retroshare-gui/src/gui/RetroShareLink.h @@ -81,8 +81,8 @@ class RetroShareLink bool operator==(const RetroShareLink& l) const { return _type == l._type && _hash == l._hash ; } - bool process(std::list *psrcIds, int flag); - static bool processUrl(const QUrl &url, std::list *psrcIds, int flag); + bool process(int flag); + static bool processUrl(const QUrl &url, int flag); private: void fromString(const QString &url); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 54b29d698..2115182cc 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -994,8 +994,7 @@ void PopupChatDialog::anchorClicked (const QUrl& link ) #endif std::list srcIds; - srcIds.push_back(dialogId); - RetroShareLink::processUrl(link, &srcIds, RSLINK_PROCESS_NOTIFY_ALL); + RetroShareLink::processUrl(link, RSLINK_PROCESS_NOTIFY_ALL); } void PopupChatDialog::dropEvent(QDropEvent *event)