void MediaOmxDecoder::PauseStateMachine()
{
  MOZ_ASSERT(NS_IsMainThread());
  GetReentrantMonitor().AssertCurrentThreadIn();
  DECODER_LOG(PR_LOG_DEBUG, ("%s", __PRETTY_FUNCTION__));
  if (!mDecoderStateMachine) {
    return;
  }
  StopProgress();
  mDecoderStateMachine->SetDormant(true);
}
/****************************************************************************
 * UpdateApp from a given url. The dol is downloaded and overwrites the old one.
 ***************************************************************************/
int UpdateTask::DownloadApp(const char *url)
{
	if(!url)
	{
		ThrowMsg(tr("Error"), tr("URL is empty."));
		return -1;
	}

	//! append slash if it is missing
	std::string destPath = Settings.UpdatePath;
	if(destPath.size() > 0 && destPath[destPath.size()-1] != '/')
		destPath += '/';

	destPath += "boot.zip";

	CreateSubfolder(Settings.UpdatePath);

	int res = DownloadFileToPath(url, destPath.c_str(), false);
	if(res < 102400)
	{
		RemoveFile(destPath.c_str());
		ThrowMsg(tr("Update failed"), tr("Could not download file."));
		return -1;
	}
	else
	{
		StartProgress(tr("Extracting file..."));

		ZipFile zip(destPath.c_str());
		zip.ExtractAll(Settings.UpdatePath);

		RemoveFile(destPath.c_str());

		StopProgress();

		if(Settings.UpdateMetaxml)
			DownloadMetaXml();
		if(Settings.UpdateIconpng)
			DownloadIconPNG();
	}

	return 1;
}
Beispiel #3
0
void nsMediaDecoder::Shutdown()
{
  StopProgress();
  mElement = nsnull;
}
const u8 * NetReceiver::ReceiveData()
{
	if(connection < 0)
		return NULL;

	if(filebuffer)
		free(filebuffer);
	filebuffer = NULL;

	filebuffer = (u8 *) malloc(filesize);
	if(!filebuffer)
	{
		ShowError(tr("Not enough memory."));
		return NULL;
	}

	StartProgress(tr("Receiving file..."));

	u32 done = 0;
	u32 blocksize = 5*1024;
	char tmptxt[200];
	snprintf(tmptxt, sizeof(tmptxt), "Incomming from: %s", incommingIP);

	int retries = 5;

	do
	{
		if(ProgressWindow::Instance()->IsCanceled())
		{
			FreeData();
			StopProgress();
			ShowError(tr("Transfer cancelled."));
			return NULL;
		}

		if (blocksize > filesize - done)
			blocksize = filesize - done;

		ShowProgress(done, filesize, tmptxt);

		int result = network_read(connection, filebuffer+done, blocksize);
		if(result < 0)
		{
			--retries;
			if(retries == 0)
			{
				FreeData();
				StopProgress();
				ShowError(tr("Transfer failed."));
				return NULL;
			}
		}
		if(!result)
		{
			--retries;
			if(!retries)
				break;
		}

		done += result;

	} while(done < filesize);

	// finish up the progress
	FinishProgress(filesize);

	StopProgress();

	if(done != filesize)
	{
		FreeData();
		ShowError(tr("Filesize doesn't match."));
	}

	char temp[50];
	network_read(connection, (u8 *) temp, 49);
	temp[49] = 0;

	snprintf(FileName, sizeof(FileName), "%s", temp);

	if(UncompressData() == NULL)
	{
		FreeData();
		ShowError(tr("Could not decompress the file."));
	}

	return filebuffer;
}