bool checkUpdate(uint32 appid, uint32 build)
		{
			XML::gcXMLDocument doc;
			doc.Create("apps");
			auto el = doc.GetRoot("apps").NewElement("app");
			el.SetAttribute("id", appid);
			el.SetText(gcString("{0}", build).c_str());

			bool bNeedsUpdate = false;

			std::function<void(uint32,uint32, bool)> callback = [&](uint32, uint32, bool)
			{
				bNeedsUpdate = true;
			};

			thread.checkAppUpdate(doc.GetRoot("apps"), callback);
			return bNeedsUpdate;
		}
Exemple #2
0
void UMcf::dumpXml(const wchar_t* path)
{
    if (!path)
        return;

    XML::gcXMLDocument doc;

    auto root = doc.Create("appupdate");
    auto mcfElFiles = root.NewElement("mcf");

    mcfElFiles.SetAttribute("build",  m_sHeader->getBuild());
    mcfElFiles.SetAttribute("appid",  m_sHeader->getId());

    auto filesElFiles = mcfElFiles.NewElement( "files" );

    for (auto file : m_pFileList)
    {
        auto el = filesElFiles.NewElement("file");
        file->genXml(el);
    }

    doc.SaveFile(gcString(path).c_str());
}
gcWString GameExplorerInfo::generateXml()
{
	gcString szName = m_pItemInfo->getName();
	gcString szVersion("1.0.0.0"); //{0}.{1}", (int)m_pItemInfo->getInstalledBranch(), (int)m_pItemInfo->getInstalledBuild());
	gcString szDevUrl = m_pItemInfo->getDevProfile();
	gcString szDevName = m_pItemInfo->getDev();

	gcString szPub = m_pItemInfo->getPublisher();
	gcString szPubUrl = m_pItemInfo->getPublisherProfile();

	if (szPub.size() == 0)
		szPub = "Unknown";

	if (szPubUrl.size() == 0)
		szPubUrl = "http://";



	gcString szPlayLink("desura://launch/{0}/{1}", m_Id.getTypeString(), m_pItemInfo->getShortName());
	gcString szChangeLogLink("{0}/{1}/{2}/changelog", m_pUser->getWebCore()->getUrl(WebCore::Root), m_Id.getTypeString(), m_pItemInfo->getShortName());
	gcString szProfileLink = m_pItemInfo->getProfile();

	gcString szDescription = m_pItemInfo->getName();
	gcString szReleaseData = "2010-01-01";

	gcString szUninstallLink("desura://uninstall/{0}/{1}", m_Id.getTypeString(), m_pItemInfo->getShortName());
	gcString szVerifyLink("desura://verify/{0}/{1}", m_Id.getTypeString(), m_pItemInfo->getShortName());

	gcString szGenere(m_pItemInfo->getGenre());
	
	std::vector<gcRefPtr<UserCore::Item::Misc::ExeInfoI>> vExeList;
	m_pItemInfo->getExeList(vExeList);


	if (m_szGuid == "")
		m_szGuid = generateGuid();

	if (szGenere.size() == 0)
		szGenere = "Unknown";

	XML::gcXMLDocument doc;

	auto gameDefFile = doc.Create("GameDefinitionFile", "xml version=\"1.0\" encoding=\"utf-16\"");
	auto gameDef = gameDefFile.NewElement("GameDefinition");


	gameDefFile.SetAttribute("xmlns:baseTypes", "urn:schemas-microsoft-com:GamesExplorerBaseTypes.v1");
	gameDefFile.SetAttribute("xmlns", "urn:schemas-microsoft-com:GameDescription.v1");
	gameDef.SetAttribute("gameID", m_szGuid.c_str());


	gameDef.WriteChild("Name", szName);
	gameDef.WriteChild("Description", szDescription);
	gameDef.WriteChild("ReleaseDate", szReleaseData);

	auto genres = gameDef.NewElement("Genres");
	genres.WriteChild("Genre", szGenere);
		
	WriteChildWithChildAndAtt("Version", "VersionNumber", "versionNumber", szVersion.c_str(), gameDef);

	auto dev = gameDef.NewElement("Developers").NewElement("Developer");
	dev.SetAttribute("URI", szDevUrl.c_str());
	dev.SetText(szDevName.c_str());


	auto publisher = gameDef.NewElement("Publishers").NewElement("Publisher");
	publisher.SetAttribute("URI", szPubUrl.c_str());
	publisher.SetText(szPub.c_str());

	
	if (vExeList.size() > 0)
	{
		auto gameExecutables = gameDef.NewElement("GameExecutables");

		for (size_t x=0; x<vExeList.size(); x++)
		{
			gcString szGameExe(UTIL::FS::PathWithFile(vExeList[x]->getExe()).getFile().getFile());

			auto gameExe = gameExecutables.NewElement("GameExecutable");
			gameExe.SetAttribute("path", szGameExe.c_str());
		}
	}

	int i = 1;



	auto extProps = gameDef.NewElement("ExtendedProperties");
	auto gameTasks = extProps.NewElement("GameTasks");
	auto playTask = gameTasks.NewElement("Play");

	WriteChildWithChildAndAtt("Primary", "URLTask", "Link", szPlayLink.c_str(), playTask);

	if (vExeList.size() > 1)
	{
		for (size_t x=0; x<vExeList.size(); x++)
		{
			gcString play("Play: {0}", vExeList[x]->getName());
			gcString link("desura://launch/{0}/{1}/{2}", m_Id.getTypeString(), m_pItemInfo->getShortName(), vExeList[x]->getName());

			auto changeLog = WriteChildWithChildAndAtt("Task", "URLTask", "Link", link.c_str(), playTask);
			changeLog.SetAttribute("index", i);
			changeLog.SetAttribute("name", play.c_str());
			i++;
		}
	}

	if (m_pItemInfo->isDownloadable())
	{
		auto changeLog = WriteChildWithChildAndAtt("Task", "URLTask", "Link", szChangeLogLink.c_str(), playTask);
		changeLog.SetAttribute("index", i);
		changeLog.SetAttribute("name", "View Update History");
		i++;
	}
		
		
	auto profile = WriteChildWithChildAndAtt("Task", "URLTask", "Link", szProfileLink.c_str(), playTask);
	profile.SetAttribute("index", i);
	profile.SetAttribute("name", "View Profile");
	i++;
		

	uint32 count = 0;
	for (uint32 x=0; x<m_pItemInfo->getBranchCount(); x++)
	{
		auto bi = m_pItemInfo->getBranch(x);

		if (!bi)
			continue;

		if (bi->getBranchId() == m_pItemInfo->getInstalledBranch())
			continue;

		if (bi->getFlags()&UserCore::Item::BranchInfoI::BF_NORELEASES)
			continue;

		if (!(bi->getFlags()&UserCore::Item::BranchInfoI::BF_ONACCOUNT) && !(bi->getFlags()&UserCore::Item::BranchInfoI::BF_FREE))
			continue;

		gcString name("Install Branch: {0}", bi->getName());
		gcString link("desura://install/{0}/{1}/{2}", m_Id.getTypeString(), m_pItemInfo->getShortName(), bi->getBranchId());

		auto branch = WriteChildWithChildAndAtt("Task", "URLTask", "Link", link.c_str(), playTask);
		branch.SetAttribute("index", x+i);
		branch.SetAttribute("name", name.c_str());
			
	}


	auto supportTask = gameTasks.NewElement("Support");

	auto verify = WriteChildWithChildAndAtt("Task", "URLTask", "Link", szVerifyLink.c_str(), supportTask);
	verify.SetAttribute("index", 0);
	verify.SetAttribute("name", "Verify Files");

	auto uninstall = WriteChildWithChildAndAtt("Task", "URLTask", "Link", szUninstallLink.c_str(), supportTask);
	uninstall.SetAttribute("index", 1);
	uninstall.SetAttribute("name", "Uninstall");


	gcWString res;
	res.resize(1);

	res[0] = 0xFF + (0xFE<<8);
	res += doc.ToWString(false);

	return res;
}