----------------------------------------------------------------------------- Read scene configuration from an XML document -----------------------------------------------------------------------------
| 160 | // Read scene configuration from an XML document |
| 161 | //----------------------------------------------------------------------------- |
| 162 | bool Scene::ReadScenes |
| 163 | ( |
| 164 | ) |
| 165 | { |
| 166 | int32 intVal; |
| 167 | char const* str; |
| 168 | |
| 169 | // Load the XML document that contains the driver configuration |
| 170 | string userPath; |
| 171 | Options::Get()->GetOptionAsString( "UserPath", &userPath ); |
| 172 | |
| 173 | string filename = userPath + "zwscene.xml"; |
| 174 | |
| 175 | TiXmlDocument doc; |
| 176 | if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) |
| 177 | { |
| 178 | return false; |
| 179 | } |
| 180 | |
| 181 | TiXmlElement const* scenesElement = doc.RootElement(); |
| 182 | |
| 183 | // Version |
| 184 | if( TIXML_SUCCESS == scenesElement->QueryIntAttribute( "version", &intVal ) ) |
| 185 | { |
| 186 | if( (uint32)intVal != c_sceneVersion ) |
| 187 | { |
| 188 | Log::Write( LogLevel_Alert, "Driver::ReadScenes - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() ); |
| 189 | return false; |
| 190 | } |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | Log::Write( LogLevel_Alert, "Driver::ReadScenes - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() ); |
| 195 | return false; |
| 196 | } |
| 197 | |
| 198 | TiXmlElement const* sceneElement = scenesElement->FirstChildElement(); |
| 199 | while( sceneElement ) |
| 200 | { |
| 201 | Scene* scene = NULL; |
| 202 | |
| 203 | if( TIXML_SUCCESS == sceneElement->QueryIntAttribute( "id", &intVal ) ) |
| 204 | { |
| 205 | scene = new Scene( (uint8)intVal ); |
| 206 | } |
| 207 | |
| 208 | if( scene == NULL ) |
| 209 | { |
| 210 | continue; |
| 211 | } |
| 212 | |
| 213 | str = sceneElement->Attribute( "label" ); |
| 214 | if( str ) |
| 215 | { |
| 216 | scene->m_label = str; |
| 217 | } |
| 218 | |
| 219 | // Read the ValueId for this scene |
nothing calls this directly
no test coverage detected