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

CDownloadTransferBT Class Reference

#include <DownloadTransferBT.h>

Inheritance diagram for CDownloadTransferBT:

CDownloadTransfer CTransfer CConnection List of all members.

Public Member Functions

 CDownloadTransferBT (CDownloadSource *pSource, CBTClient *pClient)
virtual ~CDownloadTransferBT ()
virtual BOOL Initiate ()
virtual void Close (TRISTATE bKeepSource)
virtual void Boost ()
virtual DWORD GetAverageSpeed ()
virtual DWORD GetMeasuredSpeed ()
virtual CString GetStateText (BOOL bLong)
virtual BOOL OnRun ()
virtual BOOL OnConnected ()
virtual BOOL SubtractRequested (FF::SimpleFragmentList &ppFragments)
virtual BOOL UnrequestRange (QWORD nOffset, QWORD nLength)
BOOL OnBitfield (CBTPacket *pPacket)
BOOL OnHave (CBTPacket *pPacket)
BOOL OnChoked (CBTPacket *pPacket)
BOOL OnUnchoked (CBTPacket *pPacket)
BOOL OnPiece (CBTPacket *pPacket)
BOOL OnSourceResponse (CBTPacket *pPacket)
void SendFinishedBlock (DWORD nBlock)

Public Attributes

CBTClientm_pClient
BOOL m_bChoked
BOOL m_bInterested
BYTE * m_pAvailable
FF::SimpleFragmentQueue m_oRequested
DWORD m_tRunThrottle
DWORD m_tSourceRequest

Protected Member Functions

void Send (CBTPacket *pPacket, BOOL bRelease=TRUE)
void ShowInterest ()
BOOL SendRequests ()
BOOL SelectFragment (const FF::SimpleFragmentList &oPossible, QWORD &nOffset, QWORD &nLength)

Constructor & Destructor Documentation

CDownloadTransferBT::CDownloadTransferBT CDownloadSource pSource,
CBTClient pClient
 

Definition at line 47 of file DownloadTransferBT.cpp.

References dtsConnecting, dtsNull, CDownloadBase::m_bBTH, m_bChoked, m_bInterested, CDownloadBase::m_nSize, CDownloadTransfer::m_nState, m_pAvailable, m_pClient, CDownloadTransfer::m_pDownload, CConnection::m_sUserAgent, m_tRunThrottle, m_tSourceRequest, NULL, and SIZE_UNKNOWN.

CDownloadTransferBT::~CDownloadTransferBT  )  [virtual]
 

Definition at line 65 of file DownloadTransferBT.cpp.

References m_pAvailable, m_pClient, and NULL.


Member Function Documentation

void CDownloadTransferBT::Boost  )  [virtual]
 

Reimplemented from CDownloadTransfer.

Definition at line 118 of file DownloadTransferBT.cpp.

References CConnection::m_mInput, m_pClient, NULL, and TCPBandwidthMeter::pLimit.

void CDownloadTransferBT::Close TRISTATE  bKeepSource  )  [virtual]
 

Reimplemented from CDownloadTransfer.

Definition at line 97 of file DownloadTransferBT.cpp.

References BT_PACKET_NOT_INTERESTED, CTransfer::Close(), CBTClient::Close(), CBTClient::IsOnline(), m_pClient, CBTClient::m_pDownloadTransfer, CBTPacket::New(), NULL, and CBTClient::Send().

Referenced by CBTClient::Close().

DWORD CDownloadTransferBT::GetAverageSpeed  )  [virtual]
 

Reimplemented from CDownloadTransfer.

Definition at line 124 of file DownloadTransferBT.cpp.

References GetMeasuredSpeed(), CDownloadSource::m_nSpeed, and CDownloadTransfer::m_pSource.

Referenced by CDownloadWithTorrent::ChokeTorrent().

DWORD CDownloadTransferBT::GetMeasuredSpeed  )  [virtual]
 

Reimplemented from CDownloadTransfer.

Definition at line 129 of file DownloadTransferBT.cpp.

References CConnection::m_mInput, m_pClient, CConnection::Measure(), TCPBandwidthMeter::nMeasure, and NULL.

Referenced by GetAverageSpeed().

CString CDownloadTransferBT::GetStateText BOOL  bLong  )  [virtual]
 

Reimplemented from CDownloadTransfer.

Definition at line 136 of file DownloadTransferBT.cpp.

