CCollectionFile::File* CCollectionFile::FindByURN(LPCTSTR pszURN) { Hashes::Sha1Hash oSHA1; Hashes::TigerHash oTiger; Hashes::Md5Hash oMD5; Hashes::Ed2kHash oED2K; Hashes::BtHash oBTH; oSHA1.fromUrn( pszURN ); oMD5.fromUrn( pszURN ); oTiger.fromUrn( pszURN ); oED2K.fromUrn( pszURN ); oBTH.fromUrn( pszURN ) || oBTH.fromUrn< Hashes::base16Encoding >( pszURN ); for ( POSITION pos = GetFileIterator(); pos; ) { File* pFile = GetNextFile( pos ); if ( validAndEqual( oSHA1, pFile->m_oSHA1 ) ) return pFile; if ( validAndEqual( oMD5, pFile->m_oMD5 ) ) return pFile; if ( validAndEqual( oTiger, pFile->m_oTiger ) ) return pFile; if ( validAndEqual( oED2K, pFile->m_oED2K ) ) return pFile; if ( validAndEqual( oBTH, pFile->m_oBTH ) ) return pFile; } return NULL; }
void CSearchInputBox::OnSearchPrefixTiger() { CString sSearch; m_wndSearch.GetWindowText( sSearch ); Hashes::TigerHash oTiger; if ( oTiger.fromUrn( sSearch ) || oTiger.fromString( sSearch ) ) sSearch = oTiger.toUrn(); else sSearch = _T("urn:tree:tiger/:[Tiger]"); m_wndSearch.SetWindowText( sSearch ); m_wndSearch.SetFocus(); m_wndSearch.SetSel( 16, -1 ); }
void CSearchInputBox::OnSearchPrefixSHA1Tiger() { CString sSearch; m_wndSearch.GetWindowText( sSearch ); Hashes::Sha1Hash oSHA1; Hashes::TigerHash oTiger; oSHA1.fromUrn( sSearch ) || oSHA1.fromString( sSearch ); oTiger.fromUrn( sSearch ) || oTiger.fromString( sSearch ); sSearch = _T("urn:bitprint:"); sSearch += oSHA1 ? oSHA1.toString() : _T("[SHA1]"); sSearch += _T("."); sSearch += oTiger ? oTiger.toString() : _T("[Tiger]"); m_wndSearch.SetWindowText( sSearch ); m_wndSearch.SetFocus(); m_wndSearch.SetSel( 13, -1 ); }
CLibraryFile* CLibraryMaps::LookupFileByURN(LPCTSTR pszURN, BOOL bSharedOnly, BOOL bAvailableOnly) const { ASSERT_VALID( this ); ASSERT( pszURN && *pszURN ); CLibraryFile* pFile = NULL; Hashes::TigerHash oTiger; Hashes::Sha1Hash oSHA1; Hashes::Ed2kHash oED2K; Hashes::BtHash oBTH; Hashes::Md5Hash oMD5; if ( oSHA1.fromUrn( pszURN ) ) { if ( ( pFile = LookupFileBySHA1( oSHA1, bSharedOnly, bAvailableOnly ) ) != NULL ) return pFile; } if ( oTiger.fromUrn( pszURN ) ) { if ( ( pFile = LookupFileByTiger( oTiger, bSharedOnly, bAvailableOnly ) ) != NULL ) return pFile; } if ( oED2K.fromUrn( pszURN ) ) { if ( ( pFile = LookupFileByED2K( oED2K, bSharedOnly, bAvailableOnly ) ) != NULL ) return pFile; } if ( oBTH.fromUrn( pszURN ) || oBTH.fromUrn< Hashes::base16Encoding >( pszURN ) ) { if ( ( pFile = LookupFileByBTH( oBTH, bSharedOnly, bAvailableOnly ) ) != NULL ) return pFile; } if ( oMD5.fromUrn( pszURN ) ) { if ( ( pFile = LookupFileByMD5( oMD5, bSharedOnly, bAvailableOnly ) ) != NULL ) return pFile; } return NULL; }
void CNewSearchDlg::OnChangeSearch() { CString strSearch; m_wndSearch.GetWindowText( strSearch ); BOOL bHash = FALSE; Hashes::TigerHash oTiger; Hashes::Sha1Hash oSHA1; Hashes::Ed2kHash oED2K; Hashes::Md5Hash oMD5; Hashes::BtHash oBTH; bHash |= static_cast< BOOL >( oSHA1.fromUrn( strSearch ) ); bHash |= static_cast< BOOL >( oTiger.fromUrn( strSearch ) ); bHash |= static_cast< BOOL >( oED2K.fromUrn( strSearch ) ); bHash |= static_cast< BOOL >( oMD5.fromUrn( strSearch ) ); bHash |= static_cast< BOOL >( oBTH.fromUrn( strSearch ) || oBTH.fromUrn< Hashes::base16Encoding >( strSearch ) ); if ( m_wndSchema.IsWindowVisible() == bHash ) m_wndSchema.ShowWindow( bHash ? SW_HIDE : SW_SHOW ); }