Ejemplo n.º 1
0
int DownloadAddByUrl(DownloadEnum::Category cat, const char* filename, const char* url)
{
    IDownload* dl = new IDownload(filename, url, cat);
    dl->addMirror(url);
    searchres.push_back(dl);
	return searchres.size();
}
Ejemplo n.º 2
0
bool CRepo::getDownload(IDownload& dl)
{
	std::string tmp;
	urlToPath(repourl,tmp);
	LOG_DEBUG("%s",tmp.c_str());
	this->tmpFile = fileSystem->getSpringDir() + PATH_DELIMITER + "rapid" + PATH_DELIMITER +tmp + PATH_DELIMITER +"versions.gz";
	fileSystem->createSubdirs(tmpFile);
	//first try already downloaded file, as repo master file rarely changes
	if ((fileSystem->fileExists(tmpFile)) && fileSystem->isOlder(tmpFile,REPO_RECHECK_TIME))
		return false;
	fileSystem->createSubdirs(tmpFile);
	dl = IDownload(tmpFile);
	dl.addMirror(repourl + "/versions.gz");
	return true;
}
Ejemplo n.º 3
0
bool CRapidDownloader::search(std::list<IDownload*>& result,
			      const std::string& name,
			      DownloadEnum::Category cat)
{
	LOG_DEBUG("%s", name.c_str());
	updateRepos(name);
	sdps.sort(list_compare);
	for (CSdp& sdp : sdps) {
		if (match_download_name(sdp.getShortName(), name) ||
		    (match_download_name(sdp.getName(), name))) {
			IDownload* dl =
			    new IDownload(sdp.getName().c_str(), name, cat, IDownload::TYP_RAPID);
			dl->addMirror(sdp.getShortName().c_str());
			result.push_back(dl);
		}
	}
	return true;
}
Ejemplo n.º 4
0
bool CPlasmaDownloader::search(std::list<IDownload*>& result, const std::string& name, IDownload::category category)
{
	LOG_DEBUG("%s",name.c_str());
	ContentServiceSoap12Proxy service;
	_Plasma__DownloadFile file;
	_Plasma__DownloadFileResponse fileResponse;
	std::string tmpname=name;
	file.internalName=&tmpname;
	int res;
	res=service.DownloadFile(&file, &fileResponse);
	if (res != SOAP_OK) {
		LOG_ERROR("Soap error: %d: %s",res, service.soap_fault_string());
		return false;
	}
	if (!fileResponse.DownloadFileResult) {
		LOG_DEBUG("No file found for criteria %s",name.c_str());
		return false;
	}

	std::vector<std::string>::iterator it;
	IDownload::category cat=category;
	std::string fileName=fileSystem->getSpringDir() + PATH_DELIMITER;
	switch (fileResponse.resourceType) {
	case Plasma__ResourceType__Map:
		cat=IDownload::CAT_MAPS;
		fileName.append("maps");
		break;
	case Plasma__ResourceType__Mod:
		cat=IDownload::CAT_GAMES;
		fileName.append("games");
		break;
	default:
		LOG_DEBUG("Unknown category in result: %d", cat);
		cat=IDownload::CAT_NONE;
		break;
	}
	fileName+=PATH_DELIMITER;
	if (fileResponse.links->string.size()==0) {
		LOG_DEBUG("No mirror in plasma result.");
		return false;
	}

	std::string torrent;
	torrent.assign((char*)fileResponse.torrent->__ptr,fileResponse.torrent->__size);
	IDownload* dl = new IDownload("",name);
	//parse torrent data and fill set values inside dl
	const bool bres = fileSystem->parseTorrent((char*)fileResponse.torrent->__ptr, fileResponse.torrent->__size, dl);
	if ( (dl->name == "") || (!bres)) {
		LOG_ERROR("Couldn't parse torrent filename");
		return false;
	}

	//set full path name
	fileName.append(dl->name);
	dl->name=fileName;
	dl->cat=cat;
	LOG_DEBUG("Got filename \"%s\" from torrent",fileName.c_str());

	for (it=fileResponse.links->string.begin(); it!=fileResponse.links->string.end(); ++it) {
		dl->addMirror((*it).c_str());
	}
	for (it=fileResponse.dependencies->string.begin(); it!=fileResponse.dependencies->string.end(); ++it) {
		dl->addDepend((*it).c_str());
	}
	result.push_back(dl);
	return true;
}