Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CBTClient Class Reference

#include <BTClient.h>

Inheritance diagram for CBTClient:

CTransfer CConnection List of all members.

Public Member Functions

 CBTClient ()
virtual ~CBTClient ()
virtual BOOL Connect (CDownloadTransferBT *pDownloadTransfer)
virtual void AttachTo (CConnection *pConnection)
virtual void Close ()
void Send (CBTPacket *pPacket, BOOL bRelease=TRUE)
BOOL IsOnline () const

Public Attributes

SHA1 m_pGUID
BOOL m_bExtended
BOOL m_bExchange
CUploadTransferBTm_pUpload
CDownloadm_pDownload
CDownloadTransferBTm_pDownloadTransfer

Protected Member Functions

virtual BOOL OnRun ()
virtual BOOL OnConnected ()
virtual void OnDropped (BOOL bError)
virtual BOOL OnWrite ()
virtual BOOL OnRead ()
void SendHandshake (BOOL bPart1, BOOL bPart2)
BOOL OnHandshake1 ()
BOOL OnHandshake2 ()
BOOL OnOnline ()
BOOL OnPacket (CBTPacket *pPacket)
void SendBeHandshake ()
BOOL OnBeHandshake (CBTPacket *pPacket)
BOOL OnSourceRequest (CBTPacket *pPacket)
void DetermineUserAgent ()

Protected Attributes

BOOL m_bShake
BOOL m_bOnline
BOOL m_bClosing

Constructor & Destructor Documentation

CBTClient::CBTClient  ) 
 

Definition at line 51 of file BTClient.cpp.

References CBTClients::Add(), CSettings::Bandwidth, BTClients, m_bClosing, m_bExchange, m_bExtended, m_bOnline, m_bShake, CConnection::m_mInput, CConnection::m_mOutput, m_pDownload, m_pDownloadTransfer, m_pUpload, CConnection::m_sUserAgent, NULL, TCPBandwidthMeter::pLimit, CSettings::sBandwidth::Request, and Settings.

CBTClient::~CBTClient  )  [virtual]
 

Definition at line 69 of file BTClient.cpp.

References BTClients, CConnection::m_hSocket, m_pDownload, m_pDownloadTransfer, m_pUpload, NULL, and CBTClients::Remove().


Member Function Documentation

void CBTClient::AttachTo CConnection pConnection  )  [virtual]
 

Reimplemented from CTransfer.

Definition at line 102 of file BTClient.cpp.

References CTransfer::AttachTo(), IDS_BT_CLIENT_ACCEPTED, CConnection::m_hSocket, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEFAULT, and theApp.

Referenced by CBTClients::OnAccept().

void CBTClient::Close  )  [virtual]
 

Reimplemented from CTransfer.

Definition at line 112 of file BTClient.cpp.

References CTransfer::Close(), CDownloadTransferBT::Close(), CUploadTransferBT::Close(), CDownload::IsCompleted(), m_bClosing, m_pDownload, m_pDownloadTransfer, m_pUpload, NULL, TS_FALSE, and TS_UNKNOWN.

Referenced by CUploadTransferBT::Close(), CDownloadTransferBT::Close(), OnDropped(), OnHandshake1(), OnHandshake2(), and OnRun().

BOOL CBTClient::Connect CDownloadTransferBT pDownloadTransfer  )  [virtual]
 

Definition at line 82 of file BTClient.cpp.

References CTransfer::ConnectTo(), IDS_BT_CLIENT_CONNECTING, CConnection::m_hSocket, CDownloadSource::m_nPort, CDownloadSource::m_pAddress, m_pDownload, m_pDownloadTransfer, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEFAULT, NULL, and theApp.

Referenced by CDownloadTransferBT::Initiate().

void CBTClient::DetermineUserAgent  )  [protected]
 

Definition at line 534 of file BTClient.cpp.

References SHA1::b, CUploadTransfer::m_bClientExtended, CDownloadSource::m_bClientExtended, m_bExtended, CDownloadSource::m_bPushOnly, m_pDownloadTransfer, m_pGUID, CDownloadTransfer::m_pSource, m_pUpload, CUploadTransfer::m_sNick, CDownloadSource::m_sNick, CDownloadSource::m_sServer, CConnection::m_sUserAgent, and NULL.

