2015-04-19 18:17:47 +03:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt and libtorrent.
|
|
|
|
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
|
|
|
|
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BITTORRENT_TORRENTHANDLE_H
|
|
|
|
#define BITTORRENT_TORRENTHANDLE_H
|
|
|
|
|
2019-01-06 14:11:05 +03:00
|
|
|
#include <functional>
|
|
|
|
|
2019-05-09 07:58:04 +03:00
|
|
|
#include <libtorrent/fwd.hpp>
|
2019-03-02 08:22:13 +03:00
|
|
|
#include <libtorrent/torrent_handle.hpp>
|
|
|
|
#include <libtorrent/torrent_status.hpp>
|
|
|
|
|
2017-06-05 03:22:17 +03:00
|
|
|
#include <QHash>
|
2019-05-21 07:21:17 +03:00
|
|
|
#include <QList>
|
2017-06-05 03:22:17 +03:00
|
|
|
#include <QObject>
|
2015-04-19 18:17:47 +03:00
|
|
|
#include <QQueue>
|
2017-06-05 03:22:17 +03:00
|
|
|
#include <QSet>
|
|
|
|
#include <QString>
|
2015-04-19 18:17:47 +03:00
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
#include "private/speedmonitor.h"
|
2019-03-06 08:58:07 +03:00
|
|
|
#include "downloadpriority.h"
|
2015-04-19 18:17:47 +03:00
|
|
|
#include "infohash.h"
|
|
|
|
#include "torrentinfo.h"
|
|
|
|
|
2019-03-02 08:22:13 +03:00
|
|
|
extern const QString QB_EXT;
|
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
class QBitArray;
|
2019-03-02 08:22:13 +03:00
|
|
|
class QDateTime;
|
2015-04-19 18:17:47 +03:00
|
|
|
class QStringList;
|
2019-03-02 08:22:13 +03:00
|
|
|
class QUrl;
|
2016-04-19 09:54:48 +03:00
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
namespace BitTorrent
|
|
|
|
{
|
|
|
|
class PeerInfo;
|
2019-03-02 08:22:13 +03:00
|
|
|
class Session;
|
2015-04-19 18:17:47 +03:00
|
|
|
class TrackerEntry;
|
|
|
|
struct AddTorrentParams;
|
2019-03-02 08:22:13 +03:00
|
|
|
struct PeerAddress;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2018-07-11 15:44:15 +03:00
|
|
|
struct CreateTorrentParams
|
2015-04-19 18:17:47 +03:00
|
|
|
{
|
2018-07-11 15:44:15 +03:00
|
|
|
bool restored; // is existing torrent job?
|
|
|
|
// for both new and restored torrents
|
2015-04-19 18:17:47 +03:00
|
|
|
QString name;
|
2016-02-09 11:56:48 +03:00
|
|
|
QString category;
|
2017-06-05 03:22:17 +03:00
|
|
|
QSet<QString> tags;
|
2015-04-19 18:17:47 +03:00
|
|
|
QString savePath;
|
|
|
|
bool disableTempPath;
|
|
|
|
bool sequential;
|
2016-07-15 05:15:10 +03:00
|
|
|
bool firstLastPiecePriority;
|
2015-04-19 18:17:47 +03:00
|
|
|
bool hasSeedStatus;
|
2015-10-25 01:39:40 +03:00
|
|
|
bool skipChecking;
|
2016-01-04 16:00:50 +03:00
|
|
|
bool hasRootFolder;
|
2018-07-11 15:44:15 +03:00
|
|
|
bool forced;
|
|
|
|
bool paused;
|
2017-08-14 14:44:56 +03:00
|
|
|
int uploadLimit;
|
|
|
|
int downloadLimit;
|
2015-06-04 11:03:19 +03:00
|
|
|
// for new torrents
|
2019-03-06 08:58:07 +03:00
|
|
|
QVector<DownloadPriority> filePriorities;
|
2018-07-11 15:44:15 +03:00
|
|
|
// for restored torrents
|
2015-04-19 18:17:47 +03:00
|
|
|
qreal ratioLimit;
|
2016-02-07 20:31:50 +03:00
|
|
|
int seedingTimeLimit;
|
2016-01-01 16:28:40 +03:00
|
|
|
|
2018-07-11 15:44:15 +03:00
|
|
|
CreateTorrentParams();
|
2018-12-16 10:51:36 +03:00
|
|
|
explicit CreateTorrentParams(const AddTorrentParams ¶ms);
|
2015-04-19 18:17:47 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackerInfo
|
|
|
|
{
|
|
|
|
QString lastMessage;
|
2019-05-17 06:55:16 +03:00
|
|
|
int numPeers = 0;
|
2015-04-19 18:17:47 +03:00
|
|
|
};
|
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
enum class TorrentState
|
2015-04-19 18:17:47 +03:00
|
|
|
{
|
2017-02-18 03:38:40 +03:00
|
|
|
Unknown = -1,
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
ForcedDownloading,
|
|
|
|
Downloading,
|
|
|
|
DownloadingMetadata,
|
|
|
|
Allocating,
|
|
|
|
StalledDownloading,
|
2015-06-20 09:05:53 +03:00
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
ForcedUploading,
|
|
|
|
Uploading,
|
|
|
|
StalledUploading,
|
2015-06-20 09:05:53 +03:00
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
CheckingResumeData,
|
|
|
|
QueuedDownloading,
|
|
|
|
QueuedUploading,
|
2015-06-30 11:03:46 +03:00
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
CheckingUploading,
|
|
|
|
CheckingDownloading,
|
2015-06-20 09:05:53 +03:00
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
PausedDownloading,
|
|
|
|
PausedUploading,
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2018-04-09 18:19:33 +03:00
|
|
|
Moving,
|
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
MissingFiles,
|
|
|
|
Error
|
2015-04-19 18:17:47 +03:00
|
|
|
};
|
|
|
|
|
2015-09-25 10:52:25 +03:00
|
|
|
class TorrentHandle : public QObject
|
2015-04-19 18:17:47 +03:00
|
|
|
{
|
|
|
|
Q_DISABLE_COPY(TorrentHandle)
|
2018-09-19 23:59:08 +03:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(BitTorrent::TorrentHandle)
|
2015-04-19 18:17:47 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
static const qreal USE_GLOBAL_RATIO;
|
|
|
|
static const qreal NO_RATIO_LIMIT;
|
|
|
|
|
2016-02-07 20:31:50 +03:00
|
|
|
static const int USE_GLOBAL_SEEDING_TIME;
|
|
|
|
static const int NO_SEEDING_TIME_LIMIT;
|
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
static const qreal MAX_RATIO;
|
2016-02-07 20:31:50 +03:00
|
|
|
static const int MAX_SEEDING_TIME;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2019-05-09 07:45:52 +03:00
|
|
|
TorrentHandle(Session *session, const lt::torrent_handle &nativeHandle,
|
2018-07-11 15:44:15 +03:00
|
|
|
const CreateTorrentParams ¶ms);
|
2015-04-19 18:17:47 +03:00
|
|
|
~TorrentHandle();
|
|
|
|
|
|
|
|
bool isValid() const;
|
|
|
|
InfoHash hash() const;
|
|
|
|
QString name() const;
|
|
|
|
QDateTime creationDate() const;
|
|
|
|
QString creator() const;
|
|
|
|
QString comment() const;
|
|
|
|
bool isPrivate() const;
|
|
|
|
qlonglong totalSize() const;
|
|
|
|
qlonglong wantedSize() const;
|
|
|
|
qlonglong completedSize() const;
|
|
|
|
qlonglong incompletedSize() const;
|
|
|
|
qlonglong pieceLength() const;
|
|
|
|
qlonglong wastedSize() const;
|
|
|
|
QString currentTracker() const;
|
2015-10-24 15:28:29 +03:00
|
|
|
|
|
|
|
// 1. savePath() - the path where all the files and subfolders of torrent are stored (as always).
|
|
|
|
// 2. rootPath() - absolute path of torrent file tree (save path + first item from 1st torrent file path).
|
|
|
|
// 3. contentPath() - absolute path of torrent content (root path for multifile torrents, absolute file path for singlefile torrents).
|
|
|
|
//
|
|
|
|
// These methods have 'actual' parameter (defaults to false) which allow to get actual or final path variant.
|
|
|
|
//
|
|
|
|
// Examples.
|
|
|
|
// Suppose we have three torrent with following structures and save path `/home/user/torrents`:
|
|
|
|
//
|
|
|
|
// Torrent A (multifile)
|
|
|
|
//
|
|
|
|
// torrentA/
|
|
|
|
// subdir1/
|
|
|
|
// subdir2/
|
|
|
|
// file1
|
|
|
|
// file2
|
|
|
|
// file3
|
|
|
|
// file4
|
|
|
|
//
|
|
|
|
//
|
2016-01-06 10:26:57 +03:00
|
|
|
// Torrent A* (Torrent A in "strip root folder" mode)
|
|
|
|
//
|
|
|
|
//
|
2015-10-24 15:28:29 +03:00
|
|
|
// Torrent B (singlefile)
|
|
|
|
//
|
|
|
|
// torrentB/
|
|
|
|
// subdir1/
|
|
|
|
// file1
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Torrent C (singlefile)
|
|
|
|
//
|
|
|
|
// file1
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Results:
|
|
|
|
// | | rootPath | contentPath |
|
|
|
|
// |---|------------------------------|--------------------------------------------|
|
|
|
|
// | A | /home/user/torrents/torrentA | /home/user/torrents/torrentA |
|
2016-01-06 10:26:57 +03:00
|
|
|
// | A*| <empty> | /home/user/torrents |
|
2015-10-24 15:28:29 +03:00
|
|
|
// | B | /home/user/torrents/torrentB | /home/user/torrents/torrentB/subdir1/file1 |
|
|
|
|
// | C | /home/user/torrents/file1 | /home/user/torrents/file1 |
|
|
|
|
|
|
|
|
QString savePath(bool actual = false) const;
|
|
|
|
QString rootPath(bool actual = false) const;
|
|
|
|
QString contentPath(bool actual = false) const;
|
|
|
|
|
2017-08-04 22:29:17 +03:00
|
|
|
bool useTempPath() const;
|
|
|
|
|
2016-05-08 22:47:50 +03:00
|
|
|
bool isAutoTMMEnabled() const;
|
|
|
|
void setAutoTMMEnabled(bool enabled);
|
2016-02-09 11:56:48 +03:00
|
|
|
QString category() const;
|
|
|
|
bool belongsToCategory(const QString &category) const;
|
|
|
|
bool setCategory(const QString &category);
|
|
|
|
|
2017-06-05 03:22:17 +03:00
|
|
|
QSet<QString> tags() const;
|
|
|
|
bool hasTag(const QString &tag) const;
|
|
|
|
bool addTag(const QString &tag);
|
|
|
|
bool removeTag(const QString &tag);
|
|
|
|
void removeAllTags();
|
|
|
|
|
2016-01-04 16:00:50 +03:00
|
|
|
bool hasRootFolder() const;
|
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
int filesCount() const;
|
|
|
|
int piecesCount() const;
|
2015-06-17 00:42:25 +03:00
|
|
|
int piecesHave() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
qreal progress() const;
|
|
|
|
QDateTime addedTime() const;
|
|
|
|
qreal ratioLimit() const;
|
2016-02-07 20:31:50 +03:00
|
|
|
int seedingTimeLimit() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
|
|
|
QString filePath(int index) const;
|
|
|
|
QString fileName(int index) const;
|
|
|
|
qlonglong fileSize(int index) const;
|
|
|
|
QStringList absoluteFilePaths() const;
|
|
|
|
QStringList absoluteFilePathsUnwanted() const;
|
2019-03-06 08:58:07 +03:00
|
|
|
QVector<DownloadPriority> filePriorities() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
|
|
|
TorrentInfo info() const;
|
|
|
|
bool isSeed() const;
|
|
|
|
bool isPaused() const;
|
|
|
|
bool isResumed() const;
|
|
|
|
bool isQueued() const;
|
|
|
|
bool isForced() const;
|
|
|
|
bool isChecking() const;
|
|
|
|
bool isDownloading() const;
|
|
|
|
bool isUploading() const;
|
|
|
|
bool isCompleted() const;
|
|
|
|
bool isActive() const;
|
|
|
|
bool isInactive() const;
|
2015-11-11 09:51:22 +03:00
|
|
|
bool isErrored() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
bool isSequentialDownload() const;
|
|
|
|
bool hasFirstLastPiecePriority() const;
|
|
|
|
TorrentState state() const;
|
|
|
|
bool hasMetadata() const;
|
|
|
|
bool hasMissingFiles() const;
|
|
|
|
bool hasError() const;
|
|
|
|
bool hasFilteredPieces() const;
|
|
|
|
int queuePosition() const;
|
2019-05-21 07:21:17 +03:00
|
|
|
QVector<TrackerEntry> trackers() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
QHash<QString, TrackerInfo> trackerInfos() const;
|
|
|
|
QList<QUrl> urlSeeds() const;
|
|
|
|
QString error() const;
|
|
|
|
qlonglong totalDownload() const;
|
|
|
|
qlonglong totalUpload() const;
|
2019-04-01 11:39:29 +03:00
|
|
|
qlonglong activeTime() const;
|
|
|
|
qlonglong finishedTime() const;
|
|
|
|
qlonglong seedingTime() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
qulonglong eta() const;
|
|
|
|
QVector<qreal> filesProgress() const;
|
|
|
|
int seedsCount() const;
|
|
|
|
int peersCount() const;
|
|
|
|
int leechsCount() const;
|
2015-06-17 00:42:25 +03:00
|
|
|
int totalSeedsCount() const;
|
|
|
|
int totalPeersCount() const;
|
|
|
|
int totalLeechersCount() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
int completeCount() const;
|
|
|
|
int incompleteCount() const;
|
|
|
|
QDateTime lastSeenComplete() const;
|
|
|
|
QDateTime completedTime() const;
|
2019-04-01 11:39:29 +03:00
|
|
|
qlonglong timeSinceUpload() const;
|
|
|
|
qlonglong timeSinceDownload() const;
|
|
|
|
qlonglong timeSinceActivity() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
int downloadLimit() const;
|
|
|
|
int uploadLimit() const;
|
|
|
|
bool superSeeding() const;
|
|
|
|
QList<PeerInfo> peers() const;
|
|
|
|
QBitArray pieces() const;
|
|
|
|
QBitArray downloadingPieces() const;
|
|
|
|
QVector<int> pieceAvailability() const;
|
|
|
|
qreal distributedCopies() const;
|
2017-09-06 22:47:05 +03:00
|
|
|
qreal maxRatio() const;
|
|
|
|
int maxSeedingTime() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
qreal realRatio() const;
|
|
|
|
int uploadPayloadRate() const;
|
|
|
|
int downloadPayloadRate() const;
|
2015-10-25 21:59:12 +03:00
|
|
|
qlonglong totalPayloadUpload() const;
|
|
|
|
qlonglong totalPayloadDownload() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
int connectionsCount() const;
|
|
|
|
int connectionsLimit() const;
|
|
|
|
qlonglong nextAnnounce() const;
|
|
|
|
|
|
|
|
void setName(const QString &name);
|
2019-04-01 11:39:29 +03:00
|
|
|
void setSequentialDownload(bool enable);
|
2015-04-19 18:17:47 +03:00
|
|
|
void toggleSequentialDownload();
|
2018-05-09 17:10:47 +03:00
|
|
|
void setFirstLastPiecePriority(bool enabled);
|
2015-11-26 15:08:01 +03:00
|
|
|
void toggleFirstLastPiecePriority();
|
2015-04-19 18:17:47 +03:00
|
|
|
void pause();
|
|
|
|
void resume(bool forced = false);
|
|
|
|
void move(QString path);
|
|
|
|
void forceReannounce(int index = -1);
|
|
|
|
void forceDHTAnnounce();
|
|
|
|
void forceRecheck();
|
|
|
|
void renameFile(int index, const QString &name);
|
|
|
|
bool saveTorrentFile(const QString &path);
|
2019-03-06 08:58:07 +03:00
|
|
|
void prioritizeFiles(const QVector<DownloadPriority> &priorities);
|
2015-04-19 18:17:47 +03:00
|
|
|
void setRatioLimit(qreal limit);
|
2016-02-07 20:31:50 +03:00
|
|
|
void setSeedingTimeLimit(int limit);
|
2015-04-19 18:17:47 +03:00
|
|
|
void setUploadLimit(int limit);
|
|
|
|
void setDownloadLimit(int limit);
|
|
|
|
void setSuperSeeding(bool enable);
|
|
|
|
void flushCache();
|
2019-05-21 07:21:17 +03:00
|
|
|
void addTrackers(const QVector<TrackerEntry> &trackers);
|
|
|
|
void replaceTrackers(const QVector<TrackerEntry> &trackers);
|
2015-04-19 18:17:47 +03:00
|
|
|
void addUrlSeeds(const QList<QUrl> &urlSeeds);
|
|
|
|
void removeUrlSeeds(const QList<QUrl> &urlSeeds);
|
|
|
|
bool connectPeer(const PeerAddress &peerAddress);
|
|
|
|
|
|
|
|
QString toMagnetUri() const;
|
|
|
|
|
|
|
|
bool needSaveResumeData() const;
|
|
|
|
|
2015-09-25 10:52:25 +03:00
|
|
|
// Session interface
|
2019-05-09 07:45:52 +03:00
|
|
|
lt::torrent_handle nativeHandle() const;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2019-05-09 07:45:52 +03:00
|
|
|
void handleAlert(const lt::alert *a);
|
|
|
|
void handleStateUpdate(const lt::torrent_status &nativeStatus);
|
2015-09-25 10:52:25 +03:00
|
|
|
void handleTempPathChanged();
|
2016-02-09 11:56:48 +03:00
|
|
|
void handleCategorySavePathChanged();
|
2015-09-25 10:52:25 +03:00
|
|
|
void handleAppendExtensionToggled();
|
2018-08-23 14:55:27 +03:00
|
|
|
void saveResumeData();
|
2015-09-25 10:52:25 +03:00
|
|
|
|
2016-03-22 20:10:12 +03:00
|
|
|
/**
|
|
|
|
* @brief fraction of file pieces that are available at least from one peer
|
|
|
|
*
|
|
|
|
* This is not the same as torrrent availability, it is just a fraction of pieces
|
|
|
|
* that can be downloaded right now. It varies between 0 to 1.
|
|
|
|
*/
|
|
|
|
QVector<qreal> availableFileFractions() const;
|
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
private:
|
2019-01-06 14:11:05 +03:00
|
|
|
typedef std::function<void ()> EventTrigger;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
|
|
|
void updateStatus();
|
2019-05-09 07:45:52 +03:00
|
|
|
void updateStatus(const lt::torrent_status &nativeStatus);
|
2015-04-19 18:17:47 +03:00
|
|
|
void updateState();
|
|
|
|
void updateTorrentInfo();
|
|
|
|
|
2019-05-09 07:45:52 +03:00
|
|
|
void handleStorageMovedAlert(const lt::storage_moved_alert *p);
|
|
|
|
void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p);
|
|
|
|
void handleTrackerReplyAlert(const lt::tracker_reply_alert *p);
|
|
|
|
void handleTrackerWarningAlert(const lt::tracker_warning_alert *p);
|
|
|
|
void handleTrackerErrorAlert(const lt::tracker_error_alert *p);
|
|
|
|
void handleTorrentCheckedAlert(const lt::torrent_checked_alert *p);
|
|
|
|
void handleTorrentFinishedAlert(const lt::torrent_finished_alert *p);
|
|
|
|
void handleTorrentPausedAlert(const lt::torrent_paused_alert *p);
|
|
|
|
void handleTorrentResumedAlert(const lt::torrent_resumed_alert *p);
|
|
|
|
void handleSaveResumeDataAlert(const lt::save_resume_data_alert *p);
|
|
|
|
void handleSaveResumeDataFailedAlert(const lt::save_resume_data_failed_alert *p);
|
|
|
|
void handleFastResumeRejectedAlert(const lt::fastresume_rejected_alert *p);
|
|
|
|
void handleFileRenamedAlert(const lt::file_renamed_alert *p);
|
|
|
|
void handleFileRenameFailedAlert(const lt::file_rename_failed_alert *p);
|
|
|
|
void handleFileCompletedAlert(const lt::file_completed_alert *p);
|
|
|
|
void handleMetadataReceivedAlert(const lt::metadata_received_alert *p);
|
|
|
|
void handleStatsAlert(const lt::stats_alert *p);
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2019-02-01 08:49:33 +03:00
|
|
|
void resume_impl(bool forced);
|
2015-04-19 18:17:47 +03:00
|
|
|
bool isMoveInProgress() const;
|
|
|
|
QString nativeActualSavePath() const;
|
2019-04-01 11:39:29 +03:00
|
|
|
bool isAutoManaged() const;
|
|
|
|
void setAutoManaged(bool enable);
|
2015-04-19 18:17:47 +03:00
|
|
|
|
|
|
|
void adjustActualSavePath();
|
2015-06-12 15:37:52 +03:00
|
|
|
void adjustActualSavePath_impl();
|
2017-08-05 15:51:53 +03:00
|
|
|
void move_impl(QString path, bool overwrite);
|
|
|
|
void moveStorage(const QString &newPath, bool overwrite);
|
2016-04-25 15:30:41 +03:00
|
|
|
void manageIncompleteFiles();
|
2015-04-19 18:17:47 +03:00
|
|
|
bool addUrlSeed(const QUrl &urlSeed);
|
|
|
|
bool removeUrlSeed(const QUrl &urlSeed);
|
2019-03-06 08:58:07 +03:00
|
|
|
void setFirstLastPiecePriorityImpl(bool enabled, const QVector<DownloadPriority> &updatedFilePrio = {});
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2015-09-25 10:52:25 +03:00
|
|
|
Session *const m_session;
|
2019-05-09 07:45:52 +03:00
|
|
|
lt::torrent_handle m_nativeHandle;
|
|
|
|
lt::torrent_status m_nativeStatus;
|
2016-01-04 16:00:50 +03:00
|
|
|
TorrentState m_state;
|
2015-04-19 18:17:47 +03:00
|
|
|
TorrentInfo m_torrentInfo;
|
|
|
|
SpeedMonitor m_speedMonitor;
|
|
|
|
|
|
|
|
InfoHash m_hash;
|
|
|
|
|
2017-08-05 15:51:53 +03:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
QString oldPath;
|
|
|
|
QString newPath;
|
|
|
|
// queuedPath is where files should be moved to,
|
|
|
|
// when current moving is completed
|
|
|
|
QString queuedPath;
|
|
|
|
bool queuedOverwrite = true;
|
|
|
|
} m_moveStorageInfo;
|
|
|
|
|
2015-07-22 11:41:00 +03:00
|
|
|
// m_moveFinishedTriggers is activated only when the following conditions are met:
|
|
|
|
// all file rename jobs complete, all file move jobs complete
|
|
|
|
QQueue<EventTrigger> m_moveFinishedTriggers;
|
|
|
|
int m_renameCount;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
2016-05-08 22:47:50 +03:00
|
|
|
bool m_useAutoTMM;
|
2016-02-09 11:56:48 +03:00
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
// Persistent data
|
|
|
|
QString m_name;
|
|
|
|
QString m_savePath;
|
2016-02-09 11:56:48 +03:00
|
|
|
QString m_category;
|
2017-06-05 03:22:17 +03:00
|
|
|
QSet<QString> m_tags;
|
2015-04-19 18:17:47 +03:00
|
|
|
bool m_hasSeedStatus;
|
|
|
|
qreal m_ratioLimit;
|
2016-02-07 20:31:50 +03:00
|
|
|
int m_seedingTimeLimit;
|
2015-04-19 18:17:47 +03:00
|
|
|
bool m_tempPathDisabled;
|
|
|
|
bool m_hasMissingFiles;
|
2016-01-04 16:00:50 +03:00
|
|
|
bool m_hasRootFolder;
|
2016-07-15 05:15:10 +03:00
|
|
|
bool m_needsToSetFirstLastPiecePriority;
|
2018-09-05 15:59:22 +03:00
|
|
|
bool m_needsToStartForced;
|
2015-04-19 18:17:47 +03:00
|
|
|
|
|
|
|
QHash<QString, TrackerInfo> m_trackerInfos;
|
2018-07-11 15:44:15 +03:00
|
|
|
|
2018-09-05 15:59:22 +03:00
|
|
|
enum StartupState
|
|
|
|
{
|
|
|
|
NotStarted,
|
|
|
|
Starting,
|
|
|
|
Started
|
|
|
|
};
|
|
|
|
|
|
|
|
StartupState m_startupState = NotStarted;
|
2018-09-11 14:43:08 +03:00
|
|
|
bool m_unchecked = false;
|
2015-04-19 18:17:47 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-02-18 03:38:40 +03:00
|
|
|
Q_DECLARE_METATYPE(BitTorrent::TorrentState)
|
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
#endif // BITTORRENT_TORRENTHANDLE_H
|