libktorrent  2.2.0
trackerinterface.h
1 /***************************************************************************
2  * Copyright (C) 2009 by Joris Guisson *
3  * 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 #ifndef BT_TRACKERINTERFACE_H
21 #define BT_TRACKERINTERFACE_H
22 
23 #include <QDateTime>
24 #include <QUrl>
25 #include <ktorrent_export.h>
26 #include <util/constants.h>
27 
28 namespace bt
29 {
30  enum TrackerStatus
31  {
32  TRACKER_OK,TRACKER_ANNOUNCING,TRACKER_ERROR,TRACKER_IDLE
33  };
34 
38  class KTORRENT_EXPORT TrackerInterface
39  {
40  public:
41  TrackerInterface(const QUrl &url);
42  virtual ~TrackerInterface();
43 
45  bool isStarted() const {return started;}
46 
48  QUrl trackerURL() const {return url;}
49 
51  TrackerStatus trackerStatus() const {return status;}
52 
54  QString trackerStatusString() const;
55 
57  bool timeOut() const {return time_out;}
58 
60  bool hasWarning() const {return !warning.isEmpty();}
61 
66  Uint32 getInterval() const {return interval;}
67 
69  void setInterval(Uint32 i) {interval = i;}
70 
72  int getNumSeeders() const {return seeders;}
73 
75  int getNumLeechers() const {return leechers;}
76 
78  int getTotalTimesDownloaded() const {return total_downloaded;}
79 
81  void setEnabled(bool on) {enabled = on;}
82 
84  bool isEnabled() const {return enabled;}
85 
87  Uint32 timeToNextUpdate() const;
88 
90  virtual void reset();
91 
92  protected:
93  QUrl url;
94  Uint32 interval;
95  int seeders;
96  int leechers;
97  int total_downloaded;
98  bool enabled;
99  TrackerStatus status;
100  bool time_out;
101  QDateTime request_time;
102  QString error;
103  QString warning;
104  bool started;
105  };
106 
107 }
108 
109 #endif // BT_TRACKERINTERFACE_H