Beispiel #1
0
void ProxyClient::DownloadFile(char *fileName)
{
	if (!fileName || !fileName[0])
		return;

	const char szMD5[] = "!MD5";
	if (strstr(fileName, "..") ||
		// ignore customization's
		(strlen(fileName) == 36 && !_strnicmp(fileName, szMD5, sizeof(szMD5) - 1)))
	{
		DownloadFailed(fileName);
		return;
	}

	resource_t *resource = m_Proxy->GetResource(fileName);
	if (resource) {
		m_ClientChannel.CreateFragmentsFromBuffer(resource->data, resource->nDownloadSize, FRAG_FILE_STREAM, fileName);
		return;
	}

	if (m_ClientChannel.CreateFragmentsFromFile(fileName)) {
		m_ClientChannel.FragSend();
		return;
	}

	DownloadFailed(fileName);
}
Beispiel #2
0
void Crl::Load()
{
	if(!download.Get(url.c_str(), path.c_str()))
	{
		pf_log[W_INFO] << "CRL download failed";
		throw DownloadFailed();
	}
	pf_log[W_INFO] << "Loading CRL file : \"" << path << "\".";

	if(crl)
	{
		X509_CRL_free(crl);
		crl = NULL;
	}

	// TODO: simplify-me with openssl's BIO
	FILE* f = fopen(path.c_str(), "r");
	if(!f)
		throw BadCRL(std::string(strerror(errno)));

	if(fseek(f, 0, SEEK_END))
		throw BadCRL(std::string(strerror(errno)));

	size_t file_size = ftell(f);
	rewind(f);

	char buf[file_size];
	if(fread(buf, file_size, 1, f) <= 0)
	{
		fclose(f);
		throw BadCRL(std::string(strerror(errno)));
	}

	if(file_size > INT_MAX)
		throw BadCRL(std::string("File is too big"));

	BIO* raw_crl = BIO_new_mem_buf(buf, (int)file_size);
	crl = PEM_read_bio_X509_CRL(raw_crl, NULL, NULL, NULL);
	BIO_free(raw_crl);

	if(!crl)
	{
		std::string str = std::string(ERR_error_string( ERR_get_error(), NULL));
		throw BadCRL(str);
	}

	char* str = X509_NAME_oneline (X509_CRL_get_issuer (crl), 0, 0);
	pf_log[W_INFO] << "CRL issued by: " << str;
}
void SpeedDialConfigController::ExtensionView::DownloadSucceeded(const OpStringC& path)
{
	OP_NEW_DBG("SpeedDialConfigController::ExtensionView::DownloadSucceeded", "speeddial");
	OP_DBG(("") << m_image_downloader.DownloadUrl().GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI) << " successfully saved as " << path);

	const BOOL read_ok = OpStatus::IsSuccess(m_image_reader.Read(path));

	OpFile image_file;
	if (OpStatus::IsSuccess(image_file.Construct(path)))
		OpStatus::Ignore(image_file.Delete());

	if (read_ok)
	{
		Image image = m_image_reader.GetImage();
		OP_DBG(("image size: ") << image.Width() << "x" << image.Height());
		m_button->GetOpWidget()->GetForegroundSkin()->SetBitmapImage(image);
	}
	else
		DownloadFailed();
}