BOOL CHostBrowser::ReadContent() { if ( m_nReceived < m_nLength ) { DWORD nVolume = min( m_nLength - m_nReceived, m_pInput->m_nLength ); m_nReceived += nVolume; if ( m_bDeflate && m_pInflate != NULL ) { z_streamp pStream = (z_streamp)m_pInflate; while ( nVolume || m_pBuffer->m_nLength == m_pBuffer->m_nBuffer || pStream->avail_out == 0 ) { m_pBuffer->EnsureBuffer( 1024 ); pStream->next_in = m_pInput->m_pBuffer; pStream->avail_in = m_pInput->m_nLength; pStream->next_out = m_pBuffer->m_pBuffer + m_pBuffer->m_nLength; pStream->avail_out = m_pBuffer->m_nBuffer - m_pBuffer->m_nLength; inflate( pStream, Z_SYNC_FLUSH ); m_pInput->Remove( m_pInput->m_nLength - pStream->avail_in ); nVolume -= ( m_pInput->m_nLength - pStream->avail_in ); DWORD nBlock = ( m_pBuffer->m_nBuffer - m_pBuffer->m_nLength ) - pStream->avail_out; m_pBuffer->m_nLength += nBlock; if ( ! nBlock ) break; } } else { m_pBuffer->AddBuffer( m_pInput, nVolume ); } } switch ( m_nProtocol ) { case 0: if ( ! StreamHTML() ) return FALSE; break; case PROTOCOL_G1: if ( ! StreamPacketsG1() ) return FALSE; break; case PROTOCOL_G2: if ( ! StreamPacketsG2() ) return FALSE; break; } if ( m_nReceived < m_nLength ) return TRUE; Stop( TRUE ); if ( m_pProfile->IsValid() && m_pNotify != NULL ) m_pNotify->OnProfileReceived(); theApp.Message( MSG_SYSTEM, IDS_BROWSE_FINISHED, (LPCTSTR)m_sAddress, m_nHits ); return TRUE; }
BOOL CHostBrowser::ReadContent() { CQuickLock oTransfersLock( Transfers.m_pSection ); if ( m_nProtocol != PROTOCOL_ED2K && m_nProtocol != PROTOCOL_DC ) { if ( m_nReceived < m_nLength ) { CLockedBuffer pInput( GetInput() ); DWORD nVolume = min( DWORD( m_nLength - m_nReceived ), pInput->m_nLength ); m_nReceived += nVolume; if ( ! m_bDeflate ) { m_pBuffer->AddBuffer( pInput, nVolume ); } else if ( ! pInput->InflateStreamTo( *m_pBuffer, m_pInflate ) ) // Try to decompress the stream { Stop(); // Clean up return FALSE; // Report failure } } } switch ( m_nProtocol ) { case PROTOCOL_NULL: if ( ! StreamHTML() ) return FALSE; break; case PROTOCOL_G2: if ( ! StreamPacketsG2() ) return FALSE; break; case PROTOCOL_G1: if ( ! StreamPacketsG1() ) return FALSE; break; //case PROTOCOL_ED2K: //case PROTOCOL_DC: // break; // Skip //default: // theApp.Message( MSG_ERROR, L"CHostBrowser::ReadContent(): Unknown Browse Protocol" ); } if ( m_nReceived < m_nLength ) return TRUE; Stop( TRUE ); return TRUE; }