예제 #1
0
파일: simq.c 프로젝트: AndrewCRMartin/simq
/*>void SpawnJobRunner(char *queueDir, int sleepTime, int verbose)
   ---------------------------------------------------------------
*//**
   \param[in]  queueDir   The queue directory
   \param[in]  sleepTime  Time to wait between polling for jobs
   \param[in]  verbose    Verbosity level

   Sits waiting for jobs and runs them when one appears

-  16.10.15  Original   By: ACRM
*/
void SpawnJobRunner(char *queueDir, int sleepTime, int verbose)
{
   /*** Ideally this should detach itself in the background ***/

   while(1)
   {
      if(!RunNextJob(queueDir, verbose))
      {
         sleep(sleepTime);
      }
   }
}
예제 #2
0
D2DContentDownloadDialog::D2DContentDownloadDialog(D2DView* view, D2DSubView* parent, EDownloadType type, const std::list<DownloadJob>& jobs ) : D2DDialog(view, parent)
{
	Downloader = NULL;
	Zip = NULL;

	NextJobs = jobs;

	DownloadType = type;
	UnzipNumFiles = 0;
	UnzipFile = 0;
	InitControls();
	RunNextJob();
}
예제 #3
0
/** Draws this sub-view */
void D2DContentDownloadDialog::Draw(const D2D1_RECT_F& clientRectAbs, float deltaTime)
{
	std::string message;

	if(!Downloader)
		return;

	// FIXME: This should be in an update-function
	// Start the next job if we are done unzipping or the download failed
	if(UnzipFile == UnzipNumFiles - 1 || Downloader->GetProgress().hasFailed)
	{
		UnzipFile = 0;
		UnzipNumFiles = 0;

		// Done!
		// Check for other jobs
		RunNextJob();
	}

	// Need to check again if the download failed and "RunNextJob()" has deleted the downloader
	if(!Downloader || IsHidden() || 
		(Downloader->GetProgress().LastInfo.ulProgressMax == 0 && UnzipNumFiles == 0)) // Also don't draw if we are currently not doing anything
		return;

	// Size in mbyte
	float dlCurrent = Downloader->GetProgress().LastInfo.ulProgress / (1024.0f * 1024.0f);
	float dlMax = Downloader->GetProgress().LastInfo.ulProgressMax / (1024.0f * 1024.0f);

	if(dlCurrent != dlMax &&
		Downloader->GetProgress().LastInfo.ulProgressMax != 0)
	{
		switch(Downloader->GetProgress().LastInfo.ulStatusCode)
		{
		case BINDSTATUS_FINDINGRESOURCE:
			message = "Finding resource...";
			break;
		case BINDSTATUS_CONNECTING:
			message = "Connecting...";
			break;
		case BINDSTATUS_SENDINGREQUEST:
			message = "Sending request...";
			break;
		case BINDSTATUS_MIMETYPEAVAILABLE:
			message = "Mime type available";
			break;
		case BINDSTATUS_CACHEFILENAMEAVAILABLE:
			message = "Cache filename available";
			break;
		case BINDSTATUS_BEGINDOWNLOADDATA:
			message = "Begin download";
			break;

		default:
			{
				char txt[256];
				sprintf_s(txt, "Downloading %s ... (%.2f/%.2f MBytes)", Job.DownloadPackage.c_str(), dlCurrent, dlMax);
				message = txt;
			}
		}
	}
	
	if(UnzipNumFiles > 0) // Unzip-Phase
	{
		char txt[256];
		sprintf_s(txt, "Unpacking... (%d/%d files)", UnzipFile, UnzipNumFiles);
		message = txt;

		if(UnzipFile == UnzipNumFiles - 1)
		{
			SetHidden(true);
			MainView->AddMessageBox("Success!", "Successfully downloaded and unpacked data. Please restart the game to apply the changes!");
		}
	}

	Header->SetCaption(message);

	D2DDialog::Draw(clientRectAbs, deltaTime);
	
}