⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctrllibraryfileview.cpp

📁 著名的下载软件核心Shareaza
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		dlg.m_nSize = pFile->GetSize();
		dlg.m_bSHA1 = pFile->m_bSHA1;
		if ( pFile->m_bSHA1 ) dlg.m_pSHA1 = pFile->m_pSHA1;
		dlg.m_bTiger = pFile->m_bTiger;
		if ( pFile->m_bTiger ) dlg.m_pTiger = pFile->m_pTiger;
		dlg.m_bED2K = pFile->m_bED2K;
		if ( pFile->m_bED2K ) dlg.m_pED2K = pFile->m_pED2K;
		
		pLock.Unlock();
		
		dlg.DoModal();
	}
	else
	{
		CURLExportDlg dlg;
		
		StartSelectedFileLoop();
		
		for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
		{
			dlg.AddFile( pFile );
		}
		
		if ( dlg.m_pFiles.GetCount() ) dlg.DoModal();
	}
}

void CLibraryFileView::OnUpdateLibraryMove(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( GetSelectedCount() > 0 );
}

void CLibraryFileView::OnLibraryMove() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CFileCopyDlg dlg( NULL, TRUE );
	
	StartSelectedFileLoop();
	
	for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
	{
		dlg.AddFile( pFile );
	}
	
	pLock.Unlock();
	
	dlg.DoModal();
}

void CLibraryFileView::OnUpdateLibraryCopy(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( GetSelectedCount() > 0 );
}

void CLibraryFileView::OnLibraryCopy() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CFileCopyDlg dlg( NULL, FALSE );
	
	StartSelectedFileLoop();
	
	for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
	{
		dlg.AddFile( pFile );
	}
	
	pLock.Unlock();
	
	dlg.DoModal();
}

void CLibraryFileView::OnUpdateLibraryDelete(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( GetSelectedCount() > 0 );
}

void CLibraryFileView::OnLibraryDelete() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CLibraryList pList;
	
	StartSelectedFileLoop();
	
	for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
	{
		pList.AddTail( pFile->m_nIndex );
	}
	
	while ( pList.GetCount() > 0 )
	{
		CLibraryFile* pFile = Library.LookupFile( pList.GetHead(), FALSE, FALSE, TRUE );
		if ( pFile == NULL ) continue;
		
		CDeleteFileDlg dlg( this );
		dlg.m_sName	= pFile->m_sName;
		dlg.m_bAll	= pList.GetCount() > 1;
		
		pLock.Unlock();
		if ( dlg.DoModal() != IDOK ) break;
		pLock.Lock();
		
		for ( int nProcess = dlg.m_bAll ? pList.GetCount() : 1 ; nProcess > 0 && pList.GetCount() > 0 ; nProcess-- )
		{
			if ( pFile = Library.LookupFile( pList.RemoveHead(), FALSE, FALSE, TRUE ) )
			{
				dlg.Apply( pFile );
				pFile->Delete();
			}
		}
		
		Library.Lock();
		Library.Unlock( TRUE );
	}
}

void CLibraryFileView::OnUpdateLibraryBitziWeb(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( GetSelectedCount() == 1 && Settings.Library.BitziWebSubmit.GetLength() );
}

void CLibraryFileView::OnLibraryBitziWeb() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	
	if ( CLibraryFile* pFile = GetSelectedFile() )
	{
		DWORD nIndex = pFile->m_nIndex;
		pLock.Unlock();
		CFileExecutor::ShowBitziTicket( nIndex );
	}
}

void CLibraryFileView::OnUpdateLibraryJigle(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( GetSelectedCount() == 1 );
}

void CLibraryFileView::OnLibraryJigle() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	
	if ( CLibraryFile* pFile = GetSelectedFile() )
	{
		CString strED2K;
		if ( pFile->m_bED2K ) strED2K = CED2K::HashToString( &pFile->m_pED2K );
		pLock.Unlock();
		
		if ( strED2K.GetLength() )
		{
			CString strURL;
			strURL.Format( _T("http://jigle.com/search?p=ed2k%%3A%s&v=1"), (LPCTSTR)strED2K );
			ShellExecute( GetSafeHwnd(), _T("open"), strURL, NULL, NULL, SW_SHOWNORMAL );
		}
	}
}

void CLibraryFileView::OnUpdateLibraryBitziDownload(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( GetSelectedCount() > 0 && Settings.Library.BitziXML.GetLength() );
}