References dtsTorrent, CDownloadTransfer::GetStateText(), IDS_STATUS_CHOKED, IDS_STATUS_REQUESTING, IDS_STATUS_UNINTERESTED, LoadString(), m_bChoked, m_bInterested, and CDownloadTransfer::m_nState.

BOOL CDownloadTransferBT::Initiate  )  [virtual]
 

Implements CDownloadTransfer.

Definition at line 74 of file DownloadTransferBT.cpp.

References CTransfer::Close(), CBTClient::Connect(), dtsConnecting, dtsNull, CDownloadTransfer::m_nState, m_pClient, CConnection::m_pHost, CConnection::m_sAddress, CConnection::m_tConnected, NULL, CDownloadTransfer::SetState(), and TS_FALSE.

BOOL CDownloadTransferBT::OnBitfield CBTPacket pPacket  ) 
 

Definition at line 217 of file DownloadTransferBT.cpp.

References detail::List< FragmentT, ContainerT >::clear(), detail::List< FragmentT, ContainerT >::end(), detail::List< FragmentT, ContainerT >::insert(), CBTInfo::m_nBlockCount, CBTInfo::m_nBlockSize, CDownloadBase::m_nSize, CDownloadSource::m_oAvailable, m_pAvailable, CDownloadTransfer::m_pDownload, CDownloadTransfer::m_pSource, CDownloadWithTorrent::m_pTorrent, NULL, CPacket::ReadByte(), and ShowInterest().

Referenced by CBTClient::OnPacket().

BOOL CDownloadTransferBT::OnChoked CBTPacket pPacket  ) 
 

Definition at line 337 of file DownloadTransferBT.cpp.

References FF::detail::Queue::begin(), BT_PACKET_CANCEL, FF::detail::Queue::clear(), dtsTorrent, FF::detail::Queue::end(), m_bChoked, CBTInfo::m_nBlockSize, m_oRequested, CDownloadTransfer::m_pDownload, CDownloadWithTorrent::m_pTorrent, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEBUG, CBTPacket::New(), Send(), CDownloadTransfer::SetState(), theApp, and CPacket::WriteLongBE().

Referenced by CBTClient::OnPacket().

BOOL CDownloadTransferBT::OnConnected  )  [virtual]
 

Reimplemented from CConnection.

Definition at line 184 of file DownloadTransferBT.cpp.

References CTransfer::Close(), Downloads, dtsTorrent, IDS_DOWNLOAD_CONNECTED, CDownload::IsCompleted(), CConnection::m_mInput, CDownloads::m_nLimitGeneric, m_pClient, CDownloadTransfer::m_pDownload, CConnection::m_pHost, CDownloadTransfer::m_pSource, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEFAULT, NULL, TCPBandwidthMeter::pLimit, CDownloadWithFile::PrepareFile(), CDownloadSource::SetLastSeen(), CDownloadTransfer::SetState(), theApp, TS_FALSE, and TS_TRUE.

Referenced by CBTClient::OnOnline().

BOOL CDownloadTransferBT::OnHave CBTPacket pPacket  ) 
 

Definition at line 264 of file DownloadTransferBT.cpp.

References CPacket::GetRemaining(), detail::List< FragmentT, ContainerT >::insert(), CBTInfo::m_nBlockCount, CBTInfo::m_nBlockSize, CDownloadBase::m_nSize, CDownloadSource::m_oAvailable, m_pAvailable, CDownloadTransfer::m_pDownload, CDownloadTransfer::m_pSource, CDownloadWithTorrent::m_pTorrent, NULL, CPacket::ReadLongBE(), and ShowInterest().

Referenced by CBTClient::OnPacket().

BOOL CDownloadTransferBT::OnPiece CBTPacket pPacket  ) 
 

Definition at line 499 of file DownloadTransferBT.cpp.

References CDownloadSource::AddFragment(), dtsDownloading, dtsRequesting, FF::detail::Queue::erase(), CPacket::GetRemaining(), CBTInfo::m_nBlockSize, CDownloadTransfer::m_nDownloaded, CPacket::m_nPosition, CDownloadTransfer::m_nState, CDownloadWithTorrent::m_nTorrentDownloaded, m_oRequested, CPacket::m_pBuffer, m_pClient, CDownloadTransfer::m_pDownload, CDownloadTransfer::m_pSource, CDownloadWithTorrent::m_pTorrent, NULL, CPacket::ReadLongBE(), SendRequests(), CDownloadTransfer::SetState(), CDownloadSource::SetValid(), ShowInterest(), and CDownloadWithFile::SubmitData().

