示例#1
0
bool ContentManager::DownloadContent(const ContentDownloadRequest& request) {
	if (request.NothingIsRequired()) {
		return false;
	}

	//TODO: check if content already exists on HDD or was just downloaded!

	if (request.IsEngineRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetEngineVersion())) {
			throw Exception(_("Engine being downloaded already! Please wait!"));
		}
		prDownloader().Download(DownloadEnum::CAT_ENGINE, request.GetEngineVersion(), "");
	}

	if (request.IsMapRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetMapName())) {
			throw Exception(_("Map being downloaded already! Please wait!"));
		}
		prDownloader().Download(DownloadEnum::CAT_MAP, request.GetMapName(), request.GetMapHash());
	}

	if (request.IsGameRequested()) {
		if (IsContentAlreadyBeingDownloaded(request.GetGameName())) {
			throw Exception(_("Game being downloaded already! Please wait!"));
		}
		prDownloader().Download(DownloadEnum::CAT_GAME, request.GetGameName(), request.GetGameHash());
	}

	return true;
}
示例#2
0
void ContentManager::UpdateApplication(){
	const std::string latestVersion = GetLatestApplicationVersionAvailable();
	const std::string updatedir = SlPaths::GetUpdateDir();
	const size_t mindirlen = 9; // safety, minimal is/should be: C:\update
	if ((updatedir.size() <= mindirlen)) {
		throw Exception(_T("Invalid update dir: ") + TowxString(updatedir));
	}
	if (wxDirExists(updatedir)) {
		if (!SlPaths::RmDir(updatedir)) {
			throw Exception(_T("Couldn't cleanup ") + TowxString(updatedir));
		}
	}
	if (!SlPaths::mkDir(updatedir)) {
		throw Exception(_T("couldn't create update directory") + TowxString(updatedir));
	}

	if (!wxFileName::IsDirWritable(updatedir)) {
		throw Exception(_T("dir not writable: ") + TowxString(updatedir));
	}

	const std::string dlfilepath = SlPaths::GetLobbyWriteDir() + "springlobby-latest.zip";
	if (wxFileExists(dlfilepath) && !(wxRemoveFile(dlfilepath))) {
		throw Exception(_T("couldn't delete: ") + dlfilepath);
	}
	const std::string dlurl = GetDownloadUrl(latestVersion);
	prDownloader().Download(DownloadEnum::CAT_SPRINGLOBBY, dlurl, dlfilepath);
}
void TorrentOptionsPanel::OnApply( wxCommandEvent& /*unused*/ )
{

    sett().SetHTTPMaxParallelDownloads(m_parallel_http->GetValue());

    prDownloader().UpdateSettings();
}
示例#4
0
void DownloadDataViewCtrl::OnDownloadStarted(wxCommandEvent& /*event*/)
{
	slLogDebugFunc("");

	PrDownloader::DownloadProgress* p = new PrDownloader::DownloadProgress;
	prDownloader().GetProgress(*p);
	AddItem(p);
}
示例#5
0
void ContentDownloadDialog::OnListDownload(wxDataViewEvent& /*event*/)
{
	const ContentSearchResult* res = static_cast<ContentSearchResult*>(m_search_res_w->GetSelection().GetID());

	if (res == nullptr) {
		return;
	}
	prDownloader().Download(res->category, STD_STRING(res->name));
}
示例#6
0
void DownloadDataViewCtrl::OnDownloadProgress(wxCommandEvent& /*event*/)
{

	PrDownloader::DownloadProgress* existingItem;
	PrDownloader::DownloadProgress p;
	prDownloader().GetProgress(p);

	auto item = itemsIndex.find(p.name);
	if (item == itemsIndex.end() || item->second == nullptr) {
		existingItem = new PrDownloader::DownloadProgress(p);
		AddItem(existingItem);
		return;
	}

	existingItem = item->second;
	p.CopyTo(*existingItem);
	RefreshItem(*existingItem);
}
示例#7
0
void MainWindow::OnMenuDownload( wxCommandEvent& /*event*/ )
{
	wxString lines;
	if ( !ui().AskText( _( "Which Archives to download? Put each archive on a single line, for example \ngame:ba:stable\nmap:The Rock Final" ), _( "Download Archives" ), lines, true ) ) return;
	size_t start = 0;
	int pos = 0;
	do {
		pos = lines.find('\n', start);
		wxString line = lines.substr(start, pos-start);
		line.Trim(true).Trim(false);
		const std::string category = STD_STRING(line.BeforeFirst(':'));
		const std::string archive = STD_STRING(line.AfterFirst(':'));
		if (!category.empty() && !archive.empty()) {
			prDownloader().GetDownload(category, archive);
		}
		start = pos+1;
	} while (pos != wxNOT_FOUND);
}
void DownloadOptionsPanel::OnApply(wxCommandEvent& /*unused*/)
{
	sett().SetHTTPMaxParallelDownloads(m_parallel_http->GetValue());
	SlPaths::SetDownloadDir(STD_STRING(m_DownloadDirectoryTextCtrl->GetValue()));
	prDownloader().UpdateSettings();
}