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

CDownloadWithTorrent Class Reference

#include <DownloadWithTorrent.h>

Inheritance diagram for CDownloadWithTorrent:

CDownloadWithFile CDownloadWithTransfers CDownloadWithSources CDownloadBase CDownloadWithTiger CDownloadWithSearch CDownloadWithExtras CDownload List of all members.

Public Member Functions

 CDownloadWithTorrent ()
virtual ~CDownloadWithTorrent ()
virtual void Serialize (CArchive &ar, int nVersion)
BOOL SetTorrent (CBTInfo *pTorrent)
void AddUpload (CUploadTransferBT *pUpload)
void RemoveUpload (CUploadTransferBT *pUpload)
void ChokeTorrent (DWORD tNow=0)
void OnTrackerEvent (BOOL bSuccess, LPCTSTR pszReason=NULL)
virtual BOOL FindMoreSources ()
BOOL SeedTorrent (LPCTSTR pszTarget)
void CloseTorrent ()
BOOL IsSeeding () const
float GetRatio () const
BOOL CheckTorrentRatio () const
BOOL UploadExists (in_addr *pIP) const
BOOL UploadExists (SHA1 *pGUID) const
CDownloadTransferBTCreateTorrentTransfer (CBTClient *pClient)
CBTPacketCreateBitfieldPacket ()

Public Attributes

CBTInfo m_pTorrent
BOOL m_bTorrentRequested
BOOL m_bTorrentStarted
DWORD m_tTorrentTracker
QWORD m_nTorrentUploaded
QWORD m_nTorrentDownloaded
BOOL m_bTorrentEndgame
BOOL m_bTorrentTrackerError
CString m_sTorrentTrackerError
int m_nTorrentTrackerErrors
SHA1 m_pPeerID
CString m_sKey
int m_nStartTorrentDownloads

Protected Member Functions

BOOL GenerateTorrentDownloadID ()
BOOL RunTorrent (DWORD tNow)
void OnFinishedTorrentBlock (DWORD nBlock)
void CloseTorrentUploads ()
TCHAR GenerateCharacter () const

Protected Attributes

BYTE * m_pTorrentBlock
DWORD m_nTorrentBlock
DWORD m_nTorrentSize
DWORD m_nTorrentSuccess
BOOL m_bSeeding

Private Attributes

CPtrList m_pTorrentUploads
DWORD m_tTorrentChoke
DWORD m_tTorrentSources

Friends

class CDownloadTransferBT

Constructor & Destructor Documentation

CDownloadWithTorrent::CDownloadWithTorrent  ) 
 

Definition at line 54 of file DownloadWithTorrent.cpp.

References dtAlways, GenerateCharacter(), m_bSeeding, m_bTorrentEndgame, m_bTorrentRequested, m_bTorrentStarted, m_bTorrentTrackerError, m_nStartTorrentDownloads, m_nTorrentBlock, m_nTorrentDownloaded, m_nTorrentSize, m_nTorrentSuccess, m_nTorrentTrackerErrors, m_nTorrentUploaded, m_pPeerID, m_pTorrentBlock, m_sKey, m_tTorrentChoke, m_tTorrentSources, m_tTorrentTracker, SHA1::n, and NULL.

CDownloadWithTorrent::~CDownloadWithTorrent  )  [virtual]
 

Definition at line 86 of file DownloadWithTorrent.cpp.

References CloseTorrentUploads(), m_bTorrentRequested, m_pTorrentBlock, NULL, and CBTTrackerRequest::SendStopped().


Member Function Documentation

void CDownloadWithTorrent::AddUpload CUploadTransferBT pUpload  ) 
 

Definition at line 456 of file DownloadWithTorrent.cpp.

References m_pTorrentUploads, and NULL.

Referenced by CUploadTransferBT::CUploadTransferBT().

BOOL CDownloadWithTorrent::CheckTorrentRatio  )  const
 

Definition at line 704 of file DownloadWithTorrent.cpp.