Referenced by CBTClient::OnPacket().

BOOL CDownloadTransferBT::OnRun  )  [virtual]
 

Reimplemented from CDownloadTransfer.

Definition at line 161 of file DownloadTransferBT.cpp.

References CSettings::BitTorrent, BT_PACKET_SOURCE_REQUEST, dtsDownloading, dtsRequesting, dtsTorrent, CBTClient::m_bExchange, CDownloadTransfer::m_nState, m_pClient, m_tRunThrottle, m_tSourceRequest, CBTPacket::New(), CDownloadTransfer::OnRun(), Send(), SendRequests(), Settings, ShowInterest(), and CSettings::sBitTorrent::SourceExchangePeriod.

Referenced by CBTClient::OnRun().

BOOL CDownloadTransferBT::OnSourceResponse CBTPacket pPacket  ) 
 

Definition at line 526 of file DownloadTransferBT.cpp.

References CBuffer::Add(), CDownloadWithSources::AddSourceBT(), CDownloadWithSources::AddSourceURL(), CBENode::beDict, CBENode::beInt, CBENode::beList, CBENode::beString, CBENode::Decode(), CBENode::GetInt(), CBENode::GetNode(), CPacket::GetRemaining(), CBENode::GetString(), IDS_BT_CLIENT_EXCHANGE, CBENode::IsType(), CBENode::m_nValue, CPacket::m_pBuffer, CDownloadTransfer::m_pDownload, CBENode::m_pValue, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEBUG, MSG_DEFAULT, Network, NULL, CNetwork::Resolve(), and theApp.

Referenced by CBTClient::OnPacket().

BOOL CDownloadTransferBT::OnUnchoked CBTPacket pPacket  ) 
 

Definition at line 356 of file DownloadTransferBT.cpp.

References FF::detail::Queue::clear(), dtsTorrent, m_bChoked, m_oRequested, CConnection::m_sAddress, CShareazaApp::Message(), MSG_DEBUG, SendRequests(), CDownloadTransfer::SetState(), and theApp.

Referenced by CBTClient::OnPacket().

BOOL CDownloadTransferBT::SelectFragment const FF::SimpleFragmentList oPossible,
QWORD nOffset,
QWORD nLength
[protected]
 

Definition at line 451 of file DownloadTransferBT.cpp.

References FF::detail::Fragment< Payload, OffsetType >::begin(), FF::detail::Fragment< Payload, OffsetType >::end(), FF::detail::Fragment< Payload, OffsetType >::length(), CBTInfo::m_nBlockSize, m_pAvailable, CDownloadTransfer::m_pDownload, CDownloadWithTorrent::m_pTorrent, and detail::selectBlock().

Referenced by SendRequests().

void CDownloadTransferBT::Send CBTPacket pPacket,
BOOL  bRelease = TRUE
[protected]
 

Definition at line 152 of file DownloadTransferBT.cpp.

References m_pClient, NULL, and CBTClient::Send().

Referenced by OnChoked(), OnRun(), SendFinishedBlock(), SendRequests(), ShowInterest(), and UnrequestRange().

void CDownloadTransferBT::SendFinishedBlock DWORD  nBlock  ) 
 

Definition at line 256 of file DownloadTransferBT.cpp.

References BT_PACKET_HAVE, CBTClient::IsOnline(), m_pClient, CBTPacket::New(), NULL, Send(), and CPacket::WriteLongBE().

BOOL CDownloadTransferBT::SendRequests  )  [protected]
 

Definition at line 370 of file DownloadTransferBT.cpp.

References CSettings::BitTorrent, BT_PACKET_REQUEST, CDownloadTransfer::ChunkifyRequest(), dtsDownloading, dtsRequesting, dtsTorrent, detail::List< FragmentT, ContainerT >::empty(), FF::detail::Queue::empty(), CSettings::sBitTorrent::Endgame, CDownloadWithFile::GetDisplayName(), CDownloadWithFile::GetEmptyFragmentList(), CDownloadWithTransfers::GetFirstTransfer(), CDownloadWithFile::GetProgress(), IDS_DOWNLOAD_FRAGMENT_REQUEST, m_bChoked, m_bInterested, CDownloadWithTorrent::m_bTorrentEndgame, CBTInfo::m_nBlockSize, CDownloadTransfer::m_nDownloaded, CDownloadTransfer::m_nState, m_oRequested, CDownloadTransfer::m_pDownload, CDownloadWithTorrent::m_pTorrent, CConnection::m_sAddress, CDownloadBase::m_sLocalName, CShareazaApp::Message(), MSG_DEBUG, MSG_DEFAULT, CBTPacket::New(), FF::detail::Queue::pushBack(), CSettings::sBitTorrent::RequestPipe, CSettings::sBitTorrent::RequestSize, SelectFragment(), Send(), CDownloadTransfer::SetState(), Settings, FF::detail::Queue::size(), theApp, and CPacket::WriteLongBE().

