bool CDownloadTransferBT::UnrequestRange(QWORD nOffset, QWORD nLength)
{
	ASSUME_LOCK( Transfers.m_pSection );

	if ( m_oRequested.empty() ) 
		return false;

	ASSERT( m_pDownload->m_pTorrent.m_nBlockSize != 0 );
	if ( m_pDownload->m_pTorrent.m_nBlockSize == 0 )
		return false;

	Fragments::Queue oUnrequests = extract_range( m_oRequested,
		Fragments::Fragment( nOffset, nOffset + nLength ) );

	for ( Fragments::Queue::const_iterator pFragment = oUnrequests.begin();
		pFragment != oUnrequests.end(); ++pFragment )
	{
		m_pClient->Cancel(
			(DWORD)( pFragment->begin() / m_pDownload->m_pTorrent.m_nBlockSize ),
			(DWORD)( pFragment->begin() % m_pDownload->m_pTorrent.m_nBlockSize ),
			(DWORD)( pFragment->size() ) );
	}

	return !oUnrequests.empty();
}
Beispiel #2
0
void CDownloadTransfer::DrawStateBar(CDC* pDC, CRect* prcBar, COLORREF crFill, BOOL bTop) const
{
	CFragmentBar::DrawStateBar( pDC, prcBar, m_pDownload->m_nSize, m_nOffset, m_nLength, crFill, bTop );

	if ( m_nProtocol == PROTOCOL_BT || m_nProtocol == PROTOCOL_ED2K )
	{
		for ( Fragments::Queue::const_iterator pItr = m_oRequested.begin(); pItr != m_oRequested.end(); ++pItr )
		{
			CFragmentBar::DrawStateBar( pDC, prcBar, m_pDownload->m_nSize, pItr->begin(), pItr->size(), crFill, bTop );
		}
	}
}