Esempio n. 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());
}
Esempio n. 2
0
int CzXomlLoad::LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node)
{
	CzScene* scene = NULL;
	if (parent->getClassTypeHash() == CzHashes::Scene_Hash)
		scene = (CzScene*)parent;

	CzString* file = NULL;
	CzString* condition = NULL;

	// Process LoadXoml specific attributes
	for (CzXmlNode::_AttribIterator it = node->attribs_begin(); it != node->attribs_end(); it++)
	{
		unsigned int name_hash = (*it)->getName().getHash();

		if (name_hash == CzHashes::File_Hash)
			file = &(*it)->getValue();
		else
		if (name_hash == CzHashes::Condition_Hash)
			condition = &(*it)->getValue();
	}

	if (condition != NULL)
	{
		// Find the condition variable
		bool condition_not = false;
		CzXomlVariable* var = NULL;
		if (*(condition->c_str()) == '!')
		{
			condition_not = true;
			CzString cond = condition->c_str() + 1;
			var = CzXomlVariable::GetVariable(cond, scene);
		}
		else
			var = CzXomlVariable::GetVariable(*condition, scene);
		if (var != NULL)
		{
			bool res = var->isTrue();
			if (condition_not)
				res = !res;
			if (!res)
				return -1;
		}
#if defined (_DEBUG)
		else
			CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "LoadXOML - Condition variable not found - ", condition->c_str(), DebugInfo.c_str());
#endif // _DEBUG
	}


	if (file != NULL)
		CZ_XOML->Process(parent, file->c_str(), false);

	return -1;
}
Esempio n. 3
0
void CzString::set(const CzVec2& v)
{
	FindIndex = 0;
	CzString s = v.x;
	s += ",";
	s += v.y;
	setString(s.c_str());
}
Esempio n. 4
0
void CzString::set(const CzVec4& v)
{
	CzString s = v.x;
	s += ",";
	s += v.y;
	s += ",";
	s += v.z;
	s += ",";
	s += v.w;
	setString(s.c_str());
}
Esempio n. 5
0
void CzString::set(const CzColour& v)
{
	CzString s = v.r;
	s += ",";
	s += v.g;
	s += ",";
	s += v.b;
	s += ",";
	s += v.a;
	setString(s.c_str());
}
Esempio n. 6
0
CzString::CzString(const CzString &string)
{
	FindIndex = 0;
	Data = NULL;
	Length = 0;
	Size = 0;
	AutoHash = true;
	if (string.c_str() == NULL)
		return;
	else
	{
		int len = (int)strlen(string.c_str());
		allocString(len);
		Length = len;
		memcpy(Data, string.c_str(), Length + 1);

		if (AutoHash)
			DataHash = CzString::CalculateHash(Data);
	}
}
Esempio n. 7
0
void CzXmlParser::ShowError(eCzXmlParseError error, int pos) const
{
#ifdef SHOW_ERRORS
	CzString out;
	out += getErrorString(error);
	out += " around line ";
//	out += CzString(m_pDataInput->GetLineNumber(pos));
	out += CzString(pos + 1);
	CzDebug::Log(CZ_DEBUG_CHANNEL_ERROR, out.c_str());
#endif
}
Esempio n. 8
0
bool CzCamera::_setName(IzXomlResource* target, const CzXomlProperty& prop, bool add)
{
	if (add)
	{
		CzString name = ((CzCamera*)target)->getName();
		name += (const char*)prop.p_data;
		((CzCamera*)target)->setName(name.c_str());
	}
	else
		((CzCamera*)target)->setName((const char*)prop.p_data);

	return true;
}
Esempio n. 9
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));
	}
}
Esempio n. 10
0
void CzApp::UpdateSystemTouches()
{
	CzXomlVariableArrayInt* arr = (CzXomlVariableArrayInt*)CZ_GLOBAL_RESOURCES->getVariableManager()->findVariable("touches");

	// Update system array
	int count = 1;
	if (CZ_INPUT->isMultiTouch())
		count = 5;
	CzString num;
	num.setAutoHash(false);
	int index = 0;
	for (int t = 0; t < 5; t++)
	{
		CzXomlVariableInt* var = (CzXomlVariableInt*)arr->getElement(index++);
		CzTouch* touch = CZ_INPUT->getTouch(t);
		if (touch->x != var->NativeValue)
		{
			var->NativeValue = touch->x;
			num = var->NativeValue;
			var->setValueText(num.c_str());
		}
		var = (CzXomlVariableInt*)arr->getElement(index++);
		if (touch->y != var->NativeValue)
		{
			var->NativeValue = touch->y;
			num = var->NativeValue;
			var->setValueText(num.c_str());
		}
		var = (CzXomlVariableInt*)arr->getElement(index++);
		if ((int)touch->touched != var->NativeValue)
		{
			var->NativeValue = (int)touch->touched;
			num = var->NativeValue;
			var->setValueText(num.c_str());
		}
	}
}
Esempio n. 11
0
bool CzUITextBox::_setVariable(IzXomlResource* target, const CzXomlProperty& prop, bool add)
{
	CzUITextBox* actor = (CzUITextBox*)target;

	if (add)
	{
		CzString s = actor->getTargetVariable();
		s += (const char*)prop.p_data;
		actor->setTargetVariable(s.c_str());

	}
	else
		actor->setTargetVariable((const char*)prop.p_data);

	return true;
}
Esempio n. 12
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;
}
Esempio n. 13
0
bool CzString::operator==	(const CzString &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;
}
Esempio n. 14
0
bool CzUIImageView::InitView(IzBrush* brush, int width, int height, bool native_res, float min_scale, float max_scale)
{
	Icon = new CzUIIcon();
	Scene->addActor(Icon);
	Icon->setLinkedTo(this);
	Icon->setTappable(false);

	Icon->Init(brush, width, height);
	Icon->setDepth(0);
#if defined(_DEBUG)
	CzString name = Name;
	name += "Icon";
	Icon->setName(name.c_str());
#endif	// _DEBUG

	Area = Icon->getSize();

	MinZoom = min_scale;
	MaxZoom = max_scale;

	return true;
}
Esempio n. 15
0
//
//
// Common functions
//
//
bool LUA_ValueToString(lua_State *lua, int stack_index, CzString &string)
{
    if (lua_isnumber(lua, stack_index))
	{
        float n = (float)lua_tonumber(lua, stack_index);
		int in = (int)n;
		if (n == in)
			string = in;
		else
			string = n;
	}
	else
    if (lua_isboolean(lua, stack_index))
        string = lua_toboolean(lua, stack_index) != 0;
	else
    if (lua_isvec(lua, stack_index))
	{
        const float* v = lua_tovec(lua, stack_index);
		string = *v++;
		string += ",";
		string += *v++;
		string += ",";
		string += *v++;
		string += ",";
		string += *v;
	}
	else
    if (lua_isstring(lua, stack_index))
        string = lua_tostring(lua, stack_index);
	else
		return false;

	if (string.c_str() == NULL)
		return false;

	return true;
}
Esempio n. 16
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;
}
Esempio n. 17
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;
}
Esempio n. 18
0
bool CzXomlLoad::CreateInstance(IzXomlResource* parent, CzScene* scene, CzString* template_name, CzString* parameters)
{
	if (template_name == NULL)
		return false;

	// Get the template
	CzTemplate* temp = (CzTemplate*)CzXomlResourceManager::FindResource(template_name->getHash(), CzHashes::Template_Hash, parent);
	if (temp != NULL)
	{
		if (parameters != NULL && !parameters->isEmpty())
		{
			// Create a set of XML attributes that will replace the template parameters
			CzXmlNode* replacements = new CzXmlNode();
			replacements->Managed = false;

			// Split parameter two into paramater=value pairs
			CzSlotArray<CzString*>* split = parameters->Split(':');
			CzSlotArray<CzString*>* strings = new CzSlotArray<CzString*>();
			for (int t = 0; t < split->getSize(); t++)
			{
				CzString* pair = split->element_at(t);
				if (pair != NULL)
				{
					// Split paramater / value pair
					pair->Split('=', strings);
					CzString* name = strings->element_at(0);
					CzString* value = strings->element_at(1);

					if (name != NULL && value != NULL)
					{
						// Set template paramater
						CzXmlAttribute* attrib = new CzXmlAttribute();
						attrib->Managed = false;
						attrib->setName(name->c_str());
						attrib->setValue(value->c_str());
						replacements->AddAttribute(attrib);
					}
				}
				strings->clear(true);
			}
			temp->Instantiate(scene, replacements);

			delete replacements;
			delete strings;
			split->clear(true);
			delete split;
		}
		else
			temp->Instantiate(scene, NULL);

	}
#if defined (_DEBUG)
	else
	{
		CzDebug::Log(CZ_DEBUG_CHANNEL_WARNING, "Action - FromTemplate - Cannot find template - ", template_name->c_str(), parent->getDebugInfo().c_str());
		return false;
	}
#endif

	return true;
}
Esempio n. 19
0
void CzString::Copy(CzString& string)
{
	Copy((char *)string.c_str(), 0, string.getLength());
}
Esempio n. 20
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;
}
Esempio n. 21
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;
}