Allow to fetch data asynchronously

This commit is contained in:
Vladimir Golovnev (Glassez)
2022-11-14 20:45:08 +03:00
parent c3936cd4b6
commit 991c30943a
9 changed files with 410 additions and 125 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
@@ -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
@@ -290,6 +297,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;