コード例 #1
0
ファイル: IwGameAds.cpp プロジェクト: agramonte/IwGameAds
bool CIwGameAds::ExtractAdAdModa(CIwGameAd& ad, CIwGameString& ad_body)
{
	int len, offset;

	ad.isHtml = false;
	ad.isText = false;
	ad.ImageURI = "";
	ad.LinkURI = "";
	ad.Text = "";
	ad.AdTime = s3eTimerGetMs();

	ad_body.FindReset();

	// Get Ad image
	len = ad_body.GetNextMarkedString('|', '|', offset);
	if (len > 0)
	{
		ad.ImageURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
		CIwGameError::LogError("Info: Ad Image: ", ad.ImageURI.c_str());
#endif	// _DEBUG
	}
	ad_body.StepFindIndex(-1);

	// Get Ad link
	len = ad_body.GetNextMarkedString('|', '|', offset);
	if (len > 1)
	{
		ad.LinkURI.setString(ad_body.getString() + offset, len - 1);
#if defined(_DEBUG)
		CIwGameError::LogError("Info: Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
	}


	if (ad.ImageURI.IsEmpty() || ad.LinkURI.IsEmpty())
		return false;

	return true;
}
コード例 #2
0
ファイル: IwGameAds.cpp プロジェクト: agramonte/IwGameAds
bool CIwGameAds::ExtractAdInnerActive(CIwGameAd& ad, CIwGameString& ad_body)
{
	// We dont use a full on XML parser to parse the returned XML, instead we just search for the required info
	int pos, offset, len;

	ad.isHtml = HtmlAds;
	ad.isText = false;
	ad.ImageURI = "";
	ad.LinkURI = "";
	ad.Text = "";
	ad.AdTime = s3eTimerGetMs();

	// Get Error Response
	ad_body.FindReset();
	pos = ad_body.FindNext("<tns:Response Error=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ErrorFromResponse(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Response: ", ErrorString.c_str());
#endif	// _DEBUG
		}
	}

	// Get Client ID (we store this for future ad requests during the same session)
	pos = ad_body.FindNext("<tns:Client Id=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ClientID.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Client ID: ", ClientID.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad text
	pos = ad_body.FindNext("<tns:Text");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ad.Text.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Text: ", ad.Text.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad link
	pos = ad_body.FindNext("<tns:URL");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ad.LinkURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad image
	pos = ad_body.FindNext("<tns:Image");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ad.ImageURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Image URL: ", ad.ImageURI.c_str());
#endif	// _DEBUG
		}
	}

	return true;
}
コード例 #3
0
ファイル: IwGameAds.cpp プロジェクト: agramonte/IwGameAds
bool CIwGameAds::ExtractAdKomliMobile(CIwGameAd& ad, CIwGameString& ad_body)
{
return false;
	// We dont use a full on XML parser to parse the returned XML, instead we just search for the required info
	int pos;

	ad.isHtml = false;
	ad.isText = false;
	ad.ImageURI = "";
	ad.LinkURI = "";
	ad.Text = "";
	ad.AdTime = s3eTimerGetMs();

	ad_body.FindReset();

	// Find render section
	if (ad_body.FindNext("\"action\"") < 0)
	{
		return false;
	}

	// Find click URL
	pos = ad_body.GetNextMarkedStringAfterString("\"data\"", '"', '"', ad.LinkURI);
	if (pos >= 0)
	{
#if defined(_DEBUG)
		CIwGameError::LogError("Info: Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
	}
	else
		return false;

	// Find render section
	if (ad_body.FindNext("\"render\"") < 0)
	{
		return false;
	}

	// Find Image URL
	pos = ad_body.GetNextMarkedStringAfterString("\"data\"", '"', '"', ad.ImageURI);
	if (pos > 0)
	{
#if defined(_DEBUG)
		CIwGameError::LogError("Info: Ad Image URL: ", ad.ImageURI.c_str());
#endif	// _DEBUG
	}
	else
		return false;

/*	// Find click URL
	pos = ad_body.GetNextMarkedStringAfterString("\"notify\"", '"', '"', ad.LinkURI);
	if (pos >= 0)
	{
#if defined(_DEBUG)
		CIwGameError::LogError("Info: Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
	}
	else
		return false;(*/

	return true;
}
コード例 #4
0
ファイル: IwGameAds.cpp プロジェクト: agramonte/IwGameAds
bool CIwGameAds::ExtractAdAdFonic(CIwGameAd& ad, CIwGameString& ad_body)
{
	// We dont use a full on XML parser to parse the returned XML, instead we just search for the required info
	int pos, offset, len;

	ad.isHtml = false;
	ad.isText = false;
	ad.ImageURI = "";
	ad.LinkURI = "";
	ad.Text = "";
	ad.AdTime = s3eTimerGetMs();

	// Get Error Response
	ad_body.FindReset();
	pos = ad_body.FindNext("<status");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ErrorString.setString(ad_body.getString() + offset, len);
			if (ErrorString == "error")
			{
				Error = ErrorInternalError;
				return false;
			}
			else
				Error = ErrorNone;
		}
	}

	// Get Ad format
	pos = ad_body.FindNext("<format");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			CIwGameString format;
			format.setString(ad_body.getString() + offset, len);
			if (format == "banner")
				ad.isText = false;
			else
				ad.isText = true;

