示例#1
0
int DownloadStart()
{
	int res = 0;
	std::list<IDownload*> dls;
	std::list<int>::iterator it;
	for (it = downloads.begin(); it != downloads.end(); ++it) {
		IDownload* dl = GetIDownloadByID(searchres, *it);
		if (dl == NULL) {
			continue;
		}
		dls.push_back(dl);
	}
	if (fetchDepends) {
		addDepends(dls);
	}

	if (dls.empty()) {
		LOG_DEBUG("Nothing to do, did you forget to call DownloadAdd()?");
		res = 1;
		return res;
	}
	if(!rapidDownload->download(dls))
		res = 2;
	if (!httpDownload->download(dls,1))
		res = 3;
	if (!download_engine(dls))
		res = 4;

	IDownloader::freeResult(searchres);
	dls.clear();
	return res;
}
示例#2
0
bool DownloadGetInfo(int id, downloadInfo& info)
{
	IDownload* dl = GetIDownloadByID(searchres, id);
	if (dl!=NULL) {
		strncpy(info.filename, dl->name.c_str(), NAME_LEN-1); // -1 because of 0 termination
		return true;
	}
	return false;
}
bool DownloadStart()
{
	bool res = true;
	std::list<IDownload*> dls;
	std::list<int>::iterator it;
	for (it = downloads.begin(); it != downloads.end(); ++it) {
		IDownload* dl = GetIDownloadByID(searchres, *it);
		if (dl == NULL) {
			continue;
		}
		dls.push_back(dl);
	}
	if (fetchDepends) {
		addDepends(dls);
	}

	if (dls.empty()) {
		LOG_DEBUG("Nothing to do, did you forget to call DownloadAdd()?");
		return res;
	}

	switch (typ) {
	case DL_RAPID:
	case DL_HTTP:
		if(!rapidDownload->download(dls))
			res = false;
		if (!httpDownload->download(dls,1))
			res = false;
		break;
	case DL_ENGINE:
		if (!download_engine(dls))
			res = false;
		break;
	default:
		LOG_ERROR("%s():%d  Invalid type specified: %d %d", __FUNCTION__, __LINE__, typ, downloads.size());
		res = false;
	}

	IDownloader::freeResult(searchres);
	dls.clear();
	return res;
}