libktorrent
2.1.1
src
dht
dhtpeersource.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 DHTDHTPEERSOURCE_H
21
#define DHTDHTPEERSOURCE_H
22
23
#include <qtimer.h>
24
#include <interfaces/peersource.h>
25
#include "task.h"
26
27
28
namespace
bt
29
{
30
class
WaitJob;
31
struct
DHTNode;
32
}
33
34
35
namespace
dht
36
{
37
class
DHTBase;
38
class
AnnounceTask;
39
40
41
45
class
KTORRENT_EXPORT
DHTPeerSource
:
public
bt::PeerSource
46
{
47
Q_OBJECT
48
public
:
49
DHTPeerSource
(
DHTBase
& dh_table,
const
bt::SHA1Hash
& info_hash,
const
QString & torrent_name);
50
~
DHTPeerSource
()
override
;
51
52
void
start
()
override
;
53
void
stop
(
bt::WaitJob
* wjob = 0)
override
;
54
void
manualUpdate
()
override
;
55
56
void
addDHTNode(
const
bt::DHTNode
& node);
57
void
setRequestInterval(bt::Uint32 interval);
58
59
private
Q_SLOTS:
60
void
onTimeout();
61
bool
doRequest();
62
void
onDataReady(
Task
* t);
63
void
onFinished(
Task
* t);
64
void
dhtStopped();
65
66
private
:
67
DHTBase
& dh_table;
68
AnnounceTask
* curr_task;
69
bt::SHA1Hash
info_hash;
70
QTimer timer;
71
bool
started;
72
QList<bt::DHTNode> nodes;
73
QString torrent_name;
74
bt::Uint32 request_interval;
75
};
76
77
}
78
79
#endif
bt::WaitJob
Definition:
waitjob.h:57
bt::DHTNode
Definition:
torrentinterface.h:88
bt::PeerSource
Definition:
peersource.h:60
dht::Task
Definition:
task.h:47
dht::DHTPeerSource::manualUpdate
void manualUpdate() override
bt::SHA1Hash
Stores a SHA1 hash.
Definition:
sha1hash.h:41
dht::DHTPeerSource::start
void start() override
dht::DHTBase
Definition:
dhtbase.h:53
dht::DHTPeerSource::stop
void stop(bt::WaitJob *wjob=0) override
dht::DHTPeerSource
Definition:
dhtpeersource.h:46
dht::AnnounceTask
Definition:
announcetask.h:68
Generated by
1.8.18