bool DownloadManager::GetFileAndVerifyAssociatedSha1(ConfigurationFileActionDownload configuration, wstring file, ProgressStatus progress, void *data) { DownloadInet inetacccess; Sha1Sum sha1_computed(file), sha1_read; wstring url, sha1_url; bool bRslt; for (unsigned index = 0; index < configuration.GetUrls().size(); index++) { url = configuration.GetUrls().at(index); sha1_url = configuration.GetSha1Urls().at(index); bRslt = inetacccess.GetFile((wchar_t *)url.c_str(), (wchar_t *)file.c_str(), progress, data); g_log.Log(L"DownloadManager::GetFileAndVerifyAssociatedSha1 '%s' is %u", (wchar_t *) url.c_str(), (wchar_t *) bRslt); if (bRslt == false) continue; // If cannot get the sha1 file, we cannot verify the download and report it as incorrect if (_getAssociatedFileSha1Sum(sha1_url, (wchar_t *)file.c_str(), sha1_read) == false) continue; sha1_computed.ComputeforFile(); if (sha1_computed == sha1_read) return true; } return false; }
bool MSOfficeLPIAction::Download(ProgressStatus progress, void *data) { bool bFile1, bFile2; ConfigurationFileActionDownload downloadVersion; assert(_getDownloadID() != NULL); downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), wstring(_getDownloadID())); wcscpy_s(m_szFilename, downloadVersion.GetFilename().c_str()); wcscpy_s(m_szFullFilename, m_szTempPath); wcscat_s(m_szFullFilename, m_szFilename); bFile1 = m_downloadManager->GetFileAndVerifyAssociatedSha1(downloadVersion, m_szFullFilename, progress, data); if (_needsInstallConnector()) { downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), wstring(L"OutlookHotmailConnector")); m_connectorFile = m_szTempPath; m_connectorFile += downloadVersion.GetFilename().c_str(); bFile2 = m_downloadManager->GetFileAndVerifyAssociatedSha1(downloadVersion, m_connectorFile, progress, data); return bFile1 == true && bFile2 == true; } else { return bFile1; } }
void Windows8LPIAction::CheckPrerequirements(Action * action) { if (_isASupportedSystemLanguage() == false) { _getStringFromResourceIDName(IDS_WINDOWSLPIACTION_NOSPFR, szCannotBeApplied); g_log.Log(L"Windows8LPIAction::CheckPrerequirements. Unsupported base language"); SetStatus(CannotBeApplied); return; } if (_isAlreadyApplied()) { SetStatus(AlreadyApplied); return; } ConfigurationFileActionDownload downloadVersion; downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), wstring(_getDownloadID())); if (downloadVersion.IsEmpty()) { _getStringFromResourceIDName(IDS_NOTSUPPORTEDVERSION, szCannotBeApplied); g_log.Log(L"Windows8LPIAction::CheckPrerequirements. Version not supported"); SetStatus(CannotBeApplied); return; } }
bool AdobeReaderAction::Download(ProgressStatus progress, void *data) { wstring filename; ConfigurationFileActionDownload downloadVersion; downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), ApplicationVersion(GetVersion())); GetTempPath(MAX_PATH, m_szFilename); wcscat_s(m_szFilename, downloadVersion.GetFilename().c_str()); return m_downloadManager->GetFile(downloadVersion, m_szFilename, progress, data); }
bool Windows8LPIAction::Download(ProgressStatus progress, void *data) { wchar_t filename[MAX_PATH]; ConfigurationFileActionDownload downloadVersion; downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), wstring(_getDownloadID())); GetTempPath(MAX_PATH, filename); wcscat_s(filename, downloadVersion.GetFilename().c_str()); m_filename = filename; return m_downloadManager->GetFileAndVerifyAssociatedSha1(downloadVersion, filename, progress, data); }
void setWindowsMockActionDownload(wstring version) { ConfigurationRemote remote; ConfigurationFileActionDownloads fileActionDownloads; ConfigurationFileActionDownload fileActionDownload; fileActionDownload.AddUrl(L"http://url"); fileActionDownload.SetVersion(version); fileActionDownloads.SetActionID(WindowsLPIActionID); fileActionDownloads.AddFileActionDownload(fileActionDownload); remote.AddFileActionDownloads(fileActionDownloads); ConfigurationInstance::Get().SetRemote(remote); }
bool IELPIAction::Download(ProgressStatus progress, void *data) { if (_createTempDirectory() == false) return false; wstring filename; ConfigurationFileActionDownload downloadVersion; downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), _getDownloadID()); GetTempPath(MAX_PATH, m_filename); wcscat_s(m_filename, downloadVersion.GetFilename().c_str()); return m_downloadManager->GetFile(downloadVersion, m_filename, progress, data); }
TEST_F(WindowsLPIActionTest, _isDownloadAvailable_Yes) { CreateWindowsLIPAction; ConfigurationRemote remote; ConfigurationFileActionDownloads fileActionDownloads; ConfigurationFileActionDownload fileActionDownload; EXPECT_CALL(osVersionExMock, GetVersion()).WillRepeatedly(Return(Windows7)); EXPECT_CALL(osVersionExMock, IsWindows64Bits()).WillRepeatedly(Return(false)); fileActionDownload.SetVersion(lipAction._getDownloadID()); fileActionDownloads.SetActionID(WindowsLPIActionID); fileActionDownload.AddUrl(L"http://www.softcatala.org/"); fileActionDownloads.AddFileActionDownload(fileActionDownload); remote.AddFileActionDownloads(fileActionDownloads); ConfigurationInstance::Get().SetRemote(remote); EXPECT_TRUE(lipAction._isDownloadAvailable()); }
void OutLookHotmailConnector::GetDownloadConfigurationAndTempFile(ConfigurationFileActionDownload& downloadVersion, wstring& tempFile) { wchar_t szTempPath[MAX_PATH]; GetTempPath(MAX_PATH, szTempPath); downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(MSOfficeLPIActionID, wstring(L"OutlookHotmailConnector")); tempFile = szTempPath; tempFile += downloadVersion.GetFilename().c_str(); m_installerLocation = tempFile; }
TEST_F(FirefoxLangPackActionTest, _CheckPrerequirements_Ok) { CreateFirefoxLangPackAction(L"es") EXPECT_CALL(firefoxChannelMock, GetChannel()).WillRepeatedly(Return(L"release")); ConfigurationRemote remote; ConfigurationFileActionDownloads fileActionDownloads; ConfigurationFileActionDownload fileActionDownload; fileActionDownload.SetMaxVersion(ApplicationVersion(DEFAULT_VERSION)); fileActionDownload.SetMinVersion(ApplicationVersion(DEFAULT_VERSION)); fileActionDownloads.SetActionID(FirefoxActionID); fileActionDownload.AddUrl(L"http://www.softcatala.org/"); fileActionDownloads.AddFileActionDownload(fileActionDownload); remote.AddFileActionDownloads(fileActionDownloads); ConfigurationInstance::Get().SetRemote(remote); firefoxLangPackAction.SetStatus(Selected); firefoxLangPackAction.CheckPrerequirements(NULL); EXPECT_THAT(firefoxLangPackAction.GetStatus(), Selected); }
bool DownloadManager::GetFileAndVerifyAssociatedSha1(ConfigurationFileActionDownload configuration, wstring file, Sha1Sum sha1_read, ProgressStatus progress, void *data) { DownloadInet inetacccess; Sha1Sum sha1_computed(file); wstring url; bool bRslt; for (unsigned index = 0; index < configuration.GetUrls().size(); index++) { url = configuration.GetUrls().at(index); bRslt = inetacccess.GetFile((wchar_t *)url.c_str(), (wchar_t *)file.c_str(), progress, data); g_log.Log(L"DownloadManager::GetFileAndVerifyAssociatedSha1 '%s' is %u", (wchar_t *) url.c_str(), (wchar_t *) bRslt); if (bRslt == false) continue; sha1_computed.ComputeforFile(); if (sha1_computed == sha1_read) return true; } return false; }
bool Action::_doesDownloadExist() { ConfigurationFileActionDownload downloadVersion; downloadVersion = ConfigurationInstance::Get().GetRemote().GetDownloadForActionID(GetID(), ApplicationVersion(GetVersion())); return downloadVersion.IsUsable(); }