References dtAlways, dtWhenRatio, CDownloadWithFile::GetVolumeComplete(), CDownloadBase::m_bBTH, m_nStartTorrentDownloads, m_nTorrentDownloaded, and m_nTorrentUploaded.

Referenced by CDownload::OnRun().

void CDownloadWithTorrent::ChokeTorrent DWORD  tNow = 0  ) 
 

Definition at line 480 of file DownloadWithTorrent.cpp.

References CSettings::BitTorrent, CDownloadWithTransfers::CanStartTransfers(), CSettings::Connection, CONNECTION_FIREWALLED, dtsDownloading, CSettings::sConnection::FirewallStatus, CDownloadTransferBT::GetAverageSpeed(), CUploadTransfer::GetAverageSpeed(), CDownloadWithTransfers::GetFirstTransfer(), CDownloadBase::IsCompleted(), CUploadTransferBT::m_bInterested, CUploadTransfer::m_nProtocol, CUploadTransferBT::m_nRandomUnchoke, CDownloadTransferBT::m_pClient, CUploadTransferBT::m_pClient, m_pTorrentUploads, CUploadTransferBT::m_tRandomUnchoke, m_tTorrentChoke, CShareazaApp::Message(), MSG_DEBUG, NULL, PROTOCOL_BT, CSettings::sBitTorrent::RandomPeriod, CUploadTransferBT::SetChoke(), Settings, CDownloadWithTransfers::StartNewTransfer(), theApp, and CSettings::sBitTorrent::UploadCount.

Referenced by CBTClient::OnPacket(), and RunTorrent().

void CDownloadWithTorrent::CloseTorrent  ) 
 

Definition at line 682 of file DownloadWithTorrent.cpp.

References CloseTorrentUploads(), m_bTorrentRequested, m_bTorrentStarted, and CBTTrackerRequest::SendStopped().

Referenced by CDownload::StopTrying().

void CDownloadWithTorrent::CloseTorrentUploads  )  [protected]
 

Definition at line 468 of file DownloadWithTorrent.cpp.

References CUploadTransferBT::Close(), and m_pTorrentUploads.

Referenced by CloseTorrent(), CDownload::Remove(), CDownload::Resume(), CDownload::~CDownload(), and ~CDownloadWithTorrent().

CBTPacket * CDownloadWithTorrent::CreateBitfieldPacket  ) 
 

Definition at line 424 of file DownloadWithTorrent.cpp.

References BT_PACKET_BITFIELD, CBTInfo::IsAvailable(), m_nTorrentBlock, m_pTorrent, m_pTorrentBlock, CBTPacket::New(), NULL, CPacket::Release(), and CPacket::WriteByte().

Referenced by CBTClient::OnOnline().

CDownloadTransferBT * CDownloadWithTorrent::CreateTorrentTransfer CBTClient pClient  ) 
 

Definition at line 378 of file DownloadWithTorrent.cpp.

References CDownloadWithSources::AddSourceInternal(), CDownloadWithSources::CDownloadSource, CDownloadTransferBT, CDownloadWithSources::GetFirstSource(), CDownloadBase::IsMoving(), CDownloadBase::IsPaused(), CDownloadSource::m_bPushOnly, CDownloadSource::m_nProtocol, CBTClient::m_pGUID, CDownloadSource::m_pGUID, CConnection::m_pHost, CDownloadSource::m_pNext, CDownloadSource::m_pTransfer, NULL, and PROTOCOL_BT.

Referenced by CBTClient::OnHandshake2().

BOOL CDownloadWithTorrent::FindMoreSources  )  [virtual]
 

Reimplemented in CDownloadWithSearch.

Definition at line 611 of file DownloadWithTorrent.cpp.

References CSettings::BitTorrent, CSettings::sBitTorrent::DefaultTrackerPeriod, CSettings::sBitTorrent::DownloadConnections, CBTInfo::IsAvailable(), m_bTorrentRequested, CDownloadWithFile::m_pFile, m_pTorrent, m_tTorrentSources, m_tTorrentTracker, NULL, CBTTrackerRequest::SendUpdate(), and Settings.

