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
bt::TrackerInterface::getInterval
Uint32 getInterval() const
Definition: trackerinterface.h:66
bt::TrackerInterface::getTotalTimesDownloaded
int getTotalTimesDownloaded() const
Get the number of times the torrent was downloaded.
Definition: trackerinterface.h:78
bt::TrackerInterface::getNumSeeders
int getNumSeeders() const
Get the number of seeders.
Definition: trackerinterface.h:72
bt::TrackerInterface::trackerStatusString
QString trackerStatusString() const
Get a string of the current tracker status.
bt::TrackerInterface::isStarted
bool isStarted() const
See if a start request succeeded.
Definition: trackerinterface.h:45
bt::TrackerInterface::timeOut
bool timeOut() const
Is tracker timed out.
Definition: trackerinterface.h:57
bt::TrackerInterface::reset
virtual void reset()
Reset the tracker.
bt::TrackerInterface
Definition: trackerinterface.h:39
bt::TrackerInterface::setEnabled
void setEnabled(bool on)
Enable or disable the tracker.
Definition: trackerinterface.h:81
bt::TrackerInterface::setInterval
void setInterval(Uint32 i)
Set the interval.
Definition: trackerinterface.h:69
bt::TrackerInterface::trackerURL
QUrl trackerURL() const
get the tracker url
Definition: trackerinterface.h:48
bt::TrackerInterface::getNumLeechers
int getNumLeechers() const
Get the number of leechers.
Definition: trackerinterface.h:75
bt::TrackerInterface::trackerStatus
TrackerStatus trackerStatus() const
Get the tracker status.
Definition: trackerinterface.h:51
bt::TrackerInterface::timeToNextUpdate
Uint32 timeToNextUpdate() const
Get the time in seconds to the next tracker update.
bt::TrackerInterface::isEnabled
bool isEnabled() const
Is the tracker enabled.
Definition: trackerinterface.h:84
bt::TrackerInterface::hasWarning
bool hasWarning() const
Is there any warnings.
Definition: trackerinterface.h:60