Ejemplo n.º 1
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();
}
Ejemplo n.º 2
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("") );
}