Referenced by CDownloadWithSearch::FindMoreSources().

TCHAR CDownloadWithTorrent::GenerateCharacter  )  const [inline, protected]
 

Definition at line 94 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent().

BOOL CDownloadWithTorrent::GenerateTorrentDownloadID  )  [protected]
 

Definition at line 261 of file DownloadWithTorrent.cpp.

References CSettings::BitTorrent, BT_ID1, BT_ID2, CShareazaApp::m_nVersion, m_pPeerID, CShareazaApp::Message(), MSG_DEBUG, SHA1::n, Settings, CSettings::sBitTorrent::StandardPeerID, and theApp.

Referenced by RunTorrent(), and SeedTorrent().

float CDownloadWithTorrent::GetRatio  )  const
 

Definition at line 695 of file DownloadWithTorrent.cpp.

References m_nTorrentDownloaded, and m_nTorrentUploaded.

Referenced by CDownloadTipCtrl::OnPaint(), and CDownloadsWnd::OnTimer().

BOOL CDownloadWithTorrent::IsSeeding  )  const [inline]
 

Definition at line 80 of file DownloadWithTorrent.h.

References m_bSeeding.

Referenced by CDownloads::ClearCompleted(), CDownloads::GetActiveTorrentCount(), CDownloadsCtrl::GetDownloadStatus(), CDownloads::GetSeedCount(), CDownloadTipCtrl::OnCalcSize(), CDownloadsWnd::OnContextMenu(), CDownloadTipCtrl::OnPaint(), and CDownloadsWnd::OnTimer().

void CDownloadWithTorrent::OnFinishedTorrentBlock DWORD  nBlock  )  [protected]
 

Definition at line 410 of file DownloadWithTorrent.cpp.

References CDownloadWithTransfers::GetFirstTransfer(), and PROTOCOL_BT.

Referenced by CDownloadWithTiger::FinishValidation().

void CDownloadWithTorrent::OnTrackerEvent BOOL  bSuccess,
LPCTSTR  pszReason = NULL
 

Definition at line 317 of file DownloadWithTorrent.cpp.

References CSettings::BitTorrent, IDS_BT_TRACKER_DOWN, IDS_BT_TRACKER_RETRY, LoadString(), m_bTorrentTrackerError, m_nTorrentTrackerErrors, m_sTorrentTrackerError, m_tTorrentTracker, CSettings::sBitTorrent::MaxTrackerRetry, NULL, and Settings.

Referenced by CBTTrackerRequest::Process().

void CDownloadWithTorrent::RemoveUpload CUploadTransferBT pUpload  ) 
 

Definition at line 462 of file DownloadWithTorrent.cpp.

References m_pTorrentUploads.

Referenced by CUploadTransferBT::Close().

BOOL CDownloadWithTorrent::RunTorrent DWORD  tNow  )  [protected]
 

Definition at line 168 of file DownloadWithTorrent.cpp.

References CSettings::BitTorrent, ChokeTorrent(), CSettings::Connection, CONNECTION_OPEN, CSettings::sBitTorrent::DefaultTrackerPeriod, CSettings::sBitTorrent::DownloadConnections, CSettings::Downloads, CDownloadTask::dtaskAllocate, dtsCountTorrentAndActive, CSettings::sConnection::FirewallStatus, GenerateTorrentDownloadID(), CDownloadWithSources::GetBTSourceCount(), CDownloadWithSources::GetSourceCount(), CUploads::GetTorrentUploadCount(), CDownloadWithTransfers::GetTransferCount(), CBTInfo::IsAvailable(), CDownloadBase::IsCompleted(), CNetwork::IsConnected(), CDownloadBase::IsMoving(), CFragmentedFile::IsOpen(), CDownloadBase::IsPaused(), CDownloadBase::IsTrying(), CDownloadWithFile::m_bDiskFull, m_bTorrentRequested, m_bTorrentStarted, m_nTorrentDownloaded, m_nTorrentUploaded, CDownloadWithFile::m_pFile, CDownloadBase::m_pTask, m_pTorrent, CDownloadBase::m_sLocalName, CBTInfo::m_sName, m_tTorrentChoke, m_tTorrentTracker, CShareazaApp::Message(), MSG_DEFAULT, Network, NULL, CDownloadWithFile::PrepareFile(), CBTTrackerRequest::SendStarted(), CBTTrackerRequest::SendStopped(), CBTTrackerRequest::SendUpdate(), Settings, CSettings::sDownloads::SourcesWanted, theApp, CSettings::sBitTorrent::UploadCount, and Uploads.

