Browse Source

functions for retrieving list of currently downloading files

adaptive-webui-19844
Eugene Shalygin 9 years ago
parent
commit
0a92cb74a5
  1. 5
      src/base/bittorrent/peerinfo.cpp
  2. 1
      src/base/bittorrent/peerinfo.h
  3. 14
      src/base/bittorrent/torrentinfo.cpp
  4. 1
      src/base/bittorrent/torrentinfo.h

5
src/base/bittorrent/peerinfo.cpp

@ -408,3 +408,8 @@ QString PeerInfo::flagsDescription() const
{ {
return m_flagsDescription; return m_flagsDescription;
} }
int PeerInfo::downloadingPieceIndex() const
{
return m_nativeInfo.downloading_piece_index;
}

1
src/base/bittorrent/peerinfo.h

@ -100,6 +100,7 @@ namespace BitTorrent
#ifndef DISABLE_COUNTRIES_RESOLUTION #ifndef DISABLE_COUNTRIES_RESOLUTION
QString country() const; QString country() const;
#endif #endif
int downloadingPieceIndex() const;
private: private:
void calcRelevance(const TorrentHandle *torrent); void calcRelevance(const TorrentHandle *torrent);

14
src/base/bittorrent/torrentinfo.cpp

@ -211,6 +211,20 @@ QByteArray TorrentInfo::metadata() const
return QByteArray(m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size()); return QByteArray(m_nativeInfo->metadata().get(), m_nativeInfo->metadata_size());
} }
QStringList TorrentInfo::filesForPiece(int pieceIndex) const
{
if (pieceIndex < 0)
return QStringList();
std::vector<libtorrent::file_slice> files(
nativeInfo()->map_block(pieceIndex, 0, nativeInfo()->piece_length()));
QStringList res;
for (const libtorrent::file_slice& s: files) {
res.append(filePath(s.file_index));
}
return res;
}
void TorrentInfo::renameFile(uint index, const QString &newPath) void TorrentInfo::renameFile(uint index, const QString &newPath)
{ {
if (!isValid()) return; if (!isValid()) return;

1
src/base/bittorrent/torrentinfo.h

@ -75,6 +75,7 @@ namespace BitTorrent
QList<TrackerEntry> trackers() const; QList<TrackerEntry> trackers() const;
QList<QUrl> urlSeeds() const; QList<QUrl> urlSeeds() const;
QByteArray metadata() const; QByteArray metadata() const;
QStringList filesForPiece(int pieceIndex) const;
void renameFile(uint index, const QString &newPath); void renameFile(uint index, const QString &newPath);
boost::intrusive_ptr<libtorrent::torrent_info> nativeInfo() const; boost::intrusive_ptr<libtorrent::torrent_info> nativeInfo() const;

Loading…
Cancel
Save