Beispiel #1
0
void CIwGameAds::AdImageReceived(CIwGameHttpRequest* request, int error)
{
	s3eDebugOutputString("Ad image received");
	
	// If there wwas an error then set the error
	if (error != 0)
	{
		IW_GAME_ADS->setError(ErrorHttpImage);
		IW_GAME_ADS->setErrorString("Http error retrieving image");
#if defined(_DEBUG)
		CIwGameError::LogError("Error: CIwGameAds::AdImageReceived(): ", CIwGameString(error).c_str());
#endif	// _DEBUG
	}
	else
	{
		eIwGameImageFormat format = GetImageFormatFromHeader();
		if (format == ImageFormatInvalid)
		{
			Error = ErrorInvalidImage;
			ErrorString = "Invalid image format";
		}
		else
		{
			Error = ErrorNone;
			ErrorString = "";

			AdInfo.ImageFormat = format;
#if defined(_DEBUG)
			CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Image format - ", CIwGameString((int)format).c_str());
			CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Image URL - ", AdInfo.ImageURI.c_str());
			CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Link URL - ", AdInfo.LinkURI.c_str());
#endif	// _DEBUG

			// Delete previous image (if any)
			if (AdInfo.Image != NULL)
			{
				delete AdInfo.Image;
				AdInfo.Image = NULL;
			}

			// Create new banner image
			AdInfo.Image = new CIwGameImage();
			if (!AdInfo.Image->Init((void*)request->getContent().c_str(), request->getContentLength()))
			{
#if defined(_DEBUG)
				CIwGameError::LogError("Info: CIwGameAds::AdImageReceived() - Could hot create image!");
#endif	// _DEBUG
				Error = ErrorInvalidImage;
				ErrorString = "Invalid image format";
				delete AdInfo.Image;
				AdInfo.Image = NULL;
			}
			else
			{
CIwGameError::LogError("Info: Image Width - ", CIwGameString(AdInfo.Image->getWidth()).c_str());
CIwGameError::LogError("Info: Image Height - ", CIwGameString(AdInfo.Image->getHeight()).c_str());
			}
		}
	}
	NotifyAdAvailable();
}
Beispiel #2
0
void CzAds::AdImageReceived(CzHttpRequest* request, int error)
{
	CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "CzAds::AdImageReceived: Ad image received");
	
	// If there wwas an error then set the error
	if (error != 0)
	{
		CZ_ADS->setError(ErrorHttpImage);
		CZ_ADS->setErrorString("Http error retrieving image");
#if defined(_DEBUG)
		CzDebug::Log(CZ_DEBUG_CHANNEL_ERROR, "CzAds::AdImageReceived(): ", CzString(error).c_str());
#endif	// _DEBUG
	}
	else
	{
		eAdsImageFormat format = GetImageFormatFromHeader();
		if (format == ImageFormatInvalid)
		{
			Error = ErrorInvalidImage;
			ErrorString = "Invalid image format";
		}
		else
		{
			Error = ErrorNone;
			ErrorString = "";

			AdInfo.ImageFormat = format;
#if defined(_DEBUG)
			CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "CzAds::AdImageReceived() - Image format - ", CzString((int)format).c_str());
			CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "CzAds::AdImageReceived() - Image URL - ", AdInfo.ImageURI.c_str());
			CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "CzAds::AdImageReceived() - Link URL - ", AdInfo.LinkURI.c_str());
#endif	// _DEBUG

			// Delete previous image (if any)
			if (AdInfo.Image != NULL)
			{
				delete AdInfo.Image;
				AdInfo.Image = NULL;
			}

			// Create new banner image
			AdInfo.Image = new CzImage();
			if (!AdInfo.Image->Init((void*)request->getContent().c_str(), request->getContentLength()))
			{
#if defined(_DEBUG)
				CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "CzAds::AdImageReceived() - Could hot create image!");
#endif	// _DEBUG
				Error = ErrorInvalidImage;
				ErrorString = "Invalid image format";
				delete AdInfo.Image;
				AdInfo.Image = NULL;
			}
			else
			{
CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Image Width - ", CzString(AdInfo.Image->getWidth()).c_str());
CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Image Height - ", CzString(AdInfo.Image->getHeight()).c_str());
			}
		}
	}
	NotifyAdAvailable();
}