Beispiel #1
0
void CzUIWebView::setHtml(const char* html)
{
	if (html == NULL)
		return;

	CzString h = html;
	h.URLDecode();

	printf("****************************************\n");
	printf("%sn", h.c_str());
	printf("****************************************\n");

	if (!TempFilename.isEmpty())
	{
		CzFile::DeleteFile(TempFilename.c_str());
	}
	TempFilename = "ram://web_view_";
	TempFilename += Name;
//	TempFilename += CzString((int)(PLATFORM_SYS->getTimeUTC() & 0xffffffff));	// Ensure filename is unique
	TempFilename += ".html";
	CzFile file;
	if (file.Open(TempFilename.c_str(), "wb"))
	{
		file.Write((void*)h.c_str(), h.getLength());
		file.Close();
	}
	PLATFORM_UI->NavigateWebView(WebView, TempFilename.c_str());
}
Beispiel #2
0
void CzXmlNode::UpdateAttribute(const CzString& name, const char* value, CzXmlParser* parser)
{
	CzXmlAttribute* old_attribute = getAttribute(name.c_str());

	if (old_attribute == NULL)
	{
		// Attribute was not present so add
		CzXmlAttribute* attribute;
		if (parser != NULL)
			attribute = parser->AllocAttribute();
		else
			attribute = new CzXmlAttribute();
		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));
	}
}
Beispiel #3
0
int CzXmlNode::SaveAttributes(CzFile* file)
{
	for (CzXmlAttributeList::iterator i = Attributes.begin(); i != Attributes.end(); ++i)
	{
		CzString out;
		out.allocString(512);
		out = " ";
		out += (*i)->Name.c_str();
		out += "=\"";
		out += (*i)->Value.c_str();
		out += "\"";
		if (!file->Write((void*)out.c_str(), out.getLength()))
			return -1;
	}

	return 0;
}
Beispiel #4
0
//
//
//
//	MobFox specific implementation
//
//
//
bool CzAds::RequestAdMobFox()
{
	// Build request URI string
	RequestURI = "http://my.mobfox.com/request.php";

	CzString body;
	CzString urlencoded;

	body = "rt=api";
	body += "&u=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
	body += "&i=";
	body += CZ_HTTP_MANAGER->getIPAddress();
	body += "&o=";
	body += CzString(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", CzString(body.getLength()).c_str());
	AdRequest.setBody(body.c_str());
	CZ_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(CZ_ADS_TIMEOUT);

	return true;
}
Beispiel #5
0
int CzXmlNode::SaveTree(CzFile* file, int level)
{
	int err = 0;

	CzString out;
	out.allocString(256);

	for (int t = 0; t < level; t++)
		out += "\t";
	out += "<";
	out += Name;
	if (!file->Write((void*)out.c_str(), out.getLength()))
		return -1;

	err = SaveAttributes(file);
	if (err < 0)
		return err;
	if (HasValue)
	{
		if (Value.getLength() == 0)
			out = " />\n";
		else
		{
			out = ">";
			out += Value.c_str();
		}
		out += "</";
		out += Name.c_str();
		out += ">\n";
		if (!file->Write((void*)out.c_str(), out.getLength()))
			return -1;
	}
	else
	{
		if (Children.size() == 0)
		{
			out = " />\n";
			if (!file->Write((void*)out.c_str(), out.getLength()))
				return -1;
		}
		else
		{
			out = ">\n";
			if (!file->Write((void*)out.c_str(), out.getLength()))
				return -1;
			for (CzXmlNodeList::iterator i = Children.begin(); i != Children.end(); ++i)
			{
				err = (*i)->SaveTree(file, level + 1);
				if (err < 0)
					return err;
			}
			for (int t = 0; t < level; t++)
			{
				out = "\t";
				if (!file->Write((void*)out.c_str(), out.getLength()))
					return -1;
			}
			out = "</";
			out += Name.c_str();
			out += ">\n";
			if (!file->Write((void*)out.c_str(), out.getLength()))
				return -1;
		}
	}

	return 0;
}
Beispiel #6
0
void CzString::Copy(CzString& string)
{
	Copy((char *)string.c_str(), 0, string.getLength());
}
Beispiel #7
0
//
//
//
//	ImMobi specific implementation
//
//
//
bool CzAds::RequestAdInMobi()
{
	// Build M2M request URI string
	RequestURI = "http://w.inmobi.com/showad.asm";				// Live
//	RequestURI = "http://i.w.sandbox.inmobi.com/showad.asm";	// Test

	CzString body;
	CzString urlencoded;

	body = "mk-siteid=";
	body += ApplicationID;
	body += "&mk-carrier=";
	body += CZ_HTTP_MANAGER->getIPAddress();
	body += "&h-user-agent=";
	urlencoded.URLEncode(UserAgent.c_str());
	urlencoded.ToLower();
	body += urlencoded;
	body += "&u-id=";
	body += CzString(UDID);
	body += "&d-localization=";
	urlencoded.URLEncode(PLATFORM_SYS->getDeviceLocale());
	urlencoded.ToLower();
	body += urlencoded;
//	body += "&d-netType=wifi";
	body += "&d-netType=carrier";
	body += "&mk-version=pr-spec-atata-20090521";
	if (UserAge != 0)
	{
		body += "&u-age=";
		body += CzString(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", CzString(body.getLength()).c_str());
	AdRequest.setBody(body.c_str());
	CZ_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(CZ_ADS_TIMEOUT);

	return true;
}
Beispiel #8
0
bool CzAds::RequestAdMadvertise()
{
	// Build M2M request URI string
	RequestURI = "http://ad.madvertise.de/site/";
	RequestURI += ApplicationID;

	CzString body;
	CzString urlencoded;

	body += "ua=";
	urlencoded.URLEncode(UserAgent.c_str());
	body += urlencoded;
//	body += "&ip=";
//	body += CZ_HTTP_MANAGER->getIPAddress();
	body += "&requester=madvertise_api";
	body += "&version=api_2.1";
	body += "&unique_device_id=";
	body += CzString(UDID);
	if (!ExtraInfo.isEmpty())
	{
		body += ExtraInfo;
	}
/*	CzString local = PLATFORM_SYS->getDeviceLocale();
	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 += CzString(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", CzString(body.getLength()).c_str());
	AdRequest.setBody(body.c_str());
	CZ_HTTP_MANAGER->AddRequest(&AdRequest);
	BusyTimer.setDuration(CZ_ADS_TIMEOUT);

	return true;
}