Referenced by CDownload::OnRun().

BOOL CDownloadWithTorrent::SeedTorrent LPCTSTR  pszTarget  ) 
 

Definition at line 632 of file DownloadWithTorrent.cpp.

References CSettings::Connection, CONNECTION_FIREWALLED, CDownloadWithFile::DeleteFile(), CSettings::sConnection::FirewallStatus, GenerateTorrentDownloadID(), CDownloadWithSources::GetSourceCount(), CDownloadBase::IsCompleted(), CDownloadBase::IsMoving(), CFragmentedFile::IsOpen(), CDownload::m_bComplete, m_bSeeding, m_bTorrentRequested, m_bTorrentStarted, m_nTorrentBlock, m_nTorrentDownloaded, m_nTorrentSuccess, m_nTorrentUploaded, CDownloadWithFile::m_pFile, m_pTorrentBlock, CDownloadBase::m_sLocalName, CDownload::m_tCompleted, m_tTorrentTracker, NULL, CBTTrackerRequest::SendStarted(), CDownloadBase::SetModified(), Settings, and TS_TRUE.

Referenced by CTorrentSeedDlg::CreateDownload().

void CDownloadWithTorrent::Serialize CArchive &  ar,
int  nVersion
[virtual]
 

Reimplemented from CDownloadWithFile.

Reimplemented in CDownload, CDownloadWithExtras, and CDownloadWithTiger.

Definition at line 96 of file DownloadWithTorrent.cpp.

References CBTInfo::IsAvailable(), CDownloadBase::m_bBTH, CDownloadBase::m_bBTHTrusted, CBTInfo::m_nBlockCount, CBTInfo::m_nBlockSize, m_nTorrentBlock, m_nTorrentSize, m_nTorrentSuccess, CDownloadBase::m_pBTH, CBTInfo::m_pInfoSHA1, m_pTorrent, m_pTorrentBlock, CBTInfo::Serialize(), and CDownloadWithFile::Serialize().

Referenced by CDownloadWithTiger::Serialize().

BOOL CDownloadWithTorrent::SetTorrent CBTInfo pTorrent  ) 
 

Definition at line 133 of file DownloadWithTorrent.cpp.

References CLibraryFolders::AddFolder(), CSettings::sBitTorrent::AdvancedInterface, CSettings::sBitTorrent::AdvancedInterfaceSet, CSettings::BitTorrent, CBTInfo::Copy(), CSettings::Downloads, CBTInfo::IsAvailable(), LibraryFolders, CDownloadBase::m_bBTH, CBTInfo::m_nBlockCount, CBTInfo::m_nBlockSize, m_nTorrentBlock, m_nTorrentSize, CDownloadBase::m_pBTH, CBTInfo::m_pInfoSHA1, m_pTorrent, m_pTorrentBlock, NULL, CDownloadBase::SetModified(), Settings, and CSettings::sDownloads::TorrentPath.

Referenced by CDownloads::Add().

BOOL CDownloadWithTorrent::UploadExists SHA1 pGUID  )  const
 

Definition at line 736 of file DownloadWithTorrent.cpp.

