qBittorrent
session.h
Go to the documentation of this file.
1 /*
2  * Bittorrent Client using Qt and libtorrent.
3  * Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
4  * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * In addition, as a special exception, the copyright holders give permission to
21  * link this program with the OpenSSL project's "OpenSSL" library (or with
22  * modified versions of it that use the same license as the "OpenSSL" library),
23  * and distribute the linked executables. You must obey the GNU General Public
24  * License in all respects for all of the code used other than "OpenSSL". If you
25  * modify file(s), you may extend this exception to your version of the file(s),
26  * but you are not obligated to do so. If you do not wish to do so, delete this
27  * exception statement from your version.
28  */
29 
30 #pragma once
31 
32 #include <memory>
33 #include <variant>
34 #include <vector>
35 
36 #include <libtorrent/add_torrent_params.hpp>
37 #include <libtorrent/fwd.hpp>
38 #include <libtorrent/torrent_handle.hpp>
39 
40 #include <QHash>
41 #include <QPointer>
42 #include <QSet>
43 #include <QtContainerFwd>
44 #include <QVector>
45 
46 #include "base/settingvalue.h"
47 #include "base/types.h"
48 #include "addtorrentparams.h"
49 #include "cachestatus.h"
50 #include "categoryoptions.h"
51 #include "sessionstatus.h"
52 #include "torrentinfo.h"
53 #include "trackerentry.h"
54 
55 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
56 class QNetworkConfiguration;
57 class QNetworkConfigurationManager;
58 #endif
59 class QString;
60 class QThread;
61 class QTimer;
62 class QUrl;
63 
64 class BandwidthScheduler;
65 class FileSearcher;
66 class FilterParserThread;
67 class Statistics;
68 
69 // These values should remain unchanged when adding new items
70 // so as not to break the existing user settings.
72 {
73  Pause = 0,
74  Remove = 1,
77 };
78 
80 {
83 };
84 
85 namespace Net
86 {
87  struct DownloadResult;
88 }
89 
90 namespace BitTorrent
91 {
92  class InfoHash;
93  class MagnetUri;
94  class ResumeDataStorage;
95  class Torrent;
96  class TorrentImpl;
97  class Tracker;
98  struct LoadTorrentParams;
99 
100  enum class MoveStorageMode;
101 
102  // Using `Q_ENUM_NS()` without a wrapper namespace in our case is not advised
103  // since `Q_NAMESPACE` cannot be used when the same namespace resides at different files.
104  // https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/#comment-143779
105  inline namespace SessionSettingsEnums
106  {
107  Q_NAMESPACE
108 
109  enum class BTProtocol : int
110  {
111  Both = 0,
112  TCP = 1,
113  UTP = 2
114  };
115  Q_ENUM_NS(BTProtocol)
116 
117  enum class ChokingAlgorithm : int
118  {
119  FixedSlots = 0,
120  RateBased = 1
121  };
122  Q_ENUM_NS(ChokingAlgorithm)
123 
124  enum class MixedModeAlgorithm : int
125  {
126  TCP = 0,
127  Proportional = 1
128  };
129  Q_ENUM_NS(MixedModeAlgorithm)
130 
131  enum class SeedChokingAlgorithm : int
132  {
133  RoundRobin = 0,
134  FastestUpload = 1,
135  AntiLeech = 2
136  };
137  Q_ENUM_NS(SeedChokingAlgorithm)
138 
140  {
141  Legacy,
142  SQLite
143  };
144  Q_ENUM_NS(ResumeDataStorageType)
145 
146 #if defined(Q_OS_WIN)
147  enum class OSMemoryPriority : int
148  {
149  Normal = 0,
150  BelowNormal = 1,
151  Medium = 2,
152  Low = 3,
153  VeryLow = 4
154  };
155  Q_ENUM_NS(OSMemoryPriority)
156 #endif
157  }
158 
160  {
161  struct
162  {
166  int sentBytes = -1;
167  int recvBytes = -1;
173  int recvFailedBytes = -1;
174  } net;
175 
176  struct
177  {
179  int numPeersUpDisk = -1;
181  } peer;
182 
183  struct
184  {
185  int dhtBytesIn = -1;
186  int dhtBytesOut = -1;
187  int dhtNodes = -1;
188  } dht;
189 
190  struct
191  {
192  int diskBlocksInUse = -1;
193  int numBlocksRead = -1;
194 #ifndef QBT_USES_LIBTORRENT2
196 #endif
197  int writeJobs = -1;
198  int readJobs = -1;
199  int hashJobs = -1;
200  int queuedDiskJobs = -1;
201  int diskJobTime = -1;
202  } disk;
203  };
204 
205  class Session : public QObject
206  {
207  Q_OBJECT
208  Q_DISABLE_COPY_MOVE(Session)
209 
210  public:
211  static void initInstance();
212  static void freeInstance();
213  static Session *instance();
214 
215  QString savePath() const;
216  void setSavePath(const QString &path);
217  QString downloadPath() const;
218  void setDownloadPath(const QString &path);
219  bool isDownloadPathEnabled() const;
220  void setDownloadPathEnabled(bool enabled);
221 
222  static bool isValidCategoryName(const QString &name);
223  // returns category itself and all top level categories
224  static QStringList expandCategory(const QString &category);
225 
226  QStringList categories() const;
227  CategoryOptions categoryOptions(const QString &categoryName) const;
228  QString categorySavePath(const QString &categoryName) const;
229  QString categoryDownloadPath(const QString &categoryName) const;
230  bool addCategory(const QString &name, const CategoryOptions &options = {});
231  bool editCategory(const QString &name, const CategoryOptions &options);
232  bool removeCategory(const QString &name);
233  bool isSubcategoriesEnabled() const;
234  void setSubcategoriesEnabled(bool value);
235 
236  static bool isValidTag(const QString &tag);
237  QSet<QString> tags() const;
238  bool hasTag(const QString &tag) const;
239  bool addTag(const QString &tag);
240  bool removeTag(const QString &tag);
241 
242  // Torrent Management Mode subsystem (TMM)
243  //
244  // Each torrent can be either in Manual mode or in Automatic mode
245  // In Manual Mode various torrent properties are set explicitly(eg save path)
246  // In Automatic Mode various torrent properties are set implicitly(eg save path)
247  // based on the associated category.
248  // In Automatic Mode torrent save path can be changed in following cases:
249  // 1. Default save path changed
250  // 2. Torrent category save path changed
251  // 3. Torrent category changed
252  // (unless otherwise is specified)
253  bool isAutoTMMDisabledByDefault() const;
261 
262  qreal globalMaxRatio() const;
263  void setGlobalMaxRatio(qreal ratio);
264  int globalMaxSeedingMinutes() const;
265  void setGlobalMaxSeedingMinutes(int minutes);
266  bool isDHTEnabled() const;
267  void setDHTEnabled(bool enabled);
268  bool isLSDEnabled() const;
269  void setLSDEnabled(bool enabled);
270  bool isPeXEnabled() const;
271  void setPeXEnabled(bool enabled);
272  bool isAddTorrentPaused() const;
273  void setAddTorrentPaused(bool value);
276  bool isTrackerEnabled() const;
277  void setTrackerEnabled(bool enabled);
278  bool isAppendExtensionEnabled() const;
279  void setAppendExtensionEnabled(bool enabled);
280  int refreshInterval() const;
281  void setRefreshInterval(int value);
282  bool isPreallocationEnabled() const;
283  void setPreallocationEnabled(bool enabled);
284  QString torrentExportDirectory() const;
285  void setTorrentExportDirectory(QString path);
286  QString finishedTorrentExportDirectory() const;
287  void setFinishedTorrentExportDirectory(QString path);
288 
289  int globalDownloadSpeedLimit() const;
290  void setGlobalDownloadSpeedLimit(int limit);
291  int globalUploadSpeedLimit() const;
292  void setGlobalUploadSpeedLimit(int limit);
293  int altGlobalDownloadSpeedLimit() const;
294  void setAltGlobalDownloadSpeedLimit(int limit);
295  int altGlobalUploadSpeedLimit() const;
296  void setAltGlobalUploadSpeedLimit(int limit);
297  int downloadSpeedLimit() const;
298  void setDownloadSpeedLimit(int limit);
299  int uploadSpeedLimit() const;
300  void setUploadSpeedLimit(int limit);
301  bool isAltGlobalSpeedLimitEnabled() const;
302  void setAltGlobalSpeedLimitEnabled(bool enabled);
303  bool isBandwidthSchedulerEnabled() const;
304  void setBandwidthSchedulerEnabled(bool enabled);
305 
306  int saveResumeDataInterval() const;
308  int port() const;
309  void setPort(int port);
310  QString networkInterface() const;
311  void setNetworkInterface(const QString &iface);
312  QString networkInterfaceName() const;
313  void setNetworkInterfaceName(const QString &name);
314  QString networkInterfaceAddress() const;
315  void setNetworkInterfaceAddress(const QString &address);
316  int encryption() const;
317  void setEncryption(int state);
318  bool isProxyPeerConnectionsEnabled() const;
319  void setProxyPeerConnectionsEnabled(bool enabled);
324  bool isAddTrackersEnabled() const;
325  void setAddTrackersEnabled(bool enabled);
326  QString additionalTrackers() const;
327  void setAdditionalTrackers(const QString &trackers);
328  bool isIPFilteringEnabled() const;
329  void setIPFilteringEnabled(bool enabled);
330  QString IPFilterFile() const;
331  void setIPFilterFile(QString path);
332  bool announceToAllTrackers() const;
333  void setAnnounceToAllTrackers(bool val);
334  bool announceToAllTiers() const;
335  void setAnnounceToAllTiers(bool val);
336  int peerTurnover() const;
337  void setPeerTurnover(int num);
338  int peerTurnoverCutoff() const;
339  void setPeerTurnoverCutoff(int num);
340  int peerTurnoverInterval() const;
341  void setPeerTurnoverInterval(int num);
342  int asyncIOThreads() const;
343  void setAsyncIOThreads(int num);
344  int hashingThreads() const;
345  void setHashingThreads(int num);
346  int filePoolSize() const;
347  void setFilePoolSize(int size);
348  int checkingMemUsage() const;
349  void setCheckingMemUsage(int size);
350  int diskCacheSize() const;
351  void setDiskCacheSize(int size);
352  int diskCacheTTL() const;
353  void setDiskCacheTTL(int ttl);
354  bool useOSCache() const;
355  void setUseOSCache(bool use);
356  bool isCoalesceReadWriteEnabled() const;
357  void setCoalesceReadWriteEnabled(bool enabled);
358  bool usePieceExtentAffinity() const;
359  void setPieceExtentAffinity(bool enabled);
360  bool isSuggestModeEnabled() const;
361  void setSuggestMode(bool mode);
362  int sendBufferWatermark() const;
363  void setSendBufferWatermark(int value);
364  int sendBufferLowWatermark() const;
366  int sendBufferWatermarkFactor() const;
368  int connectionSpeed() const;
369  void setConnectionSpeed(int value);
370  int socketBacklogSize() const;
371  void setSocketBacklogSize(int value);
372  bool isAnonymousModeEnabled() const;
373  void setAnonymousModeEnabled(bool enabled);
374  bool isQueueingSystemEnabled() const;
375  void setQueueingSystemEnabled(bool enabled);
376  bool ignoreSlowTorrentsForQueueing() const;
377  void setIgnoreSlowTorrentsForQueueing(bool ignore);
378  int downloadRateForSlowTorrents() const;
379  void setDownloadRateForSlowTorrents(int rateInKibiBytes);
380  int uploadRateForSlowTorrents() const;
381  void setUploadRateForSlowTorrents(int rateInKibiBytes);
382  int slowTorrentsInactivityTimer() const;
383  void setSlowTorrentsInactivityTimer(int timeInSeconds);
384  int outgoingPortsMin() const;
385  void setOutgoingPortsMin(int min);
386  int outgoingPortsMax() const;
387  void setOutgoingPortsMax(int max);
388  int UPnPLeaseDuration() const;
389  void setUPnPLeaseDuration(int duration);
390  int peerToS() const;
391  void setPeerToS(int value);
392  bool ignoreLimitsOnLAN() const;
393  void setIgnoreLimitsOnLAN(bool ignore);
394  bool includeOverheadInLimits() const;
395  void setIncludeOverheadInLimits(bool include);
396  QString announceIP() const;
397  void setAnnounceIP(const QString &ip);
398  int maxConcurrentHTTPAnnounces() const;
401  void setReannounceWhenAddressChangedEnabled(bool enabled);
402  void reannounceToAllTrackers() const;
403  int stopTrackerTimeout() const;
404  void setStopTrackerTimeout(int value);
405  int maxConnections() const;
406  void setMaxConnections(int max);
407  int maxConnectionsPerTorrent() const;
408  void setMaxConnectionsPerTorrent(int max);
409  int maxUploads() const;
410  void setMaxUploads(int max);
411  int maxUploadsPerTorrent() const;
412  void setMaxUploadsPerTorrent(int max);
413  int maxActiveDownloads() const;
414  void setMaxActiveDownloads(int max);
415  int maxActiveUploads() const;
416  void setMaxActiveUploads(int max);
417  int maxActiveTorrents() const;
418  void setMaxActiveTorrents(int max);
419  BTProtocol btProtocol() const;
420  void setBTProtocol(BTProtocol protocol);
421  bool isUTPRateLimited() const;
422  void setUTPRateLimited(bool limited);
425  bool isIDNSupportEnabled() const;
426  void setIDNSupportEnabled(bool enabled);
427  bool multiConnectionsPerIpEnabled() const;
428  void setMultiConnectionsPerIpEnabled(bool enabled);
429  bool validateHTTPSTrackerCertificate() const;
430  void setValidateHTTPSTrackerCertificate(bool enabled);
431  bool isSSRFMitigationEnabled() const;
432  void setSSRFMitigationEnabled(bool enabled);
433  bool blockPeersOnPrivilegedPorts() const;
434  void setBlockPeersOnPrivilegedPorts(bool enabled);
435  bool isTrackerFilteringEnabled() const;
436  void setTrackerFilteringEnabled(bool enabled);
437  QStringList bannedIPs() const;
438  void setBannedIPs(const QStringList &newList);
441 #if defined(Q_OS_WIN)
442  OSMemoryPriority getOSMemoryPriority() const;
443  void setOSMemoryPriority(OSMemoryPriority priority);
444 #endif
445 
446  void startUpTorrents();
447  Torrent *findTorrent(const TorrentID &id) const;
448  QVector<Torrent *> torrents() const;
449  bool hasActiveTorrents() const;
450  bool hasUnfinishedTorrents() const;
451  bool hasRunningSeed() const;
452  const SessionStatus &status() const;
453  const CacheStatus &cacheStatus() const;
454  quint64 getAlltimeDL() const;
455  quint64 getAlltimeUL() const;
456  bool isListening() const;
457 
460 
461  void banIP(const QString &ip);
462 
463  bool isKnownTorrent(const TorrentID &id) const;
464  bool addTorrent(const QString &source, const AddTorrentParams &params = AddTorrentParams());
465  bool addTorrent(const MagnetUri &magnetUri, const AddTorrentParams &params = AddTorrentParams());
466  bool addTorrent(const TorrentInfo &torrentInfo, const AddTorrentParams &params = AddTorrentParams());
467  bool deleteTorrent(const TorrentID &id, DeleteOption deleteOption = DeleteTorrent);
468  bool downloadMetadata(const MagnetUri &magnetUri);
469  bool cancelDownloadMetadata(const TorrentID &id);
470 
471  void recursiveTorrentDownload(const TorrentID &id);
472  void increaseTorrentsQueuePos(const QVector<TorrentID> &ids);
473  void decreaseTorrentsQueuePos(const QVector<TorrentID> &ids);
474  void topTorrentsQueuePos(const QVector<TorrentID> &ids);
475  void bottomTorrentsQueuePos(const QVector<TorrentID> &ids);
476 
477  // Torrent interface
478  void handleTorrentNeedSaveResumeData(const TorrentImpl *torrent);
480  void handleTorrentShareLimitChanged(TorrentImpl *const torrent);
481  void handleTorrentNameChanged(TorrentImpl *const torrent);
482  void handleTorrentSavePathChanged(TorrentImpl *const torrent);
483  void handleTorrentCategoryChanged(TorrentImpl *const torrent, const QString &oldCategory);
484  void handleTorrentTagAdded(TorrentImpl *const torrent, const QString &tag);
485  void handleTorrentTagRemoved(TorrentImpl *const torrent, const QString &tag);
486  void handleTorrentSavingModeChanged(TorrentImpl *const torrent);
487  void handleTorrentMetadataReceived(TorrentImpl *const torrent);
488  void handleTorrentPaused(TorrentImpl *const torrent);
489  void handleTorrentResumed(TorrentImpl *const torrent);
490  void handleTorrentChecked(TorrentImpl *const torrent);
491  void handleTorrentFinished(TorrentImpl *const torrent);
492  void handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector<TrackerEntry> &newTrackers);
493  void handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector<TrackerEntry> &deletedTrackers);
494  void handleTorrentTrackersChanged(TorrentImpl *const torrent);
495  void handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector<QUrl> &newUrlSeeds);
496  void handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector<QUrl> &urlSeeds);
497  void handleTorrentResumeDataReady(TorrentImpl *const torrent, const LoadTorrentParams &data);
498  void handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl);
499  void handleTorrentTrackerWarning(TorrentImpl *const torrent, const QString &trackerUrl);
500  void handleTorrentTrackerError(TorrentImpl *const torrent, const QString &trackerUrl);
501 
502  bool addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newPath, MoveStorageMode mode);
503 
504  void findIncompleteFiles(const TorrentInfo &torrentInfo, const QString &savePath
505  , const QString &downloadPath, const QStringList &filePaths = {}) const;
506 
507  signals:
509  void categoryAdded(const QString &categoryName);
510  void categoryRemoved(const QString &categoryName);
511  void downloadFromUrlFailed(const QString &url, const QString &reason);
512  void downloadFromUrlFinished(const QString &url);
513  void fullDiskError(Torrent *torrent, const QString &msg);
514  void IPFilterParsed(bool error, int ruleCount);
515  void loadTorrentFailed(const QString &error);
516  void metadataDownloaded(const TorrentInfo &info);
518  void speedLimitModeChanged(bool alternative);
519  void statsUpdated();
521  void tagAdded(const QString &tag);
522  void tagRemoved(const QString &tag);
524  void torrentAdded(Torrent *torrent);
525  void torrentCategoryChanged(Torrent *torrent, const QString &oldCategory);
526  void torrentFinished(Torrent *torrent);
528  void torrentLoaded(Torrent *torrent);
530  void torrentPaused(Torrent *torrent);
531  void torrentResumed(Torrent *torrent);
534  void torrentsUpdated(const QVector<Torrent *> &torrents);
535  void torrentTagAdded(Torrent *torrent, const QString &tag);
536  void torrentTagRemoved(Torrent *torrent, const QString &tag);
537  void trackerError(Torrent *torrent, const QString &tracker);
538  void trackerlessStateChanged(Torrent *torrent, bool trackerless);
539  void trackersAdded(Torrent *torrent, const QVector<TrackerEntry> &trackers);
540  void trackersChanged(Torrent *torrent);
541  void trackersRemoved(Torrent *torrent, const QVector<TrackerEntry> &trackers);
542  void trackerSuccess(Torrent *torrent, const QString &tracker);
543  void trackerWarning(Torrent *torrent, const QString &tracker);
544 
545  private slots:
546  void configureDeferred();
547  void readAlerts();
548  void enqueueRefresh();
549  void processShareLimits();
550  void generateResumeData();
551  void handleIPFilterParsed(int ruleCount);
552  void handleIPFilterError();
553  void handleDownloadFinished(const Net::DownloadResult &result);
554  void fileSearchFinished(const TorrentID &id, const QString &savePath, const QStringList &fileNames);
555 
556 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
557  // Session reconfiguration triggers
558  void networkOnlineStateChanged(bool online);
559  void networkConfigurationChange(const QNetworkConfiguration &);
560 #endif
561 
562  private:
564  {
565  lt::torrent_handle torrentHandle;
566  QString path;
568  };
569 
571  {
572  QString name;
573  QString pathToRemove;
575  };
576 
577  explicit Session(QObject *parent = nullptr);
578  ~Session();
579 
580  bool hasPerTorrentRatioLimit() const;
581  bool hasPerTorrentSeedingTimeLimit() const;
582 
583  // Session configuration
584  Q_INVOKABLE void configure();
585  void configureComponents();
587  void loadLTSettings(lt::settings_pack &settingsPack);
588  void configureNetworkInterfaces(lt::settings_pack &settingsPack);
589  void configurePeerClasses();
590  void adjustLimits(lt::settings_pack &settingsPack) const;
591  void applyBandwidthLimits(lt::settings_pack &settingsPack) const;
592  void initMetrics();
593  void adjustLimits();
594  void applyBandwidthLimits();
595  void processBannedIPs(lt::ip_filter &filter);
596  QStringList getListeningIPs() const;
598  void enableTracker(bool enable);
601  void enableIPFilter();
602  void disableIPFilter();
603 #if defined(Q_OS_WIN)
604  void applyOSMemoryPriority() const;
605 #endif
606 
607  bool loadTorrent(LoadTorrentParams params);
609  bool addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source, const AddTorrentParams &addTorrentParams);
610 
612  void exportTorrentFile(const TorrentInfo &torrentInfo, const QString &folderPath, const QString &baseName);
613 
614  void handleAlert(const lt::alert *a);
615  void dispatchTorrentAlert(const lt::alert *a);
616  void handleAddTorrentAlert(const lt::add_torrent_alert *p);
617  void handleStateUpdateAlert(const lt::state_update_alert *p);
618  void handleMetadataReceivedAlert(const lt::metadata_received_alert *p);
619  void handleFileErrorAlert(const lt::file_error_alert *p);
620  void handleTorrentRemovedAlert(const lt::torrent_removed_alert *p);
621  void handleTorrentDeletedAlert(const lt::torrent_deleted_alert *p);
622  void handleTorrentDeleteFailedAlert(const lt::torrent_delete_failed_alert *p);
623  void handlePortmapWarningAlert(const lt::portmap_error_alert *p);
624  void handlePortmapAlert(const lt::portmap_alert *p);
625  void handlePeerBlockedAlert(const lt::peer_blocked_alert *p);
626  void handlePeerBanAlert(const lt::peer_ban_alert *p);
627  void handleUrlSeedAlert(const lt::url_seed_alert *p);
628  void handleListenSucceededAlert(const lt::listen_succeeded_alert *p);
629  void handleListenFailedAlert(const lt::listen_failed_alert *p);
630  void handleExternalIPAlert(const lt::external_ip_alert *p);
631  void handleSessionStatsAlert(const lt::session_stats_alert *p);
632  void handleAlertsDroppedAlert(const lt::alerts_dropped_alert *p) const;
633  void handleStorageMovedAlert(const lt::storage_moved_alert *p);
634  void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p);
635  void handleSocks5Alert(const lt::socks5_alert *p) const;
636 
637  void createTorrent(const lt::torrent_handle &nativeHandle);
638 
639  void saveResumeData();
640  void saveTorrentsQueue() const;
641  void removeTorrentsQueue() const;
642 
643  std::vector<lt::alert *> getPendingAlerts(lt::time_duration time = lt::time_duration::zero()) const;
644 
645  void moveTorrentStorage(const MoveStorageJob &job) const;
647 
648  void loadCategories();
649  void storeCategories() const;
650  void upgradeCategories();
651 
652  // BitTorrent
653  lt::session *m_nativeSession = nullptr;
654 
658 
755 #if defined(Q_OS_WIN)
756  CachedSettingValue<OSMemoryPriority> m_OSMemoryPriority;
757 #endif
758 
759  // Order is important. This needs to be declared after its CachedSettingsValue
760  // counterpart, because it uses it for initialization in the constructor
761  // initialization list.
763 
765  int m_extraLimit = 0;
766  QVector<TrackerEntry> m_additionalTrackerList;
767 
768  bool m_refreshEnqueued = false;
769  QTimer *m_seedingLimitTimer = nullptr;
770  QTimer *m_resumeDataTimer = nullptr;
772  // IP filtering
773  QPointer<FilterParserThread> m_filterParser;
774  QPointer<BandwidthScheduler> m_bwScheduler;
775  // Tracker
776  QPointer<Tracker> m_tracker;
777 
778  QThread *m_ioThread = nullptr;
781 
782  QSet<TorrentID> m_downloadedMetadata;
783 
784  QHash<TorrentID, TorrentImpl *> m_torrents;
785  QHash<TorrentID, LoadTorrentParams> m_loadingTorrents;
786  QHash<QString, AddTorrentParams> m_downloadedTorrents;
787  QHash<TorrentID, RemovingTorrentData> m_removingTorrents;
789  QMap<QString, CategoryOptions> m_categories;
790  QSet<QString> m_tags;
791 
792  // I/O errored torrents
793  QSet<TorrentID> m_recentErroredTorrents;
794  QTimer *m_recentErroredTorrentsTimer = nullptr;
795 
797  lt::time_point m_statsLastTimestamp = lt::clock_type::now();
798 
801 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
802  QNetworkConfigurationManager *m_networkManager = nullptr;
803 #endif
804 
805  QList<MoveStorageJob> m_moveStorageQueue;
806 
808 
810 
812  };
813 }
void reannounceToAllTrackers() const
Definition: session.cpp:3656
int refreshInterval() const
Definition: session.cpp:573
void populateAdditionalTrackers()
Definition: session.cpp:1589
CachedSettingValue< int > m_globalMaxSeedingMinutes
Definition: session.h:716
void handleAddTorrentAlert(const lt::add_torrent_alert *p)
Definition: session.cpp:4646
QString networkInterfaceName() const
Definition: session.cpp:2813
void handleTorrentUrlSeedsAdded(TorrentImpl *const torrent, const QVector< QUrl > &newUrlSeeds)
Definition: session.cpp:3925
QSet< QString > m_tags
Definition: session.h:790
CachedSettingValue< int > m_stopTrackerTimeout
Definition: session.h:700
bool removeTag(const QString &tag)
Definition: session.cpp:850
void loadLTSettings(lt::settings_pack &settingsPack)
Definition: session.cpp:1188
void setAddTrackersEnabled(bool enabled)
Definition: session.cpp:2899
bool blockPeersOnPrivilegedPorts() const
Definition: session.cpp:3801
QString additionalTrackers() const
Definition: session.cpp:2904
CachedSettingValue< int > m_socketBacklogSize
Definition: session.h:681
void setDiskCacheTTL(int ttl)
Definition: session.cpp:3268
void setOutgoingPortsMax(int max)
Definition: session.cpp:3550
bool m_IPFilteringConfigured
Definition: session.h:656
void setGlobalMaxSeedingMinutes(int minutes)
Definition: session.cpp:952
void setPeerTurnoverInterval(int num)
Definition: session.cpp:3170
CachedSettingValue< SeedChokingAlgorithm > m_seedChokingAlgorithm
Definition: session.h:738
std::vector< lt::alert * > getPendingAlerts(lt::time_duration time=lt::time_duration::zero()) const
Definition: session.cpp:4454
void subcategoriesSupportChanged()
QSet< TorrentID > m_needSaveResumeDataTorrents
Definition: session.h:788
void setBannedIPs(const QStringList &newList)
Definition: session.cpp:2949
void setDownloadRateForSlowTorrents(int rateInKibiBytes)
Definition: session.cpp:3494
void handleSessionStatsAlert(const lt::session_stats_alert *p)
Definition: session.cpp:4884
void handlePeerBanAlert(const lt::peer_ban_alert *p)
Definition: session.cpp:4823
bool isListening() const
Definition: session.cpp:3828
void setIPFilterFile(QString path)
Definition: session.cpp:2938
void handleTorrentChecked(TorrentImpl *const torrent)
Definition: session.cpp:3963
CachedSettingValue< QStringList > m_bannedIPs
Definition: session.h:753
QString torrentExportDirectory() const
Definition: session.cpp:596
QStringList getListeningIPs() const
Definition: session.cpp:2491
void torrentTagAdded(Torrent *torrent, const QString &tag)
void setTorrentExportDirectory(QString path)
Definition: session.cpp:601
void handleTorrentTagAdded(TorrentImpl *const torrent, const QString &tag)
Definition: session.cpp:3885
void handleTorrentCategoryChanged(TorrentImpl *const torrent, const QString &oldCategory)
Definition: session.cpp:3880
int maxActiveDownloads() const
Definition: session.cpp:3430
int peerTurnover() const
Definition: session.cpp:3137
CachedSettingValue< bool > m_isTrackerFilteringEnabled
Definition: session.h:663
void removeTorrentsQueue() const
Definition: session.cpp:2430
void setPort(int port)
Definition: session.cpp:2787
qreal globalMaxRatio() const
Definition: session.cpp:928
void handleTorrentTrackersRemoved(TorrentImpl *const torrent, const QVector< TrackerEntry > &deletedTrackers)
Definition: session.cpp:3910
void torrentSavingModeChanged(Torrent *torrent)
QString m_lastExternalIP
Definition: session.h:807
CachedSettingValue< int > m_saveResumeDataInterval
Definition: session.h:730
int maxActiveUploads() const
Definition: session.cpp:3445
QVector< Torrent * > torrents() const
Definition: session.cpp:1997
lt::time_point m_statsLastTimestamp
Definition: session.h:797
void handleAlertsDroppedAlert(const lt::alerts_dropped_alert *p) const
Definition: session.cpp:4960
int uploadSpeedLimit() const
Definition: session.cpp:2711
CachedSettingValue< bool > m_isLSDEnabled
Definition: session.h:660
void torrentPaused(Torrent *torrent)
bool cancelDownloadMetadata(const TorrentID &id)
Definition: session.cpp:1850
void setResumeDataStorageType(ResumeDataStorageType type)
Definition: session.cpp:2990
bool hasTag(const QString &tag) const
Definition: session.cpp:834
bool isTrackerFilteringEnabled() const
Definition: session.cpp:3814
void setTrackerEnabled(bool enabled)
Definition: session.cpp:918
bool isReannounceWhenAddressChangedEnabled() const
Definition: session.cpp:3643
bool isAltGlobalSpeedLimitEnabled() const
Definition: session.cpp:2726
CachedSettingValue< bool > m_isAltGlobalSpeedLimitEnabled
Definition: session.h:728
bool hasPerTorrentSeedingTimeLimit() const
Definition: session.cpp:4222
void setDisableAutoTMMWhenDefaultSavePathChanged(bool value)
Definition: session.cpp:888
int globalMaxSeedingMinutes() const
Definition: session.cpp:947
QTimer * m_resumeDataTimer
Definition: session.h:770
SeedChokingAlgorithm seedChokingAlgorithm() const
Definition: session.cpp:2881
void handlePeerBlockedAlert(const lt::peer_blocked_alert *p)
Definition: session.cpp:4793
void setMaxUploads(int max)
Definition: session.cpp:3696
int asyncIOThreads() const
Definition: session.cpp:3179
QVector< TrackerEntry > m_additionalTrackerList
Definition: session.h:766
void setConnectionSpeed(int value)
Definition: session.cpp:3374
static Session * instance()
Definition: session.cpp:997
QHash< TorrentID, LoadTorrentParams > m_loadingTorrents
Definition: session.h:785
CachedSettingValue< int > m_UPnPLeaseDuration
Definition: session.h:693
bool isTrackerEnabled() const
Definition: session.cpp:913
CachedSettingValue< int > m_peerTurnoverCutoff
Definition: session.h:751
void trackersAdded(Torrent *torrent, const QVector< TrackerEntry > &trackers)
CachedSettingValue< bool > m_isPreallocationEnabled
Definition: session.h:721
bool isIDNSupportEnabled() const
Definition: session.cpp:3749
bool addMoveTorrentStorageJob(TorrentImpl *torrent, const QString &newPath, MoveStorageMode mode)
Definition: session.cpp:4027
bool isDHTEnabled() const
Definition: session.cpp:498
CachedSettingValue< QString > m_savePath
Definition: session.h:741
CachedSettingValue< int > m_globalDownloadSpeedLimit
Definition: session.h:724
void torrentAboutToBeRemoved(Torrent *torrent)
void trackersChanged(Torrent *torrent)
void setIPFilteringEnabled(bool enabled)
Definition: session.cpp:2923
void handleStorageMovedFailedAlert(const lt::storage_moved_failed_alert *p)
Definition: session.cpp:4989
LoadTorrentParams initLoadTorrentParams(const AddTorrentParams &addTorrentParams)
Definition: session.cpp:2049
void applyBandwidthLimits()
Definition: session.cpp:1012
CachedSettingValue< bool > m_isReannounceWhenAddressChangedEnabled
Definition: session.h:699
void handleTorrentTrackerWarning(TorrentImpl *const torrent, const QString &trackerUrl)
Definition: session.cpp:4209
void handleTorrentSavingModeChanged(TorrentImpl *const torrent)
Definition: session.cpp:3895
void handleTorrentDeleteFailedAlert(const lt::torrent_delete_failed_alert *p)
Definition: session.cpp:4706
int sendBufferWatermark() const
Definition: session.cpp:3330
void setUploadSpeedLimit(int limit)
Definition: session.cpp:2718
void decreaseTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1889
int outgoingPortsMin() const
Definition: session.cpp:3531
void setUseOSCache(bool use)
Definition: session.cpp:3282
QThread * m_ioThread
Definition: session.h:778
bool m_listenInterfaceConfigured
Definition: session.h:657
void handleSocks5Alert(const lt::socks5_alert *p) const
Definition: session.cpp:5041
void setAsyncIOThreads(int num)
Definition: session.cpp:3184
int globalDownloadSpeedLimit() const
Definition: session.cpp:2596
QString networkInterface() const
Definition: session.cpp:2799
CachedSettingValue< int > m_refreshInterval
Definition: session.h:720
void setUTPRateLimited(bool limited)
Definition: session.cpp:3727
void setAnnounceIP(const QString &ip)
Definition: session.cpp:3620
bool isAddTorrentPaused() const
Definition: session.cpp:903
CachedSettingValue< bool > m_usePieceExtentAffinity
Definition: session.h:675
int slowTorrentsInactivityTimer() const
Definition: session.cpp:3517
void setStopTrackerTimeout(int value)
Definition: session.cpp:3667
static bool isValidCategoryName(const QString &name)
Definition: session.cpp:630
QString finishedTorrentExportDirectory() const
Definition: session.cpp:608
void setDownloadPathEnabled(bool enabled)
Definition: session.cpp:546
void setMaxRatioAction(MaxRatioAction act)
Definition: session.cpp:3838
CachedSettingValue< MixedModeAlgorithm > m_utpMixedMode
Definition: session.h:707
void fullDiskError(Torrent *torrent, const QString &msg)
void setTrackerFilteringEnabled(bool enabled)
Definition: session.cpp:3819
void setSendBufferLowWatermark(int value)
Definition: session.cpp:3348
QHash< TorrentID, RemovingTorrentData > m_removingTorrents
Definition: session.h:787
CachedSettingValue< bool > m_isAutoTMMDisabledByDefault
Definition: session.h:745
void setSuggestMode(bool mode)
Definition: session.cpp:3322
void handleTorrentMetadataReceived(TorrentImpl *const torrent)
Definition: session.cpp:3937
void trackersRemoved(Torrent *torrent, const QVector< TrackerEntry > &trackers)
void banIP(const QString &ip)
Definition: session.cpp:1771
void setUPnPLeaseDuration(int duration)
Definition: session.cpp:3564
int UPnPLeaseDuration() const
Definition: session.cpp:3559
CachedSettingValue< int > m_uploadRateForSlowTorrents
Definition: session.h:689
bool includeOverheadInLimits() const
Definition: session.cpp:3601
bool hasRunningSeed() const
Definition: session.cpp:1763
void setSSRFMitigationEnabled(bool enabled)
Definition: session.cpp:3793
int stopTrackerTimeout() const
Definition: session.cpp:3662
CachedSettingValue< bool > m_isAddTrackersEnabled
Definition: session.h:713
void setMultiConnectionsPerIpEnabled(bool enabled)
Definition: session.cpp:3767
void setHashingThreads(int num)
Definition: session.cpp:3198
CachedSettingValue< int > m_globalUploadSpeedLimit
Definition: session.h:725
CachedSettingValue< int > m_port
Definition: session.h:731
CachedSettingValue< bool > m_isIPFilteringEnabled
Definition: session.h:662
void setPieceExtentAffinity(bool enabled)
Definition: session.cpp:3314
void setAltGlobalUploadSpeedLimit(int limit)
Definition: session.cpp:2678
CachedSettingValue< QString > m_torrentExportDirectory
Definition: session.h:722
void initializeNativeSession()
Definition: session.cpp:1052
bool removeCategory(const QString &name)
Definition: session.cpp:760
void setMaxActiveUploads(int max)
Definition: session.cpp:3450
CachedSettingValue< bool > m_isDownloadPathEnabled
Definition: session.h:744
void setBandwidthSchedulerEnabled(bool enabled)
Definition: session.cpp:2747
void setAltGlobalDownloadSpeedLimit(int limit)
Definition: session.cpp:2653
void setReannounceWhenAddressChangedEnabled(bool enabled)
Definition: session.cpp:3648
CachedSettingValue< bool > m_isDisableAutoTMMWhenDefaultSavePathChanged
Definition: session.h:747
bool isDisableAutoTMMWhenCategoryChanged() const
Definition: session.cpp:873
int maxConnections() const
Definition: session.cpp:3676
CachedSettingValue< bool > m_isDHTEnabled
Definition: session.h:659
int diskCacheTTL() const
Definition: session.cpp:3263
CachedSettingValue< qreal > m_globalMaxRatio
Definition: session.h:715
int port() const
Definition: session.cpp:2782
CachedSettingValue< int > m_connectionSpeed
Definition: session.h:680
BTProtocol btProtocol() const
Definition: session.cpp:3706
QString downloadPath() const
Definition: session.cpp:625
void handleExternalIPAlert(const lt::external_ip_alert *p)
Definition: session.cpp:4870
void bottomTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1942
int outgoingPortsMax() const
Definition: session.cpp:3545
void setSaveResumeDataInterval(int value)
Definition: session.cpp:2764
void loadTorrentFailed(const QString &error)
void setSendBufferWatermark(int value)
Definition: session.cpp:3335
void handleFileErrorAlert(const lt::file_error_alert *p)
Definition: session.cpp:4759
CachedSettingValue< int > m_asyncIOThreads
Definition: session.h:667
CachedSettingValue< bool > m_isDisableAutoTMMWhenCategoryChanged
Definition: session.h:746
int altGlobalDownloadSpeedLimit() const
Definition: session.cpp:2646
QPointer< FilterParserThread > m_filterParser
Definition: session.h:773
void configureDeferred()
Definition: session.cpp:4230
CachedSettingValue< QString > m_networkInterfaceName
Definition: session.h:733
quint64 getAlltimeDL() const
Definition: session.cpp:4409
void setEncryption(int state)
Definition: session.cpp:2842
CachedSettingValue< QString > m_IPFilterFile
Definition: session.h:664
void setGlobalMaxRatio(qreal ratio)
Definition: session.cpp:935
int peerTurnoverCutoff() const
Definition: session.cpp:3151
FileSearcher * m_fileSearcher
Definition: session.h:780
void setDisableAutoTMMWhenCategoryChanged(bool value)
Definition: session.cpp:878
CachedSettingValue< int > m_maxConcurrentHTTPAnnounces
Definition: session.h:698
CachedSettingValue< QString > m_finishedTorrentExportDirectory
Definition: session.h:723
CachedSettingValue< int > m_maxActiveUploads
Definition: session.h:685
CachedSettingValue< int > m_altGlobalDownloadSpeedLimit
Definition: session.h:726
void torrentCategoryChanged(Torrent *torrent, const QString &oldCategory)
bool isPeXEnabled() const
Definition: session.cpp:529
CachedSettingValue< int > m_peerTurnover
Definition: session.h:750
void configureComponents()
Definition: session.cpp:1030
bool addTag(const QString &tag)
Definition: session.cpp:839
CachedSettingValue< bool > m_isSuggestMode
Definition: session.h:676
void setMaxConcurrentHTTPAnnounces(int value)
Definition: session.cpp:3634
bool isAddTrackersEnabled() const
Definition: session.cpp:2894
void moveTorrentStorage(const MoveStorageJob &job) const
Definition: session.cpp:4081
void torrentFinishedChecking(Torrent *torrent)
CachedSettingValue< int > m_slowTorrentsInactivityTimer
Definition: session.h:690
int peerToS() const
Definition: session.cpp:3573
void setSubcategoriesEnabled(bool value)
Definition: session.cpp:803
int sendBufferLowWatermark() const
Definition: session.cpp:3343
void exportTorrentFile(const TorrentInfo &torrentInfo, const QString &folderPath, const QString &baseName)
Definition: session.cpp:2340
Statistics * m_statistics
Definition: session.h:771
QList< MoveStorageJob > m_moveStorageQueue
Definition: session.h:805
void setAltGlobalSpeedLimitEnabled(bool enabled)
Definition: session.cpp:2731
bool announceToAllTiers() const
Definition: session.cpp:3123
bool isIPFilteringEnabled() const
Definition: session.cpp:2918
void handleMoveTorrentStorageJobFinished()
Definition: session.cpp:4097
int sendBufferWatermarkFactor() const
Definition: session.cpp:3356
CachedSettingValue< ResumeDataStorageType > m_resumeDataStorageType
Definition: session.h:754
CachedSettingValue< int > m_maxConnections
Definition: session.h:701
CachedSettingValue< int > m_checkingMemUsage
Definition: session.h:670
bool isSubcategoriesEnabled() const
Definition: session.cpp:798
void setBTProtocol(BTProtocol protocol)
Definition: session.cpp:3711
bool usePieceExtentAffinity() const
Definition: session.cpp:3309
void setDownloadPath(const QString &path)
Definition: session.cpp:2455
void setDiskCacheSize(int size)
Definition: session.cpp:3248
int connectionSpeed() const
Definition: session.cpp:3369
bool isPreallocationEnabled() const
Definition: session.cpp:586
CachedSettingValue< bool > m_useOSCache
Definition: session.h:673
void setFinishedTorrentExportDirectory(QString path)
Definition: session.cpp:613
void setSlowTorrentsInactivityTimer(int timeInSeconds)
Definition: session.cpp:3522
void setCheckingMemUsage(int size)
Definition: session.cpp:3226
int checkingMemUsage() const
Definition: session.cpp:3221
QTimer * m_seedingLimitTimer
Definition: session.h:769
CachedSettingValue< ChokingAlgorithm > m_chokingAlgorithm
Definition: session.h:737
CachedSettingValue< bool > m_isAppendExtensionEnabled
Definition: session.h:719
void setPeXEnabled(bool enabled)
Definition: session.cpp:534
CachedSettingValue< int > m_diskCacheTTL
Definition: session.h:672
QHash< TorrentID, TorrentImpl * > m_torrents
Definition: session.h:784
bool addCategory(const QString &name, const CategoryOptions &options={})
Definition: session.cpp:701
CachedSettingValue< int > m_sendBufferWatermarkFactor
Definition: session.h:679
int maxConnectionsPerTorrent() const
Definition: session.cpp:3061
void setProxyPeerConnectionsEnabled(bool enabled)
Definition: session.cpp:2859
void torrentTagRemoved(Torrent *torrent, const QString &tag)
CachedSettingValue< int > m_altGlobalUploadSpeedLimit
Definition: session.h:727
QString announceIP() const
Definition: session.cpp:3615
CachedSettingValue< int > m_maxUploads
Definition: session.h:702
void setRefreshInterval(int value)
Definition: session.cpp:578
CachedSettingValue< int > m_maxRatioAction
Definition: session.h:740
void setAnonymousModeEnabled(bool enabled)
Definition: session.cpp:3400
void configurePeerClasses()
Definition: session.cpp:1485
void enableTracker(bool enable)
Definition: session.cpp:1563
CachedSettingValue< QString > m_networkInterfaceAddress
Definition: session.h:734
void handleStateUpdateAlert(const lt::state_update_alert *p)
Definition: session.cpp:5012
CachedSettingValue< bool > m_IDNSupportEnabled
Definition: session.h:708
void setUtpMixedMode(MixedModeAlgorithm mode)
Definition: session.cpp:3741
void setFilePoolSize(int size)
Definition: session.cpp:3212
int hashingThreads() const
Definition: session.cpp:3193
void setDHTEnabled(bool enabled)
Definition: session.cpp:503
void processShareLimits()
Definition: session.cpp:1602
int peerTurnoverInterval() const
Definition: session.cpp:3165
quint64 getAlltimeUL() const
Definition: session.cpp:4414
bool hasActiveTorrents() const
Definition: session.cpp:1747
CachedSettingValue< int > m_peerTurnoverInterval
Definition: session.h:752
CachedSettingValue< bool > m_multiConnectionsPerIpEnabled
Definition: session.h:709
CachedSettingValue< int > m_encryption
Definition: session.h:735
bool ignoreLimitsOnLAN() const
Definition: session.cpp:3587
void setMaxActiveDownloads(int max)
Definition: session.cpp:3435
void setSavePath(const QString &path)
Definition: session.cpp:2435
void setSeedChokingAlgorithm(SeedChokingAlgorithm mode)
Definition: session.cpp:2886
bool isBandwidthSchedulerEnabled() const
Definition: session.cpp:2742
CachedSettingValue< bool > m_isDisableAutoTMMWhenCategorySavePathChanged
Definition: session.h:748
void handleTorrentSaveResumeDataRequested(const TorrentImpl *torrent)
Definition: session.cpp:1991
void handlePortmapAlert(const lt::portmap_alert *p)
Definition: session.cpp:4787
void recursiveTorrentDownload(const TorrentID &id)
Definition: session.cpp:4275
void setGlobalUploadSpeedLimit(int limit)
Definition: session.cpp:2628
void processBannedIPs(lt::ip_filter &filter)
Definition: session.cpp:1114
int socketBacklogSize() const
Definition: session.cpp:3382
void tagAdded(const QString &tag)
void torrentAdded(Torrent *torrent)
void setIgnoreSlowTorrentsForQueueing(bool ignore)
Definition: session.cpp:3480
QString IPFilterFile() const
Definition: session.cpp:2933
const CacheStatus & cacheStatus() const
Definition: session.cpp:4306
static Session * m_instance
Definition: session.h:811
lt::session * m_nativeSession
Definition: session.h:653
int globalUploadSpeedLimit() const
Definition: session.cpp:2621
CachedSettingValue< int > m_peerToS
Definition: session.h:694
void setAnnounceToAllTrackers(bool val)
Definition: session.cpp:3114
int maxConcurrentHTTPAnnounces() const
Definition: session.cpp:3629
bool isDownloadPathEnabled() const
Definition: session.cpp:541
void handleMetadataReceivedAlert(const lt::metadata_received_alert *p)
Definition: session.cpp:4736
void setIncludeOverheadInLimits(bool include)
Definition: session.cpp:3606
void IPFilterParsed(bool error, int ruleCount)
void setOutgoingPortsMin(int min)
Definition: session.cpp:3536
void storeCategories() const
Definition: session.cpp:4126
void findIncompleteFiles(const TorrentInfo &torrentInfo, const QString &savePath, const QString &downloadPath, const QStringList &filePaths={}) const
Definition: session.cpp:2268
static void initInstance()
Definition: session.cpp:985
QMap< QString, CategoryOptions > m_categories
Definition: session.h:789
void setMaxConnectionsPerTorrent(int max)
Definition: session.cpp:3066
CachedSettingValue< int > m_maxUploadsPerTorrent
Definition: session.h:704
CachedSettingValue< BTProtocol > m_btProtocol
Definition: session.h:705
void setPeerTurnoverCutoff(int num)
Definition: session.cpp:3156
void trackerError(Torrent *torrent, const QString &tracker)
QPointer< BandwidthScheduler > m_bwScheduler
Definition: session.h:774
ResumeDataStorage * m_resumeDataStorage
Definition: session.h:779
const SessionStatus & status() const
Definition: session.cpp:4301
bool addTorrent_impl(const std::variant< MagnetUri, TorrentInfo > &source, const AddTorrentParams &addTorrentParams)
Definition: session.cpp:2094
bool loadTorrent(LoadTorrentParams params)
Definition: session.cpp:2243
CachedSettingValue< int > m_hashingThreads
Definition: session.h:668
CachedSettingValue< int > m_outgoingPortsMax
Definition: session.h:692
void setIgnoreLimitsOnLAN(bool ignore)
Definition: session.cpp:3592
CachedSettingValue< bool > m_isBandwidthSchedulerEnabled
Definition: session.h:729
bool isSSRFMitigationEnabled() const
Definition: session.cpp:3788
void handleDownloadFinished(const Net::DownloadResult &result)
Definition: session.cpp:1694
void handleTorrentSavePathChanged(TorrentImpl *const torrent)
Definition: session.cpp:3875
int altGlobalUploadSpeedLimit() const
Definition: session.cpp:2671
bool isAutoTMMDisabledByDefault() const
Definition: session.cpp:863
bool hasUnfinishedTorrents() const
Definition: session.cpp:1755
bool ignoreSlowTorrentsForQueueing() const
Definition: session.cpp:3475
void setAnnounceToAllTiers(bool val)
Definition: session.cpp:3128
QSet< TorrentID > m_recentErroredTorrents
Definition: session.h:793
void categoryAdded(const QString &categoryName)
void setMaxUploadsPerTorrent(int max)
Definition: session.cpp:3090
int maxUploads() const
Definition: session.cpp:3691
bool deleteTorrent(const TorrentID &id, DeleteOption deleteOption=DeleteTorrent)
Definition: session.cpp:1792
CachedSettingValue< bool > m_isTrackerEnabled
Definition: session.h:749
CachedSettingValue< bool > m_coalesceReadWriteEnabled
Definition: session.h:674
CachedSettingValue< int > m_maxActiveTorrents
Definition: session.h:686
void setGlobalDownloadSpeedLimit(int limit)
Definition: session.cpp:2603
void handleIPFilterParsed(int ruleCount)
Definition: session.cpp:4432
void setPreallocationEnabled(bool enabled)
Definition: session.cpp:591
bool isDisableAutoTMMWhenDefaultSavePathChanged() const
Definition: session.cpp:883
void handleTorrentNameChanged(TorrentImpl *const torrent)
Definition: session.cpp:3871
void downloadFromUrlFinished(const QString &url)
void handleTorrentPaused(TorrentImpl *const torrent)
Definition: session.cpp:3953
void speedLimitModeChanged(bool alternative)
bool multiConnectionsPerIpEnabled() const
Definition: session.cpp:3762
void handleListenFailedAlert(const lt::listen_failed_alert *p)
Definition: session.cpp:4861
void setPeerTurnover(int num)
Definition: session.cpp:3142
void setValidateHTTPSTrackerCertificate(bool enabled)
Definition: session.cpp:3780
bool isQueueingSystemEnabled() const
Definition: session.cpp:3411
CachedSettingValue< bool > m_includeOverheadInLimits
Definition: session.h:696
int saveResumeDataInterval() const
Definition: session.cpp:2759
bool m_refreshEnqueued
Definition: session.h:768
void metadataDownloaded(const TorrentInfo &info)
CachedSettingValue< QString > m_networkInterface
Definition: session.h:732
void setBlockPeersOnPrivilegedPorts(bool enabled)
Definition: session.cpp:3806
void handleTorrentTrackersAdded(TorrentImpl *const torrent, const QVector< TrackerEntry > &newTrackers)
Definition: session.cpp:3900
void saveTorrentsQueue() const
Definition: session.cpp:2412
QString savePath() const
Definition: session.cpp:620
void upgradeCategories()
Definition: session.cpp:4146
void trackerSuccess(Torrent *torrent, const QString &tracker)
void handleAlert(const lt::alert *a)
Definition: session.cpp:4482
ChokingAlgorithm chokingAlgorithm() const
Definition: session.cpp:2868
void torrentFinished(Torrent *torrent)
QHash< QString, AddTorrentParams > m_downloadedTorrents
Definition: session.h:786
QString networkInterfaceAddress() const
Definition: session.cpp:2823
CachedSettingValue< int > m_downloadRateForSlowTorrents
Definition: session.h:688
void handleTorrentTrackerError(TorrentImpl *const torrent, const QString &trackerUrl)
Definition: session.cpp:4022
void setDisableAutoTMMWhenCategorySavePathChanged(bool value)
Definition: session.cpp:898
void handleTorrentTagRemoved(TorrentImpl *const torrent, const QString &tag)
Definition: session.cpp:3890
void handleStorageMovedAlert(const lt::storage_moved_alert *p)
Definition: session.cpp:4966
void categoryRemoved(const QString &categoryName)
QStringList bannedIPs() const
Definition: session.cpp:2995
bool isDisableAutoTMMWhenCategorySavePathChanged() const
Definition: session.cpp:893
bool m_deferredConfigureScheduled
Definition: session.h:655
void handleTorrentResumed(TorrentImpl *const torrent)
Definition: session.cpp:3958
void handleTorrentRemovedAlert(const lt::torrent_removed_alert *p)
Definition: session.cpp:4669
CachedSettingValue< bool > m_isUTPRateLimited
Definition: session.h:706
bool isLSDEnabled() const
Definition: session.cpp:513
void handleListenSucceededAlert(const lt::listen_succeeded_alert *p)
Definition: session.cpp:4850
bool useOSCache() const
Definition: session.cpp:3277
static QStringList expandCategory(const QString &category)
Definition: session.cpp:642
CachedSettingValue< bool > m_SSRFMitigationEnabled
Definition: session.h:711
int downloadRateForSlowTorrents() const
Definition: session.cpp:3489
void handleTorrentNeedSaveResumeData(const TorrentImpl *torrent)
Definition: session.cpp:1972
void recursiveTorrentDownloadPossible(Torrent *torrent)
void torrentResumed(Torrent *torrent)
bool isKnownTorrent(const TorrentID &id) const
Definition: session.cpp:3845
bool isSuggestModeEnabled() const
Definition: session.cpp:3304
const bool m_wasPexEnabled
Definition: session.h:762
void setAdditionalTrackers(const QString &trackers)
Definition: session.cpp:2909
CachedSettingValue< int > m_sendBufferLowWatermark
Definition: session.h:678
bool hasPerTorrentRatioLimit() const
Definition: session.cpp:4214
void handleTorrentShareLimitChanged(TorrentImpl *const torrent)
Definition: session.cpp:3866
bool m_needUpgradeDownloadPath
Definition: session.h:809
CachedSettingValue< int > m_maxActiveDownloads
Definition: session.h:684
bool announceToAllTrackers() const
Definition: session.cpp:3109
QSet< TorrentID > m_downloadedMetadata
Definition: session.h:782
CacheStatus m_cacheStatus
Definition: session.h:800
CachedSettingValue< bool > m_ignoreLimitsOnLAN
Definition: session.h:695
void generateResumeData()
Definition: session.cpp:2365
void configureListeningInterface()
Definition: session.cpp:2590
CachedSettingValue< QString > m_additionalTrackers
Definition: session.h:714
static bool isValidTag(const QString &tag)
Definition: session.cpp:829
void handleUrlSeedAlert(const lt::url_seed_alert *p)
Definition: session.cpp:4830
Q_INVOKABLE void configure()
Definition: session.cpp:1019
CachedSettingValue< bool > m_blockPeersOnPrivilegedPorts
Definition: session.h:712
void enableBandwidthScheduler()
Definition: session.cpp:1578
void handleTorrentResumeDataReady(TorrentImpl *const torrent, const LoadTorrentParams &data)
Definition: session.cpp:4010
bool isCoalesceReadWriteEnabled() const
Definition: session.cpp:3291
void setIDNSupportEnabled(bool enabled)
Definition: session.cpp:3754
CachedSettingValue< int > m_filePoolSize
Definition: session.h:669
SessionStatus m_status
Definition: session.h:799
CachedSettingValue< TorrentContentLayout > m_torrentContentLayout
Definition: session.h:718
void setSocketBacklogSize(int value)
Definition: session.cpp:3387
CachedSettingValue< bool > m_isAddTorrentPaused
Definition: session.h:717
CachedSettingValue< bool > m_announceToAllTiers
Definition: session.h:666
CachedSettingValue< bool > m_isProxyPeerConnectionsEnabled
Definition: session.h:736
void setTorrentContentLayout(TorrentContentLayout value)
Definition: session.cpp:4469
int maxActiveTorrents() const
Definition: session.cpp:3460
int uploadRateForSlowTorrents() const
Definition: session.cpp:3503
bool addTorrent(const QString &source, const AddTorrentParams &params=AddTorrentParams())
Definition: session.cpp:2007
void setUploadRateForSlowTorrents(int rateInKibiBytes)
Definition: session.cpp:3508
CachedSettingValue< int > m_sendBufferWatermark
Definition: session.h:677
void setMaxActiveTorrents(int max)
Definition: session.cpp:3465
void fileSearchFinished(const TorrentID &id, const QString &savePath, const QStringList &fileNames)
Definition: session.cpp:1714
MixedModeAlgorithm utpMixedMode() const
Definition: session.cpp:3736
void setNetworkInterfaceAddress(const QString &address)
Definition: session.cpp:2828
bool downloadMetadata(const MagnetUri &magnetUri)
Definition: session.cpp:2283
CachedSettingValue< QString > m_downloadPath
Definition: session.h:742
void downloadFromUrlFailed(const QString &url, const QString &reason)
void createTorrent(const lt::torrent_handle &nativeHandle)
Definition: session.cpp:4588
CachedSettingValue< bool > m_announceToAllTrackers
Definition: session.h:665
int maxUploadsPerTorrent() const
Definition: session.cpp:3085
void setChokingAlgorithm(ChokingAlgorithm mode)
Definition: session.cpp:2873
void setNetworkInterface(const QString &iface)
Definition: session.cpp:2804
bool isProxyPeerConnectionsEnabled() const
Definition: session.cpp:2854
QTimer * m_recentErroredTorrentsTimer
Definition: session.h:794
int diskCacheSize() const
Definition: session.cpp:3237
void configureNetworkInterfaces(lt::settings_pack &settingsPack)
Definition: session.cpp:1421
void torrentSavePathChanged(Torrent *torrent)
CategoryOptions categoryOptions(const QString &categoryName) const
Definition: session.cpp:664
CachedSettingValue< bool > m_ignoreSlowTorrentsForQueueing
Definition: session.h:687
void torrentsUpdated(const QVector< Torrent * > &torrents)
bool validateHTTPSTrackerCertificate() const
Definition: session.cpp:3775
void trackerWarning(Torrent *torrent, const QString &tracker)
void handleTorrentTrackerReply(TorrentImpl *const torrent, const QString &trackerUrl)
Definition: session.cpp:4017
void torrentLoaded(Torrent *torrent)
void topTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1917
MaxRatioAction maxRatioAction() const
Definition: session.cpp:3833
TorrentContentLayout torrentContentLayout() const
Definition: session.cpp:4464
bool isUTPRateLimited() const
Definition: session.cpp:3722
void setDownloadSpeedLimit(int limit)
Definition: session.cpp:2703
QString categorySavePath(const QString &categoryName) const
Definition: session.cpp:669
CachedSettingValue< QString > m_announceIP
Definition: session.h:697
void setAddTorrentPaused(bool value)
Definition: session.cpp:908
CachedSettingValue< int > m_maxConnectionsPerTorrent
Definition: session.h:703
void increaseTorrentsQueuePos(const QVector< TorrentID > &ids)
Definition: session.cpp:1862
void handlePortmapWarningAlert(const lt::portmap_error_alert *p)
Definition: session.cpp:4782
void setNetworkInterfaceName(const QString &name)
Definition: session.cpp:2818
CachedSettingValue< bool > m_isPeXEnabled
Definition: session.h:661
void handleTorrentFinished(TorrentImpl *const torrent)
Definition: session.cpp:3968
QSet< QString > tags() const
Definition: session.cpp:824
bool isAnonymousModeEnabled() const
Definition: session.cpp:3395
int filePoolSize() const
Definition: session.cpp:3207
QPointer< Tracker > m_tracker
Definition: session.h:776
void setSendBufferWatermarkFactor(int value)
Definition: session.cpp:3361
bool isAppendExtensionEnabled() const
Definition: session.cpp:556
CachedSettingValue< bool > m_isQueueingEnabled
Definition: session.h:683
bool editCategory(const QString &name, const CategoryOptions &options)
Definition: session.cpp:728
void torrentMetadataReceived(Torrent *torrent)
SessionMetricIndices m_metricIndices
Definition: session.h:796
QStringList categories() const
Definition: session.cpp:659
void handleTorrentUrlSeedsRemoved(TorrentImpl *const torrent, const QVector< QUrl > &urlSeeds)
Definition: session.cpp:3931
void setCoalesceReadWriteEnabled(bool enabled)
Definition: session.cpp:3296
void setQueueingSystemEnabled(bool enabled)
Definition: session.cpp:3416
Session(QObject *parent=nullptr)
Definition: session.cpp:305
CachedSettingValue< QStringList > m_storedTags
Definition: session.h:739
CachedSettingValue< int > m_diskCacheSize
Definition: session.h:671
CachedSettingValue< bool > m_isAnonymousModeEnabled
Definition: session.h:682
QString categoryDownloadPath(const QString &categoryName) const
Definition: session.cpp:682
CachedSettingValue< bool > m_isSubcategoriesEnabled
Definition: session.h:743
void setPeerToS(int value)
Definition: session.cpp:3578
void dispatchTorrentAlert(const lt::alert *a)
Definition: session.cpp:4571
void updateSeedingLimitTimer()
Definition: session.cpp:3852
void handleTorrentTrackersChanged(TorrentImpl *const torrent)
Definition: session.cpp:3920
void handleIPFilterError()
Definition: session.cpp:4444
void setAppendExtensionEnabled(bool enabled)
Definition: session.cpp:561
void setLSDEnabled(bool enabled)
Definition: session.cpp:518
int encryption() const
Definition: session.cpp:2837
void handleTorrentDeletedAlert(const lt::torrent_deleted_alert *p)
Definition: session.cpp:4688
ResumeDataStorageType resumeDataStorageType() const
Definition: session.cpp:2985
void setMaxConnections(int max)
Definition: session.cpp:3681
CachedSettingValue< int > m_outgoingPortsMin
Definition: session.h:691
void trackerlessStateChanged(Torrent *torrent, bool trackerless)
CachedSettingValue< bool > m_validateHTTPSTrackerCertificate
Definition: session.h:710
void setAutoTMMDisabledByDefault(bool value)
Definition: session.cpp:868
void tagRemoved(const QString &tag)
int downloadSpeedLimit() const
Definition: session.cpp:2696
Torrent * findTorrent(const TorrentID &id) const
Definition: session.cpp:1742
static void freeInstance()
Definition: session.cpp:991
flag icons free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: session.h:86
T value(const QString &key, const T &defaultValue={})
Definition: preferences.cpp:64
DeleteOption
Definition: session.h:80
@ DeleteTorrent
Definition: session.h:81
@ DeleteTorrentAndFiles
Definition: session.h:82
MaxRatioAction
Definition: session.h:72
@ Remove
Definition: session.h:74
@ EnableSuperSeeding
Definition: session.h:76
@ DeleteFiles
Definition: session.h:75
@ Pause
Definition: session.h:73
lt::torrent_handle torrentHandle
Definition: session.h:565
struct BitTorrent::SessionMetricIndices::@0 net
struct BitTorrent::SessionMetricIndices::@3 disk
struct BitTorrent::SessionMetricIndices::@1 peer
struct BitTorrent::SessionMetricIndices::@2 dht