1 /* 2 SPDX-FileCopyrightText: 2009 Joris Guisson <joris.guisson@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef BT_TORRENTSTATS_H 8 #define BT_TORRENTSTATS_H 9 10 #include <QString> 11 #include <ktorrent_export.h> 12 #include <qdatetime.h> 13 #include <util/constants.h> 14 15 #if defined ERROR 16 #undef ERROR 17 #endif 18 19 namespace bt 20 { 21 enum TorrentStatus { 22 NOT_STARTED, 23 SEEDING_COMPLETE, 24 DOWNLOAD_COMPLETE, 25 SEEDING, 26 DOWNLOADING, 27 STALLED, 28 STOPPED, 29 ALLOCATING_DISKSPACE, 30 ERROR, 31 QUEUED, 32 CHECKING_DATA, 33 NO_SPACE_LEFT, 34 PAUSED, 35 SUPERSEEDING, 36 INVALID_STATUS, 37 }; 38 39 struct KTORRENT_EXPORT TorrentStats { 40 /// Error message for the user 41 QString error_msg; 42 /// QDateTime when the torrent was added 43 QDateTime time_added; 44 /// Name of the torrent 45 QString torrent_name; 46 /// Path of the dir or file where the data will get saved 47 QString output_path; 48 /// The number of bytes imported (igore these for average speed) 49 Uint64 imported_bytes; 50 /// Total number of bytes downloaded. 51 Uint64 bytes_downloaded; 52 /// Total number of bytes uploaded. 53 Uint64 bytes_uploaded; 54 /// The number of bytes left (gets sent to the tracker) 55 Uint64 bytes_left; 56 /// The number of bytes left to download (bytes_left - excluded bytes) 57 Uint64 bytes_left_to_download; 58 /// total number of bytes in torrent 59 Uint64 total_bytes; 60 /// The total number of bytes which need to be downloaded 61 Uint64 total_bytes_to_download; 62 /// The download rate in bytes per sec 63 Uint32 download_rate; 64 /// The upload rate in bytes per sec 65 Uint32 upload_rate; 66 /// The number of peers we are connected to 67 Uint32 num_peers; 68 /// The number of chunks we are currently downloading 69 Uint32 num_chunks_downloading; 70 /// The total number of chunks 71 Uint32 total_chunks; 72 /// The number of chunks which have been downloaded 73 Uint32 num_chunks_downloaded; 74 /// Get the number of chunks which have been excluded 75 Uint32 num_chunks_excluded; 76 /// Get the number of chunks left 77 Uint32 num_chunks_left; 78 /// Size of each chunk 79 Uint32 chunk_size; 80 /// Total seeders in swarm 81 Uint32 seeders_total; 82 /// Num seeders connected to 83 Uint32 seeders_connected_to; 84 /// Total leechers in swarm 85 Uint32 leechers_total; 86 /// Num leechers connected to 87 Uint32 leechers_connected_to; 88 /// Status of the download 89 TorrentStatus status; 90 /// The number of bytes downloaded in this session 91 Uint64 session_bytes_downloaded; 92 /// The number of bytes uploaded in this session 93 Uint64 session_bytes_uploaded; 94 /// See if we are running 95 bool running; 96 /// See if the torrent has been started 97 bool started; 98 /// Whether or not the torrent is queued 99 bool queued; 100 /// See if we are allowed to startup this torrent automatically. 101 bool autostart; 102 /// See if the torrent is stopped by error 103 bool stopped_by_error; 104 /// See if the download is completed 105 bool completed; 106 /// See if this torrent is paused 107 bool paused; 108 /// Set to true if torrent was stopped due to reaching max share ration or max seed time 109 bool auto_stopped; 110 /// Set to true if superseeding is enabled 111 bool superseeding; 112 /// Whether or not the QM can start this torrent 113 bool qm_can_start; 114 /// See if we have a multi file torrent 115 bool multi_file_torrent; 116 /// Private torrent (i.e. no use of DHT) 117 bool priv_torrent; 118 /// Maximum share ratio 119 float max_share_ratio; 120 /// Maximum seed time in hours 121 float max_seed_time; 122 /// Number of corrupted chunks found since the last check 123 Uint32 num_corrupted_chunks; 124 /// TimeStamp when we last saw download activity 125 TimeStamp last_download_activity_time; 126 /// TimeStamp when we last saw upload activity 127 TimeStamp last_upload_activity_time; 128 129 TorrentStats(); 130 131 /// Calculate the share ratio 132 float shareRatio() const; 133 134 /// Are we over the max share ratio 135 bool overMaxRatio() const; 136 137 /// Convert the status into a human readable string 138 QString statusToString() const; 139 }; 140 } 141 142 #endif // BT_TORRENTSTATS_H 143