bool CIRTranslator::LoadIRMap(const std::string &irMapPath) { std::string remoteMapTag; #ifdef TARGET_POSIX remoteMapTag = "lircmap"; #else remoteMapTag = "irssmap"; #endif // Load our xml file, and fill up our mapping tables CXBMCTinyXML xmlDoc; // Load the config file CLog::Log(LOGINFO, "Loading %s", irMapPath.c_str()); if (!xmlDoc.LoadFile(irMapPath)) { CLog::Log(LOGERROR, "%s, Line %d\n%s", irMapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); return false; } TiXmlElement* pRoot = xmlDoc.RootElement(); std::string strValue = pRoot->Value(); if (strValue != remoteMapTag) { CLog::Log(LOGERROR, "%s Doesn't contain <%s>", irMapPath.c_str(), remoteMapTag.c_str()); return false; } // Run through our window groups TiXmlNode* pRemote = pRoot->FirstChild(); while (pRemote != nullptr) { if (pRemote->Type() == TiXmlNode::TINYXML_ELEMENT) { const char *szRemote = pRemote->Value(); if (szRemote != nullptr) { TiXmlAttribute* pAttr = pRemote->ToElement()->FirstAttribute(); if (pAttr != nullptr) MapRemote(pRemote, pAttr->Value()); } } pRemote = pRemote->NextSibling(); } return true; }
bool CIRTranslator::LoadIRMap(const std::string &irMapPath) { std::string remoteMapTag = URIUtils::GetFileName(irMapPath); size_t lastindex = remoteMapTag.find_last_of("."); if (lastindex != std::string::npos) remoteMapTag = remoteMapTag.substr(0, lastindex); StringUtils::ToLower(remoteMapTag); // Load our xml file, and fill up our mapping tables CXBMCTinyXML xmlDoc; // Load the config file CLog::Log(LOGINFO, "Loading %s", irMapPath.c_str()); if (!xmlDoc.LoadFile(irMapPath)) { CLog::Log(LOGERROR, "%s, Line %d\n%s", irMapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc()); return false; } TiXmlElement* pRoot = xmlDoc.RootElement(); std::string strValue = pRoot->Value(); if (strValue != remoteMapTag) { CLog::Log(LOGERROR, "%s Doesn't contain <%s>", irMapPath.c_str(), remoteMapTag.c_str()); return false; } // Run through our window groups TiXmlNode* pRemote = pRoot->FirstChild(); while (pRemote != nullptr) { if (pRemote->Type() == TiXmlNode::TINYXML_ELEMENT) { const char *szRemote = pRemote->Value(); if (szRemote != nullptr) { TiXmlAttribute* pAttr = pRemote->ToElement()->FirstAttribute(); if (pAttr != nullptr) MapRemote(pRemote, pAttr->Value()); } } pRemote = pRemote->NextSibling(); } return true; }