Referenced by OnHandshake2().

BOOL CBTClient::IsOnline  )  const [inline]
 

Definition at line 79 of file BTClient.h.

References m_bOnline.

Referenced by CDownloadTransferBT::Close(), and CDownloadTransferBT::SendFinishedBlock().

BOOL CBTClient::OnBeHandshake CBTPacket pPacket  )  [protected]
 

Definition at line 871 of file BTClient.cpp.

References CBuffer::Add(), CBENode::beString, BT_PACKET_SOURCE_REQUEST, CBENode::Decode(), CBENode::GetNode(), CPacket::GetRemaining(), CBENode::GetString(), IDS_BT_CLIENT_EXTENDED, CBENode::IsType(), CUploadTransfer::m_bClientExtended, CDownloadSource::m_bClientExtended, m_bExchange, CPacket::m_pBuffer, m_pDownloadTransfer, CDownloadTransfer::m_pSource, m_pUpload, CConnection::m_sAddress, CDownloadSource::m_sNick, CDownloadSource::m_sServer, CConnection::m_sUserAgent, CShareazaApp::Message(), MSG_DEFAULT, CBTPacket::New(), NULL, Send(), and theApp.

Referenced by OnPacket().

BOOL CBTClient::OnConnected  )  [protected, virtual]
 

Reimplemented from CConnection.

Definition at line 212 of file BTClient.cpp.

References IDS_BT_CLIENT_HANDSHAKING, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEFAULT, SendHandshake(), and theApp.

void CBTClient::OnDropped BOOL  bError  )  [protected, virtual]
 

Reimplemented from CConnection.

Definition at line 222 of file BTClient.cpp.

References Close(), IDS_BT_CLIENT_DROP_CONNECTED, IDS_BT_CLIENT_DROP_CONNECTING, IDS_BT_CLIENT_DROP_HANDSHAKE, CConnection::m_bConnected, m_bOnline, CConnection::m_sAddress, CShareazaApp::Message(), MSG_ERROR, and theApp.

BOOL CBTClient::OnHandshake1  )  [protected]
 

Definition at line 321 of file BTClient.cpp.

References CSettings::BitTorrent, BT_PROTOCOL_HEADER, BT_PROTOCOL_HEADER_LEN, Close(), CSettings::sBitTorrent::DownloadConnections, Downloads, dtsCountTorrentAndActive, CDownloads::FindByBTH(), CDownloadWithTransfers::GetTransferCount(), IDS_BT_CLIENT_DUPLICATE, IDS_BT_CLIENT_INACTIVE_FILE, IDS_BT_CLIENT_MAX_CONNECTIONS, IDS_BT_CLIENT_UNKNOWN_FILE, IDS_BT_CLIENT_WRONG_FILE, CDownload::IsShared(), CDownload::IsTrying(), CConnection::m_bInitiated, m_bOnline, m_bShake, CDownloadBase::m_pBTH, CBuffer::m_pBuffer, m_pDownload, m_pDownloadTransfer, CConnection::m_pHost, CConnection::m_pInput, CConnection::m_sAddress, CShareazaApp::Message(), MSG_ERROR, NULL, CBuffer::Remove(), SendHandshake(), Settings, theApp, and CDownloadWithTorrent::UploadExists().

Referenced by OnRead().

BOOL CBTClient::OnHandshake2  )  [protected]
 

Definition at line 414 of file BTClient.cpp.

References SHA1::b, Close(), CDownloadWithTorrent::CreateTorrentTransfer(), DetermineUserAgent(), dtNever, IDS_BT_CLIENT_DUPLICATE, IDS_BT_CLIENT_UNKNOWN_FILE, CDownload::IsMoving(), CDownload::IsPaused(), m_bExtended, CConnection::m_bInitiated, m_bOnline, CDownloadWithTorrent::m_nStartTorrentDownloads, CBuffer::m_pBuffer, m_pDownload, m_pDownloadTransfer, CDownloadSource::m_pGUID, m_pGUID, CConnection::m_pInput, CDownloadTransfer::m_pSource, m_pUpload, CConnection::m_sAddress, CConnection::m_sUserAgent, CShareazaApp::Message(), MSG_ERROR, NULL, OnOnline(), CBuffer::Remove(), theApp, and CDownloadWithTorrent::UploadExists().