void CLibraryFileView::OnLibraryBitziDownload() 
{
	if ( ! Settings.Library.BitziOkay )
	{
		CString strFormat;
		Skin.LoadString( strFormat, IDS_LIBRARY_BITZI_MESSAGE );
		if ( AfxMessageBox( strFormat, MB_ICONQUESTION|MB_YESNO ) != IDYES ) return;
		Settings.Library.BitziOkay = TRUE;
		Settings.Save();
	}

	CSingleLock pLock( &Library.m_pSection, TRUE );
	CBitziDownloadDlg dlg;

	StartSelectedFileLoop();

	for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
	{
		if ( pFile->m_bSHA1 ) dlg.AddFile( pFile->m_nIndex );
	}

	pLock.Unlock();

	dlg.DoModal();
}

void CLibraryFileView::OnUpdateLibraryProperties(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable( GetSelectedCount() > 0 );
}

void CLibraryFileView::OnLibraryProperties() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CFilePropertiesSheet dlg;

	StartSelectedFileLoop();

	for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
	{
		dlg.Add( pFile->m_nIndex );
	}

	pLock.Unlock();

	dlg.DoModal();
}

void CLibraryFileView::OnUpdateLibraryShared(CCmdUI* pCmdUI) 
{
	CSingleLock pLock( &Library.m_pSection );
	TRISTATE bShared = TS_UNKNOWN;
	
	if ( GetSelectedCount() > 0 && pLock.Lock( 100 ) )
	{
		StartSelectedFileLoop();
		
		for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
		{
			if ( bShared == TS_UNKNOWN )
			{
				bShared = pFile->IsShared() ? TS_TRUE : TS_FALSE;
			}
			else if ( ( bShared == TS_TRUE ) != pFile->IsShared() )
			{
				pCmdUI->Enable( FALSE );
				return;
			}
		}
	}
	
	pCmdUI->Enable( GetSelectedCount() > 0 );
	pCmdUI->SetCheck( bShared == TS_TRUE );
}

void CLibraryFileView::OnLibraryShared() 
{
	Library.Lock();

	StartSelectedFileLoop();

	for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
	{
		if ( pFile->IsShared() )
			pFile->m_bShared = pFile->m_pFolder->IsShared() ? TS_FALSE : TS_UNKNOWN;
		else
			pFile->m_bShared = pFile->m_pFolder->IsShared() ? TS_UNKNOWN : TS_TRUE;
		pFile->m_nUpdateCookie++;
	}

	Library.Unlock( TRUE );
}

void CLibraryFileView::OnUpdateLibraryUnlink(CCmdUI* pCmdUI) 
{
	CLibraryTreeItem* pItem = GetFolderSelection();
	pCmdUI->Enable( GetSelectedCount() > 0 && pItem && pItem->m_pVirtual && pItem->m_pSelNext == 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;

	StartSelectedFileLoop();

	for ( CLibraryFile* pFile ; pFile = GetNextSelectedFile() ; )
	{
		pFolder->RemoveFile( pFile );
	}
}

void CLibraryFileView::OnUpdateSearchForThis(CCmdUI* pCmdUI) 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pCmdUI->Enable( pSearch.CanSearchForThis() );
}

void CLibraryFileView::OnSearchForThis() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pLock.Unlock();
	pSearch.RunSearchForThis();
}

void CLibraryFileView::OnUpdateSearchForSimilar(CCmdUI* pCmdUI) 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pCmdUI->Enable( pSearch.CanSearchForSimilar() );
}

void CLibraryFileView::OnSearchForSimilar() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pLock.Unlock();
	pSearch.RunSearchForSimilar();
}

void CLibraryFileView::OnUpdateSearchForArtist(CCmdUI* pCmdUI) 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pCmdUI->Enable( pSearch.CanSearchForArtist() );
}

void CLibraryFileView::OnSearchForArtist() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pLock.Unlock();
	pSearch.RunSearchForArtist();
}

void CLibraryFileView::OnUpdateSearchForAlbum(CCmdUI* pCmdUI) 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pCmdUI->Enable( pSearch.CanSearchForAlbum() );
}

void CLibraryFileView::OnSearchForAlbum() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pLock.Unlock();
	pSearch.RunSearchForAlbum();
}

void CLibraryFileView::OnUpdateSearchForSeries(CCmdUI* pCmdUI) 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pCmdUI->Enable( pSearch.CanSearchForSeries() );
}

void CLibraryFileView::OnSearchForSeries() 
{
	CSingleLock pLock( &Library.m_pSection, TRUE );
	CRelatedSearch pSearch( GetSelectedFile() );
	pLock.Unlock();
	pSearch.RunSearchForSeries();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -