Exemplo n.º 1
0
void CLocalSearch::WriteVirtualTree()
{
	CSingleLock oLock( &Library.m_pSection );
	if ( oLock.Lock( 100 ) )
	{
		m_pPacket = AlbumToPacket( Library.GetAlbumRoot() );
		oLock.Unlock();
		if ( m_pPacket != NULL ) DispatchPacket();
	}

	if ( oLock.Lock( 100 ) )
	{
		m_pPacket = FoldersToPacket();
		oLock.Unlock();
		if ( m_pPacket != NULL ) DispatchPacket();
	}
}
Exemplo n.º 2
0
bool CLocalSearch::ExecuteSharedFiles(INT_PTR nMaximum, INT_PTR& nHits)
{
	CSingleLock oLock( &Library.m_pSection );
	if ( ! oLock.Lock( 250 ) )
		return false;

	auto_ptr< CFileList > pFiles( Library.Search(
		m_pSearch, nMaximum, FALSE,
		// Ghost files only for G2
		m_nProtocol != PROTOCOL_G2 ) );

	if ( pFiles.get() )
	{
		CFileList oFilesInPacket;

		for ( POSITION pos = pFiles->GetHeadPosition() ;
			pos && ( ! nMaximum || ( nHits + oFilesInPacket.GetCount() < nMaximum ) ); )
		{
			CLibraryFile* pFile = pFiles->GetNext( pos );

			if ( IsValidForHit( pFile ) )
			{
				oFilesInPacket.AddTail( pFile );
			}
		}

		SendHits( oFilesInPacket );

		nHits += oFilesInPacket.GetCount();
	}

	// Is it a browser request?
	if ( ! m_pSearch && m_nProtocol == PROTOCOL_G2 )
	{
		// Send virtual tree		
		DispatchPacket( AlbumToPacket( Library.GetAlbumRoot() ) );

		// Send physical tree
		DispatchPacket( FoldersToPacket() );
	}

	return true;
}