libktorrent  2.1.1
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 
60  Uint32 getInterval() const {return interval;}
61 
63  void setInterval(Uint32 i) {interval = i;}
64 
66  int getNumSeeders() const {return seeders;}
67 
69  int getNumLeechers() const {return leechers;}
70 
72  int getTotalTimesDownloaded() const {return total_downloaded;}
73 
75  void setEnabled(bool on) {enabled = on;}
76 
78  bool isEnabled() const {return enabled;}
79 
81  Uint32 timeToNextUpdate() const;
82 
84  virtual void reset();
85 
86  protected:
87  QUrl url;
88  Uint32 interval;
89  int seeders;
90  int leechers;
91  int total_downloaded;
92  bool enabled;
93  TrackerStatus status;
94  QDateTime request_time;
95  QString error;
96  QString warning;
97  bool started;
98  };
99 
100 }
101 
102 #endif // BT_TRACKERINTERFACE_H