libktorrent  2.1.1
torrentstats.h
1 /***************************************************************************
2  * Copyright (C) 2009 by *
3  * Joris Guisson <joris.guisson@gmail.com> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef BT_TORRENTSTATS_H
22 #define BT_TORRENTSTATS_H
23 
24 #include <QString>
25 #include <util/constants.h>
26 #include <ktorrent_export.h>
27 #include <qdatetime.h>
28 
29 #if defined ERROR
30 #undef ERROR
31 #endif
32 
33 namespace bt
34 {
35  enum TorrentStatus
36  {
37  NOT_STARTED,
38  SEEDING_COMPLETE,
39  DOWNLOAD_COMPLETE,
40  SEEDING,
41  DOWNLOADING,
42  STALLED,
43  STOPPED,
44  ALLOCATING_DISKSPACE,
45  ERROR,
46  QUEUED,
47  CHECKING_DATA,
48  NO_SPACE_LEFT,
49  PAUSED,
50  SUPERSEEDING,
51  INVALID_STATUS
52  };
53 
54  struct KTORRENT_EXPORT TorrentStats
55  {
57  QString error_msg;
59  QDateTime time_added;
61  QString torrent_name;
63  QString output_path;
65  Uint64 imported_bytes;
67  Uint64 bytes_downloaded;
69  Uint64 bytes_uploaded;
71  Uint64 bytes_left;
73  Uint64 bytes_left_to_download;
75  Uint64 total_bytes;
77  Uint64 total_bytes_to_download;
79  Uint32 download_rate;
81  Uint32 upload_rate;
83  Uint32 num_peers;
85  Uint32 num_chunks_downloading;
87  Uint32 total_chunks;
89  Uint32 num_chunks_downloaded;
91  Uint32 num_chunks_excluded;
93  Uint32 num_chunks_left;
95  Uint32 chunk_size;
97  Uint32 seeders_total;
99  Uint32 seeders_connected_to;
101  Uint32 leechers_total;
103  Uint32 leechers_connected_to;
105  TorrentStatus status;
107  Uint64 session_bytes_downloaded;
109  Uint64 session_bytes_uploaded;
111  bool running;
113  bool started;
115  bool queued;
117  bool autostart;
119  bool stopped_by_error;
121  bool completed;
123  bool paused;
125  bool auto_stopped;
127  bool superseeding;
129  bool qm_can_start;
131  bool multi_file_torrent;
133  bool priv_torrent;
135  float max_share_ratio;
137  float max_seed_time;
139  Uint32 num_corrupted_chunks;
141  TimeStamp last_download_activity_time;
143  TimeStamp last_upload_activity_time;
144 
146 
148  float shareRatio() const;
149 
151  bool overMaxRatio() const;
152 
154  QString statusToString() const;
155  };
156 }
157 
158 #endif // BT_TORRENTSTATS_H
bt::TorrentStats
Definition: torrentstats.h:73