Example #1
0
HRESULT DWFileResumeList::Load(LPWSTR filename)
{

	(log << "Loading Resume Time file: " << filename << "\n").Write();
	LogMessageIndent indent(&log);

	HRESULT hr;

	strCopy(m_filename, filename);

	XMLDocument file;
	file.SetLogCallback(m_pLogCallback);
	if FAILED(hr = file.Load(m_filename))
	{
		(log << "Could not load Resume Time file: " << m_filename << "\n").Show();
		if FAILED(MakeFile(filename))
			return (log << "Could not load or make the Resume Time File: " << m_filename << "\n").Show(hr);

		if FAILED(hr = file.Load(m_filename))
			return (log << "Could not load or make the Resume Time File: " << m_filename << "\n").Show(hr);
	}
Example #2
0
HRESULT DVBTChannels::LoadChannels(LPWSTR filename)
{
	CAutoLock lock(&m_networksLock);

	(log << "Loading DVBT Channels file: " << filename << "\n").Write();
	LogMessageIndent indent(&log);

	HRESULT hr;

	strCopy(m_filename, filename);

	XMLDocument file;
	file.SetLogCallback(m_pLogCallback);
	if FAILED(hr = file.Load(m_filename))
	{
		return (log << "Could not load channels file: " << m_filename << "\n").Show(hr);
	}

	int elementCount = file.Elements.Count();
	for ( int item=0 ; item<elementCount ; item++ )
	{
		XMLElement *element = file.Elements.Item(item);
		if (_wcsicmp(element->name, L"Bandwidth") == 0)
		{
			m_bandwidth = StringToLong(element->value);
			continue;
		}

		if (_wcsicmp(element->name, L"Network") == 0)
		{
			DVBTChannels_Network *pNewNetwork = new DVBTChannels_Network(this);
			pNewNetwork->SetLogCallback(m_pLogCallback);
			pNewNetwork->bandwidth = m_bandwidth;
			if (pNewNetwork->LoadFromXML(element) == S_OK)
			{
				m_networks.push_back(pNewNetwork);
				g_pOSD->Data()->AddList(pNewNetwork);
			}
			else
				delete pNewNetwork;
			continue;
		}
	}

	if (m_networks.size() == 0)
		return (log << "You need to specify at least one network in your channels file\n").Show(E_FAIL);

	indent.Release();
	(log << "Finished Loading DVBT Channels file: " << filename << "\n").Write();

	return S_OK;
}
bool Localization::LoadSet(const std::string& name)
{
	const std::string path = name + "_" + App::GetLanguageSymbol() + ".translations.xml";

	XMLDocument doc;
	if (!doc.Load(path))
	{
		Log::Error("Failed to load localization set from " + path);
		return false;
	}

	XMLNode* translationsNode = doc.AsNode()->GetFirstNode("translations");
	if (!translationsNode)
	{
		Log::Error("Failed to find 'translationSet' node in " + path);
		return false;
	}

	// Load groups

	for (XMLNode* groupNode = XMLNode_GetFirstNode(translationsNode, "group"); groupNode; groupNode = XMLNode_GetNext(groupNode, "group"))
	{
		const std::string groupName = XMLNode_GetAttributeValue(groupNode, "name");

		// Load translations

		for (XMLNode* translationNode = XMLNode_GetFirstNode(groupNode, "translation"); translationNode; translationNode = XMLNode_GetNext(translationNode, "translation"))
		{
			const std::string translationName = XMLNode_GetAttributeValue(translationNode, "name");
			const char* value = XMLNode_GetAttributeValue(translationNode, "value");

			const std::string fullName = name + "." + groupName + "." + translationName;

			g_strings[fullName] = value;
		}
	}

	return true;
}