libktorrent  2.1.1
httptracker.h
1 /***************************************************************************
2  * Copyright (C) 2005 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 BTHTTPTRACKER_H
21 #define BTHTTPTRACKER_H
22 
23 #include <QTimer>
24 #include <ktorrent_export.h>
25 #include "tracker.h"
26 
27 
28 class KJob;
29 
30 namespace KIO
31 {
32  class MetaData;
33 }
34 
35 namespace bt
36 {
37 
38 
45  class KTORRENT_EXPORT HTTPTracker : public Tracker
46  {
47  Q_OBJECT
48  public:
49  HTTPTracker(const QUrl &url,TrackerDataSource* tds,const PeerID & id,int tier);
50  ~HTTPTracker() override;
51 
52  void start() override;
53  void stop(WaitJob* wjob = 0) override;
54  void completed() override;
55  Uint32 failureCount() const override {return failures;}
56  void scrape() override;
57 
58  static void setProxy(const QString & proxy,const bt::Uint16 proxy_port);
59  static void setProxyEnabled(bool on);
60  static void setUseQHttp(bool on);
61 
62  private Q_SLOTS:
63  void onKIOAnnounceResult(KJob* j);
64 #ifdef HAVE_HTTPANNOUNEJOB
65  void onQHttpAnnounceResult(KJob* j);
66 #endif
67  void onScrapeResult(KJob* j);
68  void emitInvalidURLFailure();
69  void onTimeout();
70  void manualUpdate() override;
71 
72  private:
73  void doRequest(WaitJob* wjob = 0);
74  bool updateData(const QByteArray & data);
75  void setupMetaData(KIO::MetaData & md);
76  void doAnnounceQueue();
77  void doAnnounce(const QUrl &u);
78  void onAnnounceResult(const QUrl &url,const QByteArray & data,KJob* j);
79 
80  private:
81  KJob* active_job;
82  QList<QUrl> announce_queue;
83  QString event;
84  QTimer timer;
85  QString error;
86  Uint32 failures;
87  bool supports_partial_seed_extension;
88 
89 
90  static bool proxy_on;
91  static QString proxy;
92  static Uint16 proxy_port;
93  static bool use_qhttp;
94  };
95 
96 }
97 
98 #endif
bt::HTTPTracker::failureCount
Uint32 failureCount() const override
Definition: httptracker.h:55
bt::HTTPTracker::stop
void stop(WaitJob *wjob=0) override
bt::WaitJob
Definition: waitjob.h:57
bt::HTTPTracker::scrape
void scrape() override
bt::TrackerDataSource
Definition: tracker.h:40
bt::HTTPTracker::start
void start() override
bt::HTTPTracker::completed
void completed() override
bt::Tracker
Definition: tracker.h:55
bt::PeerID
Definition: peerid.h:51
bt::HTTPTracker
Communicates with the tracker.
Definition: httptracker.h:46