File indexing completed on 2025-01-05 04:37:26
0001 /* 0002 SPDX-FileCopyrightText: 2009 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef BT_TORRENTSTATS_H 0008 #define BT_TORRENTSTATS_H 0009 0010 #include <QString> 0011 #include <ktorrent_export.h> 0012 #include <qdatetime.h> 0013 #include <util/constants.h> 0014 0015 #if defined ERROR 0016 #undef ERROR 0017 #endif 0018 0019 namespace bt 0020 { 0021 enum TorrentStatus { 0022 NOT_STARTED, 0023 SEEDING_COMPLETE, 0024 DOWNLOAD_COMPLETE, 0025 SEEDING, 0026 DOWNLOADING, 0027 STALLED, 0028 STOPPED, 0029 ALLOCATING_DISKSPACE, 0030 ERROR, 0031 QUEUED, 0032 CHECKING_DATA, 0033 NO_SPACE_LEFT, 0034 PAUSED, 0035 SUPERSEEDING, 0036 INVALID_STATUS, 0037 }; 0038 0039 struct KTORRENT_EXPORT TorrentStats { 0040 /// Error message for the user 0041 QString error_msg; 0042 /// QDateTime when the torrent was added 0043 QDateTime time_added; 0044 /// Name of the torrent 0045 QString torrent_name; 0046 /// Path of the dir or file where the data will get saved 0047 QString output_path; 0048 /// The number of bytes imported (igore these for average speed) 0049 Uint64 imported_bytes; 0050 /// Total number of bytes downloaded. 0051 Uint64 bytes_downloaded; 0052 /// Total number of bytes uploaded. 0053 Uint64 bytes_uploaded; 0054 /// The number of bytes left (gets sent to the tracker) 0055 Uint64 bytes_left; 0056 /// The number of bytes left to download (bytes_left - excluded bytes) 0057 Uint64 bytes_left_to_download; 0058 /// total number of bytes in torrent 0059 Uint64 total_bytes; 0060 /// The total number of bytes which need to be downloaded 0061 Uint64 total_bytes_to_download; 0062 /// The download rate in bytes per sec 0063 Uint32 download_rate; 0064 /// The upload rate in bytes per sec 0065 Uint32 upload_rate; 0066 /// The number of peers we are connected to 0067 Uint32 num_peers; 0068 /// The number of chunks we are currently downloading 0069 Uint32 num_chunks_downloading; 0070 /// The total number of chunks 0071 Uint32 total_chunks; 0072 /// The number of chunks which have been downloaded 0073 Uint32 num_chunks_downloaded; 0074 /// Get the number of chunks which have been excluded 0075 Uint32 num_chunks_excluded; 0076 /// Get the number of chunks left 0077 Uint32 num_chunks_left; 0078 /// Size of each chunk 0079 Uint32 chunk_size; 0080 /// Total seeders in swarm 0081 Uint32 seeders_total; 0082 /// Num seeders connected to 0083 Uint32 seeders_connected_to; 0084 /// Total leechers in swarm 0085 Uint32 leechers_total; 0086 /// Num leechers connected to 0087 Uint32 leechers_connected_to; 0088 /// Status of the download 0089 TorrentStatus status; 0090 /// The number of bytes downloaded in this session 0091 Uint64 session_bytes_downloaded; 0092 /// The number of bytes uploaded in this session 0093 Uint64 session_bytes_uploaded; 0094 /// See if we are running 0095 bool running; 0096 /// See if the torrent has been started 0097 bool started; 0098 /// Whether or not the torrent is queued 0099 bool queued; 0100 /// See if we are allowed to startup this torrent automatically. 0101 bool autostart; 0102 /// See if the torrent is stopped by error 0103 bool stopped_by_error; 0104 /// See if the download is completed 0105 bool completed; 0106 /// See if this torrent is paused 0107 bool paused; 0108 /// Set to true if torrent was stopped due to reaching max share ration or max seed time 0109 bool auto_stopped; 0110 /// Set to true if superseeding is enabled 0111 bool superseeding; 0112 /// Whether or not the QM can start this torrent 0113 bool qm_can_start; 0114 /// See if we have a multi file torrent 0115 bool multi_file_torrent; 0116 /// Private torrent (i.e. no use of DHT) 0117 bool priv_torrent; 0118 /// Maximum share ratio 0119 float max_share_ratio; 0120 /// Maximum seed time in hours 0121 float max_seed_time; 0122 /// Number of corrupted chunks found since the last check 0123 Uint32 num_corrupted_chunks; 0124 /// TimeStamp when we last saw download activity 0125 TimeStamp last_download_activity_time; 0126 /// TimeStamp when we last saw upload activity 0127 TimeStamp last_upload_activity_time; 0128 0129 TorrentStats(); 0130 0131 /// Calculate the share ratio 0132 float shareRatio() const; 0133 0134 /// Are we over the max share ratio 0135 bool overMaxRatio() const; 0136 0137 /// Convert the status into a human readable string 0138 QString statusToString() const; 0139 }; 0140 } 0141 0142 #endif // BT_TORRENTSTATS_H