コード例 #1
0
HRESULT AutoUpdater::ParseCurrentVersionXML(HttpItem *itm)
{
	// Add File Path to internal structure
	xmlDoc.xmlHeader.szFilePath = itm->getSaveAsPath();
	
	// Parse the file if it exists
	XMLReader * xmlFile = LoadConfigFile(xmlDoc.xmlHeader.szFilePath);

	// Read XML File and Fill in VersionDescriptors
	while(!EndAttribute(xmlFile, "Header"))
	{
		if(StartAttribute(xmlFile, "Document"))
		{	
			xmlDoc.xmlHeader.docHeader.defName = xmlFile->getAttributeValue("name");
			xmlDoc.xmlHeader.docHeader.updDate = xmlFile->getAttributeValue("updated");
		}

		if(StartAttribute(xmlFile, "UpdateList"))
		{
			xmlDoc.xmlHeader.updHeader.dashTotal = xmlFile->getAttributeValueAsInt("dash");
			xmlDoc.xmlHeader.updHeader.skinTotal = xmlFile->getAttributeValueAsInt("skins");
			xmlDoc.xmlHeader.updHeader.pluginTotal = xmlFile->getAttributeValueAsInt("plugins");
		}
	}

	DebugMsg("AutoUpdater", "Version Definition File:  Header Data Loaded");

	// Parse the dash update data and place into version descriptors
	xmlFile->restart();
	while(!EndAttribute(xmlFile, "DashUpdate"))
	{
		if(StartAttribute(xmlFile, "Dash"))
		{
			tempVersion = new VersionDescriptor;

			tempVersion->szName = xmlFile->getAttributeValue("name");
			tempVersion->nMajorVersion = xmlFile->getAttributeValueAsInt("major");
			tempVersion->nMinorVersion = xmlFile->getAttributeValueAsInt("minor");
			tempVersion->nRevisionNumber = xmlFile->getAttributeValueAsInt("rev");
			tempVersion->nVersionType = xmlFile->getAttributeValueAsInt("type");
			tempVersion->szFileName = xmlFile->getAttributeValue("file");
			tempVersion->nUpdateID = xmlFile->getAttributeValueAsInt("uid");
			tempVersion->nFileType = FILETYPE_DASH;

			// Insert data into xmlDoc version descriptor map
			xmlDoc.xmlDescriptors.insert(map<int, VersionDescriptor>::value_type(tempVersion->nUpdateID, *tempVersion));
			delete tempVersion;
		}
	}
	DebugMsg("AutoUpdater", "Version Definition File:  Dash Data Loaded: %d", xmlDoc.xmlHeader.updHeader.dashTotal);
	// Parse the Skin update data and place into version descriptors
	xmlFile->restart();
	while(!EndAttribute(xmlFile, "SkinUpdate"))
	{
		if(StartAttribute(xmlFile, "Skin"))
		{
			tempVersion = new VersionDescriptor;

			tempVersion->szName = xmlFile->getAttributeValue("name");
			tempVersion->nMajorVersion = xmlFile->getAttributeValueAsInt("major");
			tempVersion->nMinorVersion = xmlFile->getAttributeValueAsInt("minor");
			tempVersion->nRevisionNumber = xmlFile->getAttributeValueAsInt("rev");
			tempVersion->nVersionType = xmlFile->getAttributeValueAsInt("type");
			tempVersion->szFileName = xmlFile->getAttributeValue("file");
			tempVersion->nUpdateID = xmlFile->getAttributeValueAsInt("uid");
			tempVersion->nFileType = FILETYPE_SKIN;

			// Insert data into xmlDoc version descriptor map
			xmlDoc.xmlDescriptors.insert(map<int, VersionDescriptor>::value_type(tempVersion->nUpdateID, *tempVersion));
			delete tempVersion;
		}
	}
	
	DebugMsg("AutoUpdater", "Version Definition File:  Skin Data Loaded: %d", xmlDoc.xmlHeader.updHeader.skinTotal);
	// Parse the Skin update data and place into version descriptors
	xmlFile->restart();
	while(!EndAttribute(xmlFile, "PluginUpdate"))
	{
		if(StartAttribute(xmlFile, "Plugin"))
		{
			tempVersion = new VersionDescriptor;

			tempVersion->szName = xmlFile->getAttributeValue("name");
			tempVersion->nMajorVersion = xmlFile->getAttributeValueAsInt("major");
			tempVersion->nMinorVersion = xmlFile->getAttributeValueAsInt("minor");
			tempVersion->nRevisionNumber = xmlFile->getAttributeValueAsInt("rev");
			tempVersion->nVersionType = xmlFile->getAttributeValueAsInt("type");
			tempVersion->szFileName = xmlFile->getAttributeValue("file");
			tempVersion->nUpdateID = xmlFile->getAttributeValueAsInt("uid");
			tempVersion->nFileType = FILETYPE_PLUGIN;

			// Insert data into xmlDoc version descriptor map
			xmlDoc.xmlDescriptors.insert(map<int, VersionDescriptor>::value_type(tempVersion->nUpdateID, *tempVersion));
			delete tempVersion;
		}
	}

	DebugMsg("AutoUpdater", "Version Definition File:  Plugin Data Loaded: %d", xmlDoc.xmlHeader.updHeader.pluginTotal);
	// Parse the ChangeLog update data and place into version descriptors
	
	xmlFile->restart();
	tempChangelog = new ChangelogDescriptor;
	while(!EndAttribute(xmlFile, "Update"))
	{
		
		if(StartAttribute(xmlFile, "Changelog"))
		{
			tempChangelog->szName = xmlFile->getAttributeValue("name");
			tempChangelog->szDate = xmlFile->getAttributeValue("date");

			string key, val;

			while (!EndAttribute(xmlFile, "Changelog"))
			{
				key = xmlFile->getNodeName();
				key = xmlFile->getNodeData();

				if (StartAttribute(xmlFile, key.c_str()))
				{
					val = xmlFile->getSubNodeData();
					if(strcmp(make_lowercaseA(key).c_str(), "data")==0) {
						tempChangelog->szLogData = val;
					}
				}
			}
		}
	}

	// Insert data into xmlDoc version descriptor map
	xmlDoc.xmlChangeLog = *tempChangelog;
	delete tempChangelog;

	DebugMsg("AutoUpdater", "Version Definition File:  Plugin Data Loaded: %d", xmlDoc.xmlHeader.updHeader.pluginTotal);
	return S_OK;
}
コード例 #2
0
void SkinManager::ExtractSkinInfo(skinitem* Skin)
{
	if (Skin->isCompressed)
	{
		// Check to see if Data Path exists
		string datapath = SETTINGS::getInstance().getDataPath() + "Skins\\";
		HRESULT hr;
		if (!FileExists(datapath)){
			DebugMsg("SkinManager", "Creating %s folder", datapath.c_str());
			_mkdir(datapath.c_str());
		}
		// Check to see if xmlpath exists "skins\\default.xzp\\"
		if (!FileExists(Skin->xmlpath)){
			DebugMsg("SkinManager", "Creating %s folder", Skin->xmlpath.c_str());
			_mkdir(Skin->xmlpath.c_str());
		}
		// Check to see if Settings folder exists
		string tempcfg = Skin->xmlpath + "Settings\\";
		if(!FileExists(tempcfg)){
		DebugMsg("SkinManager", "Creating %s folder", tempcfg.c_str());
		_mkdir(tempcfg.c_str());
		}

		// Check to see if Menu Settings Exists, if not, extract it
		string strbuff = Skin->xmlpath + "Settings\\MenuSettings.xml";
		if (!FileExists(Skin->xmlpath + "Settings\\MenuSettings.xml"))
		{
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "Settings\\MenuSettings.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}

		// Check to see if SkinSettings Exists, if not, extract it
		strbuff = Skin->xmlpath + "Settings\\SkinSettings.xml";
		if (!FileExists(Skin->xmlpath + "Settings\\SkinSettings.xml"))
		{
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "Settings\\SkinSettings.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}

		// Check to verify that XML Folder Exists
		string tempxml = Skin->xmlpath + "XML\\";
		if (!FileExists(tempxml))
		{
			DebugMsg("SkinManager", "Creating %s folder", tempxml.c_str());
			_mkdir(tempxml.c_str());
		}

		// Look for BkgListA and extract that
		strbuff = Skin->xmlpath + "XML\\BkgListA.xml";
		if (!FileExists(Skin->xmlpath + "XML\\BkgListA.xml")){
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "XML\\BkgListA.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}
		// Look for BkgListB and extract that
		strbuff = Skin->xmlpath + "XML\\BkgListB.xml";
		if (!FileExists(Skin->xmlpath + "XML\\BkgListB.xml")){
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "XML\\BkgListB.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}
			// Look for VisualList and extract that
		strbuff = Skin->xmlpath + "XML\\VisualList.xml";
		if (!FileExists(Skin->xmlpath + "XML\\VisualList.xml")){
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "XML\\VisualList.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}
		XMLReader * xml = LoadConfigFile(strbuff);
		// Extract the visual files as well
		DebugMsg("SkinManager","Extracting Visual XML files");
		while (xml && xml->read())
		{
			if(StartAttribute(xml, "visual"))
			{
				DebugMsg("SkinManager", "Reading VisualList.xml");
				strbuff = xml->getAttributeValue("path");
				DebugMsg("SkinManager", "Path: %s", strbuff.c_str());
				tempxml = Skin->xmlpath + strbuff;
				DebugMsg("SkinManager", "TempPath: %s", tempxml.c_str());
				if (!FileExists(tempxml)){
					DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
					hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, strbuff);
					if (hr == S_OK)
					{
						DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
					} else {
						DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
					}
				}
			}
		}
	}
}