mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
Merge pull request #1107 from csoler/v0.6-Links2
fixed bug causing RsCollection to fail on remote files. Now using RsC…
This commit is contained in:
commit
45c8e9ea96
@ -445,10 +445,10 @@ void SearchDialog::collCreate()
|
||||
details.type = DIR_TYPE_FILE;
|
||||
|
||||
dirVec.push_back(details);
|
||||
}//if (!item->text(SR_HASH_COL).isEmpty())
|
||||
}//for (int i = 0; i < numdls; ++i)
|
||||
}
|
||||
}
|
||||
|
||||
RsCollection(dirVec).openNewColl(this);
|
||||
RsCollection(dirVec,RS_FILE_HINTS_LOCAL).openNewColl(this);
|
||||
}
|
||||
|
||||
void SearchDialog::collModif()
|
||||
|
@ -509,9 +509,18 @@ void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
||||
collectionMenu.addAction(collCreateAct);
|
||||
collectionMenu.addAction(collOpenAct);
|
||||
|
||||
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu ) ;
|
||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
||||
contextMnu.addAction( downloadAct) ;
|
||||
if(type == DIR_TYPE_DIR)
|
||||
{
|
||||
QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), &contextMnu ) ;
|
||||
connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ;
|
||||
contextMnu.addAction( downloadActI) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu ) ;
|
||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
||||
contextMnu.addAction( downloadAct) ;
|
||||
}
|
||||
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction( copylinkAct) ;
|
||||
@ -545,7 +554,16 @@ void RemoteSharedFilesDialog::expanded(const QModelIndex& indx)
|
||||
|
||||
model->updateRef(proxyModel->mapToSource(indx)) ;
|
||||
}
|
||||
void RemoteSharedFilesDialog::downloadRemoteSelectedInteractive()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
|
||||
std::cerr << "Downloading Files" ;
|
||||
std::cerr << std::endl ;
|
||||
|
||||
QModelIndexList lst = getSelected() ;
|
||||
model -> downloadSelected(lst,true) ;
|
||||
}
|
||||
void RemoteSharedFilesDialog::downloadRemoteSelected()
|
||||
{
|
||||
/* call back to the model (which does all the interfacing? */
|
||||
@ -554,7 +572,7 @@ void RemoteSharedFilesDialog::downloadRemoteSelected()
|
||||
std::cerr << std::endl ;
|
||||
|
||||
QModelIndexList lst = getSelected() ;
|
||||
model -> downloadSelected(lst) ;
|
||||
model -> downloadSelected(lst,false) ;
|
||||
}
|
||||
|
||||
void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList<RetroShareLink>& urls,bool& has_unhashed_files)
|
||||
|
@ -187,6 +187,7 @@ class RemoteSharedFilesDialog : public SharedFilesDialog
|
||||
|
||||
private slots:
|
||||
void downloadRemoteSelected();
|
||||
void downloadRemoteSelectedInteractive();
|
||||
void expanded(const QModelIndex& indx);
|
||||
};
|
||||
|
||||
|
@ -2133,7 +2133,8 @@ void TransfersDialog::collCreate()
|
||||
std::set<RsFileHash>::iterator it ;
|
||||
getDLSelectedItems(&items, NULL);
|
||||
|
||||
for (it = items.begin(); it != items.end(); ++it) {
|
||||
for (it = items.begin(); it != items.end(); ++it)
|
||||
{
|
||||
FileInfo info;
|
||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||
|
||||
@ -2144,9 +2145,9 @@ void TransfersDialog::collCreate()
|
||||
details.type = DIR_TYPE_FILE;
|
||||
|
||||
dirVec.push_back(details);
|
||||
}//for (it = items.begin();
|
||||
}
|
||||
|
||||
RsCollection(dirVec).openNewColl(this);
|
||||
RsCollection(dirVec,RS_FILE_HINTS_LOCAL).openNewColl(this);
|
||||
}
|
||||
|
||||
void TransfersDialog::collModif()
|
||||
|
@ -1027,12 +1027,12 @@ void MainWindow::addFriend()
|
||||
}
|
||||
|
||||
/** New RSCollection ShortCut */
|
||||
void MainWindow::newRsCollection()
|
||||
{
|
||||
std::vector <DirDetails> dirVec;
|
||||
|
||||
RsCollection(dirVec).openNewColl(this);
|
||||
}
|
||||
// void MainWindow::newRsCollection()
|
||||
// {
|
||||
// std::vector <DirDetails> dirVec;
|
||||
//
|
||||
// RsCollection(dirVec).openNewColl(this);
|
||||
// }
|
||||
|
||||
/** Shows Share Manager */
|
||||
void MainWindow::openShareManager()
|
||||
|
@ -223,7 +223,7 @@ private slots:
|
||||
|
||||
/** Toolbar fns. */
|
||||
void addFriend();
|
||||
void newRsCollection();
|
||||
//void newRsCollection();
|
||||
void showMessengerWindow();
|
||||
void showStatisticsWindow();
|
||||
#ifdef ENABLE_WEBUI
|
||||
|
@ -1065,10 +1065,12 @@ void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndex
|
||||
std::vector <DirDetails> dirVec;
|
||||
getDirDetailsFromSelect(list, dirVec);
|
||||
|
||||
RsCollection(dirVec).openNewColl(parent);
|
||||
FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
||||
|
||||
RsCollection(dirVec,f).openNewColl(parent);
|
||||
}
|
||||
|
||||
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
||||
void RetroshareDirModel::downloadSelected(const QModelIndexList &list,bool interactive)
|
||||
{
|
||||
if (!RemoteMode)
|
||||
{
|
||||
@ -1085,35 +1087,38 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
||||
std::vector <DirDetails> dirVec;
|
||||
|
||||
getDirDetailsFromSelect(list, dirVec);
|
||||
FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
||||
|
||||
/* Fire off requests */
|
||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||
{
|
||||
if (!RemoteMode)
|
||||
{
|
||||
continue; /* don't try to download local stuff */
|
||||
}
|
||||
if(interactive)
|
||||
RsCollection(dirVec,f).downloadFiles() ;
|
||||
else /* Fire off requests */
|
||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||
{
|
||||
if (!RemoteMode)
|
||||
{
|
||||
continue; /* don't try to download local stuff */
|
||||
}
|
||||
|
||||
const DirDetails& details = dirVec[i];
|
||||
const DirDetails& details = dirVec[i];
|
||||
|
||||
/* if it is a file */
|
||||
if (details.type == DIR_TYPE_FILE)
|
||||
{
|
||||
std::cerr << "RetroshareDirModel::downloadSelected() Calling File Request";
|
||||
std::cerr << std::endl;
|
||||
std::list<RsPeerId> srcIds;
|
||||
srcIds.push_back(details.id);
|
||||
rsFiles -> FileRequest(details.name, details.hash,
|
||||
details.count, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
}
|
||||
/* if it is a dir, copy all files included*/
|
||||
else if (details.type == DIR_TYPE_DIR)
|
||||
{
|
||||
int prefixLen = details.path.rfind(details.name);
|
||||
if (prefixLen < 0) continue;
|
||||
downloadDirectory(details, prefixLen);
|
||||
}
|
||||
}
|
||||
/* if it is a file */
|
||||
if (details.type == DIR_TYPE_FILE)
|
||||
{
|
||||
std::cerr << "RetroshareDirModel::downloadSelected() Calling File Request";
|
||||
std::cerr << std::endl;
|
||||
std::list<RsPeerId> srcIds;
|
||||
srcIds.push_back(details.id);
|
||||
rsFiles -> FileRequest(details.name, details.hash,
|
||||
details.count, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds);
|
||||
}
|
||||
/* if it is a dir, copy all files included*/
|
||||
else if (details.type == DIR_TYPE_DIR)
|
||||
{
|
||||
int prefixLen = details.path.rfind(details.name);
|
||||
if (prefixLen < 0) continue;
|
||||
downloadDirectory(details, prefixLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* recursively download a directory */
|
||||
|
@ -63,7 +63,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
||||
bool visible() { return _visible ;}
|
||||
|
||||
/* Callback from GUI */
|
||||
void downloadSelected(const QModelIndexList &list);
|
||||
void downloadSelected(const QModelIndexList &list, bool interactive);
|
||||
void createCollectionFile(QWidget *parent, const QModelIndexList &list);
|
||||
|
||||
void getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec);
|
||||
|
@ -56,14 +56,20 @@ RsCollection::RsCollection(const FileTree& fr)
|
||||
recursAddElements(_xml_doc,fr,0,_root) ;
|
||||
}
|
||||
|
||||
RsCollection::RsCollection(const std::vector<DirDetails>& file_infos, QObject *parent)
|
||||
RsCollection::RsCollection(const std::vector<DirDetails>& file_infos,FileSearchFlags flags, QObject *parent)
|
||||
: QObject(parent), _xml_doc("RsCollection")
|
||||
{
|
||||
_root = _xml_doc.createElement("RsCollection");
|
||||
_xml_doc.appendChild(_root);
|
||||
|
||||
if(! ( (flags & RS_FILE_HINTS_LOCAL) || (flags & RS_FILE_HINTS_REMOTE)))
|
||||
{
|
||||
std::cerr << "(EE) Wrong flags passed to RsCollection constructor. Please fix the code!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0;i<file_infos.size();++i)
|
||||
recursAddElements(_xml_doc,file_infos[i],_root) ;
|
||||
recursAddElements(_xml_doc,file_infos[i],_root,flags) ;
|
||||
}
|
||||
|
||||
RsCollection::~RsCollection()
|
||||
@ -170,7 +176,7 @@ void RsCollection::recursCollectColFileInfos(const QDomElement& e,std::vector<Co
|
||||
}
|
||||
|
||||
|
||||
void RsCollection::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e) const
|
||||
void RsCollection::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e,FileSearchFlags flags) const
|
||||
{
|
||||
if (details.type == DIR_TYPE_FILE)
|
||||
{
|
||||
@ -194,12 +200,11 @@ void RsCollection::recursAddElements(QDomDocument& doc,const DirDetails& details
|
||||
continue;
|
||||
|
||||
DirDetails subDirDetails;
|
||||
FileSearchFlags flags = RS_FILE_HINTS_LOCAL;
|
||||
|
||||
if (!rsFiles->RequestDirDetails(details.children[i].ref, subDirDetails, flags))
|
||||
continue;
|
||||
|
||||
recursAddElements(doc,subDirDetails,d) ;
|
||||
recursAddElements(doc,subDirDetails,d,flags) ;
|
||||
}
|
||||
|
||||
e.appendChild(d) ;
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
|
||||
RsCollection(QObject *parent = 0) ;
|
||||
// create from list of files and directories
|
||||
RsCollection(const std::vector<DirDetails>& file_entries, QObject *parent = 0) ;
|
||||
RsCollection(const std::vector<DirDetails>& file_entries, FileSearchFlags flags, QObject *parent = 0) ;
|
||||
RsCollection(const FileTree& fr);
|
||||
virtual ~RsCollection() ;
|
||||
|
||||
@ -98,7 +98,7 @@ private slots:
|
||||
|
||||
private:
|
||||
|
||||
void recursAddElements(QDomDocument&,const DirDetails&,QDomElement&) const ;
|
||||
void recursAddElements(QDomDocument&, const DirDetails&, QDomElement&, FileSearchFlags flags) const ;
|
||||
void recursAddElements(QDomDocument&,const ColFileInfo&,QDomElement&) const;
|
||||
void recursAddElements(QDomDocument& doc,const FileTree& ft,uint32_t index,QDomElement& e) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user