本文整理汇总了C++中CLibraryFile::IsAvailable方法的典型用法代码示例。如果您正苦于以下问题:C++ CLibraryFile::IsAvailable方法的具体用法?C++ CLibraryFile::IsAvailable怎么用?C++ CLibraryFile::IsAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLibraryFile
的用法示例。
在下文中一共展示了CLibraryFile::IsAvailable方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WhatsNew
CFileList* CLibraryMaps::WhatsNew(const CQuerySearch* pSearch, int nMaximum) const
{
ASSUME_LOCK( Library.m_pSection );
const DWORD tNow = static_cast< DWORD >( time( NULL ) );
CFileList* pHits = NULL;
for ( POSITION pos = GetFileIterator() ; pos ; )
{
CLibraryFile* pFile = GetNextFile( pos );
if ( pFile->IsAvailable() && pFile->IsShared() && pFile->m_oSHA1 &&
( ! pSearch->m_pSchema || pSearch->m_pSchema->Equals( pFile->m_pSchema ) ) )
{
const DWORD nTime = pFile->GetCreationTime();
if ( nTime && nTime + 12 * 60 * 60 > tNow ) // 12 hours
{
pFile->m_nHitsToday++;
pFile->m_nHitsTotal++;
if ( ! pHits )
pHits = new CFileList;
pHits->AddTail( pFile );
if ( nMaximum && pHits->GetCount() >= nMaximum )
break;
}
}
}
return pHits;
}
示例2: SetCollection
void CAlbumFolder::SetCollection(SHA1* pSHA1, CCollectionFile* pCollection)
{
m_bCollSHA1 = TRUE;
m_pCollSHA1 = *pSHA1;
m_sBestView.Empty();
if ( m_pCollection != NULL )
{
delete m_pCollection;
m_pCollection = NULL;
}
if ( CXMLElement* pMetadata = pCollection->GetMetadata() )
{
pMetadata = pMetadata->Clone();
SetMetadata( pMetadata );
delete pMetadata;
}
for ( POSITION pos = LibraryMaps.GetFileIterator() ; pos ; )
{
CLibraryFile* pFile = LibraryMaps.GetNextFile( pos );
if ( pFile->IsAvailable() )
{
if ( m_pCollSHA1 == pFile->m_pSHA1 ||
pCollection->FindFile( pFile, TRUE ) ) AddFile( pFile );
}
}
m_nUpdateCookie++;
Library.m_nUpdateCookie++;
}
示例3: CullDeletedFiles
void CLibraryMaps::CullDeletedFiles(CLibraryFile* pMatch)
{
ASSUME_LOCK( Library.m_pSection );
if ( CFileList* pList = LookupFilesByHash( pMatch, FALSE, FALSE, 0 ) )
{
for ( POSITION pos = pList->GetHeadPosition() ; pos ; )
{
CLibraryFile* pFile = const_cast< CLibraryFile* >( pList->GetNext( pos ) );
if ( ! pFile->IsAvailable() )
pFile->Delete( TRUE );
}
delete pList;
}
}
示例4: Browse
CFileList* CLibraryMaps::Browse(int nMaximum) const
{
ASSUME_LOCK( Library.m_pSection );
CFileList* pHits = NULL;
for ( POSITION pos = GetFileIterator() ; pos ; )
{
CLibraryFile* pFile = GetNextFile( pos );
if ( pFile->IsAvailable() && pFile->IsShared() && pFile->m_oSHA1 )
{
if ( ! pHits )
pHits = new CFileList;
pHits->AddTail( pFile );
if ( nMaximum && pHits->GetCount() >= nMaximum )
break;
}
}
return pHits;
}
示例5: Update
void CLibraryMetaPanel::Update()
{
CSingleLock pLock1( &Library.m_pSection, TRUE );
CSingleLock pLock2( &m_pSection, TRUE );
CLibraryListPtr pSel( GetViewSelection() );
m_nSelected = pSel ? static_cast< int >( pSel->GetCount() ) : 0;
// Show info for library files only
CLibraryFile* pFirst = NULL;
if ( m_nSelected )
{
const CLibraryListItem& pItem = pSel->GetHead();
if ( pItem.Type == CLibraryListItem::LibraryFile )
pFirst = Library.LookupFile( pItem );
if ( pFirst == NULL ) m_nSelected = 0;
}
m_nIcon32 = m_nIcon48 = -1;
if ( m_nSelected == 1 )
{
m_nIndex = pFirst->m_nIndex;
m_sName = pFirst->m_sName;
m_sPath = pFirst->GetPath();
m_sFolder = pFirst->GetFolder();
m_sSize = Settings.SmartVolume( pFirst->GetSize() );
m_sType = ShellIcons.GetTypeString( m_sName );
m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 );
m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 );
m_nRating = pFirst->m_nRating;
}
else if ( m_nSelected > 1 )
{
CString strFormat;
LoadString( strFormat, IDS_LIBPANEL_MULTIPLE_FILES );
m_sName.Format( strFormat, m_nSelected );
QWORD nSize = 0;
m_sFolder = pFirst->GetFolder();
m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 );
m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 );
m_nRating = 0;
for ( POSITION pos = pSel->GetHeadPosition() ; pos ; )
{
CLibraryFile* pFile = Library.LookupFile( pSel->GetNext( pos ) );
if ( pFile == NULL ) continue;
nSize += pFile->GetSize() / 1024;
if ( pFile->IsAvailable() && pFile->GetFolder().CompareNoCase( m_sFolder ) )
{
LoadString( m_sFolder, IDS_LIBPANEL_MULTIPLE_FOLDERS );
}
int nIcon = ShellIcons.Get( pFile->GetPath(), 48 );
if ( nIcon != m_nIcon48 ) m_nIcon48 = -1;
nIcon = ShellIcons.Get( pFile->GetPath(), 32 );
if ( nIcon != m_nIcon32 ) m_nIcon32 = -1;
}
m_sSize = Settings.SmartVolume( nSize );
m_sPath.Empty();
m_sType.Empty();
}
m_pSchema = NULL;
if ( pSel )
{
for ( POSITION pos = pSel->GetHeadPosition() ; pos ; )
{
const CLibraryListItem& pItem = pSel->GetNext( pos );
if ( pItem.Type != CLibraryListItem::LibraryFile ) continue;
CLibraryFile* pFile = Library.LookupFile( pItem );
if ( pFile == NULL ) continue;
m_pSchema = pFile->m_pSchema;
if ( m_pSchema ) break;
}
}
if ( m_pServiceData )
{
m_pMetadata->Setup( m_pServiceData );
}
else
{
m_pMetadata->Setup( m_pSchema );
if ( m_pSchema && pSel )
{
for ( POSITION pos = pSel->GetHeadPosition() ; pos ; )
{
const CLibraryListItem& pItem = pSel->GetNext( pos );
if ( pItem.Type != CLibraryListItem::LibraryFile ) continue;
if ( CLibraryFile* pFile = Library.LookupFile( pItem ) )
{
if ( pFile->m_pMetadata != NULL &&
m_pSchema->Equals( pFile->m_pSchema ) )
//.........这里部分代码省略.........
示例6: OnFileRemove
void CLibraryMaps::OnFileRemove(CLibraryFile* pFile)
{
CLibraryFile* pOld;
if ( pFile->m_nIndex )
{
pOld = LookupFile( pFile->m_nIndex );
if ( pOld == pFile )
{
m_pIndexMap.RemoveKey( pFile->m_nIndex );
if ( pOld->IsAvailable() )
{
m_nFiles --;
m_nVolume -= pFile->m_nSize;
}
}
}
pOld = LookupFileByName( pFile->GetNameLC(), pFile->m_nSize, FALSE, FALSE );
if ( pOld == pFile ) m_pNameMap.RemoveKey( pFile->GetNameLC() );
if ( pFile->IsAvailable() )
{
CString strPath( pFile->GetPath() );
ToLower( strPath );
pOld = LookupFileByPath( strPath );
if ( pOld == pFile )
m_pPathMap.RemoveKey( strPath );
}
if ( POSITION pos = m_pDeleted.Find( pFile ) )
m_pDeleted.RemoveAt( pos );
if ( pFile->m_oSHA1 )
{
CLibraryFile** pPrev = &m_pSHA1Map[ pFile->m_oSHA1[ 0 ] & HASH_MASK ];
for ( CLibraryFile* pOther = *pPrev ; pOther ; pOther = pOther->m_pNextSHA1 )
{
if ( pOther == pFile )
{
*pPrev = pOther->m_pNextSHA1;
break;
}
pPrev = &pOther->m_pNextSHA1;
}
pFile->m_pNextSHA1 = NULL;
}
if ( pFile->m_oTiger )
{
CLibraryFile** pPrev = &m_pTigerMap[ pFile->m_oTiger[ 0 ] & HASH_MASK ];
for ( CLibraryFile* pOther = *pPrev ; pOther ; pOther = pOther->m_pNextTiger )
{
if ( pOther == pFile )
{
*pPrev = pOther->m_pNextTiger;
break;
}
pPrev = &pOther->m_pNextTiger;
}
pFile->m_pNextTiger = NULL;
}
if ( pFile->m_oED2K )
{
CLibraryFile** pPrev = &m_pED2KMap[ pFile->m_oED2K[ 0 ] & HASH_MASK ];
for ( CLibraryFile* pOther = *pPrev ; pOther ; pOther = pOther->m_pNextED2K )
{
if ( pOther == pFile )
{
*pPrev = pOther->m_pNextED2K;
break;
}
pPrev = &pOther->m_pNextED2K;
}
pFile->m_pNextED2K = NULL;
}
if ( pFile->m_oBTH )
{
CLibraryFile** pPrev = &m_pBTHMap[ pFile->m_oBTH[ 0 ] & HASH_MASK ];
for ( CLibraryFile* pOther = *pPrev ; pOther ; pOther = pOther->m_pNextBTH )
{
if ( pOther == pFile )
{
*pPrev = pOther->m_pNextBTH;
break;
}
pPrev = &pOther->m_pNextBTH;
}
//.........这里部分代码省略.........
示例7: Update
void CLibraryAlbumView::Update()
{
CLibraryTreeItem* pFolders = GetFolderSelection();
m_pStaticStyle = m_pStyle;
m_pStyle = NULL;
BOOL bGhostFolder = FALSE;
if ( pFolders != NULL && pFolders->m_pVirtual != NULL && pFolders->m_pSelNext == NULL )
{
CAlbumFolder* pFolder = pFolders->m_pVirtual;
if ( CheckURI( pFolder->m_sSchemaURI, CSchema::uriMusicAlbum ) )
m_pStyle = CSchema::uriMusicAlbum;
else if ( CheckURI( pFolder->m_sSchemaURI, CSchema::uriMusicArtist ) )
m_pStyle = CSchema::uriMusicArtist;
else if ( CheckURI( pFolder->m_sSchemaURI, CSchema::uriMusicAll ) || CheckURI( pFolder->m_sSchemaURI, CSchema::uriMusicGenre ) )
m_pStyle = CSchema::uriMusicAll;
else if ( CheckURI( pFolder->m_sSchemaURI, CSchema::uriGhostFolder ) )
bGhostFolder = TRUE;
}
CSchemaPtr pSchema = SchemaCache.Get( Settings.Library.FilterURI );
DWORD nCookie = GetFolderCookie();
BOOL bChanged = m_pStyle != m_pStaticStyle;
if ( Settings.Library.ShowVirtual )
pSchema = NULL;
CLibraryAlbumTrack** pList = m_pList + m_nCount - 1;
for ( int nItem = m_nCount ; nItem ; nItem--, pList-- )
{
CLibraryAlbumTrack* pTrack = *pList;
CLibraryFile* pFile = Library.LookupFile( pTrack->m_nIndex );
if ( pFile != NULL && pFile->m_nSelectCookie == nCookie &&
( pFile->IsAvailable() || bGhostFolder ) &&
( ! pSchema || pSchema->Equals( pFile->m_pSchema ) ||
( ! pFile->m_pMetadata && pSchema->FilterType( pFile->m_sName ) ) ) )
{
bChanged |= pTrack->Update( pFile );
pFile->m_nListCookie = nCookie;
}
else
{
if ( pTrack == m_pFocus ) m_pFocus = NULL;
if ( pTrack == m_pFirst ) m_pFirst = NULL;
if ( pTrack->m_bSelected ) Select( pTrack, TRI_FALSE );
delete pTrack;
MoveMemory( pList, pList + 1, ( m_nCount - nItem ) * sizeof *pList );
m_nCount--;
bChanged = TRUE;
}
}
if ( bChanged )
{
CRect rcClient;
GetClientRect( &rcClient );
int nMax = m_nCount * m_szTrack.cy;
m_nScroll = max( 0, min( m_nScroll, nMax - rcClient.Height() + 1 ) );
}
for ( POSITION pos = LibraryMaps.GetFileIterator() ; pos ; )
{
CLibraryFile* pFile = LibraryMaps.GetNextFile( pos );
if ( pFile->m_nSelectCookie == nCookie &&
pFile->m_nListCookie != nCookie &&
( pFile->IsAvailable() || bGhostFolder ) &&
( ! pSchema || pSchema->Equals( pFile->m_pSchema ) ||
( ! pFile->m_pMetadata && pSchema->FilterType( pFile->m_sName ) ) ) )
{
CLibraryAlbumTrack* pTrack = new CLibraryAlbumTrack( pFile );
if ( m_nCount == m_nBuffer )
{
m_nBuffer += 64;
CLibraryAlbumTrack** pNewList = new CLibraryAlbumTrack*[ m_nBuffer ];
if ( m_nCount ) CopyMemory( pNewList, m_pList, m_nCount * sizeof( CLibraryAlbumTrack* ) );
delete [] m_pList;
m_pList = pNewList;
}
m_pList[ m_nCount++ ] = pTrack;
pFile->m_nListCookie = nCookie;
bChanged = TRUE;
}
}
if ( bChanged )
{
m_pStaticStyle = m_pStyle;
qsort( m_pList, m_nCount, sizeof *m_pList, SortList );
UpdateScroll();
}
}
示例8: Update
void CLibraryDetailView::Update()
{
GET_LIST();
CSchema* pSchema = SchemaCache.Get( Settings.Library.FilterURI );
DWORD nCookie = GetFolderCookie();
if ( Settings.Library.ShowVirtual ) pSchema = NULL;
if ( m_nStyle == LVS_REPORT )
{
CLibraryTreeItem* pTree = GetFolderSelection();
if ( pTree != NULL && pTree->m_pVirtual != NULL && pTree->m_pSelNext == NULL &&
pTree->m_pVirtual->m_pSchema != NULL )
{
CString strURI = pTree->m_pVirtual->m_pSchema->GetContainedURI( CSchema::stFile );
if ( strURI.GetLength() && ( m_pSchema == NULL || m_pSchema->m_sURI != strURI ) )
{
if ( CSchema* pSchema = SchemaCache.Get( strURI ) )
{
CPtrList pColumns;
CSchemaColumnsDlg::LoadColumns( pSchema, &pColumns );
SetViewSchema( pSchema, &pColumns, TRUE, FALSE );
}
}
}
}
LDVITEM* pItem = m_pList + m_nList - 1;
for ( DWORD nCount = m_nList ; nCount ; nCount--, pItem-- )
{
CLibraryFile* pFile = Library.LookupFile( pItem->nIndex );
if ( pFile && pFile->m_nSelectCookie == nCookie && pFile->IsAvailable() &&
( ! pSchema || pSchema->Equals( pFile->m_pSchema ) ||
( ! pFile->m_pMetadata && pSchema->FilterType( pFile->m_sName ) ) ) )
{
pFile->m_nListCookie = nCookie;
}
else
{
SelRemove( pItem->nIndex );
CStringArray* pSaved = pItem->pText;
CopyMemory( pItem, pItem + 1, sizeof(LDVITEM) * ( m_nList - nCount ) );
pItem[ m_nList - nCount ].pText = pSaved;
m_nList--;
}
}
for ( POSITION pos = LibraryMaps.GetFileIterator() ; pos ; )
{
CLibraryFile* pFile = LibraryMaps.GetNextFile( pos );
if ( pFile->m_nSelectCookie == nCookie &&
pFile->m_nListCookie != nCookie &&
pFile->IsAvailable() &&
( ! pSchema || pSchema->Equals( pFile->m_pSchema ) ||
( ! pFile->m_pMetadata && pSchema->FilterType( pFile->m_sName ) ) ) )
{
if ( m_nList == m_nBuffer ) // MUST EQUAL
{
m_nBuffer += 64;
LDVITEM* pList = new LDVITEM[ m_nBuffer ];
if ( m_nList ) CopyMemory( pList, m_pList, m_nList * sizeof(LDVITEM) );
if ( m_pList ) delete [] m_pList;
ZeroMemory( pList + m_nList, ( m_nBuffer - m_nList ) * sizeof(LDVITEM) );
m_pList = pList;
}
m_pList[ m_nList ].nIndex = pFile->m_nIndex;
m_pList[ m_nList ].nState &= ~LDVI_SELECTED;
m_nList++;
pFile->m_nListCookie = nCookie;
}
}
m_nListCookie++;
SortItems();
}
示例9: Search
CFileList* CLibraryDictionary::Search(const CQuerySearch* pSearch, const int nMaximum, const bool bLocal, const bool bAvailableOnly)
{
ASSUME_LOCK( Library.m_pSection );
if ( ! m_bValid )
{
BuildHashTable();
if ( ! m_bValid )
return NULL;
}
// Only check the hash when a search comes from other client.
if ( ! bLocal && ! m_pTable->Check( pSearch ) )
return NULL;
++m_nSearchCookie;
CLibraryFile* pHit = NULL;
CQuerySearch::const_iterator pWordEntry = pSearch->begin();
const CQuerySearch::const_iterator pLastWordEntry = pSearch->end();
for ( ; pWordEntry != pLastWordEntry; ++pWordEntry )
{
if ( pWordEntry->first[ 0 ] == L'-' )
continue;
CString strWord( pWordEntry->first, static_cast< int >( pWordEntry->second ) );
CFileList* pList = NULL;
if ( m_oWordMap.Lookup( strWord, pList ) )
{
for ( POSITION pos = pList->GetHeadPosition(); pos; )
{
CLibraryFile* pFile = pList->GetNext( pos );
if ( bAvailableOnly && ! pFile->IsAvailable() )
continue;
if ( ! bLocal && ! pFile->IsShared() )
continue;
if ( pFile->m_nSearchCookie == m_nSearchCookie )
{
++pFile->m_nSearchWords;
}
else
{
pFile->m_nSearchCookie = m_nSearchCookie;
pFile->m_nSearchWords = 1;
pFile->m_pNextHit = pHit;
pHit = pFile;
}
}
}
}
size_t nLowerBound = ( pSearch->tableSize() >= 3 ) ?
( pSearch->tableSize() * 2 / 3 ) : pSearch->tableSize();
CFileList* pHits = NULL;
for ( ; pHit; pHit = pHit->m_pNextHit )
{
ASSERT( pHit->m_nSearchCookie == m_nSearchCookie );
if ( pHit->m_nSearchWords < nLowerBound )
continue;
if ( pSearch->Match( pHit->GetSearchName(),
pHit->m_pSchema ? (LPCTSTR)pHit->m_pSchema->GetURI() : NULL,
pHit->m_pMetadata, pHit ) )
{
if ( ! pHits )
pHits = new CFileList;
pHits->AddTail( pHit );
if ( ! bLocal )
{
pHit->m_nHitsToday ++;
pHit->m_nHitsTotal ++;
}
if ( pHit->m_nCollIndex )
{
CLibraryFile* pCollection = LibraryMaps.LookupFile( pHit->m_nCollIndex, ! bLocal, bAvailableOnly );
if ( pCollection )
{
if ( pCollection->m_nSearchCookie != m_nSearchCookie )
{
pCollection->m_nSearchCookie = m_nSearchCookie;
pHits->AddHead( pCollection );
}
}
else
{
// Collection removed without deleting indexes
pHit->m_nCollIndex = 0ul;
}
}
if ( nMaximum > 0 && pHits->GetCount() >= nMaximum )
//.........这里部分代码省略.........