----------------------------------------------------------------------------- Load the XML that maps manufacturer and product IDs to human-readable names -----------------------------------------------------------------------------
| 140 | // Load the XML that maps manufacturer and product IDs to human-readable names |
| 141 | //----------------------------------------------------------------------------- |
| 142 | bool ManufacturerSpecificDB::LoadProductXML |
| 143 | ( |
| 144 | ) |
| 145 | { |
| 146 | LockGuard LG(m_MfsMutex); |
| 147 | |
| 148 | |
| 149 | // Parse the Z-Wave manufacturer and product XML file. |
| 150 | string configPath; |
| 151 | Options::Get()->GetOptionAsString( "ConfigPath", &configPath ); |
| 152 | |
| 153 | string filename = configPath + "manufacturer_specific.xml"; |
| 154 | |
| 155 | TiXmlDocument* pDoc = new TiXmlDocument(); |
| 156 | if( !pDoc->LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) |
| 157 | { |
| 158 | delete pDoc; |
| 159 | Log::Write( LogLevel_Info, "Unable to load %s", filename.c_str() ); |
| 160 | return false; |
| 161 | } |
| 162 | pDoc->SetUserData((void *)filename.c_str()); |
| 163 | TiXmlElement const* root = pDoc->RootElement(); |
| 164 | |
| 165 | char const* str; |
| 166 | char* pStopChar; |
| 167 | |
| 168 | str = root->Attribute("Revision"); |
| 169 | if (str) { |
| 170 | Log::Write(LogLevel_Info, "Manufacturer_Specific.xml file Revision is %s", str); |
| 171 | m_revision = atoi(str); |
| 172 | } else { |
| 173 | Log::Write(LogLevel_Warning, "Manufacturer_Specific.xml file has no Revision"); |
| 174 | m_revision = 0; |
| 175 | } |
| 176 | |
| 177 | TiXmlElement const* manufacturerElement = root->FirstChildElement(); |
| 178 | while( manufacturerElement ) |
| 179 | { |
| 180 | str = manufacturerElement->Value(); |
| 181 | if( str && !strcmp( str, "Manufacturer" ) ) |
| 182 | { |
| 183 | // Read in the manufacturer attributes |
| 184 | str = manufacturerElement->Attribute( "id" ); |
| 185 | if( !str ) |
| 186 | { |
| 187 | Log::Write( LogLevel_Info, "Error in manufacturer_specific.xml at line %d - missing manufacturer id attribute", manufacturerElement->Row() ); |
| 188 | delete pDoc; |
| 189 | return false; |
| 190 | } |
| 191 | uint16 manufacturerId = (uint16)strtol( str, &pStopChar, 16 ); |
| 192 | |
| 193 | str = manufacturerElement->Attribute( "name" ); |
| 194 | if( !str ) |
| 195 | { |
| 196 | Log::Write( LogLevel_Info, "Error in manufacturer_specific.xml at line %d - missing manufacturer name attribute", manufacturerElement->Row() ); |
| 197 | delete pDoc; |
| 198 | return false; |
| 199 | } |
nothing calls this directly
no test coverage detected