Referenced by OnPiece(), OnRun(), and OnUnchoked().

void CDownloadTransferBT::ShowInterest  )  [protected]
 

Definition at line 289 of file DownloadTransferBT.cpp.

References BT_PACKET_INTERESTED, BT_PACKET_NOT_INTERESTED, FF::detail::Queue::clear(), CDownloadWithFile::GetEmptyFragmentList(), m_bInterested, CBTInfo::m_nBlockSize, m_oRequested, m_pAvailable, CDownloadTransfer::m_pDownload, CDownloadWithTorrent::m_pTorrent, CBTPacket::New(), NULL, and Send().

Referenced by OnBitfield(), OnHave(), OnPiece(), and OnRun().

BOOL CDownloadTransferBT::SubtractRequested FF::SimpleFragmentList ppFragments  )  [virtual]
 

Implements CDownloadTransfer.

Definition at line 467 of file DownloadTransferBT.cpp.

References FF::detail::Queue::begin(), FF::detail::Queue::empty(), FF::detail::Queue::end(), detail::List< FragmentT, ContainerT >::erase(), m_bChoked, and m_oRequested.

BOOL CDownloadTransferBT::UnrequestRange QWORD  nOffset,
QWORD  nLength
[virtual]
 

Reimplemented from CDownloadTransfer.

Definition at line 474 of file DownloadTransferBT.cpp.

References FF::detail::Queue::begin(), BT_PACKET_CANCEL, FF::detail::Queue::empty(), FF::detail::Queue::end(), detail::extractRange(), CBTInfo::m_nBlockSize, m_oRequested, CDownloadTransfer::m_pDownload, CDownloadWithTorrent::m_pTorrent, CBTPacket::New(), Send(), and CPacket::WriteLongBE().


Member Data Documentation

BOOL CDownloadTransferBT::m_bChoked
 

Definition at line 43 of file DownloadTransferBT.h.

Referenced by CDownloadTransferBT(), GetStateText(), OnChoked(), CDownloads::OnRun(), OnUnchoked(), SendRequests(), CDownloadTransfer::SetState(), and SubtractRequested().

BOOL CDownloadTransferBT::m_bInterested
 

Definition at line 44 of file DownloadTransferBT.h.

Referenced by CDownloadTransferBT(), GetStateText(), SendRequests(), CDownloadTransfer::SetState(), and ShowInterest().

FF::SimpleFragmentQueue CDownloadTransferBT::m_oRequested
 

Definition at line 47 of file DownloadTransferBT.h.

Referenced by OnChoked(), OnPiece(), OnUnchoked(), SendRequests(), ShowInterest(), SubtractRequested(), and UnrequestRange().

BYTE* CDownloadTransferBT::m_pAvailable
 

Definition at line 46 of file DownloadTransferBT.h.

Referenced by CDownloadTransferBT(), OnBitfield(), OnHave(), SelectFragment(), ShowInterest(), and ~CDownloadTransferBT().

CBTClient* CDownloadTransferBT::m_pClient
 

Definition at line 42 of file DownloadTransferBT.h.

Referenced by Boost(), CDownloadTransferBT(), CDownloadWithTorrent::ChokeTorrent(), Close(), GetMeasuredSpeed(), Initiate(), OnConnected(), OnPiece(), OnRun(), Send(), SendFinishedBlock(), and ~CDownloadTransferBT().

DWORD CDownloadTransferBT::m_tRunThrottle
 

Definition at line 48 of file DownloadTransferBT.h.

Referenced by CDownloadTransferBT(), and OnRun().

DWORD CDownloadTransferBT::m_tSourceRequest
 

Definition at line 49 of file DownloadTransferBT.h.

Referenced by CDownloadTransferBT(), and OnRun().


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