mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed compilation after removal of RsCollection::downloadFiles
This commit is contained in:
parent
8366cbca59
commit
0551f4f819
@ -598,7 +598,7 @@ void SearchDialog::collOpen()
|
||||
RsCollection::RsCollectionErrorCode err;
|
||||
qinfo.setFile(QString::fromUtf8(path.c_str()));
|
||||
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||
RsCollection(qinfo.absoluteFilePath(),err).downloadFiles();
|
||||
RsCollectionDialog::downloadFiles(RsCollection(qinfo.absoluteFilePath(),err));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -613,7 +613,7 @@ void SearchDialog::collOpen()
|
||||
RsCollection collection(fileName, err);
|
||||
|
||||
if(err == RsCollection::RsCollectionErrorCode::NO_ERROR)
|
||||
collection.downloadFiles();
|
||||
RsCollectionDialog::downloadFiles(collection);
|
||||
else
|
||||
QMessageBox::information(nullptr,tr("Error open RsCollection file"),RsCollection::errorString(err));
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ void SharedFilesDialog::collOpen()
|
||||
RsCollection collection(fileName,err);
|
||||
|
||||
if(err == RsCollection::RsCollectionErrorCode::NO_ERROR)
|
||||
collection.downloadFiles();
|
||||
RsCollectionDialog::downloadFiles(collection);
|
||||
}
|
||||
|
||||
void LocalSharedFilesDialog::playselectedfiles()
|
||||
|
@ -1975,7 +1975,7 @@ void TransfersDialog::pasteLink()
|
||||
for(auto &it : links)
|
||||
col.merge_in(it.name(),it.size(),RsFileHash(it.hash().toStdString())) ;
|
||||
|
||||
col.downloadFiles();
|
||||
RsCollectionDialog::downloadFiles(col);
|
||||
}
|
||||
|
||||
void TransfersDialog::getDLSelectedItems(std::set<RsFileHash> *ids, std::set<int> *rows)
|
||||
@ -2555,7 +2555,7 @@ void TransfersDialog::collOpen()
|
||||
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||
{
|
||||
RsCollection::RsCollectionErrorCode code;
|
||||
RsCollection(qinfo.absoluteFilePath(),code).downloadFiles();
|
||||
RsCollectionDialog::downloadFiles(RsCollection(qinfo.absoluteFilePath(),code));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2572,7 +2572,7 @@ void TransfersDialog::collOpen()
|
||||
RsCollection collection(fileName,code);
|
||||
|
||||
if(code == RsCollection::RsCollectionErrorCode::NO_ERROR)
|
||||
collection.downloadFiles();
|
||||
RsCollectionDialog::downloadFiles(collection);
|
||||
else
|
||||
QMessageBox::information(nullptr,tr("Error openning collection file"),RsCollection::errorString(code));
|
||||
}
|
||||
@ -2597,7 +2597,7 @@ void TransfersDialog::collAutoOpen(const QString &fileHash)
|
||||
RsCollection::RsCollectionErrorCode err;
|
||||
|
||||
if (qinfo.exists() && qinfo.absoluteFilePath().endsWith(RsCollection::ExtensionString))
|
||||
RsCollection(qinfo.absoluteFilePath(),err).autoDownloadFiles();
|
||||
RsCollectionDialog::downloadFiles(RsCollection(qinfo.absoluteFilePath(),err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "gui/common/FilesDefs.h"
|
||||
#include "gui/common/GroupDefs.h"
|
||||
#include "gui/common/RsCollection.h"
|
||||
#include "gui/common/RsCollectionDialog.h"
|
||||
#include "gui/common/RsUrlHandler.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
@ -1253,7 +1253,7 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list,bool inter
|
||||
FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
||||
|
||||
if(interactive)
|
||||
RsCollection(dirVec,f).downloadFiles() ;
|
||||
RsCollectionDialog::downloadFiles(RsCollection(dirVec,f)) ;
|
||||
else /* Fire off requests */
|
||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "HomePage.h"
|
||||
#include "chat/ChatDialog.h"
|
||||
#include "common/PeerDefs.h"
|
||||
#include "common/RsCollection.h"
|
||||
#include "common/RsCollectionDialog.h"
|
||||
#include "common/RsUrlHandler.h"
|
||||
#include "connect/ConfCertDialog.h"
|
||||
#include "connect/ConnectFriendWizard.h"
|
||||
@ -1724,9 +1724,8 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
|
||||
case TYPE_FILE_TREE:
|
||||
{
|
||||
auto ft = RsFileTree::fromRadix64(
|
||||
link.radix().toStdString() );
|
||||
RsCollection(*ft).downloadFiles();
|
||||
auto ft = RsFileTree::fromRadix64(link.radix().toStdString() );
|
||||
RsCollectionDialog::downloadFiles(RsCollection(*ft));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1778,7 +1777,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
|
||||
// were single file links found?
|
||||
if (fileLinkFound)
|
||||
col.downloadFiles();
|
||||
RsCollectionDialog::downloadFiles(col);
|
||||
|
||||
int countProcessed = 0;
|
||||
int countError = 0;
|
||||
|
@ -37,11 +37,10 @@
|
||||
|
||||
const QString RsCollection::ExtensionString = QString("rscollection") ;
|
||||
|
||||
RsCollection::RsCollection(QObject *parent)
|
||||
: QObject(parent), mFileTree(new RsFileTree)
|
||||
RsCollection::RsCollection()
|
||||
{
|
||||
mFileTree = std::unique_ptr<RsFileTree>(new RsFileTree());
|
||||
}
|
||||
|
||||
RsCollection::RsCollection(const RsFileTree& ft)
|
||||
{
|
||||
mFileTree = std::unique_ptr<RsFileTree>(new RsFileTree(ft));
|
||||
@ -50,8 +49,8 @@ RsCollection::RsCollection(const RsFileTree& ft)
|
||||
mHashes.insert(std::make_pair(mFileTree->fileData(i).hash,i ));
|
||||
}
|
||||
|
||||
RsCollection::RsCollection(const std::vector<DirDetails>& file_infos,FileSearchFlags flags, QObject *parent)
|
||||
: QObject(parent), mFileTree(new RsFileTree)
|
||||
RsCollection::RsCollection(const std::vector<DirDetails>& file_infos,FileSearchFlags flags)
|
||||
: mFileTree(new RsFileTree)
|
||||
{
|
||||
if(! ( (flags & RS_FILE_HINTS_LOCAL) || (flags & RS_FILE_HINTS_REMOTE)))
|
||||
{
|
||||
@ -70,39 +69,6 @@ RsCollection::~RsCollection()
|
||||
{
|
||||
}
|
||||
|
||||
void RsCollection::downloadFiles() const
|
||||
{
|
||||
#ifdef TODO_COLLECTION
|
||||
// print out the element names of all elements that are direct children
|
||||
// of the outermost element.
|
||||
QDomElement docElem = _xml_doc.documentElement();
|
||||
|
||||
std::vector<ColFileInfo> colFileInfos ;
|
||||
|
||||
recursCollectColFileInfos(docElem,colFileInfos,QString(),false) ;
|
||||
|
||||
RsCollectionDialog(_fileName, colFileInfos, false).exec() ;
|
||||
#endif
|
||||
}
|
||||
|
||||
void RsCollection::autoDownloadFiles() const
|
||||
{
|
||||
#ifdef TODO_COLLECTION
|
||||
QDomElement docElem = _xml_doc.documentElement();
|
||||
|
||||
std::vector<ColFileInfo> colFileInfos;
|
||||
|
||||
recursCollectColFileInfos(docElem,colFileInfos,QString(),false);
|
||||
|
||||
QString dlDir = QString::fromUtf8(rsFiles->getDownloadDirectory().c_str());
|
||||
|
||||
foreach(ColFileInfo colFileInfo, colFileInfos)
|
||||
{
|
||||
autoDownloadFiles(colFileInfo, dlDir);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RsCollection::autoDownloadFiles(ColFileInfo colFileInfo, QString dlDir) const
|
||||
{
|
||||
if (!colFileInfo.filename_has_wrong_characters)
|
||||
@ -197,15 +163,20 @@ QString RsCollection::errorString(RsCollectionErrorCode code)
|
||||
switch(code)
|
||||
{
|
||||
default: [[fallthrough]] ;
|
||||
case RsCollectionErrorCode::UNKNOWN_ERROR: return tr("Unknown error");
|
||||
case RsCollectionErrorCode::NO_ERROR: return tr("No error");
|
||||
case RsCollectionErrorCode::FILE_READ_ERROR: return tr("Error while openning file");
|
||||
case RsCollectionErrorCode::FILE_CONTAINS_HARMFUL_STRINGS: return tr("Collection file contains potentially harmful code");
|
||||
case RsCollectionErrorCode::INVALID_ROOT_NODE: return tr("Invalid root node. RsCollection node was expected.");
|
||||
case RsCollectionErrorCode::XML_PARSING_ERROR: return tr("XML parsing error in collection file");
|
||||
case RsCollectionErrorCode::UNKNOWN_ERROR: return QObject::tr("Unknown error");
|
||||
case RsCollectionErrorCode::NO_ERROR: return QObject::tr("No error");
|
||||
case RsCollectionErrorCode::FILE_READ_ERROR: return QObject::tr("Error while openning file");
|
||||
case RsCollectionErrorCode::FILE_CONTAINS_HARMFUL_STRINGS: return QObject::tr("Collection file contains potentially harmful code");
|
||||
case RsCollectionErrorCode::INVALID_ROOT_NODE: return QObject::tr("Invalid root node. RsCollection node was expected.");
|
||||
case RsCollectionErrorCode::XML_PARSING_ERROR: return QObject::tr("XML parsing error in collection file");
|
||||
}
|
||||
}
|
||||
|
||||
RsCollection::RsCollection(const RsCollection& col)
|
||||
: mFileTree(new RsFileTree(*col.mFileTree)),mHashes(col.mHashes)
|
||||
{
|
||||
}
|
||||
|
||||
RsCollection::RsCollection(const QString& fileName, RsCollectionErrorCode& error)
|
||||
: mFileTree(new RsFileTree)
|
||||
{
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDomDocument>
|
||||
#include <QFile>
|
||||
@ -53,10 +52,8 @@ public:
|
||||
};
|
||||
Q_DECLARE_METATYPE(ColFileInfo)
|
||||
|
||||
class RsCollection : public QObject
|
||||
class RsCollection
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class RsCollectionErrorCode:uint8_t {
|
||||
NO_ERROR = 0x00,
|
||||
@ -67,9 +64,9 @@ public:
|
||||
XML_PARSING_ERROR = 0x05,
|
||||
};
|
||||
|
||||
RsCollection(QObject *parent = 0) ;
|
||||
// create from list of files and directories
|
||||
RsCollection(const std::vector<DirDetails>& file_entries, FileSearchFlags flags, QObject *parent = 0) ;
|
||||
RsCollection();
|
||||
RsCollection(const RsCollection&);
|
||||
RsCollection(const std::vector<DirDetails>& file_entries, FileSearchFlags flags) ;
|
||||
RsCollection(const RsFileTree& ft);
|
||||
RsCollection(const QString& filename,RsCollectionErrorCode& error_code);
|
||||
|
||||
@ -87,10 +84,6 @@ public:
|
||||
|
||||
static const QString ExtensionString ;
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool load(QWidget *parent);
|
||||
bool save(QWidget *parent) const ;
|
||||
#endif
|
||||
// Save to disk
|
||||
bool save(const QString& fileName) const ;
|
||||
|
||||
@ -101,11 +94,6 @@ public:
|
||||
// total number of files in the collection
|
||||
qulonglong count() const;
|
||||
|
||||
// Download the content.
|
||||
void downloadFiles() const ;
|
||||
// Auto Download all the content.
|
||||
void autoDownloadFiles() const ;
|
||||
|
||||
static bool isCollectionFile(const QString& fileName);
|
||||
|
||||
void updateHashes(const std::map<RsFileHash,RsFileHash>& old_to_new_hashes);
|
||||
@ -120,15 +108,6 @@ private:
|
||||
// This function is used to merge an existing RsFileTree into the RsCollection
|
||||
void recursMergeTree(RsFileTree::DirIndex parent, const RsFileTree& tree, const RsFileTree::DirData &dd);
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void recursAddElements(QDomDocument&,const ColFileInfo&,QDomElement&) const;
|
||||
void recursAddElements(
|
||||
QDomDocument& doc, const RsFileTree& ft, uint32_t index,
|
||||
QDomElement& e ) const;
|
||||
|
||||
void recursCollectColFileInfos(const QDomElement&,std::vector<ColFileInfo>& colFileInfos,const QString& current_dir,bool bad_chars_in_parent) const ;
|
||||
#endif
|
||||
|
||||
// check that the file is a valid rscollection file, and not a lol bomb or some shit like this
|
||||
static bool checkFile(const QString &fileName, RsCollectionErrorCode &error);
|
||||
|
||||
@ -138,13 +117,6 @@ private:
|
||||
std::unique_ptr<RsFileTree> mFileTree;
|
||||
std::map<RsFileHash,RsFileTree::FileIndex> mHashes; // used to efficiently update files being hashed
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
QDomDocument _xml_doc ;
|
||||
QString _fileName ;
|
||||
bool _saved;
|
||||
QDomElement _root ;
|
||||
#endif
|
||||
|
||||
friend class RsCollectionDialog ;
|
||||
};
|
||||
|
||||
|
@ -136,6 +136,17 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName, RsColl
|
||||
close();
|
||||
}
|
||||
|
||||
init(collectionFileName);
|
||||
}
|
||||
|
||||
RsCollectionDialog::RsCollectionDialog(const RsCollection& coll, RsCollectionDialogMode mode)
|
||||
: _mode(mode)
|
||||
{
|
||||
mCollection = new RsCollection(coll);
|
||||
init(QString());
|
||||
}
|
||||
void RsCollectionDialog::init(const QString& collectionFileName)
|
||||
{
|
||||
ui.setupUi(this) ;
|
||||
ui._filename_TL->setText(collectionFileName);
|
||||
|
||||
@ -800,6 +811,12 @@ bool RsCollectionDialog::openExistingCollection(const QString& fileName, bool sh
|
||||
return RsCollectionDialog(fileName,DOWNLOAD).exec();
|
||||
}
|
||||
|
||||
bool RsCollectionDialog::downloadFiles(const RsCollection &collection)
|
||||
{
|
||||
return RsCollectionDialog(collection,DOWNLOAD).exec();
|
||||
}
|
||||
|
||||
|
||||
bool RsCollectionDialog::openNewCollection(const RsFileTree& tree)
|
||||
{
|
||||
RsCollection collection(tree);
|
||||
|
@ -43,8 +43,12 @@ public:
|
||||
// Open existing collection for download
|
||||
static bool openExistingCollection(const QString& fileName, bool showError = true);
|
||||
|
||||
// Open existing collection for download
|
||||
static bool downloadFiles(const RsCollection& collection);
|
||||
protected:
|
||||
//bool eventFilter(QObject *obj, QEvent *ev);
|
||||
static QString errorString(RsCollection::RsCollectionErrorCode code);
|
||||
|
||||
void init(const QString& collectionFileName);
|
||||
|
||||
enum RsCollectionDialogMode {
|
||||
UNKNOWN = 0x00,
|
||||
@ -53,6 +57,7 @@ protected:
|
||||
};
|
||||
|
||||
RsCollectionDialog(const QString& filename, RsCollectionDialogMode mode) ;
|
||||
RsCollectionDialog(const RsCollection& coll, RsCollectionDialogMode mode) ;
|
||||
|
||||
private slots:
|
||||
void directoryLoaded(QString dirLoaded);
|
||||
|
Loading…
Reference in New Issue
Block a user