Exemplo n.º 1
0
void CLocalSearch::WriteTrailer()
{
	ASSERT( m_pPacket != NULL );

	if ( m_nProtocol == PROTOCOL_G1 )
		WriteTrailerG1();
	else
		WriteTrailerG2();
}
Exemplo n.º 2
0
void CLocalSearch::WriteTrailer(CPacket* pPacket, CSchemaMap& pSchemas, BYTE nHits)
{
	ASSERT( pPacket != NULL );

	switch ( m_nProtocol )
	{
	case PROTOCOL_G1:
		WriteTrailerG1( static_cast< CG1Packet* >( pPacket ), pSchemas, nHits );
		break;
	case PROTOCOL_G2:
		WriteTrailerG2( static_cast< CG2Packet* >( pPacket ), pSchemas, nHits );
		break;
	case PROTOCOL_DC:
		WriteTrailerDC( static_cast< CDCPacket* >( pPacket ), pSchemas, nHits );
		break;
	default:
		ASSERT( FALSE );
	}
}
Exemplo n.º 3
0
int CLocalSearch::ExecutePartialFiles(int nMaximum)
{
	ASSERT( m_nProtocol == PROTOCOL_G2 );
	ASSERT( m_pSearch != NULL );

	if ( m_pSearch->m_bTiger == FALSE && m_pSearch->m_bSHA1 == FALSE &&
		 m_pSearch->m_bED2K  == FALSE && m_pSearch->m_bBTH == FALSE ) return 0;

	CSingleLock pLock( &Transfers.m_pSection );
	if ( ! pLock.Lock( 50 ) ) return 0;

	int nCount = 0;
	m_pPacket = NULL;

	for ( POSITION pos = Downloads.GetIterator() ; pos ; )
	{
		CDownload* pDownload = Downloads.GetNext( pos );

		if ( ! pDownload->IsShared() ) continue;

		if (	( m_pSearch->m_bTiger && pDownload->m_bTiger && m_pSearch->m_pTiger == pDownload->m_pTiger )
			||	( m_pSearch->m_bSHA1  && pDownload->m_bSHA1  && m_pSearch->m_pSHA1  == pDownload->m_pSHA1 )
			||	( m_pSearch->m_bED2K  && pDownload->m_bED2K  && m_pSearch->m_pED2K  == pDownload->m_pED2K )
			||	( m_pSearch->m_bBTH   && pDownload->m_bBTH   && m_pSearch->m_pBTH   == pDownload->m_pBTH ) )
		{
			if ( pDownload->m_bBTH || pDownload->IsStarted() )
			{
				if ( m_pPacket == NULL ) CreatePacketG2();
				AddHit( pDownload, nCount++ );
			}
		}
	}

	if ( m_pPacket != NULL )
	{
		WriteTrailerG2();
		DispatchPacket();
	}

	return nCount;
}