/*static*/ QString TalkerCode::defaultTalkerCode(const QString &fullLanguageCode, const QString &moduleName) { TalkerCode tmpTalkerCode; //tmpTalkerCode.setFullLanguageCode(fullLanguageCode); tmpTalkerCode.setOutputModule(moduleName); //tmpTalkerCode.normalize(); return tmpTalkerCode.getTalkerCode(); }
/** * Loads notify events from a file. Clearing data if clear is True. */ void SpeechData::loadNotifyEventsFromFile( const QString& filename, bool clear) { // Open existing event list. QFile file( filename ); if ( !file.open( IO_ReadOnly ) ) { kdDebug() << "SpeechData::loadNotifyEventsFromFile: Unable to open file " << filename << endl; } // QDomDocument doc( "http://www.kde.org/share/apps/kttsd/stringreplacer/wordlist.dtd []" ); QDomDocument doc( "" ); if ( !doc.setContent( &file ) ) { file.close(); kdDebug() << "SpeechData::loadNotifyEventsFromFile: File not in proper XML format. " << filename << endl; } // kdDebug() << "StringReplacerConf::load: document successfully parsed." << endl; file.close(); if ( clear ) { notifyDefaultPresent = NotifyPresent::Passive; notifyDefaultOptions.action = NotifyAction::SpeakMsg; notifyDefaultOptions.talker = QString::null; notifyDefaultOptions.customMsg = QString::null; notifyAppMap.clear(); } // Event list. QDomNodeList eventList = doc.elementsByTagName("notifyEvent"); const int eventListCount = eventList.count(); for (int eventIndex = 0; eventIndex < eventListCount; ++eventIndex) { QDomNode eventNode = eventList.item(eventIndex); QDomNodeList propList = eventNode.childNodes(); QString eventSrc; QString event; QString actionName; QString message; TalkerCode talkerCode; const int propListCount = propList.count(); for (int propIndex = 0; propIndex < propListCount; ++propIndex) { QDomNode propNode = propList.item(propIndex); QDomElement prop = propNode.toElement(); if (prop.tagName() == "eventSrc") eventSrc = prop.text(); if (prop.tagName() == "event") event = prop.text(); if (prop.tagName() == "action") actionName = prop.text(); if (prop.tagName() == "message") message = prop.text(); if (prop.tagName() == "talker") talkerCode = TalkerCode(prop.text(), false); } NotifyOptions notifyOptions; notifyOptions.action = NotifyAction::action( actionName ); notifyOptions.talker = talkerCode.getTalkerCode(); notifyOptions.customMsg = message; if ( eventSrc != "default" ) { notifyOptions.eventName = NotifyEvent::getEventName( eventSrc, event ); NotifyEventMap notifyEventMap = notifyAppMap[ eventSrc ]; notifyEventMap[ event ] = notifyOptions; notifyAppMap[ eventSrc ] = notifyEventMap; } else { notifyOptions.eventName = QString::null; notifyDefaultPresent = NotifyPresent::present( event ); notifyDefaultOptions = notifyOptions; } } }