----------------------------------------------------------------------------- Read our configuration from an XML document -----------------------------------------------------------------------------
| 697 | // Read our configuration from an XML document |
| 698 | //----------------------------------------------------------------------------- |
| 699 | bool Driver::ReadCache |
| 700 | ( |
| 701 | ) |
| 702 | { |
| 703 | char str[32]; |
| 704 | int32 intVal; |
| 705 | |
| 706 | // Load the XML document that contains the driver configuration |
| 707 | string userPath; |
| 708 | Options::Get()->GetOptionAsString( "UserPath", &userPath ); |
| 709 | |
| 710 | snprintf( str, sizeof(str), "ozwcache_0x%08x.xml", m_homeId ); |
| 711 | string filename = userPath + string(str); |
| 712 | |
| 713 | TiXmlDocument doc; |
| 714 | if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) |
| 715 | { |
| 716 | return false; |
| 717 | } |
| 718 | doc.SetUserData((void *)filename.c_str()); |
| 719 | TiXmlElement const* driverElement = doc.RootElement(); |
| 720 | |
| 721 | // Version |
| 722 | if( TIXML_SUCCESS != driverElement->QueryIntAttribute( "version", &intVal ) || (uint32)intVal != c_configVersion ) |
| 723 | { |
| 724 | Log::Write( LogLevel_Warning, "WARNING: Driver::ReadCache - %s is from an older version of OpenZWave and cannot be loaded.", filename.c_str() ); |
| 725 | return false; |
| 726 | } |
| 727 | |
| 728 | // Capabilities |
| 729 | if( TIXML_SUCCESS == driverElement->QueryIntAttribute( "revision", &intVal ) ) |
| 730 | { |
| 731 | m_mfs->setLatestRevision(intVal); |
| 732 | } |
| 733 | |
| 734 | |
| 735 | // Home ID |
| 736 | char const* homeIdStr = driverElement->Attribute( "home_id" ); |
| 737 | if( homeIdStr ) |
| 738 | { |
| 739 | char* p; |
| 740 | uint32 homeId = (uint32)strtoul( homeIdStr, &p, 0 ); |
| 741 | |
| 742 | if( homeId != m_homeId ) |
| 743 | { |
| 744 | Log::Write( LogLevel_Warning, "WARNING: Driver::ReadCache - Home ID in file %s is incorrect", filename.c_str() ); |
| 745 | return false; |
| 746 | } |
| 747 | } |
| 748 | else |
| 749 | { |
| 750 | Log::Write( LogLevel_Warning, "WARNING: Driver::ReadCache - Home ID is missing from file %s", filename.c_str() ); |
| 751 | return false; |
| 752 | } |
| 753 | |
| 754 | // Node ID |
| 755 | if( TIXML_SUCCESS == driverElement->QueryIntAttribute( "node_id", &intVal ) ) |
| 756 | { |
nothing calls this directly
no test coverage detected