References CUploadTransfer::m_nProtocol, CUploadTransfer::m_nState, CUploadTransferBT::m_pClient, CBTClient::m_pGUID, m_pTorrentUploads, PROTOCOL_BT, and upsNull.

BOOL CDownloadWithTorrent::UploadExists in_addr *  pIP  )  const
 

Definition at line 722 of file DownloadWithTorrent.cpp.

References CUploadTransfer::m_nProtocol, CUploadTransfer::m_nState, CConnection::m_pHost, m_pTorrentUploads, PROTOCOL_BT, and upsNull.

Referenced by CBTClient::OnHandshake1(), and CBTClient::OnHandshake2().


Friends And Related Function Documentation

friend class CDownloadTransferBT [friend]
 

Definition at line 104 of file DownloadWithTorrent.h.

Referenced by CreateTorrentTransfer().


Member Data Documentation

BOOL CDownloadWithTorrent::m_bSeeding [protected]
 

Definition at line 63 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), IsSeeding(), CDownload::OnRun(), and SeedTorrent().

BOOL CDownloadWithTorrent::m_bTorrentEndgame
 

Definition at line 51 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CDownloadTransferED2K::SendFragmentRequests(), and CDownloadTransferBT::SendRequests().

BOOL CDownloadWithTorrent::m_bTorrentRequested
 

Definition at line 46 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CloseTorrent(), FindMoreSources(), CBTTrackerRequest::Process(), RunTorrent(), SeedTorrent(), and ~CDownloadWithTorrent().

BOOL CDownloadWithTorrent::m_bTorrentStarted
 

Definition at line 47 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CloseTorrent(), CBTTrackerRequest::Process(), RunTorrent(), and SeedTorrent().

BOOL CDownloadWithTorrent::m_bTorrentTrackerError
 

Definition at line 52 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CDownloadsCtrl::GetDownloadStatus(), CDownloadTipCtrl::OnCalcSize(), CDownloadsWnd::OnDownloadsHelp(), OnTrackerEvent(), and CDownload::Resume().

int CDownloadWithTorrent::m_nStartTorrentDownloads
 

Definition at line 57 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CheckTorrentRatio(), CDownloadsWnd::OnDownloadsTorrentInfo(), CBTClient::OnHandshake2(), and CDownloadEditDlg::OnTorrentInfo().

DWORD CDownloadWithTorrent::m_nTorrentBlock [protected]
 

Definition at line 60 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CreateBitfieldPacket(), CDownloadWithTiger::FindNewValidationBlock(), CDownloadWithTiger::FinishValidation(), CDownloadWithTiger::GetNextVerifyRange(), CDownloadWithTiger::IsFullyVerified(), CDownload::OnMoved(), CDownloadWithTiger::ResetVerification(), SeedTorrent(), Serialize(), SetTorrent(), and CDownloadWithTiger::ValidationCanFinish().

QWORD CDownloadWithTorrent::m_nTorrentDownloaded
 

Definition at line 50 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CheckTorrentRatio(), GetRatio(), CDownloadTipCtrl::OnPaint(), CDownloadTransferBT::OnPiece(), CDownloadsCtrl::PaintDownload(), RunTorrent(), and SeedTorrent().

DWORD CDownloadWithTorrent::m_nTorrentSize [protected]
 

Definition at line 61 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CDownloadWithTiger::FindNewValidationBlock(), CDownloadWithTiger::FinishValidation(), CDownloadWithTiger::GetNextVerifyRange(), CDownloadWithTiger::GetVerifyLength(), Serialize(), and SetTorrent().

DWORD CDownloadWithTorrent::m_nTorrentSuccess [protected]
 

Definition at line 62 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CDownloadWithTiger::FinishValidation(), CDownloadWithTiger::IsFullyVerified(), CDownload::OnMoved(), CDownloadWithTiger::ResetVerification(), SeedTorrent(), Serialize(), and CDownloadWithTiger::ValidationCanFinish().

int CDownloadWithTorrent::m_nTorrentTrackerErrors
 

