TKeyListIterator CCategory::VariableList( TKeyList& aKeys )const { TKeyListIterator ret( aKeys.end() ); TVariableSeq::const_iterator I_variables( _variables.begin() ); if( aKeys.size() ) { I_variables = _variables.find( aKeys.back() ); if( I_variables != _variables.end() ) { ++I_variables; } } for( ; I_variables != _variables.end(); ++I_variables ) { if( ret == aKeys.end() ) { ret = aKeys.insert( ret, I_variables->first ); } else { aKeys.push_back( I_variables->first ); } } return ret; }
bool CConfigParser::ParseActions(DOMNodeList* actionNodeList, ADeviceListener& configClass) { USES_CONVERSION; // Parse all the actions if(actionNodeList != NULL && actionNodeList->getLength() > 0) { DOMNodeList* actionNodes = actionNodeList->item(0)->getChildNodes(); for(unsigned long i = 0; i < actionNodes->getLength(); i++) { DOMNode* actionNode = actionNodes->item(i); wstring actionType = actionNode->getNodeName(); if(actionType.compare(L"#text") == 0) continue; XMLCh* xmlChNameTxt = L"name"; wstring actionName; if(actionNode->hasAttributes()) { DOMNode* nameAttribute = actionNode->getAttributes()->getNamedItem(xmlChNameTxt); actionName = nameAttribute->getNodeValue(); } if(actionType.compare(L"sendCopyDataWindowMessage") == 0 || actionType.compare(L"sendCommandWindowMessage") == 0) { wstring message = actionNode->getAttributes()->getNamedItem(L"message")->getNodeValue(); bool findByClass = FALSE; wstring windowAttributeName = L"window"; if(actionNode->getAttributes()->getNamedItem(L"window") == NULL) { findByClass = TRUE; windowAttributeName = L"windowClass"; } wstring window = actionNode->getAttributes()->getNamedItem(windowAttributeName.c_str())->getNodeValue(); CSendWindowMessageAction* messageActionToAdd = NULL; if(actionType.compare(L"sendCommandWindowMessage") == 0) { messageActionToAdd = new CSendWindowMessageAction(_wtol(message.c_str()), OLE2T(window.c_str()), findByClass); } if(actionType.compare(L"sendCopyDataWindowMessage") == 0) { messageActionToAdd = new CSendWindowMessageAction(OLE2T(message.c_str()), OLE2T(window.c_str()), findByClass); } if(messageActionToAdd != NULL) configClass.AddAction(actionName, messageActionToAdd); } if(actionType.compare(L"execute") == 0) { char* executable = XMLString::transcode( actionNode->getAttributes()->getNamedItem(L"executable")->getNodeValue()); char* commandline = XMLString::transcode( actionNode->getAttributes()->getNamedItem(L"commandline")->getNodeValue()); configClass.AddAction(actionName, new CExecuteAction(executable, commandline)); XMLString::release(&executable); XMLString::release(&commandline); } if(actionType.compare(L"keyPress") == 0) { TKeyList keys; DOMNodeList* keyNodes = actionNode->getChildNodes(); unsigned long count = keyNodes->getLength(); for(unsigned long keyIdx=0; keyIdx < keyNodes->getLength(); keyIdx++) { DOMNode* keyNode = keyNodes->item(keyIdx); if(wcscmp(keyNode->getNodeName(), L"#text") == 0) continue; const XMLCh* keyValue = keyNode->getFirstChild()->getNodeValue(); if(keyValue == NULL) continue; int test = VK_CONTROL; keys.push_back(_wtoi(keyValue)); } configClass.AddAction(actionName, new CKeyboardAction(keys)); } if(actionType.compare(L"winampPlayPause") == 0) { configClass.AddAction(actionName, new CWinampPlayPause()); } if(actionType.compare(L"winampMute") == 0) { configClass.AddAction(actionName, new CWinampMute()); } // We make the assumption that the macros were put at the end of the // config file, otherwise the actions they execute may not exist! if(actionType.compare(L"macro") == 0) { wstring type = actionNode->getAttributes()->getNamedItem(L"type")->getNodeValue(); CMacroAction* actionToAdd = new CMacroAction(type.compare(L"all") == 0 ? true : false); DOMNodeList* macroActions = actionNode->getChildNodes(); unsigned long count = macroActions->getLength(); for(unsigned long actionIdx=0; actionIdx < count; actionIdx++) { DOMNode* macroActionNode = macroActions->item(actionIdx); if(wcscmp(macroActionNode->getNodeName(), L"#text") == 0) continue; wstring macroActionName = macroActionNode->getAttributes()->getNamedItem(L"name")->getNodeValue(); actionToAdd->AddAction(configClass.GetActions()[macroActionName]); } configClass.AddAction(actionName, actionToAdd); } } } return true; }