Referenced by OnRead().

BOOL CBTClient::OnOnline  )  [protected]
 

Definition at line 779 of file BTClient.cpp.

References CDownloadWithTorrent::CreateBitfieldPacket(), CDownloadWithFile::GetDisplayName(), IDS_BT_CLIENT_ONLINE, m_bExtended, m_bOnline, m_pDownload, m_pDownloadTransfer, m_pUpload, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEFAULT, NULL, CUploadTransferBT::OnConnected(), CDownloadTransferBT::OnConnected(), Send(), SendBeHandshake(), and theApp.

Referenced by OnHandshake2().

BOOL CBTClient::OnPacket CBTPacket pPacket  )  [protected]
 

Definition at line 802 of file BTClient.cpp.

References BT_PACKET_BITFIELD, BT_PACKET_CANCEL, BT_PACKET_CHOKE, BT_PACKET_HANDSHAKE, BT_PACKET_HAVE, BT_PACKET_INTERESTED, BT_PACKET_KEEPALIVE, BT_PACKET_NOT_INTERESTED, BT_PACKET_PIECE, BT_PACKET_REQUEST, BT_PACKET_SOURCE_REQUEST, BT_PACKET_SOURCE_RESPONSE, BT_PACKET_UNCHOKE, CDownloadWithTorrent::ChokeTorrent(), m_bExchange, m_bExtended, CBTPacket::m_nType, m_pDownload, m_pDownloadTransfer, m_pUpload, NULL, OnBeHandshake(), CDownloadTransferBT::OnBitfield(), CUploadTransferBT::OnCancel(), CDownloadTransferBT::OnChoked(), CDownloadTransferBT::OnHave(), CUploadTransferBT::OnInterested(), CDownloadTransferBT::OnPiece(), CUploadTransferBT::OnRequest(), OnSourceRequest(), CDownloadTransferBT::OnSourceResponse(), CDownloadTransferBT::OnUnchoked(), and CUploadTransferBT::OnUninterested().

Referenced by OnRead().

BOOL CBTClient::OnRead  )  [protected, virtual]
 

Reimplemented from CConnection.

Definition at line 246 of file BTClient.cpp.

References BT_PROTOCOL_HEADER_LEN, m_bOnline, m_bShake, CBuffer::m_nLength, CConnection::m_pInput, OnHandshake1(), OnHandshake2(), OnPacket(), CConnection::OnRead(), CBTPacket::ReadBuffer(), and CPacket::Release().

BOOL CBTClient::OnRun  )  [protected, virtual]
 

Reimplemented from CConnection.

Definition at line 160 of file BTClient.cpp.

References CBuffer::Add(), CSettings::BitTorrent, Close(), CSettings::Connection, IDS_BT_CLIENT_CONNECT_TIMEOUT, IDS_BT_CLIENT_HANDSHAKE_TIMEOUT, IDS_BT_CLIENT_LOST, CSettings::sBitTorrent::LinkPing, CSettings::sBitTorrent::LinkTimeout, CConnection::m_bConnected, m_bOnline, CConnection::m_mInput, CConnection::m_mOutput, CBuffer::m_nLength, m_pDownloadTransfer, CConnection::m_pOutput, m_pUpload, CConnection::m_sAddress, CConnection::m_tConnected, CShareazaApp::Message(), MSG_ERROR, NULL, CUploadTransferBT::OnRun(), CDownloadTransferBT::OnRun(), CConnection::OnRun(), OnWrite(), Settings, theApp, CSettings::sConnection::TimeoutConnect, CSettings::sConnection::TimeoutHandshake, and TCPBandwidthMeter::tLast.

BOOL CBTClient::OnSourceRequest CBTPacket pPacket  )  [protected]
 

Definition at line 935 of file BTClient.cpp.

References CBENode::Add(), BT_PACKET_SOURCE_RESPONSE, dtsRequesting, CBENode::Encode(), CBENode::GetCount(), CDownloadWithSources::GetFirstSource(), CSourceURL::m_bBTC, CSourceURL::m_pBTC, m_pDownload, CBTPacket::New(), NULL, CSourceURL::Parse(), PROTOCOL_BT, PROTOCOL_HTTP, Send(), and CPacket::Write().

