libktorrent
2.2.0
src
peer
peerconnector.h
1
/***************************************************************************
2
* Copyright (C) 2010 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
21
#ifndef BT_PEERCONNECTOR_H
22
#define BT_PEERCONNECTOR_H
23
24
#include <QSharedPointer>
25
#include <ktorrent_export.h>
26
#include <util/constants.h>
27
#include <util/resourcemanager.h>
28
#include <net/address.h>
29
#include "connectionlimit.h"
30
31
#if (QT_VERSION < QT_VERSION_CHECK(4, 7, 0))
32
template
<
class
T>
33
uint qHash(
const
QSharedPointer<T> &ptr)
34
{
35
return
qHash<T>(ptr.data());
36
}
37
#endif
38
39
40
namespace
bt
41
{
42
class
Authenticate;
43
class
PeerManager;
44
48
class
KTORRENT_EXPORT
PeerConnector
:
public
Resource
49
{
50
public
:
51
enum
Method
52
{
53
TCP_WITH_ENCRYPTION,
54
TCP_WITHOUT_ENCRYPTION,
55
UTP_WITH_ENCRYPTION,
56
UTP_WITHOUT_ENCRYPTION
57
};
58
59
PeerConnector
(
const
net::Address
& addr,
bool
local,
PeerManager
* pman, ConnectionLimit::Token::Ptr token);
60
~
PeerConnector
()
override
;
61
63
void
authenticationFinished
(
bt::Authenticate
* auth,
bool
ok);
64
66
void
start
();
67
71
static
void
setMaxActive
(Uint32 mc);
72
73
typedef
QSharedPointer<PeerConnector> Ptr;
74
typedef
QWeakPointer<PeerConnector> WPtr;
75
77
void
setWeakPointer
(WPtr ptr);
78
79
80
private
:
81
void
acquired()
override
;
82
83
private
:
84
class
Private;
85
Private* d;
86
};
87
88
}
89
90
#endif // BT_PEERCONNECTOR_H
net::Address
Definition:
address.h:41
bt::PeerConnector::start
void start()
Start connecting.
bt::PeerManager
Manages all the Peers.
Definition:
peermanager.h:67
bt::Resource
Definition:
resourcemanager.h:41
bt::PeerConnector::setMaxActive
static void setMaxActive(Uint32 mc)
bt::PeerConnector::authenticationFinished
void authenticationFinished(bt::Authenticate *auth, bool ok)
Called when an authentication attempt is finished.
bt::Authenticate
Authenicate a peer.
Definition:
authenticate.h:47
bt::PeerConnector::setWeakPointer
void setWeakPointer(WPtr ptr)
Set a weak pointer to this object.
bt::PeerConnector
Definition:
peerconnector.h:49
Generated by
1.8.20