Example #1
0
void CDownloadManager::ProcessDownloads()
{
	if (_allDownloadsDone || _downloads.empty()) 
	{
		return; // nothing to do
	}

	if (DownloadInProgress())
	{
		return; // download still in progress
	}

	// No download in progress, pick a new from the queue
	for (Downloads::const_iterator i = _downloads.begin(); i != _downloads.end(); ++i)
	{
		if (i->second->GetStatus() == CDownload::NOT_STARTED_YET)
		{
			DM_LOG(LC_MAINMENU, LT_INFO)LOGSTRING("Starting download: %i", i->first);

			i->second->Start();

			// Check if this download has a related one, if yes, launch both at once
			int relatedId = i->second->GetRelatedDownloadId();

			if (relatedId != -1)
			{
				CDownloadPtr related = GetDownload(relatedId);

				if (related)
				{
					DM_LOG(LC_MAINMENU, LT_INFO)LOGSTRING("Starting related download: %i", relatedId);

					related->Start();
				}
			}

			return;
		}
	}

	// No download left to handle
	_allDownloadsDone = true;
}
Example #2
0
CDownloadSource* CDownloadTransfer::GetSource() const
{
	ASSUME_LOCK( Transfers.m_pSection );
	ASSERT( ! m_pSource || GetDownload()->CheckSource( m_pSource ) );
	return m_pSource;
}