CAlbumFolder* CAlbumFolder::FindFile(CLibraryFile* pFile) const
{
	if ( m_pFiles.Find( pFile ) != NULL ) return (CAlbumFolder*)this;

	POSITION pos = GetFolderIterator();
	CAlbumFolder* pFirst = pos ? GetNextFolder( pos ) : NULL;

	if ( GetFolderCount() > 1 )
	{
		while ( pos )
		{
			CAlbumFolder* pFolder = GetNextFolder( pos )->FindFile( pFile );
			if ( pFolder != NULL ) return pFolder;
		}

		CAlbumFolder* pFolder = pFirst->FindFile( pFile );
		if ( pFolder != NULL ) return pFolder;
	}
	else if ( pFirst != NULL )
	{
		CAlbumFolder* pFolder = pFirst->FindFile( pFile );
		if ( pFolder != NULL ) return pFolder;
	}

	return NULL;
}
BOOL CFilesProfilePage::OnInitDialog()
{
	CSettingsPage::OnInitDialog();

	CRect rc;
	m_wndList.GetClientRect( &rc );
	rc.right -= GetSystemMetrics( SM_CXVSCROLL ) + 1;
	m_wndList.InsertColumn( 0, _T("File"), LVCFMT_LEFT, rc.right, -1 );
	ShellIcons.AttachTo( &m_wndList, 16 );	// m_wndList.SetImageList()

	{
		CQuickLock oLock( Library.m_pSection );

		CAlbumFolder* pFolder = LibraryFolders.GetAlbumTarget( CSchema::uriFavouritesFolder, _T("Title"), NULL );
		if ( pFolder != NULL )
		{
			for ( POSITION pos = pFolder->GetFileIterator() ; pos ; )
			{
				CLibraryFile* pFile = pFolder->GetNextFile( pos );

				if ( pFile->IsShared() )
				{
					m_wndList.InsertItem( LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM, m_wndList.GetItemCount(),
						pFile->m_sName, 0, 0, ShellIcons.Get( pFile->GetPath(), 16 ), pFile->m_nIndex );
				}
			}
		}
	}

	UpdateData( FALSE );

	return TRUE;
}
CAlbumFolder* CAlbumFolder::GetTarget(CSchemaMember* pMember, LPCTSTR pszValue) const
{
	if ( m_pSchema == pMember->m_pSchema )
	{
		if ( pszValue == NULL )
		{
			return (CAlbumFolder*)this;
		}
		else if ( m_pXML != NULL )
		{
			CString strValue = pMember->GetValueFrom( m_pXML, NULL, TRUE );
			CXMLNode::UniformString( strValue );
			if ( strValue.CompareNoCase( pszValue ) == 0 ) return (CAlbumFolder*)this;
		}
	}

	for ( POSITION pos = GetFolderIterator() ; pos ; )
	{
		CAlbumFolder* pCheck	= GetNextFolder( pos );
		CAlbumFolder* pResult	= pCheck->GetTarget( pMember, pszValue );
		if ( pResult ) return pResult;
	}

	return NULL;
}
BOOL CAlbumFolder::CheckFolder(CAlbumFolder* pFolder, BOOL bRecursive) const
{
	for ( POSITION pos = GetFolderIterator() ; pos ; )
	{
		CAlbumFolder* pCheck = GetNextFolder( pos );
		if ( pCheck == pFolder ) return TRUE;
		if ( bRecursive && pCheck->CheckFolder( pFolder, TRUE ) ) return TRUE;
	}

	return FALSE;
}
CAlbumFolder* CAlbumFolder::FindCollection(SHA1* pSHA1)
{
	if ( m_bCollSHA1 && *pSHA1 == m_pCollSHA1 ) return this;

	for ( POSITION pos = GetFolderIterator() ; pos ; )
	{
		CAlbumFolder* pFolder = GetNextFolder( pos );
		if ( CAlbumFolder* pFind = pFolder->FindCollection( pSHA1 ) ) return pFind;
	}

	return NULL;
}
void CLibraryFileView::OnLibraryUnlink()
{
	CSingleLock pLock( &Library.m_pSection, TRUE );

	CLibraryTreeItem* pItem = GetFolderSelection();

	if ( pItem == NULL || pItem->m_pVirtual == NULL || pItem->m_pSelNext != NULL ) return;

	CAlbumFolder* pFolder = pItem->m_pVirtual;
	if ( ! LibraryFolders.CheckAlbum( pFolder ) ) return;

	POSITION posSel = StartSelectedFileLoop();
	while ( CLibraryFile* pFile = GetNextSelectedFile( posSel ) )
	{
		pFolder->RemoveFile( pFile );
	}
}
void CAlbumFolder::Serialize(CArchive& ar, int nVersion)
{
	POSITION pos;

	if ( ar.IsStoring() )
	{
		ar << m_sSchemaURI;

		ar.WriteCount( m_pXML != NULL ? 1 : 0 );
		if ( m_pXML ) m_pXML->Serialize( ar );

		ar << m_bCollSHA1;
		if ( m_bCollSHA1 ) ar.Write( &m_pCollSHA1, sizeof(SHA1) );

		ar << m_sName;
		ar << m_bExpanded;
		ar << m_bAutoDelete;
		ar << m_sBestView;

		ar.WriteCount( GetFolderCount() );

		for ( pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pFolder = GetNextFolder( pos );
			pFolder->Serialize( ar, nVersion );
		}

		ar.WriteCount( GetFileCount() );

		for ( pos = GetFileIterator() ; pos ; )
		{
			CLibraryFile* pFile = GetNextFile( pos );
			ar << pFile->m_nIndex;
		}
	}
	else
	{
		CLibraryFile* pCollection = NULL;

		if ( m_pParent != NULL )
		{
			ar >> m_sSchemaURI;
			m_pSchema = SchemaCache.Get( m_sSchemaURI );
		}
		else
		{
BOOL CAlbumFolder::MountCollection(SHA1* pSHA1, CCollectionFile* pCollection, BOOL bForce)
{
	if ( ! bForce )
	{
		BOOL bResult = FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			bResult |= GetNextFolder( pos )->MountCollection( pSHA1, pCollection, bForce );
		}

		if ( m_pSchema == NULL ) return bResult;

		if ( m_pSchema->GetContained( pCollection->GetThisURI() ) == NULL &&
			 m_sSchemaURI != CSchema::uriCollectionsFolder ) return bResult;
	}

	CAlbumFolder* pFolder = NULL;

	for ( POSITION pos = GetFolderIterator() ; pos ; )
	{
		pFolder = GetNextFolder( pos );
		if ( pFolder->m_bCollSHA1 && *pSHA1 == pFolder->m_pCollSHA1 ) break;
		pFolder = NULL;
	}

	if ( pFolder == NULL )
	{
		pFolder = AddFolder( pCollection->GetThisURI(), pCollection->GetTitle() );
	}

	pFolder->SetCollection( pSHA1, pCollection );

	m_nUpdateCookie++;
	Library.m_nUpdateCookie++;

	return TRUE;
}
Exemple #9
0
void CLibraryFrame::RunLocalSearch(CQuerySearch* pSearch)
{
	CWaitCursor pCursor;

	pSearch->BuildWordList( true, true );

	CSingleLock oLock( &Library.m_pSection, TRUE );

	CAlbumFolder* pRoot = Library.GetAlbumRoot();
	if ( ! pRoot ) return;

	CAlbumFolder* pFolder = pRoot->GetFolderByURI( CSchema::uriSearchFolder );
	if ( pFolder == NULL )
	{
		pFolder = pRoot->AddFolder( CSchema::uriSearchFolder, L"Search Results" );
		if ( pFolder->m_pSchema != NULL )
		{
			int nColon = pFolder->m_pSchema->m_sTitle.Find( L':' );
			if ( nColon >= 0 )
				pFolder->m_sName = pFolder->m_pSchema->m_sTitle.Mid( nColon + 1 );
		}
	}
	else
	{
		// Get translated name of the default search folder
		// We will clear it, not others as user may want to keep several folders
		CString strFolderName;
		int nColon = pFolder->m_pSchema->m_sTitle.Find( L':' );
		if ( nColon >= 0 )
			strFolderName = pFolder->m_pSchema->m_sTitle.Mid( nColon + 1 );
		if ( ! strFolderName.IsEmpty() )
			pFolder	= pRoot->GetFolder( strFolderName );

		if ( pFolder == NULL )
		{
			pFolder = pRoot->AddFolder( CSchema::uriSearchFolder, L"Search Results" );
			if ( pFolder->m_pSchema != NULL && ! strFolderName.IsEmpty() )
				pFolder->m_sName = strFolderName;
		}
		else
			pFolder->Clear();
	}

	if ( pFolder->m_pSchema )
	{
		CString strDate, strTime;
		SYSTEMTIME pTime;

		GetLocalTime( &pTime );
		GetDateFormat( LOCALE_USER_DEFAULT, 0, &pTime, L"yyyy-MM-dd", strDate.GetBuffer( 64 ), 64 );
		GetTimeFormat( LOCALE_USER_DEFAULT, 0, &pTime, L"hh:mm tt", strTime.GetBuffer( 64 ), 64 );
		strDate.ReleaseBuffer(); strTime.ReleaseBuffer();

		CXMLElement* pOuter = pFolder->m_pSchema->Instantiate();
		CXMLElement* pInner = pOuter->AddElement( L"searchFolder" );
		pInner->AddAttribute( L"title", pFolder->m_sName );
		pInner->AddAttribute( L"content", pSearch->m_sSearch );
		pInner->AddAttribute( L"date", strDate );
		pInner->AddAttribute( L"time", strTime );
		pFolder->SetMetadata( pOuter );
		delete pOuter;
	}

	if ( CFileList* pFiles = Library.Search( pSearch, 0, TRUE ) )
	{
		for ( POSITION pos = pFiles->GetHeadPosition(); pos; )
		{
			const CLibraryFile* pFile = pFiles->GetNext( pos );

			if ( Settings.Search.SchemaTypes && pSearch->m_pSchema != NULL )
			{
				if ( ! pSearch->m_pSchema->FilterType( pFile->m_sName ) )
					pFile = NULL;
			}

			if ( pFile != NULL && pFile->IsAvailable() )
				pFolder->AddFile( const_cast< CLibraryFile* >( pFile ) );
		}

		delete pFiles;
	}

	oLock.Unlock();

	Update();
	Display( pFolder );
	GetParent()->PostMessage( WM_COMMAND, ID_VIEW_LIBRARY );
}
int CLibraryHeaderPanel::Update()
{
	CAlbumFolder* pFolder = GetSelectedAlbum();
	if ( pFolder == NULL || pFolder->m_pSchema == NULL ) return 0;

	m_nIcon32	= pFolder->m_pSchema->m_nIcon32;
	m_nIcon48	= pFolder->m_pSchema->m_nIcon48;

	m_sTitle	= pFolder->m_pSchema->m_sHeaderTitle;
	m_sSubtitle	= pFolder->m_pSchema->m_sHeaderSubtitle;

	if ( pFolder->GetParent() == NULL )
	{
		QWORD nTotalVolume;
		DWORD nTotalFiles;
		CString str;

		LibraryMaps.GetStatistics( &nTotalFiles, &nTotalVolume );
		str.Format( _T("%lu"), nTotalFiles );
		m_sSubtitle.Replace( _T("{totalFiles}"), str );
		str = Settings.SmartVolume( nTotalVolume, KiloBytes );
		m_sSubtitle.Replace( _T("{totalVolume}"), str );
	}

	pFolder->m_pSchema->ResolveTokens( m_sTitle, pFolder->m_pXML );
	pFolder->m_pSchema->ResolveTokens( m_sSubtitle, pFolder->m_pXML );

	if ( m_sTitle.IsEmpty() ) m_sTitle = pFolder->m_sName;

	m_pMetadata.Setup( pFolder->m_pSchema );
	m_pMetadata.Remove( pFolder->m_pSchema->GetFirstMemberName() );

	m_pMetadata.Combine( pFolder->m_pXML );

	m_pMetadata.CreateLinks();
	m_pMetadata.Clean( 54 );

	if ( m_pMetadata.GetCount() )
	{
		CClientDC dc( this );
		CFont* pFont = (CFont*)dc.SelectObject( &CoolInterface.m_fntNormal );
		m_nKeyWidth = m_nMetaWidth = 0;
		m_pMetadata.ComputeWidth( &dc, m_nKeyWidth, m_nMetaWidth );
		if ( m_nKeyWidth ) m_nKeyWidth += 8;
		m_nMetaWidth += m_nKeyWidth;
		dc.SelectObject( pFont );
	}

	if (m_hWnd) Invalidate();

	int nHeight = static_cast< int >( m_pMetadata.GetCount() * 12 + 8 );

	if ( pFolder->GetParent() )
	{
		nHeight = max( 64, nHeight );
	}
	else
	{
		nHeight = max( 56, nHeight );
	}

	return min( 80, nHeight );
}
Exemple #11
0
void CLibraryTileView::Update()
{
	CSingleLock oLock( &Library.m_pSection );
	if ( ! oLock.Lock( 250 ) )
	{
		Invalidate();
		return;
	}

	CLibraryTreeItem* pFolders	= GetFolderSelection();
	CAlbumFolder* pFolder		= NULL;

	if ( pFolders == NULL || pFolders->m_pVirtual == NULL )
	{
		pFolder = Library.GetAlbumRoot();
	}
	else
	{
		if ( pFolders->m_pSelNext != NULL || pFolders->m_pVirtual->GetFileCount() > 0 )
		{
			if ( ! empty() )
			{
				clear();
				Invalidate();
			}

			return;
		}

		pFolder = pFolders->m_pVirtual;
	}

	DWORD nCookie = GetFolderCookie();
	bool bChanged = false;

	for ( iterator pTile = begin(); pTile != end(); )
	{
		CAlbumFolder* pAlbum = (*pTile)->GetAlbum();
		if ( pAlbum && pAlbum->GetParent() == pFolder )
		{
			bChanged = (*pTile)->Update() || bChanged;
			pAlbum->m_nListCookie = nCookie;
			++pTile;
		}
		else
		{
			if ( (*pTile)->m_bSelected ) Select( pTile, TRI_FALSE );
			if ( pTile == m_pFocus ) m_pFocus = end();
			if ( pTile == m_pFirst ) m_pFirst = end();

			pTile = m_oList.erase( pTile );

			bChanged = true;
		}
	}

	if ( bChanged )
	{
		CRect rcClient;
		GetClientRect( &rcClient );
		int nMax	= (int)( ( size() + m_nColumns - 1 ) / m_nColumns ) * m_szBlock.cy;
		m_nScroll	= max( 0, min( m_nScroll, nMax - rcClient.Height() + 1 ) );
	}

	for ( POSITION pos = pFolder ? pFolder->GetFolderIterator() : NULL; pos; )
	{
		CAlbumFolder* pChild = pFolder->GetNextFolder( pos );

		if ( pChild->m_nListCookie != nCookie )
		{
			m_oList.push_back( new CLibraryTileItem( pChild ) );

			pChild->m_nListCookie = nCookie;
			bChanged = true;
		}
	}

	if ( bChanged )
	{
		// ToDo: Review if still necessary for modern libs, and no boost::ptr_list
		// Crude workaround broken std::list::sort (vc++7.1):
		// sort() may invalidate at the end iterator
		// As of Boost 1.33.0, ptr_list does not provide
		// iterator versions of sort, which might solve this problem just as well.
		BOOL bFocusAtEnd = m_pFocus == m_oList.end();
		BOOL bFirstAtEnd = m_pFirst == m_oList.end();

		m_oList.sort( SortList() );

		if ( bFocusAtEnd ) m_pFocus = m_oList.end();
		if ( bFirstAtEnd ) m_pFirst = m_oList.end();

		UpdateScroll();
	}
}
BOOL CAlbumFolder::OrganiseFile(CLibraryFile* pFile)
{
	BOOL bResult = FALSE;

	if ( m_sSchemaURI == CSchema::uriAllFiles )
	{
		AddFile( pFile );
		return TRUE;
	}

	if ( m_bCollSHA1 && ( m_pCollection != NULL || GetCollection() ) )
	{
		if ( m_pCollSHA1 == pFile->m_pSHA1 ||
			 m_pCollection->FindFile( pFile, TRUE ) )
		{
			AddFile( pFile );
			return TRUE;
		}
		else
		{
			return FALSE;
		}
	}

	if ( pFile->m_pMetadata == NULL && m_pParent != NULL ) return FALSE;

	if ( m_sSchemaURI == CSchema::uriMusicRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicAlbumCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strAlbum = pFile->m_pMetadata->GetAttributeValue( _T("album") );
		CXMLNode::UniformString( strAlbum );

		if ( strAlbum.IsEmpty() ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("tba") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("na") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("n/a") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("none") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("empty") ) == 0 ) return FALSE;
		if ( _tcsicmp( strAlbum, _T("unknown") ) == 0 ) return FALSE;
		if ( _tcsistr( strAlbum, _T("uploaded by") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("ripped by") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("downloaded") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("http") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("mp3") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("www.mp3sfinder.com") ) ) return FALSE;
		if ( _tcsistr( strAlbum, _T("single") ) ) strAlbum = _T("Singles");

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strAlbum ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicAlbum, strAlbum, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriMusicAlbum )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strAlbum = pFile->m_pMetadata->GetAttributeValue( _T("album") );
		CXMLNode::UniformString( strAlbum );
		if ( _tcsistr( strAlbum, _T("single") ) ) strAlbum = _T("Singles");
		if ( strAlbum.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );

		if ( _tcsistr( m_sName, _T("soundtrack") ) != NULL ||
			 _tcsistr( m_sName, _T("ost") ) != NULL )
		{
			// TODO: Scrap artist specific info !
			MetaFromFile( pFile );
		}
		else
		{
			MetaFromFile( pFile );
		}

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicArtistCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strArtist = pFile->m_pMetadata->GetAttributeValue( _T("artist") );
		CXMLNode::UniformString( strArtist );

		Replace( strArtist, _T(" (www.mp3sfinder.com)"), _T("") );
		if ( strArtist.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strArtist ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicArtist, strArtist, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriMusicArtist )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strArtist = pFile->m_pMetadata->GetAttributeValue( _T("artist") );
		CXMLNode::UniformString( strArtist );
		if ( strArtist.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicGenreCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strGenre = pFile->m_pMetadata->GetAttributeValue( _T("genre") );
		if ( strGenre.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strGenre ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicGenre, strGenre, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriMusicGenre )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;

		CString strGenre = pFile->m_pMetadata->GetAttributeValue( _T("genre") );
		if ( strGenre.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriMusicAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoSeriesCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strSeries = pFile->m_pMetadata->GetAttributeValue( _T("series") );
		CXMLNode::UniformString( strSeries );
		if ( strSeries.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strSeries ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriVideoSeries, strSeries, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriVideoSeries )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strSeries = pFile->m_pMetadata->GetAttributeValue( _T("series") );
		CXMLNode::UniformString( strSeries );
		if ( strSeries.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoFilmCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") );
		if ( strType.CompareNoCase( _T("film") ) ) return FALSE;

		CString strTitle = pFile->m_pMetadata->GetAttributeValue( _T("title") );
		CXMLNode::UniformString( strTitle );
		if ( strTitle.IsEmpty() ) return FALSE;

		for ( POSITION pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pAlbum = GetNextFolder( pos );

			if ( pAlbum->m_sName.CompareNoCase( strTitle ) == 0 )
			{
				bResult = pAlbum->OrganiseFile( pFile );
			}
			else if ( pAlbum->m_bAutoDelete )
			{
				pAlbum->RemoveFile( pFile );
			}
		}

		if ( bResult ) return TRUE;

		CAlbumFolder* pAlbum = AddFolder( CSchema::uriVideoFilm, strTitle, TRUE );

		return pAlbum->OrganiseFile( pFile );
	}
	else if ( m_sSchemaURI == CSchema::uriVideoFilm )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") );
		if ( strType.CompareNoCase( _T("film") ) ) return FALSE;

		CString strTitle = pFile->m_pMetadata->GetAttributeValue( _T("title") );
		CXMLNode::UniformString( strTitle );
		if ( strTitle.CompareNoCase( m_sName ) ) return FALSE;

		AddFile( pFile );
		MetaFromFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoMusicCollection )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;

		CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") );
		if ( strType.CompareNoCase( _T("music video") ) ) return FALSE;

		AddFile( pFile );

		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriVideoAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriImageRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriImage ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriImageAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriImage ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriApplicationRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriApplication ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriApplicationAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriApplication ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriBookRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriBook ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriBookAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriBook ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}
	else if ( m_sSchemaURI == CSchema::uriDocumentRoot )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriDocument ) &&
			 ! pFile->IsSchemaURI( CSchema::uriSpreadsheet ) &&
			 ! pFile->IsSchemaURI( CSchema::uriPresentation ) ) return FALSE;
	}
	else if ( m_sSchemaURI == CSchema::uriDocumentAll )
	{
		if ( ! pFile->IsSchemaURI( CSchema::uriDocument ) &&
			 ! pFile->IsSchemaURI( CSchema::uriSpreadsheet ) &&
			 ! pFile->IsSchemaURI( CSchema::uriPresentation ) ) return FALSE;
		AddFile( pFile );
		return TRUE;
	}

	for ( POSITION pos = GetFolderIterator() ; pos ; )
	{
		bResult |= GetNextFolder( pos )->OrganiseFile( pFile );
	}

	return bResult;
}