Exemple #1
0
void CRemote::PageNewSearch()
{
	if ( CheckCookie() ) return;

	CMainWnd* pMainWnd = (CMainWnd*)theApp.m_pMainWnd;
	if ( pMainWnd == NULL || ! pMainWnd->IsKindOf( RUNTIME_CLASS(CMainWnd) ) ) return;

	CSingleLock pLock( &theApp.m_pSection );
	if ( ! SafeLock( pLock ) ) return;

	const CString strSearch = GetKey( L"search" );
	const CString strSchema = GetKey( L"schema" );

	if ( strSearch.IsEmpty() || ( ! strSchema.IsEmpty() && SchemaCache.Get( strSchema ) == NULL ) )
	{
		m_sRedirect = L"home";
		return;
	}

	CQuerySearchPtr pSearch	= new CQuerySearch();
	pSearch->m_sSearch		= strSearch;
	pSearch->m_pSchema		= SchemaCache.Get( strSchema );

	CString strURI;
	if ( pSearch->m_pSchema != NULL )
		strURI = pSearch->m_pSchema->GetURI();

	Settings.Search.LastSchemaURI = strURI;

	pMainWnd->PostMessage( WM_OPENSEARCH, (WPARAM)pSearch.Detach() );
	pLock.Unlock();
	Sleep( 500 );

	m_sRedirect = L"search";
}
Exemple #2
0
void CSearchWnd::ExecuteSearch()
{
    CQuickLock pLock( m_pMatches->m_pSection );

    CSearchPtr pManaged;
    if ( ! empty() )
        pManaged = m_oSearches.back();

    m_wndPanel.ShowSearch( pManaged );

    if ( pManaged )
    {
        CQuerySearchPtr pSearch = pManaged->GetSearch();
        if ( pSearch && pSearch->m_bAutostart )
        {
            if ( ! pSearch->CheckValid() )
            {
                // Invalid search, open help window
                CQuerySearch::SearchHelp();
            }
            else if ( AdultFilter.IsSearchFiltered( pSearch->m_sKeywords ) )
            {
                // Adult search blocked, open help window
                CHelpDlg::Show( _T("SearchHelp.AdultSearch") );
            }
            else
            {
                m_bPaused	= FALSE;
                m_bWaitMore	= FALSE;
                m_tSearch	= GetTickCount();

                pManaged->Stop();
                pManaged->Start();

                m_nMaxResults = m_pMatches->m_nGnutellaHits + Settings.Gnutella.MaxResults;
                m_nMaxED2KResults = m_pMatches->m_nED2KHits + Settings.eDonkey.MaxResults;
                m_nMaxQueryCount = pManaged->m_nQueryCount + Settings.Gnutella2.QueryLimit;

                m_wndPanel.Disable();

                if ( m_bPanel && Settings.Search.HideSearchPanel )
                {
                    m_bPanel = FALSE;
                    OnSkinChange();
                }
            }
        }
    }

    UpdateMessages();
}
Exemple #3
0
void CHomeSearchCtrl::Search(bool bAutostart)
{
	CString strText, strURI, strEntry, strClear;

	m_wndText.GetWindowText( strText );
	strText.TrimLeft();
	strText.TrimRight();

	LoadString( strClear, IDS_SEARCH_PAD_CLEAR_HISTORY );
	if ( _tcscmp ( strClear , strText ) == 0 ) return;

	// Check if user mistakenly pasted download link to search input box
	if (theApp.OpenURL( strText, TRUE, TRUE ) )
	{
		m_wndText.SetWindowText( _T("") );
		return;
	}

	CSchemaPtr pSchema = m_wndSchema.GetSelected();
	if ( pSchema != NULL ) strURI = pSchema->GetURI();

	Settings.Search.LastSchemaURI = strURI;

	CQuerySearchPtr pSearch = new CQuerySearch();
	pSearch->m_bAutostart	= bAutostart;
	pSearch->m_sSearch		= strText;
	pSearch->m_pSchema		= pSchema;
	BOOL bValid = pSearch->CheckValid( false );
	if ( ! bValid && bAutostart )
	{
		// Invalid search, open help window
		CQuerySearch::SearchHelp();
	}
	else if ( AdultFilter.IsSearchFiltered( pSearch->m_sSearch ) && bAutostart )
	{
		// Adult search blocked, open help window
		CHelpDlg::Show( _T("SearchHelp.AdultSearch") );
	}
	else
	{
		if ( bValid )
		{
			// Load all
			CStringList oList;
			for ( int i = 0; ; i++ )
			{
				strEntry.Format( _T("Search.%.2i"), i + 1 );
				CString strValue( theApp.GetProfileString( _T("Search"), strEntry ) );
				if ( strValue.IsEmpty() )
					break;
				int lf = strValue.Find( _T('\n') );
				if ( strText.CompareNoCase( ( lf != -1 ) ? strValue.Left( lf ) : strValue ) )
					oList.AddTail( strValue );
			}

			// Cut to 200 items
			while ( oList.GetCount() >= 200 )
				oList.RemoveTail();

			// New one (at top)
			oList.AddHead( strURI.IsEmpty() ? strText : ( strText + _T('\n') + strURI ) );

			// Save list
			POSITION pos = oList.GetHeadPosition();
			for ( int i = 0; pos; ++i )
			{
				strEntry.Format( _T("Search.%.2i"), i + 1 );
				theApp.WriteProfileString( _T("Search"), strEntry, oList.GetNext( pos ) );
			}

			FillHistory();
		}

		new CSearchWnd( pSearch );
	}

	m_wndText.SetWindowText( _T("") );
}
Exemple #4
0
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;
}