Merge pull request #18034 from glassez/fetch-async

Fetch data asynchronously
This commit is contained in:
Vladimir Golovnev
2022-12-15 06:59:29 +03:00
committed by GitHub
10 changed files with 427 additions and 133 deletions

View File

@@ -80,10 +80,10 @@ namespace BitTorrent
lt::operation_t operation;
};
class TorrentImpl final : public QObject, public Torrent
class TorrentImpl final : public Torrent
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(TorrentImpl)
Q_DECLARE_TR_FUNCTIONS(BitTorrent::TorrentImpl)
public:
TorrentImpl(SessionImpl *session, lt::session *nativeSession
@@ -227,7 +227,7 @@ namespace BitTorrent
void removeUrlSeeds(const QVector<QUrl> &urlSeeds) override;
bool connectPeer(const PeerAddress &peerAddress) override;
void clearPeers() override;
bool setMetadata(const TorrentInfo &torrentInfo) override;
void setMetadata(const TorrentInfo &torrentInfo) override;
StopCondition stopCondition() const override;
void setStopCondition(StopCondition stopCondition) override;
@@ -236,6 +236,13 @@ namespace BitTorrent
nonstd::expected<QByteArray, QString> exportToBuffer() const override;
nonstd::expected<void, QString> exportToFile(const Path &path) const override;
void fetchPeerInfo(std::function<void (QVector<PeerInfo>)> resultHandler) const override;
void fetchURLSeeds(std::function<void (QVector<QUrl>)> resultHandler) const override;
void fetchFilesProgress(std::function<void (QVector<qreal>)> resultHandler) const override;
void fetchPieceAvailability(std::function<void (QVector<int>)> resultHandler) const override;
void fetchDownloadingPieces(std::function<void (QBitArray)> resultHandler) const override;
void fetchAvailableFileFractions(std::function<void (QVector<qreal>)> resultHandler) const override;
bool needSaveResumeData() const;
// Session interface
@@ -292,6 +299,9 @@ namespace BitTorrent
nonstd::expected<lt::entry, QString> exportTorrent() const;
template <typename Func, typename Callback>
void invokeAsync(Func func, Callback resultHandler) const;
SessionImpl *const m_session = nullptr;
lt::session *m_nativeSession = nullptr;
lt::torrent_handle m_nativeHandle;