Exemplo n.º 1
0
bool CIwGameFile::GetFileType(const char* file_path, CIwGameString& type)
{
	int						len = strlen(file_path) - 1;
	const char*				name_ptr = file_path + len;

	// Scan backwards looking for dot
	int index = 0;
	while (len >= 0)
	{
		if (*name_ptr == '.')
		{
			type.setString(name_ptr + 1, index);
			type.ToLower();
			break;
		}
		else
		if (len == 0)
		{
			type.setString(name_ptr, index + 1);
			type.ToLower();
			break;
		}
		name_ptr--;
		index++;
		len--;
	}
	
	return true;
}
Exemplo n.º 2
0
//
//
//
//	AdFonic specific implementation
//
//
//
bool CIwGameAds::RequestAdAdFonic()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	CIwGameString urlencoded;

	RequestURI = "http://adfonic.net/ad/";
	RequestURI += ApplicationID;
	RequestURI += "?";
	RequestURI += "r.id=";
	urlencoded.URLEncode(CIwGameString(UDID).c_str());
	RequestURI += urlencoded;
	RequestURI += "&s.test=0";
	RequestURI += "&t.format=xml";
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 3
0
void CIwGameXmlParser::ShowError(eXMLParserError error, int pos) const
{
#ifdef SHOW_ERRORS
	s3eDebugOutputString(GetErrorString(error));
	s3eDebugOutputString(" at line ");
	CIwGameString num = CIwGameString(m_pDataInput->GetLineNumber(pos));
	s3eDebugOutputString(num.c_str());
#endif
}
Exemplo n.º 4
0
//
// 
// 
//
// CIwGameCommandIfVar Implementation
// 
// 
// 
//
bool CIwGameCommandIfVar::Execute(float dt)
{
	if (!IIwGameCommandExecutor::Execute(dt))
		return false;

	CIwGame* game = NULL;
	CIwGameScene* scene = NULL;
	CIwGameActor* actor = NULL;
	unsigned int class_hash = Program->getManager()->getParent()->getClassTypeHash();
	if (class_hash == CIwGameXomlNames::Game_Hash)
		game = (CIwGame*)Program->getManager()->getParent();
	else
	if (class_hash == CIwGameXomlNames::Scene_Hash)
		scene = (CIwGameScene*)Program->getManager()->getParent();

	if (game != NULL)
		scene = game->findScene(Params[3].getHash());

	IIwGameXomlResource* cont = (actor != NULL) ? (IIwGameXomlResource*)actor : (IIwGameXomlResource*)scene;
	CIwGameXomlVariable* var = CIwGameXomlVariable::GetVariable(Params[0], scene);
	if (var != NULL)
	{
		CIwGameString op = getParameter2(cont);
		op.ToLower();
		if (op == "==")
			ReturnValue = (int)var->checkCondition(CO_Equal, getParameter3(cont));
		else
		if (op == "!=")
			ReturnValue = (int)var->checkCondition(CO_NotEqual, getParameter3(cont));
		else
		if (op == "gt")
			ReturnValue = (int)var->checkCondition(CO_Greater, getParameter3(cont));
		else
		if (op == "lt")
			ReturnValue = (int)var->checkCondition(CO_Less, getParameter3(cont));
		else
		if (op == "gte")
			ReturnValue = (int)var->checkCondition(CO_GreaterEqual, getParameter3(cont));
		else
		if (op == "lte")
			ReturnValue = (int)var->checkCondition(CO_LessEqual, getParameter3(cont));
		else
		if (op == "and")
			ReturnValue = (int)var->checkCondition(CO_And, getParameter3(cont));
		else
			CIwGameError::LogError("Warning: IfVar command - operator invalid - ", op.c_str());
	}
	else
		CIwGameError::LogError("Warning: IfVar command - variable not found - ", Params[0].c_str());

	return false;
}
Exemplo n.º 5
0
//
//
//
//	VServ specific implementation
//
//
//
bool CIwGameAds::RequestAdVServ()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	// Build M2M request URI string
	RequestURI = "http://a.vserv.mobi/delivery/adapi.php?";
	CIwGameString urlencoded;

	RequestURI += "zoneid=";
	RequestURI += ApplicationID;
	RequestURI += "&im=";
	RequestURI += CIwGameString(UDID);
	RequestURI += "&ic=";
	RequestURI += s3eDeviceGetString(S3E_DEVICE_LOCALE);
	RequestURI += "&app=1";
	RequestURI += "&ts=1";
	RequestURI += "&ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
	if (Width != 0)
	{
		RequestURI += "&sw=";
		RequestURI += CIwGameString(Width);
	}
	if (Height != 0)
	{
		RequestURI += "&sh=";
		RequestURI += CIwGameString(Height);
	}
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 6
0
//
//
//
//	MillennialMedia specific implementation
//
//
//
bool CIwGameAds::RequestAdMillennialMedia()
{
	// Build M2M request URI string
	//RequestURI = "http://ads.mp.mydas.mobi/getAd.php5?";
    RequestURI = "http://ads.mydas.mobi/getAd?";
	CIwGameString urlencoded;

	RequestURI += "apid=";
	RequestURI += ApplicationID;
	RequestURI += "&auid=";
	RequestURI += CIwGameString(UDID);
	RequestURI += "&ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
//	RequestURI += "&mode=test";
//	RequestURI += "&uip=";
//	RequestURI += IW_GAME_HTTP_MANAGER->getIPAddress();

	if (UserAge != 0)
	{
		RequestURI += "&age=";
		RequestURI += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			RequestURI += "&gender=female";
		else
			RequestURI += "&gender=male";
	}
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 7
0
bool CIwGameUITextView::InitView(bool native_res, float min_scale, float max_scale)
{
	TextActor->setTappable(false);
#if defined(_DEBUG)
	CIwGameString name = Name;
	name += "text";
	TextActor->setName(name.c_str());
#endif	// _DEBUG

	Area = TextActor->getSize();

	MinZoom = min_scale;
	MaxZoom = max_scale;

	return true;
}
Exemplo n.º 8
0
bool CIwGameString::operator==	(const CIwGameString &op)
{
	if (Data == NULL)
		return false;

	if (AutoHash && op.isAutohash())
	{
		if (DataHash == op.getHash())
			return true;
	}
	else
	{
		if (strcmp(op.c_str(), Data) == 0)
			return true;
	}
	return false;
}
Exemplo n.º 9
0
void CIwGameXmlNode::UpdateAttribute(CIwGameString& name, const char* value)
{
	CIwGameXmlAttribute* old_attribute = GetAttribute(name.c_str());

	if (old_attribute == NULL)
	{
		// Attribute was not present so add
		CIwGameXmlAttribute* attribute = CIwGameXmlParser::AllocAttribute();
		attribute->setName((char*)name.c_str(), name.GetLength());
		attribute->setValue((char*)value, strlen(value));
		Attributes.push_back(attribute);
	}
	else
	{
		// Attribute was present so update it
		old_attribute->setName((char*)name.c_str(), name.GetLength());
		old_attribute->setValue((char*)value, strlen(value));
	}
}
Exemplo n.º 10
0
bool CIwGameString::SplitFilename(CIwGameString& filename, CIwGameString& ext)
{
	int index = 0;
	
	// Find the dot
	for (int t = GetLength() - 1; t != 0; t--)
	{
		if (*(Data + t) == '.')
		{
			index = t;
			break;
		}
	}
	if (index == 0) return false;
	
	filename.Copy(Data, 0, index);
	ext.Copy(Data, index + 1, GetLength() - index - 1);
	
	return true;
}
Exemplo n.º 11
0
CIwGameString::CIwGameString(const CIwGameString &string)
{
	FindIndex = 0;
	Data = NULL;
	AutoHash = true;
	if (string.c_str() == NULL)
	{
		Length = 0;
		Size = 0;
	}
	else
	{
		int len = (int)strlen(string.c_str());
		allocString(len);
		Length = len;
		strcpy(Data, string.c_str());

		if (AutoHash)
			DataHash = IwHashString(Data);
	}
}
Exemplo n.º 12
0
bool CIwGameUITextView::setProperty(unsigned int element_name, CIwGameString& data, bool delta)
{
	if (CIwGameUIBase::setProperty(element_name, data, delta))
		return true;

	if (element_name == CIwGameXomlNames::MinZoom_Hash)
	{
		if (delta)
			setMinZoom(MinZoom + data.GetAsFloat());
		else
			setMinZoom(data.GetAsFloat());
	}
	else
	if (element_name == CIwGameXomlNames::MaxZoom_Hash)
	{
		if (delta)
			setMaxZoom(MaxZoom + data.GetAsFloat());
		else
			setMaxZoom(data.GetAsFloat());
	}
	else
	if (element_name == CIwGameXomlNames::Zoom_Hash)
	{
		if (delta)
			setZoom(Zoom + data.GetAsFloat());
		else
			setZoom(data.GetAsFloat());
	}
	else
		return false;

	return true;
}
Exemplo n.º 13
0
CIwGameXmlStringList* CIwGameXmlAttribute::GetValueAsList()
{
	CIwGameXmlStringList* pList = new CIwGameXmlStringList;
	
	// Separate Value by commas
	int			len = Value.GetLength();
	const char* text = Value.c_str();
	char		c;
	
	while ((c = *text++) != 0)
	{
		// Find a none white space
		if (c != ' ' && c != '\t' && c != '\n' && c != ',')
		{
			int count = 0;
			const char* found = text;
			
			// Find end of string
			while (count++ < 63)
			{
				c = *text;
				if (c == '\n' || c == ',' || c == 0)
					break;
				text++;
			}
			int len = text - found;
			if (len > 0)
			{
				CIwGameString *pString = new CIwGameString();
				pString->Copy((char*)found, 0, len);
			
				pList->push_back(pString);
			}
		}
	}

	return pList;
}
Exemplo n.º 14
0
bool CIwGameUISlider::setProperty(unsigned int element_name, CIwGameString& data, bool delta)
{
	if (CIwGameUIBase::setProperty(element_name, data, delta))
		return true;

	float float_pool[8];

	if (element_name == CIwGameXomlNames::SliderSize_Hash)
	{
		SliderSize = data.GetAsInt();
	}
	else
	if (element_name == CIwGameXomlNames::Value_Hash)
	{
		Value = data.GetAsFloat();
	}
	else
	if (element_name == CIwGameXomlNames::ValueRange_Hash)
	{
		data.GetAsListOfFloat(float_pool);
		ValueRange.x = float_pool[0];
		ValueRange.y = float_pool[1];
	}
	else
	if (element_name == CIwGameXomlNames::SliderType_Hash)
	{
		unsigned int type_hash = data.getHash();

		if (type_hash == IW_GAME_HASH("vertical"))
			SliderType = SliderType_Vertical;
		else
			SliderType = SliderType_Horizontal;
	}
	else
		return false;

	return true;
}
Exemplo n.º 15
0
//
//
//
//	KomliMobile specific implementation
//
//
//
bool CIwGameAds::RequestAdKomliMobile()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	// Build M2M request URI string
	RequestURI = "http://a.zestadz.com/waphandler/deliverad?";
	CIwGameString urlencoded;

	RequestURI += "ip=";
	RequestURI += IW_GAME_HTTP_MANAGER->getIPAddress();
	RequestURI += "&cid=";
	RequestURI += ApplicationID;
	RequestURI += "&ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
	RequestURI += "&response_type=xml";
//	RequestURI += CIwGameString(UDID);
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 16
0
//
//
//
//	AdModa specific implementation
//
//
//
bool CIwGameAds::RequestAdAdModa()
{
	// Get device surface dimensions
	Width = IwGxGetScreenWidth();
	Height = IwGxGetScreenHeight();

	// Build M2M request URI string
	RequestURI = "http://www.admoda.com/ads/fetch.php?";
	CIwGameString urlencoded;

	RequestURI += "v=4";
	RequestURI += "&l=php";
	RequestURI += "&z=";
	RequestURI += ApplicationID;
//	RequestURI += "&a=";
//	RequestURI += IW_GAME_HTTP_MANAGER->getIPAddress();
	RequestURI += "&ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 17
0
//
//
//
//	MobFox specific implementation
//
//
//
bool CIwGameAds::RequestAdMobFox()
{
	// Build request URI string
	RequestURI = "http://my.mobfox.com/request.php";

	CIwGameString body;
	CIwGameString urlencoded;

	body = "rt=api";
	body += "&u=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
	body += "&i=";
	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&o=";
	body += CIwGameString(UDID);
	body += "&m=live";
	body += "&s=";
	body += ApplicationID;
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 18
0
int CIwGameString::GetNextMarkedStringAfterString(const char* search_string, char start_mark, char end_mark, CIwGameString& out_string)
{
	int pos = FindNext(search_string);
	if (pos >= 0)
	{
		// Get the text label
		int offset;
		StepFindIndex(strlen(search_string));
		int len = GetNextMarkedString(start_mark, end_mark, offset);
		if (len > 0)
		{
			out_string.setString(getString() + offset, len);
			return pos;
		}
		
		return -1;
	}

	return -1;
}
Exemplo n.º 19
0
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;
}
Exemplo n.º 20
0
//
//
//
//	ImMobi specific implementation
//
//
//
bool CIwGameAds::RequestAdInMobi()
{
	// Build M2M request URI string
	RequestURI = "http://w.inmobi.com/showad.asm";				// Live
//	RequestURI = "http://i.w.sandbox.inmobi.com/showad.asm";	// Test
    
    int slotSize = (int)SlotSize;

	CIwGameString body;
	CIwGameString urlencoded;

	body = "mk-siteid=";
	body += ApplicationID;
	body += "&mk-carrier=";
	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&h-user-agent=";
	urlencoded.URLEncode(UserAgent.c_str());
	urlencoded.ToLower();
	body += urlencoded;
	body += "&u-id=";
	body += CIwGameString(UDID);
	body += "&d-localization=";
	urlencoded.URLEncode(s3eDeviceGetString(S3E_DEVICE_LOCALE));
	urlencoded.ToLower();
	body += urlencoded;
//	body += "&d-netType=wifi";
	body += "&d-netType=carrier";
    body += "&mk-ad-slot=";
    body += CIwGameString(slotSize);
	body += "&mk-version=pr-SPEC-CTATA-20130111";
	if (UserAge != 0)
	{
		body += "&u-age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&u-gender=f";
		else
			body += "&u-gender=m";
	}
	if (!UserGPSLocation.IsEmpty())
	{
		body += "&u-latlong=";
		body += UserGPSLocation;
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&u-interests=";
		body += UserKeywords;
	}
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}
//	body.ToLower();

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("X-Mkhoj-SiteID", ApplicationID.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 21
0
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;
}
Exemplo n.º 22
0
bool CIwGameAds::ExtractLinkAndImageFromtHTML(CIwGameAd& ad, CIwGameString& html)
{
	int pos, offset;

	// Check to see if the html has a clickable link
	pos = html.Find("href=");
	if (pos > 0)
	{
		// Get the click link
		int idx = html.getFindIndex();
		int len = html.GetNextMarkedString('"', '"', offset);
		if (len < 0)
		{
			html.setFindIndex(idx);
			len = html.GetNextMarkedString('\'', '\'', offset);
		}
		if (len > 0)
		{
			ad.LinkURI.setString(html.getString() + offset, len);
#if defined(_DEBUG)
			CIwGameError::LogError("Info: Ad Link URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
		
			// Check to see if the html has an image available
			pos = html.Find("img ");
			if (pos > 0)
			{
				// Grab the image url
				pos = html.FindNext("src=");
				if (pos > 0)
				{
					idx = html.getFindIndex();
					len = html.GetNextMarkedString('"', '"', offset);
					if (len < 0)
					{
						html.setFindIndex(idx);
						len = html.GetNextMarkedString('\'', '\'', offset);
					}
					if (len > 0)
					{
						ad.ImageURI.setString(html.getString() + offset, len);
#if defined(_DEBUG)
						CIwGameError::LogError("Info: Ad Image URL: ", ad.ImageURI.c_str());
#endif	// _DEBUG
						return true;
					}
				}
			}
		}
	}

	return false;
}
Exemplo n.º 23
0
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;
}
Exemplo n.º 24
0
//
//
//
//	Mojiva specific implementation
//
//
//
bool CIwGameAds::RequestAdMojiva()
{
	// Build M2M request URI string
	RequestURI = "http://ads.mojiva.com/ad?";

	CIwGameString urlencoded;

	RequestURI += "zone=";
	RequestURI += ApplicationID;
	RequestURI += "&ip=";
	RequestURI += IW_GAME_HTTP_MANAGER->getIPAddress();
	urlencoded.URLEncode(UserAgent.c_str());
	RequestURI += urlencoded;
	RequestURI += "&udid=";
	RequestURI += CIwGameString(UDID);

	if (!ExtraInfo.IsEmpty())
	{
		RequestURI += ExtraInfo;
	}

/*	CIwGameString local = s3eDeviceGetString(S3E_DEVICE_LOCALE);
	int pos = local.Contains('_');
	if (pos >= 0)
	{
		// Strip language and underscore
		local.setString(local.c_str() + pos + 1, 2);
		local.ToUpper();
		body += "&country=";
		body += local;
	}*/

/*	if (UserAge != 0)
	{
		body += "&age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&gender=F";
		else
			body += "&gender=M";
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&keywords=";
		body += UserKeywords;
	}*/

	AdRequest.setGET();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", "0");
	AdRequest.setBody("");
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}
Exemplo n.º 25
0
bool IIwGameBrush::LoadFromXoml(IIwGameXomlResource* parent, bool load_children, CIwGameXmlNode* node)
{
	// Get brush data
	eIwGameBrushType	type = BT_Solid;
	CIwFVec4			colour;
	CIwGameString*		name = NULL;
	CIwGameString*		image_name = NULL;
	CIwRect				rect = CIwRect(0, 0, 0, 0);
	CIwRect				scale_area = CIwRect(0, 0, 0, 0);
	CIwGameString*		condition = NULL;

	CIwGameScene* scene = NULL;
	if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Actor_Hash)
		scene = ((CIwGameActor*)parent)->getScene();
	else
	if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Scene_Hash)
		scene = (CIwGameScene*)parent;

	for (CIwGameXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); ++it)
	{
		unsigned int attrib_hash = (*it)->getName().getHash();

		if (attrib_hash == CIwGameXomlNames::Name_Hash)
		{
			name = &(*it)->GetValue();
		}
		else
		if (attrib_hash == CIwGameXomlNames::Type_Hash)
		{
			unsigned int type_hash = (*it)->GetValue().getHash();
			if (type_hash == CIwGameXomlNames::Solid_Hash)
				type = BT_Solid;
			else
			if (type_hash == CIwGameXomlNames::Gradient_Hash)
				type = BT_Gradient;
			else
			if (type_hash == CIwGameXomlNames::Image_Hash)
				type = BT_Image;
			else
			if (type_hash == CIwGameXomlNames::Patch9_Hash)
				type = BT_9Patch;
			else
			{
				CIwGameError::LogError("Error: XOML - Invalid brush type - ", (*it)->GetValue().c_str());
				return false;
			}
		}
		else
		if (attrib_hash == CIwGameXomlNames::Colour_Hash)
		{
			if (!(*it)->GetValueAsPoint4(colour))
				CIwGameError::LogError("Warning: XOML - Brush Colour should be a vec4");
		}
		else
		if (attrib_hash == CIwGameXomlNames::Image_Hash)
		{
			image_name = &(*it)->GetValue();
			type = BT_Image;
		}
		else
		if (attrib_hash == CIwGameXomlNames::SrcRect_Hash)
		{
			if (!(*it)->GetValueAsRect(rect))
				CIwGameError::LogError("Warning: XOML - Brush SrcRect should be a rect");
		}
		else
		if (attrib_hash == CIwGameXomlNames::Tag_Hash)
		{
			setTag((*it)->GetValue().c_str());
		}
		else
		if (attrib_hash == CIwGameXomlNames::ScaleArea_Hash)
		{
			if (!(*it)->GetValueAsRect(scale_area))
				CIwGameError::LogError("Warning: XOML - Brush ScaleArea should be a rect");
		}
		else
		if (attrib_hash == CIwGameXomlNames::Condition_Hash)
		{
			condition = &(*it)->GetValue();
		}
	}

	if (condition != NULL)
	{
		// Find the condition variable
		bool condition_not = false;
		CIwGameXomlVariable* var = NULL;
		if (*(condition->c_str()) == '!')
		{
			condition_not = true;
			CIwGameString cond = condition->c_str() + 1;
			var = CIwGameXomlVariable::GetVariable(cond, scene);
		}
		else
			var = CIwGameXomlVariable::GetVariable(*condition, scene);
		if (var != NULL)
		{
			bool res = var->isTrue();
			if (condition_not)
				res = !res;
			if (!res)
			{
				IW_GAME_XOML->setExitOnError(false);
				return false;
			}
		}
#if defined (_DEBUG)
		else
			CIwGameError::LogError("Warning: condition variable not found - ", condition->c_str());
#endif // _DEBUG
	}

	IIwGameBrush* brush = NULL;
	switch (type)
	{
	case BT_Solid:
		{
			CIwGameBrushSolid* b = new CIwGameBrushSolid();
			b->setColour((uint8)colour.x, (uint8)colour.y, (uint8)colour.z, (uint8)colour.w);
			brush = b;
		}
		break;
	case BT_Gradient:
		{
		}
		break;
	case BT_Image:
	case BT_9Patch:
		{
			CIwGameImage* image = NULL;

			if (image_name == NULL)
			{
				CIwGameError::LogError("Error: An image / patch9 brush requires an image to be specified");
				return false;
			}
	
			if (scene != NULL)
			{
				image = (CIwGameImage*)scene->getResourceManager()->findResource(image_name->getHash(), CIwGameXomlNames::Image_Hash);
				if (image == NULL)
					CIwGameError::LogError("Warning: XOML - Brush - Could not find brush image - ", image_name->c_str());
			}
			else
			{
				image = (CIwGameImage*)IW_GAME_GLOBAL_RESOURCES->getResourceManager()->findResource(image_name->getHash(), CIwGameXomlNames::Image_Hash);
				if (image == NULL)
					CIwGameError::LogError("Warning: XOML - Brush - Could not find brush image - ", image_name->c_str());
			}

			if (image != NULL)
			{
				if (type == BT_Image)
				{
					CIwGameBrushImage* b = new CIwGameBrushImage();
					b->setImage(image);
					b->setSrcRect(rect);
					brush = b;
				}
				else
				if (type == BT_9Patch)
				{
					CIwGameBrushImage9* b = new CIwGameBrushImage9();
					b->setImage(image);
					b->setSrcRect(rect);
					b->setScalableArea(scale_area);
					brush = b;
				}
			}
		}
		break;
	}

	if (brush != NULL)
	{
		brush->setName(name->c_str());
		brush->setBrushType(type);

		// If we are declared inside a scene then material is local to the scene
		if (scene != NULL)
			scene->getResourceManager()->addResource(brush);
		else
			IW_GAME_GLOBAL_RESOURCES->getResourceManager()->addResource(brush);
	}

	IW_GAME_XOML->setExitOnError(false);
	return false;
}
Exemplo n.º 26
0
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;
}
Exemplo n.º 27
0
//
// 
// 
//
// CIwGameCommandSetVariable Implementation
// 
// 
// 
//
bool CIwGameCommandSetVariable::Execute(float dt)
{
	if (!IIwGameCommandExecutor::Execute(dt))
		return false;

	CIwGame* game = NULL;
	CIwGameScene* scene = NULL;
	unsigned int class_hash = Program->getManager()->getParent()->getClassTypeHash();
	if (class_hash == CIwGameXomlNames::Game_Hash)
		game = (CIwGame*)Program->getManager()->getParent();
	else
	if (class_hash == CIwGameXomlNames::Scene_Hash)
		scene = (CIwGameScene*)Program->getManager()->getParent();

	if (game != NULL)
		scene = game->findScene(Params[2].getHash());

	IIwGameXomlResource* cont = (IIwGameXomlResource*)scene;
	// Set the variables value
	CIwGameXomlVariable* var = CIwGameXomlVariable::GetVariable(Params[0], scene);
	if (var != NULL)
	{
		unsigned int hash = getParameter2(cont).getHash();
		if (hash == CIwGameXomlNames::Rand_Hash || hash == CIwGameXomlNames::RandChar_Hash)
		{
			CIwGameString rnd;
			rnd.setAutoHash(false);
			float min, max;

			if (hash == CIwGameXomlNames::Rand_Hash)
			{
				min = getParameter4(cont).GetAsFloat();
				max = getParameter5(cont).GetAsFloat();
			}
			else
			{
				min = (float)getParameter4(cont)[0];
				max = (float)getParameter5(cont)[0];
			}

			if (var->isArray())
			{
				CIwGameXomlVariableArray* arr = (CIwGameXomlVariableArray*)var;
				for (int t = 0; t < arr->getSize(); t++)
				{
					CIwGameXomlVariable* var2 = arr->getElement(t);
					float num = min + (((float)rand() * (max - min)) / RAND_MAX);

					if (hash == CIwGameXomlNames::Rand_Hash)
					{
						if (var2->Type == VT_Bool)
							rnd = (bool)(num > 0.5f);
						else
						if (var2->Type == VT_Int)
							rnd = (int)num;
						else
							rnd = num;
					}
					else
						rnd = (char)num;
					var2->setValue(rnd.c_str());
				}
			}
			else
			{
				float num = min + (((float)rand() * (max - min)) / RAND_MAX);
				if (hash == CIwGameXomlNames::Rand_Hash)
				{
					if (var->Type == VT_Bool)
						rnd = (bool)(num > 0.5f);
					else
					if (var->Type == VT_Int)
						rnd = (int)num;
					else
						rnd = num;
				}
				else
					rnd = (char)num;
				var->setValue(rnd.c_str());
			}
		}
		else
			var->setValue(getParameter2(cont).c_str());
	}

	return false;
}
Exemplo n.º 28
0
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;
}
Exemplo n.º 29
0
bool CIwGameImage::LoadFromXoml(IIwGameXomlResource* parent, bool load_children, CIwGameXmlNode* node)
{
	// Process image attributes
	CIwGameString* name = NULL;
	CIwGameString* location = NULL;
	bool preload = true;
	bool blocking = false;
	CIwGameString* condition = NULL;

	CIwGameScene* scene = NULL;
	if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Actor_Hash)
		scene = ((CIwGameActor*)parent)->getScene();
	else
	if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Scene_Hash)
		scene = (CIwGameScene*)parent;

	for (CIwGameXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++)
	{
		unsigned int name_hash = (*it)->getName().getHash();

		if (name_hash == CIwGameXomlNames::Name_Hash)
		{
			name = &(*it)->GetValue();
			setName(name->c_str());
		}
		else
		if (name_hash == CIwGameXomlNames::Tag_Hash)
			setTag((*it)->GetValue().c_str());
		else
		if (name_hash == CIwGameXomlNames::Location_Hash)
			location = &(*it)->GetValue();
		else
 		if (name_hash == CIwGameXomlNames::Preload_Hash)
			preload = (*it)->GetValueAsBool();
		else
 		if (name_hash == CIwGameXomlNames::Blocking_Hash)
			blocking = (*it)->GetValueAsBool();
		else
		if (name_hash == CIwGameXomlNames::Condition_Hash)
			condition = &(*it)->GetValue();
		else
		if (name_hash == CIwGameXomlNames::Format_Hash)
		{
			FormatSet = true;
			unsigned int format_hash = (*it)->GetValue().getHash();
			if (format_hash == IW_GAME_HASH("RGB_565"))
				Format = CIwImage::RGB_565;
			else
			if (format_hash == IW_GAME_HASH("RGBA_4444"))
				Format = CIwImage::RGBA_4444;
			else
			if (format_hash == IW_GAME_HASH("RGBA_5551"))
				Format = CIwImage::RGBA_5551;
			else
			if (format_hash == IW_GAME_HASH("RGB_888"))
				Format = CIwImage::RGB_888;
			else
			if (format_hash == IW_GAME_HASH("RGBA_6666"))
				Format = CIwImage::RGBA_6666;
			else
			if (format_hash == IW_GAME_HASH("RGB_332"))
				Format = CIwImage::RGB_332;
			else
			if (format_hash == IW_GAME_HASH("RGBA_8888"))
				Format = CIwImage::RGBA_8888;
			else
			{
				FormatSet = false;
				CIwGameError::LogError("Warning: Invalid texture format set - ", (*it)->GetValue().c_str());
			}
		}
		else
 		if (name_hash == CIwGameXomlNames::Filter_Hash)
			setFilter((*it)->GetValueAsBool());
	}

	if (location == NULL || name == NULL)
		CIwGameError::LogError("Warning: An Image requires a location and a name to be specified");

	if (condition != NULL)
	{
		// Find the condition variable
		bool condition_not = false;
		CIwGameXomlVariable* var = NULL;
		if (*(condition->c_str()) == '!')
		{
			condition_not = true;
			CIwGameString cond = condition->c_str() + 1;
			var = CIwGameXomlVariable::GetVariable(cond, scene);
		}
		else
			var = CIwGameXomlVariable::GetVariable(*condition, scene);
		if (var != NULL)
		{
			bool res = var->isTrue();
			if (condition_not)
				res = !res;
			if (!res)
			{
				IW_GAME_XOML->setExitOnError(false);
				return false;
			}
		}
#if defined (_DEBUG)
		else
			CIwGameError::LogError("Warning: condition variable not found - ", condition->c_str());
#endif // _DEBUG
	}

	if (location != NULL)
	{
		// Check to see if image is located externally
		if (CIwGameFile::isHttp(location->c_str(), location->GetLength()))
		{
			Init(location->c_str());
		}
		else
		if (CIwGameFile::isFile(location->c_str(), location->GetLength()))
		{
			Init(location->c_str());
		}
		else
		{
			// Find resource group
			CIwGameResourceGroup* group = NULL;
			if (parent != NULL && parent->getClassTypeHash() == CIwGameXomlNames::Scene_Hash)
				group = (CIwGameResourceGroup*)scene->getResourceManager()->findResource(location->c_str(), CIwGameXomlNames::ResourceGroup_Hash);
			else
				group = (CIwGameResourceGroup*)IW_GAME_GLOBAL_RESOURCES->getResourceManager()->findResource(location->c_str(), CIwGameXomlNames::ResourceGroup_Hash);

			if (group != NULL)
				Init(name->c_str(), group->getResourceGroup());
			else
			{
				CIwGameError::LogError("Error: XOML - Invalid image resource group name - ", location->c_str());
				return false;
			}
		}
		if (preload)
		{
			Load(blocking);
		}
	}

	// If we are declared inside a scene then image is local to the scene
	if (scene != NULL)
		return scene->getResourceManager()->addResource(this);
	else
		return IW_GAME_GLOBAL_RESOURCES->getResourceManager()->addResource(this);

	return true;
}
Exemplo n.º 30
0
bool CIwGameAds::RequestAdMadvertise()
{
	// Build M2M request URI string
	RequestURI = "http://ad.madvertise.de/site/";
	RequestURI += ApplicationID;

	CIwGameString body;
	CIwGameString urlencoded;

	body += "ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
//	body += "&ip=";
//	body += IW_GAME_HTTP_MANAGER->getIPAddress();
	body += "&requester=madvertise_api";
	body += "&version=api_2.1";
	body += "&unique_device_id=";
	body += CIwGameString(UDID);
	if (!ExtraInfo.IsEmpty())
	{
		body += ExtraInfo;
	}

/*	CIwGameString local = s3eDeviceGetString(S3E_DEVICE_LOCALE);
	int pos = local.Contains('_');
	if (pos >= 0)
	{
		// Strip language and underscore
		local.setString(local.c_str() + pos + 1, 2);
		local.ToUpper();
		body += "&country=";
		body += local;
	}*/

	if (UserAge != 0)
	{
		body += "&age=";
		body += CIwGameString(UserAge);
	}
	if (UserGender != GenderInvalid)
	{
		if (UserGender == GenderFemale)
			body += "&gender=F";
		else
			body += "&gender=M";
	}
	if (!UserKeywords.IsEmpty())
	{
		body += "&keywords=";
		body += UserKeywords;
	}

	AdRequest.setPOST();
	AdRequest.setURI(RequestURI.c_str());
	AdRequest.setContentAvailableCallback(&AdInfoRetrievedCallback, NULL);
	AdRequest.SetHeader("User-Agent", UserAgent.c_str());
	AdRequest.SetHeader("Accept", "application/xml");
	AdRequest.SetHeader("Content-Type", "application/x-www-form-urlencoded");
	AdRequest.SetHeader("Content-Length", CIwGameString(body.GetLength()).c_str());
	AdRequest.setBody(body.c_str());
	IW_GAME_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(IW_GAME_ADS_TIMEOUT);

	return true;
}