Definition at line 54 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), OnTrackerEvent(), and CDownload::Resume().

QWORD CDownloadWithTorrent::m_nTorrentUploaded
 

Definition at line 49 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CheckTorrentRatio(), GetRatio(), CDownloadTipCtrl::OnPaint(), CDownloadsCtrl::PaintDownload(), RunTorrent(), SeedTorrent(), and CUploadTransferBT::ServeRequests().

SHA1 CDownloadWithTorrent::m_pPeerID
 

Definition at line 55 of file DownloadWithTorrent.h.

Referenced by CLocalSearch::AddHit(), CDownloadWithTorrent(), GenerateTorrentDownloadID(), and CBTClient::SendHandshake().

CBTInfo CDownloadWithTorrent::m_pTorrent
 

Definition at line 45 of file DownloadWithTorrent.h.

Referenced by CLocalSearch::AddHit(), CDownloadSource::CheckHash(), CDownloadWithTiger::ContinueValidation(), CreateBitfieldPacket(), FindMoreSources(), CDownloadWithTiger::FindNewValidationBlock(), CDownloadWithTiger::FinishValidation(), CDownloadTransferBT::OnBitfield(), CUploadTransferBT::OnCancel(), CDownloadTransferBT::OnChoked(), CDownloadsWnd::OnDownloadsLaunch(), CDownloadsWnd::OnDownloadsTorrentInfo(), CDownloadTransferBT::OnHave(), CDownloadEditDlg::OnInitDialog(), CDownload::OnMoved(), CDownloadTransferBT::OnPiece(), CUploadTransferBT::OnRequest(), CDownloadsWnd::OnTimer(), CDownloadEditDlg::OnTorrentInfo(), CDownloadsWnd::Prepare(), CDownloadWithTiger::ResetVerification(), RunTorrent(), CDownloadTransferBT::SelectFragment(), CDownloadTransferBT::SendRequests(), Serialize(), CUploadTransferBT::ServeRequests(), SetTorrent(), CDownloadTransferBT::ShowInterest(), CDownloadTransferBT::UnrequestRange(), and CDownload::~CDownload().

BYTE* CDownloadWithTorrent::m_pTorrentBlock [protected]
 

Definition at line 59 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), CreateBitfieldPacket(), CDownloadWithTiger::FindNewValidationBlock(), CDownloadWithTiger::FinishValidation(), CDownloadWithTiger::GetNextVerifyRange(), CDownloadWithTiger::GetVerifyLength(), CDownloadWithTiger::ResetVerification(), CDownloadWithTiger::RunValidation(), SeedTorrent(), Serialize(), SetTorrent(), CDownloadWithTiger::ValidationCanFinish(), and ~CDownloadWithTorrent().

CPtrList CDownloadWithTorrent::m_pTorrentUploads [private]
 

Definition at line 65 of file DownloadWithTorrent.h.

Referenced by AddUpload(), ChokeTorrent(), CloseTorrentUploads(), RemoveUpload(), and UploadExists().

CString CDownloadWithTorrent::m_sKey
 

Definition at line 56 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent().

CString CDownloadWithTorrent::m_sTorrentTrackerError
 

Definition at line 53 of file DownloadWithTorrent.h.

Referenced by CDownloadTipCtrl::OnCalcSize(), CDownloadTipCtrl::OnPaint(), and OnTrackerEvent().

DWORD CDownloadWithTorrent::m_tTorrentChoke [private]
 

Definition at line 66 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), ChokeTorrent(), and RunTorrent().

DWORD CDownloadWithTorrent::m_tTorrentSources [private]
 

Definition at line 67 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), and FindMoreSources().

DWORD CDownloadWithTorrent::m_tTorrentTracker
 

Definition at line 48 of file DownloadWithTorrent.h.

Referenced by CDownloadWithTorrent(), FindMoreSources(), OnTrackerEvent(), CBTTrackerRequest::Process(), RunTorrent(), and SeedTorrent().


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