#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Format: ", ad.Text.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad text
	pos = ad_body.FindNext("<![CDATA[");
	if (pos >= 0)
	{
		int end_pos = ad_body.FindNext("]]>");
		if (end_pos > 0)
		{
			ad.Text.setString(ad_body.getString() + pos + 9, end_pos - pos - 9);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Text: ", ad.Text.c_str());
#endif	// _DEBUG
			ad.isHtml = true;
		}
	}
	ad_body.FindReset();

	// Get Ad link
	pos = ad_body.FindNext("url=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ad.LinkURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad image
	pos = ad_body.FindNext("src=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ad.ImageURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Image URL: ", ad.ImageURI.c_str());
#endif	// _DEBUG
		}
	}

	return true;
}
コード例 #5
0
ファイル: IwGameAds.cpp プロジェクト: agramonte/IwGameAds
bool CIwGameAds::ExtractAdMobFox(CIwGameAd& ad, CIwGameString& ad_body)
{
	// We dont use a full on XML parser to parse the returned XML, instead we just search for the required info
	int pos, offset, len;

	ad.isHtml = false;
	ad.isText = false;
	ad.ImageURI = "";
	ad.LinkURI = "";
	ad.Text = "";
	ad.AdTime = s3eTimerGetMs();

	// Get Error Response
	ad_body.FindReset();
	pos = ad_body.FindNext("<request type=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ErrorString.setString(ad_body.getString() + offset, len);
			if (ErrorString == "noAd")
			{
				Error = ErrorNoAd;
				return false;
			}
			else
				Error = ErrorNone;
			if (ErrorString == "textAd")
			{
				ad.isHtml = true;
				ad.isText = true;
			}
		}
	}

	// Get Ad text
	pos = ad_body.FindNext("<htmlString>");
	if (pos >= 0)
	{
		// Find closeing tag
		int end_pos = ad_body.FindNext("</htmlString>");
		if (end_pos > 0)
		{
			ad.Text.setString(ad_body.getString() + pos, end_pos - pos);
			ad.Text.ReplaceHTMLCodes();
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Text: ", ad.Text.c_str());
#endif	// _DEBUG
		}
		// If we can successfully extract the link and banner information from the text ad then unmark the ad as html/text
		if (ExtractLinkAndImageFromtHTML(ad, ad.Text))
		{
			ad.isHtml = false;
			ad.isText = false;
			return true;
		}
	}
	else
		ad_body.FindReset();

	// Get Ad link
	pos = ad_body.FindNext("<clickurl");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ad.LinkURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad image
	pos = ad_body.FindNext("<imageurl");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ad.ImageURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Image URL: ", ad.ImageURI.c_str());
#endif	// _DEBUG
		}
	}

	return true;
}