1 /* 2 SPDX-FileCopyrightText: 2005 Ivan Vasic <ivasic@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 #ifndef BTTRACKERSLIST_H 7 #define BTTRACKERSLIST_H 8 9 #include <QUrl> 10 #include <ktorrent_export.h> 11 12 namespace bt 13 { 14 struct TrackerTier; 15 class TrackerInterface; 16 17 struct TrackersStatusInfo { 18 int trackers_count; 19 int errors; 20 int timeout_errors; 21 int warnings; 22 }; 23 24 /** 25 * @author Ivan Vasić <ivasic@gmail.com> 26 * 27 * This interface is used to provide access to AnnounceList object which holds a list of available trackers for a torrent. 28 */ 29 class KTORRENT_EXPORT TrackersList 30 { 31 public: 32 TrackersList(); 33 virtual ~TrackersList(); 34 35 /** 36 * Get the current tracker (for non private torrents this returns 0, seeing that 37 * all trackers are used at the same time) 38 */ 39 virtual TrackerInterface *getCurrentTracker() const = 0; 40 41 /** 42 * Sets the current tracker and does the announce. For non private torrents, this 43 * does nothing. 44 * @param t The Tracker 45 */ 46 virtual void setCurrentTracker(TrackerInterface *t) = 0; 47 48 /** 49 * Sets the current tracker and does the announce. For non private torrents, this 50 * does nothing. 51 * @param url Url of the tracker 52 */ 53 virtual void setCurrentTracker(const QUrl &url) = 0; 54 55 /** 56 * Gets a list of all available trackers. 57 */ 58 virtual QList<TrackerInterface *> getTrackers() = 0; 59 60 /** 61 * Adds a tracker URL to the list. 62 * @param url The URL 63 * @param custom Is it a custom tracker 64 * @param tier Which tier (or priority) the tracker has, tier 1 are 65 * the main trackers, tier 2 are backups ... 66 * @return The Tracker 67 */ 68 virtual TrackerInterface *addTracker(const QUrl &url, bool custom = true, int tier = 1) = 0; 69 70 /** 71 * Removes the tracker from the list. 72 * @param t The Tracker 73 */ 74 virtual bool removeTracker(TrackerInterface *t) = 0; 75 76 /** 77 * Removes the tracker from the list. 78 * @param url The tracker url 79 */ 80 virtual bool removeTracker(const QUrl &url) = 0; 81 82 /** 83 * Return true if a tracker can be removed 84 * @param t The tracker 85 */ 86 virtual bool canRemoveTracker(TrackerInterface *t) = 0; 87 88 /** 89 * Restores the default tracker and does the announce. 90 */ 91 virtual void restoreDefault() = 0; 92 93 /** 94 * Set a tracker enabled or not 95 */ 96 virtual void setTrackerEnabled(const QUrl &url, bool on) = 0; 97 98 /** 99 * Merge an other tracker list. 100 * @param first The first TrackerTier 101 */ 102 void merge(const bt::TrackerTier *first); 103 104 /** 105 * Returns true if no tracker is reachable 106 */ 107 virtual bool noTrackersReachable() const = 0; 108 109 /** 110 * Returns true if any tracker has time out error 111 */ 112 virtual TrackersStatusInfo getTrackersStatusInfo() const = 0; 113 }; 114 115 } 116 117 #endif 118