#ifndef DOWNLOADQUEUECONTROLLER_H #define DOWNLOADQUEUECONTROLLER_H #include "control/TransferBatch.h" #include "control/Utilities.h" #include "megaapi.h" #include #include "TransferMetaData.h" #include #include #include class DownloadQueueController : public QObject, public mega::MegaRequestListener { Q_OBJECT public: DownloadQueueController(mega::MegaApi* _megaApi, const QMap& pathMap); void initialize(QQueue* downloadQueue, BlockingBatch& downloadBatches, unsigned long long appDataId, const QString& path); void startAvailableSpaceChecking(); void addTransferBatch(std::shared_ptr batch); void removeBatch(); int getDownloadQueueSize(); bool isDownloadQueueEmpty(); void clearDownloadQueue(); WrappedNode* dequeueDownloadQueue(); unsigned long long getCurrentAppDataId() const; const QString& getCurrentTargetPath() const; signals: void finishedAvailableSpaceCheck(bool isDownloadPossible); protected: void onRequestFinish(mega::MegaApi*, mega::MegaRequest *request, mega::MegaError *e) override; private: void tryDownload(); bool hasEnoughSpaceForDownloads(); void askUserForChoice(); mega::MegaApi *mMegaApi; const QMap& mPathMap; std::unique_ptr mListener; std::atomic mFolderCountPendingSizeComputation; std::atomic mTotalQueueDiskSize; unsigned long long mCurrentAppDataId; QString mCurrentTargetPath; BlockingBatch* mDownloadBatches; QQueue* mDownloadQueue; }; #endif // DOWNLOADQUEUECONTROLLER_H