----------------------------------------------------------------------------- Read button info per node from file. -----------------------------------------------------------------------------
| 6510 | // Read button info per node from file. |
| 6511 | //----------------------------------------------------------------------------- |
| 6512 | void Driver::ReadButtons |
| 6513 | ( |
| 6514 | uint8 const _nodeId |
| 6515 | ) |
| 6516 | { |
| 6517 | int32 intVal; |
| 6518 | int32 nodeId; |
| 6519 | int32 buttonId; |
| 6520 | char const* str; |
| 6521 | |
| 6522 | // Load the XML document that contains the driver configuration |
| 6523 | string userPath; |
| 6524 | Options::Get()->GetOptionAsString( "UserPath", &userPath ); |
| 6525 | |
| 6526 | string filename = userPath + "zwbutton.xml"; |
| 6527 | |
| 6528 | TiXmlDocument doc; |
| 6529 | if( !doc.LoadFile( filename.c_str(), TIXML_ENCODING_UTF8 ) ) |
| 6530 | { |
| 6531 | Log::Write( LogLevel_Debug, "Driver::ReadButtons - zwbutton.xml file not found."); |
| 6532 | return; |
| 6533 | } |
| 6534 | doc.SetUserData((void *)filename.c_str()); |
| 6535 | TiXmlElement const* nodesElement = doc.RootElement(); |
| 6536 | str = nodesElement->Value(); |
| 6537 | if( str && strcmp( str, "Nodes" )) |
| 6538 | { |
| 6539 | Log::Write( LogLevel_Warning, "WARNING: Driver::ReadButtons - zwbutton.xml is malformed"); |
| 6540 | return; |
| 6541 | } |
| 6542 | |
| 6543 | // Version |
| 6544 | if( TIXML_SUCCESS == nodesElement->QueryIntAttribute( "version", &intVal ) ) |
| 6545 | { |
| 6546 | if( (uint32)intVal != 1 ) |
| 6547 | { |
| 6548 | Log::Write( LogLevel_Info, "Driver::ReadButtons - %s is from an older version of OpenZWave and cannot be loaded.", "zwbutton.xml" ); |
| 6549 | return; |
| 6550 | } |
| 6551 | } |
| 6552 | else |
| 6553 | { |
| 6554 | Log::Write( LogLevel_Warning, "WARNING: Driver::ReadButtons - zwbutton.xml is from an older version of OpenZWave and cannot be loaded." ); |
| 6555 | return; |
| 6556 | } |
| 6557 | |
| 6558 | TiXmlElement const* nodeElement = nodesElement->FirstChildElement(); |
| 6559 | while( nodeElement ) |
| 6560 | { |
| 6561 | str = nodeElement->Value(); |
| 6562 | if( str && !strcmp( str, "Node" )) |
| 6563 | { |
| 6564 | Node* node = NULL; |
| 6565 | if( TIXML_SUCCESS == nodeElement->QueryIntAttribute( "id", &intVal ) ) |
| 6566 | { |
| 6567 | if( _nodeId == intVal ) |
| 6568 | { |
| 6569 | node = GetNodeUnsafe( intVal ); |
no test coverage detected