diff --git a/libretroshare/src/file_sharing/file_tree.cc b/libretroshare/src/file_sharing/file_tree.cc
index 59987553c..75736ddc8 100644
--- a/libretroshare/src/file_sharing/file_tree.cc
+++ b/libretroshare/src/file_sharing/file_tree.cc
@@ -30,15 +30,63 @@ FileTree *FileTree::create(const std::string& radix64_string)
return ft ;
}
-static void recurs_buildFileTree(FileTreeImpl& ft,uint32_t index,void *ref)
+void FileTreeImpl::recurs_buildFileTree(FileTreeImpl& ft,uint32_t index,const DirDetails& dd,bool remote)
{
+ if(ft.mDirs.size() <= index)
+ ft.mDirs.resize(index+1) ;
+
+ ft.mDirs[index].name = dd.name ;
+ ft.mDirs[index].subfiles.clear();
+ ft.mDirs[index].subdirs.clear();
+
+ DirDetails dd2 ;
+
+ FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
+
+ for(uint32_t i=0;i
RequestDirDetails(dd.children[i].ref,dd2,flags))
+ {
+ if(dd.children[i].type == DIR_TYPE_FILE)
+ {
+ FileTree::FileData f ;
+ f.name = dd2.name ;
+ f.size = dd2.count ;
+ f.hash = dd2.hash ;
+
+ ft.mDirs[index].subfiles.push_back(ft.mFiles.size()) ;
+ ft.mFiles.push_back(f) ;
+ }
+ else if(dd.children[i].type == DIR_TYPE_DIR)
+ {
+ ft.mDirs[index].subdirs.push_back(ft.mDirs.size());
+ recurs_buildFileTree(ft,ft.mDirs.size(),dd2,remote) ;
+ }
+ else
+ std::cerr << "(EE) Unsupported DirDetails type." << std::endl;
+ }
+ else
+ std::cerr << "(EE) Cannot request dir details for pointer " << dd.children[i].ref << std::endl;
}
-FileTree *FileTree::create(void *ref)
+bool FileTreeImpl::getDirectoryContent(uint32_t index,std::vector& subdirs,std::vector& subfiles) const
+{
+ if(index >= mDirs.size())
+ return false ;
+
+ subdirs = mDirs[index].subdirs ;
+
+ subfiles.clear() ;
+ for(uint32_t i=0;i subdirs ;
@@ -22,4 +24,6 @@ protected:
};
std::vector mFiles ;
std::vector mDirs ;
+
+ friend class FileTree ;
};
diff --git a/libretroshare/src/retroshare/rsfiles.h b/libretroshare/src/retroshare/rsfiles.h
index 22a7dd8bf..422b1e9fd 100644
--- a/libretroshare/src/retroshare/rsfiles.h
+++ b/libretroshare/src/retroshare/rsfiles.h
@@ -144,7 +144,7 @@ class FileTree
public:
virtual ~FileTree() {}
- static FileTree *create(void *ref) ;
+ static FileTree *create(const DirDetails& dd, bool remote) ;
static FileTree *create(const std::string& radix64_string) ;
virtual std::string toRadix64() const =0 ;
@@ -160,6 +160,8 @@ public:
virtual uint32_t root() const { return 0;}
virtual bool getDirectoryContent(uint32_t index,std::vector& subdirs,std::vector& subfiles) const = 0;
+ virtual void print() const=0;
+
uint32_t mTotalFiles ;
uint64_t mTotalSize ;
};
diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp
index 9279642c3..a43e3cc5f 100644
--- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp
+++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp
@@ -511,7 +511,8 @@ void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
contextMnu.addAction( downloadAct) ;
- if ( type == DIR_TYPE_FILE ) {
+ //if ( type == DIR_TYPE_FILE )
+ {
contextMnu.addSeparator() ;//------------------------------------
contextMnu.addAction( copylinkAct) ;
contextMnu.addAction( sendlinkAct) ;
@@ -572,6 +573,18 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
if (details.type == DIR_TYPE_DIR)
{
+ FileTree *ft = FileTree::create(details,remote) ;
+
+ std::cerr << "Created collection file tree:" << std::endl;
+ ft->print();
+
+ RetroShareLink link = RetroShareLink::createCollection(QString::fromUtf8(details.name.c_str()), details.count,QString::fromStdString(ft->toRadix64())) ;
+
+ if(link.valid())
+ urls.push_back(link) ;
+
+ delete ft ;
+#ifdef TO_REMOVE
for(uint32_t j=0;j