Referenced by OnPacket().

BOOL CBTClient::OnWrite  )  [protected, virtual]
 

Reimplemented from CConnection.

Definition at line 237 of file BTClient.cpp.

References CConnection::OnWrite().

Referenced by OnRun(), Send(), and SendHandshake().

void CBTClient::Send CBTPacket pPacket,
BOOL  bRelease = TRUE
 

Definition at line 141 of file BTClient.cpp.

References m_bOnline, CConnection::m_hSocket, CPacket::m_nProtocol, CConnection::m_pOutput, NULL, OnWrite(), PROTOCOL_BT, CPacket::Release(), and CBTPacket::ToBuffer().

Referenced by CDownloadTransferBT::Close(), OnBeHandshake(), OnOnline(), OnSourceRequest(), CDownloadTransferBT::Send(), SendBeHandshake(), CUploadTransferBT::ServeRequests(), and CUploadTransferBT::SetChoke().

void CBTClient::SendBeHandshake  )  [protected]
 

Definition at line 852 of file BTClient.cpp.

References CBENode::Add(), BT_PACKET_HANDSHAKE, CBENode::Encode(), CGProfile::GetNick(), MyProfile, CBTPacket::New(), Send(), Settings, CSettings::SmartAgent(), and CPacket::Write().

Referenced by OnOnline().

void CBTClient::SendHandshake BOOL  bPart1,
BOOL  bPart2
[protected]
 

Definition at line 300 of file BTClient.cpp.

References CBuffer::Add(), BT_PROTOCOL_HEADER, CDownloadBase::m_pBTH, m_pDownload, CConnection::m_pOutput, CDownloadWithTorrent::m_pPeerID, NULL, OnWrite(), and CBuffer::Print().

Referenced by OnConnected(), and OnHandshake1().


Member Data Documentation

BOOL CBTClient::m_bClosing [protected]
 

Definition at line 51 of file BTClient.h.

Referenced by CBTClient(), and Close().

BOOL CBTClient::m_bExchange
 

Definition at line 43 of file BTClient.h.

Referenced by CBTClient(), OnBeHandshake(), OnPacket(), and CDownloadTransferBT::OnRun().

BOOL CBTClient::m_bExtended
 

Definition at line 42 of file BTClient.h.

Referenced by CBTClient(), DetermineUserAgent(), OnHandshake2(), OnOnline(), and OnPacket().

BOOL CBTClient::m_bOnline [protected]
 

Definition at line 50 of file BTClient.h.

Referenced by CBTClient(), IsOnline(), OnDropped(), OnHandshake1(), OnHandshake2(), OnOnline(), OnRead(), OnRun(), and Send().

BOOL CBTClient::m_bShake [protected]
 

Definition at line 49 of file BTClient.h.

Referenced by CBTClient(), OnHandshake1(), and OnRead().

CDownload* CBTClient::m_pDownload
 

Definition at line 46 of file BTClient.h.

Referenced by CBTClient(), Close(), Connect(), OnHandshake1(), OnHandshake2(), OnOnline(), OnPacket(), OnSourceRequest(), SendHandshake(), and ~CBTClient().

CDownloadTransferBT* CBTClient::m_pDownloadTransfer
 

Definition at line 47 of file BTClient.h.

Referenced by CBTClient(), CDownloadTransferBT::Close(), Close(), Connect(), DetermineUserAgent(), OnBeHandshake(), OnHandshake1(), OnHandshake2(), OnOnline(), OnPacket(), OnRun(), and ~CBTClient().

SHA1 CBTClient::m_pGUID
 

Definition at line 41 of file BTClient.h.

Referenced by CDownloadWithTorrent::CreateTorrentTransfer(), DetermineUserAgent(), OnHandshake2(), and CDownloadWithTorrent::UploadExists().

CUploadTransferBT* CBTClient::m_pUpload
 

Definition at line 45 of file BTClient.h.

Referenced by CBTClient(), CUploadTransferBT::Close(), Close(), DetermineUserAgent(), OnBeHandshake(), OnHandshake2(), OnOnline(), OnPacket(), OnRun(), and ~CBTClient().


The documentation for this class was generated from the following files:
Generated on Thu Dec 15 10:40:04 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2