void CSearchWnd::Serialize(CArchive& ar) { CQuickLock pLock( m_pMatches->m_pSection ); int nVersion = 1; if ( ar.IsStoring() ) { ar << nVersion; ar.WriteCount( size() ); for ( iterator pManaged = begin() ; pManaged != end() ; ++pManaged ) { (*pManaged)->Serialize( ar ); } } else // Loading { ar >> nVersion; if ( nVersion != 1 ) AfxThrowUserException(); for ( DWORD_PTR nCount = ar.ReadCount() ; nCount > 0 ; nCount-- ) { CSearchPtr pManaged( new CManagedSearch() ); pManaged->Serialize( ar ); m_oSearches.push_back( pManaged ); } } CBaseMatchWnd::Serialize( ar ); if ( ar.IsLoading() ) { if ( ! empty() ) m_wndPanel.ShowSearch( m_oSearches.back() ); PostMessage( WM_TIMER, 1 ); SendMessage( WM_TIMER, 2 ); SetAlert( FALSE ); } }
CSearchPtr CSearchPanel::GetSearch() { CSearchPtr pManaged( new CManagedSearch() ); CQuerySearchPtr pSearch = pManaged->GetSearch(); CString sSearch; m_boxSearch.m_wndSearch.GetWindowText( sSearch ); pSearch->m_oSHA1.fromUrn( sSearch ) || pSearch->m_oSHA1.fromString( sSearch ); pSearch->m_oTiger.fromUrn( sSearch ) || pSearch->m_oTiger.fromString( sSearch ); pSearch->m_oED2K.fromUrn( sSearch ) || pSearch->m_oED2K.fromString( sSearch ); pSearch->m_oMD5.fromUrn( sSearch ) || pSearch->m_oMD5.fromString( sSearch ); pSearch->m_oBTH.fromUrn( sSearch ) || pSearch->m_oBTH.fromString( sSearch ) || pSearch->m_oBTH.fromUrn< Hashes::base16Encoding >( sSearch ) || pSearch->m_oBTH.fromString< Hashes::base16Encoding >( sSearch ); if ( pSearch->m_oSHA1 || pSearch->m_oTiger || pSearch->m_oED2K || pSearch->m_oBTH || pSearch->m_oMD5 ) { // Hash search } else { // Keyword search pSearch->m_sSearch = sSearch; } if ( CSchemaPtr pSchema = m_boxSearch.m_wndSchemas.GetSelected() ) { pSearch->m_pSchema = pSchema; pSearch->m_pXML = pSchema->Instantiate(); m_boxSchema.m_wndSchema.UpdateData( pSearch->m_pXML->AddElement( pSchema->m_sSingular ), TRUE ); Settings.Search.LastSchemaURI = pSchema->GetURI(); } else { Settings.Search.LastSchemaURI.Empty(); } if ( m_bAdvanced ) { pManaged->m_bAllowG2 = m_boxAdvanced.m_wndCheckBoxG2.GetCheck(); pManaged->m_bAllowG1 = m_boxAdvanced.m_wndCheckBoxG1.GetCheck(); pManaged->m_bAllowED2K = m_boxAdvanced.m_wndCheckBoxED2K.GetCheck(); pManaged->m_bAllowDC = m_boxAdvanced.m_wndCheckBoxDC.GetCheck(); if ( ! pManaged->m_bAllowG2 && ! pManaged->m_bAllowG1 && ! pManaged->m_bAllowED2K && ! pManaged->m_bAllowDC ) { m_boxAdvanced.m_wndCheckBoxG2.SetCheck( BST_CHECKED ); m_boxAdvanced.m_wndCheckBoxG1.SetCheck( BST_CHECKED ); m_boxAdvanced.m_wndCheckBoxED2K.SetCheck( BST_CHECKED ); m_boxAdvanced.m_wndCheckBoxDC.SetCheck( BST_CHECKED ); pManaged->m_bAllowG2 = TRUE; pManaged->m_bAllowG1 = TRUE; pManaged->m_bAllowED2K = TRUE; pManaged->m_bAllowDC = TRUE; } if ( m_boxAdvanced.m_wndSizeMin.m_hWnd != NULL ) { CString strWindowValue; m_boxAdvanced.m_wndSizeMin.GetWindowText( strWindowValue ); if ( strWindowValue.IsEmpty() || ( _tcsicmp( strWindowValue, _T("any") ) == 0 ) ) pSearch->m_nMinSize = 0; else { if ( !_tcsstr( strWindowValue, _T("B") ) && !_tcsstr( strWindowValue, _T("b") ) ) strWindowValue += _T("B"); pSearch->m_nMinSize = Settings.ParseVolume( strWindowValue ); } m_boxAdvanced.m_wndSizeMax.GetWindowText( strWindowValue ); if ( strWindowValue.IsEmpty() || ( _tcsicmp( strWindowValue, _T("any") ) == 0 ) || ( _tcsicmp( strWindowValue, _T("max") ) == 0 ) ) pSearch->m_nMaxSize = SIZE_UNKNOWN; else { if ( !_tcsstr( strWindowValue, _T("B") ) && !_tcsstr( strWindowValue, _T("b") ) ) strWindowValue += _T("B"); pSearch->m_nMaxSize = Settings.ParseVolume( strWindowValue ); } // Check it wasn't invalid if ( pSearch->m_nMinSize >pSearch->m_nMaxSize ) pSearch->m_nMaxSize = SIZE_UNKNOWN; } } pSearch->PrepareCheck(); return pManaged; }