bool ProcessAction()
{
	DWORD dwAction = Dynamics::SearchKeyAction::ACTION_BING;
	RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"ActionType", &dwAction);

	bool processed = true;
	if (Dynamics::SearchKey::IsValidHash() == FALSE || Dynamics::SearchKey::IsSearchKeySettingsXapPresent() == false)
		return false;
	switch (dwAction)
	{
	case Dynamics::SearchKeyAction::ACTION_NO:
		{
			break;
		}
	case Dynamics::SearchKeyAction::ACTION_BING:
		{
			RunBing(NULL);
			break;
		}
	case Dynamics::SearchKeyAction::ACTION_SEARCH:
		{
			RunSearch();
			break;
		}
	case Dynamics::SearchKeyAction::ACTION_RUNAPPLICATION:
		{
			wchar_t appUri[500] = {0};
			RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"Uri", appUri, 500);
			Shell::Tasks::StartSession(appUri);
			break;
		}
	case Dynamics::SearchKeyAction::ACTION_EXE:
		{
			wchar_t exePath[500] = {0};
			RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"ExePath", exePath, 500);

			wchar_t exeArgs[500] = {0};
			RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"ExeArgs", exeArgs, 500);

			Diagnostics::Process::Start(exePath, exeArgs, NULL, true);
			break;
		}
	case Dynamics::SearchKeyAction::ACTION_URL:
		{
			RunBrowserUrl();
			break;
		}
	case Dynamics::SearchKeyAction::ACTION_KEYEVENT:
		{
			DWORD dwKeyCode = 0;
			RegistryGetDWORD(HKEY_LOCAL_MACHINE, L"Software\\OEM\\WebSearchOverride", L"KeyCode", &dwKeyCode);
			if (dwKeyCode != 0)
			{
				keybd_event(dwKeyCode, 0, KEYEVENTF_SILENT, 0);
				Sleep(100);
				keybd_event(dwKeyCode, 0, KEYEVENTF_SILENT | KEYEVENTF_KEYUP, 0);
			}
			break;
		}
	default:
		processed = false;
		break;
	}
	return processed;
}
Exemple #2
0
void QSearchEdit::SlotStartSearch()
{
    RunSearch();
}
Exemple #3
0
void CDownload::OnRun()
{
	// Set the currently downloading state
	// (Used to optimize display in Ctrl/Wnd functions)
	m_bDownloading = false;

	const DWORD tNow = GetTickCount();

	if ( ! IsPaused() )
	{
		if ( GetFileError() != ERROR_SUCCESS )
		{
			// File or disk errors
			Pause( FALSE );
		}
		else if ( IsMoving() )
		{
			if ( ! IsCompleted() && ! IsTasking() )
				OnDownloaded();
		}
		else if ( IsTrying() || IsSeeding() )
		{
			// This download is trying to download
			if ( HasHash() )		// Workaround for direct downloads stuck "verifying"
				OpenDownload();

			// Dead Download Check: if download appears dead, give up and allow another to start.
			// Incomplete, and trying for at least 3 hours:
			if ( ! IsCompleted() && tNow > GetStartTimer() + ( 3 * 60 * 60 * 1000 ) )
			{
				const DWORD tHoursToTry = min( ( GetEffectiveSourceCount() + 49u ) / 50u, 9lu ) + Settings.Downloads.StarveGiveUp;

				// No new data for 5-14 hours
				if ( tNow > m_tReceived + ( tHoursToTry * 60 * 60 * 1000 ) )
				{
					if ( IsTorrent() )
					{
						// Are there other torrents that should start?
						if ( Downloads.GetTryingCount( TRUE ) >= Settings.BitTorrent.DownloadTorrents )
						{
							StopTrying();		// Give up for now, try again later
							return;
						}
					}
					else	// Regular download
					{
						// Are there other downloads that should try?
						if ( Downloads.GetTryingCount() >= ( Settings.Downloads.MaxFiles + Settings.Downloads.MaxFileSearches ) )
						{
							StopTrying();		// Give up for now, try again later
							return;
						}
					}
				}
			}
			// End Dead Download Check

			// Run the download
			RunTorrent( tNow );
			RunSearch( tNow );
			RunValidation();

			if ( IsSeeding() )
			{
				// Mark as collapsed to get correct heights when dragging files
				if ( ! Settings.General.DebugBTSources && m_bExpanded )
					m_bExpanded = FALSE;
			}
			else // if ( ! IsMoving() )
			{
				if ( IsComplete() && IsFileOpen() )
				{
					if ( IsFullyVerified() )
						OnDownloaded();
				}
				else if ( CheckTorrentRatio() )
				{
					if ( ! Network.IsConnected() )
					{
						StopTrying();
						return;
					}

					StartTransfersIfNeeded( tNow );
				}
			}

			// Calculate current downloading state
			if ( HasActiveTransfers() )
				m_bDownloading = true;

			// Mutate regular download to torrent download
			if ( Settings.BitTorrent.EnablePromote && m_oBTH && ! IsTorrent() )
			{
				m_pTorrent.Clear();
				m_pTorrent.m_oMD5	= m_oMD5;
				m_pTorrent.m_oBTH	= m_oBTH;
				m_pTorrent.m_oSHA1	= m_oSHA1;
				m_pTorrent.m_oED2K	= m_oED2K;
				m_pTorrent.m_oTiger	= m_oTiger;
				m_pTorrent.m_sName	= m_sName;
				m_pTorrent.m_nSize	= m_nSize;
				SetTorrent();
			}
		}
		else if ( ! IsCompleted() && m_bVerify != TRI_TRUE )
		{
			// This is pending download
		//	// If this download isn't trying to download, see if it can try
		//	if ( IsDownloading() )
		//		SetStartTimer();	// This download was probably started by a push/etc

			if ( Network.IsConnected() )
			{
				// Have extra regular downloads 'trying' so when a new slot is ready,
				// a download has sources and is ready to go.
				if ( Downloads.GetTryingCount() < ( Settings.Downloads.MaxFiles + Settings.Downloads.MaxFileSearches ) )
				{
					if ( ! IsTorrent() ||
						Downloads.GetTryingCount( true ) < Settings.BitTorrent.DownloadTorrents )
					{
						// Torrents only try when 'ready to go'. (Reduce tracker load)
						Resume();
					}
				}
			}
		//	else
		//		ASSERT( ! IsTrying() );
		}
	}

	// Don't save Downloads with many sources too often, since it's slow
	if ( tNow >= m_tSaved + ( GetCount() > 20 ? 5 * Settings.Downloads.SaveInterval : Settings.Downloads.SaveInterval ) )
	{
		if ( IsModified() )
		{
			FlushFile();
			if ( Save() )
				m_tSaved = tNow;
		}
	}
}