void InstalledWizardThread::parseMod(DesuraId parId, DesuraId id, const XML::gcXMLElement &mod, gcRefPtr<WildcardManager> &pWildCard, const XML::gcXMLElement &info)
{
	gcString name = mod.GetChild("name");

	if (name == "" && info.IsValid())
		name = info.GetChild("name");

	if (name == "")
		return;

	if (m_bTriggerNewEvent)
		onNewItemEvent(name);

	triggerProgress();

	m_uiDone++;

	UserCore::Misc::InstallInfo temp(id, parId);

	try
	{
		temp.loadXmlData(mod, pWildCard);

		if (m_bTriggerNewEvent)
			onModFound(temp);
	}
	catch (gcException &except)
	{
		Warning("ItemWizard: Error in xml parsing (installed wizard, mods): {0}\n", except);
	}
}
Esempio n. 2
0
void InstallInfo::loadXmlData(const XML::gcXMLElement &xmlNode, WildcardManager* pWildCard)
{
	WildcardManager lwc(pWildCard);

	auto wcNode = xmlNode.FirstChildElement("wcards");
	if (wcNode.IsValid())
	{
		lwc.parseXML(wcNode);
	}

	xmlNode.GetChild("name", m_szName);
	auto icsNode = xmlNode.FirstChildElement("settings").FirstChildElement("installlocations");

	if (!icsNode.IsValid())
		return;
		
	icsNode.for_each_child("installlocation", [&](const XML::gcXMLElement &xmlChild)
	{
		if (m_bInstalled)
			return;

		const std::string path = xmlChild.GetChild("path");
		const std::string check = xmlChild.GetChild("check");

		if (path.empty() || check.empty())
			return;

		char* CheckRes = nullptr;
		char* PathRes = nullptr;

		try
		{
			lwc.constructPath(check.c_str(), &CheckRes);
			lwc.constructPath(path.c_str(), &PathRes);

			if (CheckRes && PathRes && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(CheckRes)))
			{
				m_szPath = PathRes;
				m_bInstalled = true;
			}
		}
		catch (gcException &e)
		{
			Debug(gcString("InstallInfo: Error parsing wildcards for installInfo: {0}\n", e));
		}

		safe_delete(CheckRes);
		safe_delete(PathRes);
	});
}
Esempio n. 3
0
void BranchInfo::loadXmlData(const XML::gcXMLElement &xmlNode)
{
	xmlNode.GetChild("name", m_szName);
	xmlNode.GetChild("price", m_szCost);
	xmlNode.GetChild("eula", m_szEulaUrl);

	auto eNode = xmlNode.FirstChildElement("eula");

	if (eNode.IsValid())
	{
		const std::string date = eNode.GetAtt("date");

		if (!date.empty() && m_szEulaDate != date)
		{
			m_uiFlags &= ~BF_ACCEPTED_EULA;
			m_szEulaDate = date;
		}
	}

	gcString preload;
	xmlNode.GetChild("preload", preload);

	if (m_szPreOrderDate.size() > 0 && (preload.size() == 0 || preload == "0"))
	{
		m_szPreOrderDate = "";
		m_uiFlags &= ~BF_PREORDER;

		onBranchInfoChangedEvent();
	}
	else if (preload != "0")
	{
		m_szPreOrderDate = preload;
		m_uiFlags |= BF_PREORDER;

		onBranchInfoChangedEvent();
	}


	bool nameon = false;
	bool free = false;
	bool onaccount = false;
	bool regionlock = false;
	bool memberlock = false;
	bool demo = false;
	bool test = false;
	bool cdkey = false;
	gcString cdkeyType;

	xmlNode.GetChild("nameon", nameon);
	xmlNode.GetChild("free", free);
	xmlNode.GetChild("onaccount", onaccount);
	xmlNode.GetChild("regionlock", regionlock);
	xmlNode.GetChild("inviteonly", memberlock);
	xmlNode.GetChild("demo", demo);
	xmlNode.GetChild("test", test);
	xmlNode.GetChild("cdkey", cdkey);
	xmlNode.FirstChildElement("cdkey").GetAtt("type", cdkeyType);

	uint32 global = -1;
	xmlNode.GetChild("global", global);

	if (global != -1)
		m_uiGlobalId = MCFBranch::BranchFromInt(global, true);

	if (nameon)
		m_uiFlags |= BF_DISPLAY_NAME;

	if (free)
		m_uiFlags |= BF_FREE;

	if (onaccount)
		m_uiFlags |= BF_ONACCOUNT;

	if (regionlock)
		m_uiFlags |= BF_REGIONLOCK;

	if (memberlock)
		m_uiFlags |= BF_MEMBERLOCK;

	if (demo)
		m_uiFlags |= BF_DEMO;

	if (test)
		m_uiFlags |= BF_TEST;

	if (cdkey)
		m_uiFlags |= BF_CDKEY;

	if (cdkeyType == "steam")
		m_uiFlags |= BF_STEAMGAME;

	//no mcf no release
	auto mcfNode = xmlNode.FirstChildElement("mcf");
	if (!mcfNode.IsValid())
	{
		m_uiFlags |= BF_NORELEASES;
	}
	else
	{
		m_uiFlags &= ~BF_NORELEASES;

		uint32 build = -1;
		mcfNode.GetChild("build", build);

		m_uiLatestBuild = MCFBuild::BuildFromInt(build);
	}

	auto toolsNode = xmlNode.FirstChildElement("tools");

	if (toolsNode.IsValid())
	{
		m_vToolList.clear();

		toolsNode.for_each_child("tool", [this](const XML::gcXMLElement &xmlTool)
		{
			const std::string id = xmlTool.GetText();

			if (!id.empty())
				m_vToolList.push_back(DesuraId(id.c_str(), "tools"));
		});
	}

	auto scriptNode = xmlNode.FirstChildElement("installscript");

	if (scriptNode.IsValid())
		processInstallScript(scriptNode);
}
void InstalledWizardThread::parseGame(DesuraId id, const XML::gcXMLElement &game, gcRefPtr<WildcardManager> &pWildCard, const XML::gcXMLElement &info)
{
	pWildCard->updateInstallWildcard("INSTALL_PATH", "INSTALL_PATH");
	pWildCard->updateInstallWildcard("PARENT_INSTALL_PATH", "%INSTALL_PATH%");


	gcString name = game.GetChild("name");

	if (name == "" && info.IsValid())
		name = info.GetChild("name");

	if (name == "")
		return;

	if (m_bTriggerNewEvent)
		onNewItemEvent(name);

	triggerProgress();
	m_uiDone++;

	UserCore::Misc::InstallInfo temp(id);

	try
	{
		if (info.IsValid())
			temp.loadXmlData(info, pWildCard);

		temp.loadXmlData(game, pWildCard);
	}
	catch (gcException &except)
	{
		Warning("ItemWizard: Error in xml parsing (installed wizard, games): {0}\n", except);
		return;
	}

	if (m_bTriggerNewEvent)
		onGameFound(temp);
	else
		m_vGameList.push_back(temp);

	pWildCard->updateInstallWildcard("INSTALL_PATH", "INSTALL_PATH");
	pWildCard->updateInstallWildcard("PARENT_INSTALL_PATH", temp.getPath());

	std::map<uint64, XML::gcXMLElement> mModMap;

	info.FirstChildElement("mods").for_each_child("mods", [&mModMap, this](const XML::gcXMLElement &mod)
	{
		if (isStopped())
			return;

		const std::string szId = mod.GetAtt("siteareaid");
		DesuraId internId(szId.c_str(), "mods");

		if (internId.isOk())
			mModMap[internId.toInt64()] = mod;
	});

	game.FirstChildElement("mods").for_each_child("mods", [&](const XML::gcXMLElement &mod)
	{
		if (isStopped())
			return;

		const std::string szId = mod.GetAtt("siteareaid");
		DesuraId internId(szId.c_str(), "mods");

		if (internId.isOk())
			parseMod(id, internId, mod, pWildCard, mModMap[internId.toInt64()]);
	});
}